babylon.max.js 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178
  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/action.ts":
  314. /*!***************************!*\
  315. !*** ./Actions/action.ts ***!
  316. \***************************/
  317. /*! exports provided: Action */
  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__, "Action", function() { return Action; });
  322. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  323. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  324. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  325. /**
  326. * The action to be carried out following a trigger
  327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  328. */
  329. var Action = /** @class */ (function () {
  330. /**
  331. * Creates a new Action
  332. * @param triggerOptions the trigger, with or without parameters, for the action
  333. * @param condition an optional determinant of action
  334. */
  335. function Action(
  336. /** the trigger, with or without parameters, for the action */
  337. triggerOptions, condition) {
  338. this.triggerOptions = triggerOptions;
  339. /**
  340. * An event triggered prior to action being executed.
  341. */
  342. this.onBeforeExecuteObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  343. if (triggerOptions.parameter) {
  344. this.trigger = triggerOptions.trigger;
  345. this._triggerParameter = triggerOptions.parameter;
  346. }
  347. else if (triggerOptions.trigger) {
  348. this.trigger = triggerOptions.trigger;
  349. }
  350. else {
  351. this.trigger = triggerOptions;
  352. }
  353. this._nextActiveAction = this;
  354. this._condition = condition;
  355. }
  356. /**
  357. * Internal only
  358. * @hidden
  359. */
  360. Action.prototype._prepare = function () {
  361. };
  362. /**
  363. * Gets the trigger parameters
  364. * @returns the trigger parameters
  365. */
  366. Action.prototype.getTriggerParameter = function () {
  367. return this._triggerParameter;
  368. };
  369. /**
  370. * Internal only - executes current action event
  371. * @hidden
  372. */
  373. Action.prototype._executeCurrent = function (evt) {
  374. if (this._nextActiveAction._condition) {
  375. var condition = this._nextActiveAction._condition;
  376. var currentRenderId = this._actionManager.getScene().getRenderId();
  377. // We cache the current evaluation for the current frame
  378. if (condition._evaluationId === currentRenderId) {
  379. if (!condition._currentResult) {
  380. return;
  381. }
  382. }
  383. else {
  384. condition._evaluationId = currentRenderId;
  385. if (!condition.isValid()) {
  386. condition._currentResult = false;
  387. return;
  388. }
  389. condition._currentResult = true;
  390. }
  391. }
  392. this.onBeforeExecuteObservable.notifyObservers(this);
  393. this._nextActiveAction.execute(evt);
  394. this.skipToNextActiveAction();
  395. };
  396. /**
  397. * Execute placeholder for child classes
  398. * @param evt optional action event
  399. */
  400. Action.prototype.execute = function (evt) {
  401. };
  402. /**
  403. * Skips to next active action
  404. */
  405. Action.prototype.skipToNextActiveAction = function () {
  406. if (this._nextActiveAction._child) {
  407. if (!this._nextActiveAction._child._actionManager) {
  408. this._nextActiveAction._child._actionManager = this._actionManager;
  409. }
  410. this._nextActiveAction = this._nextActiveAction._child;
  411. }
  412. else {
  413. this._nextActiveAction = this;
  414. }
  415. };
  416. /**
  417. * Adds action to chain of actions, may be a DoNothingAction
  418. * @param action defines the next action to execute
  419. * @returns The action passed in
  420. * @see https://www.babylonjs-playground.com/#1T30HR#0
  421. */
  422. Action.prototype.then = function (action) {
  423. this._child = action;
  424. action._actionManager = this._actionManager;
  425. action._prepare();
  426. return action;
  427. };
  428. /**
  429. * Internal only
  430. * @hidden
  431. */
  432. Action.prototype._getProperty = function (propertyPath) {
  433. return this._actionManager._getProperty(propertyPath);
  434. };
  435. /**
  436. * Internal only
  437. * @hidden
  438. */
  439. Action.prototype._getEffectiveTarget = function (target, propertyPath) {
  440. return this._actionManager._getEffectiveTarget(target, propertyPath);
  441. };
  442. /**
  443. * Serialize placeholder for child classes
  444. * @param parent of child
  445. * @returns the serialized object
  446. */
  447. Action.prototype.serialize = function (parent) {
  448. };
  449. /**
  450. * Internal only called by serialize
  451. * @hidden
  452. */
  453. Action.prototype._serialize = function (serializedAction, parent) {
  454. var serializationObject = {
  455. type: 1,
  456. children: [],
  457. name: serializedAction.name,
  458. properties: serializedAction.properties || []
  459. };
  460. // Serialize child
  461. if (this._child) {
  462. this._child.serialize(serializationObject);
  463. }
  464. // Check if "this" has a condition
  465. if (this._condition) {
  466. var serializedCondition = this._condition.serialize();
  467. serializedCondition.children.push(serializationObject);
  468. if (parent) {
  469. parent.children.push(serializedCondition);
  470. }
  471. return serializedCondition;
  472. }
  473. if (parent) {
  474. parent.children.push(serializationObject);
  475. }
  476. return serializationObject;
  477. };
  478. /**
  479. * Internal only
  480. * @hidden
  481. */
  482. Action._SerializeValueAsString = function (value) {
  483. if (typeof value === "number") {
  484. return value.toString();
  485. }
  486. if (typeof value === "boolean") {
  487. return value ? "true" : "false";
  488. }
  489. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]) {
  490. return value.x + ", " + value.y;
  491. }
  492. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  493. return value.x + ", " + value.y + ", " + value.z;
  494. }
  495. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  496. return value.r + ", " + value.g + ", " + value.b;
  497. }
  498. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  499. return value.r + ", " + value.g + ", " + value.b + ", " + value.a;
  500. }
  501. return value; // string
  502. };
  503. /**
  504. * Internal only
  505. * @hidden
  506. */
  507. Action._GetTargetProperty = function (target) {
  508. return {
  509. name: "target",
  510. targetType: target._isMesh ? "MeshProperties"
  511. : target._isLight ? "LightProperties"
  512. : target._isCamera ? "CameraProperties"
  513. : "SceneProperties",
  514. value: target._isScene ? "Scene" : target.name
  515. };
  516. };
  517. return Action;
  518. }());
  519. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.Action"] = Action;
  520. /***/ }),
  521. /***/ "./Actions/actionEvent.ts":
  522. /*!********************************!*\
  523. !*** ./Actions/actionEvent.ts ***!
  524. \********************************/
  525. /*! exports provided: ActionEvent */
  526. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  527. "use strict";
  528. __webpack_require__.r(__webpack_exports__);
  529. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return ActionEvent; });
  530. /**
  531. * ActionEvent is the event being sent when an action is triggered.
  532. */
  533. var ActionEvent = /** @class */ (function () {
  534. /**
  535. * Creates a new ActionEvent
  536. * @param source The mesh or sprite that triggered the action
  537. * @param pointerX The X mouse cursor position at the time of the event
  538. * @param pointerY The Y mouse cursor position at the time of the event
  539. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  540. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  541. * @param additionalData additional data for the event
  542. */
  543. function ActionEvent(
  544. /** The mesh or sprite that triggered the action */
  545. source,
  546. /** The X mouse cursor position at the time of the event */
  547. pointerX,
  548. /** The Y mouse cursor position at the time of the event */
  549. pointerY,
  550. /** The mesh that is currently pointed at (can be null) */
  551. meshUnderPointer,
  552. /** the original (browser) event that triggered the ActionEvent */
  553. sourceEvent,
  554. /** additional data for the event */
  555. additionalData) {
  556. this.source = source;
  557. this.pointerX = pointerX;
  558. this.pointerY = pointerY;
  559. this.meshUnderPointer = meshUnderPointer;
  560. this.sourceEvent = sourceEvent;
  561. this.additionalData = additionalData;
  562. }
  563. /**
  564. * Helper function to auto-create an ActionEvent from a source mesh.
  565. * @param source The source mesh that triggered the event
  566. * @param evt The original (browser) event
  567. * @param additionalData additional data for the event
  568. * @returns the new ActionEvent
  569. */
  570. ActionEvent.CreateNew = function (source, evt, additionalData) {
  571. var scene = source.getScene();
  572. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  573. };
  574. /**
  575. * Helper function to auto-create an ActionEvent from a source sprite
  576. * @param source The source sprite that triggered the event
  577. * @param scene Scene associated with the sprite
  578. * @param evt The original (browser) event
  579. * @param additionalData additional data for the event
  580. * @returns the new ActionEvent
  581. */
  582. ActionEvent.CreateNewFromSprite = function (source, scene, evt, additionalData) {
  583. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  584. };
  585. /**
  586. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  587. * @param scene the scene where the event occurred
  588. * @param evt The original (browser) event
  589. * @returns the new ActionEvent
  590. */
  591. ActionEvent.CreateNewFromScene = function (scene, evt) {
  592. return new ActionEvent(null, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt);
  593. };
  594. /**
  595. * Helper function to auto-create an ActionEvent from a primitive
  596. * @param prim defines the target primitive
  597. * @param pointerPos defines the pointer position
  598. * @param evt The original (browser) event
  599. * @param additionalData additional data for the event
  600. * @returns the new ActionEvent
  601. */
  602. ActionEvent.CreateNewFromPrimitive = function (prim, pointerPos, evt, additionalData) {
  603. return new ActionEvent(prim, pointerPos.x, pointerPos.y, null, evt, additionalData);
  604. };
  605. return ActionEvent;
  606. }());
  607. /***/ }),
  608. /***/ "./Actions/actionManager.ts":
  609. /*!**********************************!*\
  610. !*** ./Actions/actionManager.ts ***!
  611. \**********************************/
  612. /*! exports provided: ActionManager */
  613. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  614. "use strict";
  615. __webpack_require__.r(__webpack_exports__);
  616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return ActionManager; });
  617. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  618. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  619. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  620. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  621. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  622. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  623. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  624. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  625. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  626. /**
  627. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  628. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  630. */
  631. var ActionManager = /** @class */ (function () {
  632. /**
  633. * Creates a new action manager
  634. * @param scene defines the hosting scene
  635. */
  636. function ActionManager(scene) {
  637. // Members
  638. /** Gets the list of actions */
  639. this.actions = new Array();
  640. /** Gets the cursor to use when hovering items */
  641. this.hoverCursor = '';
  642. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  643. scene.actionManagers.push(this);
  644. }
  645. // Methods
  646. /**
  647. * Releases all associated resources
  648. */
  649. ActionManager.prototype.dispose = function () {
  650. var index = this._scene.actionManagers.indexOf(this);
  651. for (var i = 0; i < this.actions.length; i++) {
  652. var action = this.actions[i];
  653. ActionManager.Triggers[action.trigger]--;
  654. if (ActionManager.Triggers[action.trigger] === 0) {
  655. delete ActionManager.Triggers[action.trigger];
  656. }
  657. }
  658. if (index > -1) {
  659. this._scene.actionManagers.splice(index, 1);
  660. }
  661. };
  662. /**
  663. * Gets hosting scene
  664. * @returns the hosting scene
  665. */
  666. ActionManager.prototype.getScene = function () {
  667. return this._scene;
  668. };
  669. /**
  670. * Does this action manager handles actions of any of the given triggers
  671. * @param triggers defines the triggers to be tested
  672. * @return a boolean indicating whether one (or more) of the triggers is handled
  673. */
  674. ActionManager.prototype.hasSpecificTriggers = function (triggers) {
  675. for (var index = 0; index < this.actions.length; index++) {
  676. var action = this.actions[index];
  677. if (triggers.indexOf(action.trigger) > -1) {
  678. return true;
  679. }
  680. }
  681. return false;
  682. };
  683. /**
  684. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  685. * speed.
  686. * @param triggerA defines the trigger to be tested
  687. * @param triggerB defines the trigger to be tested
  688. * @return a boolean indicating whether one (or more) of the triggers is handled
  689. */
  690. ActionManager.prototype.hasSpecificTriggers2 = function (triggerA, triggerB) {
  691. for (var index = 0; index < this.actions.length; index++) {
  692. var action = this.actions[index];
  693. if (triggerA == action.trigger || triggerB == action.trigger) {
  694. return true;
  695. }
  696. }
  697. return false;
  698. };
  699. /**
  700. * Does this action manager handles actions of a given trigger
  701. * @param trigger defines the trigger to be tested
  702. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  703. * @return whether the trigger is handled
  704. */
  705. ActionManager.prototype.hasSpecificTrigger = function (trigger, parameterPredicate) {
  706. for (var index = 0; index < this.actions.length; index++) {
  707. var action = this.actions[index];
  708. if (action.trigger === trigger) {
  709. if (parameterPredicate) {
  710. if (parameterPredicate(action.getTriggerParameter())) {
  711. return true;
  712. }
  713. }
  714. else {
  715. return true;
  716. }
  717. }
  718. }
  719. return false;
  720. };
  721. Object.defineProperty(ActionManager.prototype, "hasPointerTriggers", {
  722. /**
  723. * Does this action manager has pointer triggers
  724. */
  725. get: function () {
  726. for (var index = 0; index < this.actions.length; index++) {
  727. var action = this.actions[index];
  728. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPointerOutTrigger) {
  729. return true;
  730. }
  731. }
  732. return false;
  733. },
  734. enumerable: true,
  735. configurable: true
  736. });
  737. Object.defineProperty(ActionManager.prototype, "hasPickTriggers", {
  738. /**
  739. * Does this action manager has pick triggers
  740. */
  741. get: function () {
  742. for (var index = 0; index < this.actions.length; index++) {
  743. var action = this.actions[index];
  744. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPickUpTrigger) {
  745. return true;
  746. }
  747. }
  748. return false;
  749. },
  750. enumerable: true,
  751. configurable: true
  752. });
  753. Object.defineProperty(ActionManager, "HasTriggers", {
  754. /**
  755. * Does exist one action manager with at least one trigger
  756. **/
  757. get: function () {
  758. for (var t in ActionManager.Triggers) {
  759. if (ActionManager.Triggers.hasOwnProperty(t)) {
  760. return true;
  761. }
  762. }
  763. return false;
  764. },
  765. enumerable: true,
  766. configurable: true
  767. });
  768. Object.defineProperty(ActionManager, "HasPickTriggers", {
  769. /**
  770. * Does exist one action manager with at least one pick trigger
  771. **/
  772. get: function () {
  773. for (var t in ActionManager.Triggers) {
  774. if (ActionManager.Triggers.hasOwnProperty(t)) {
  775. var t_int = parseInt(t);
  776. if (t_int >= ActionManager.OnPickTrigger && t_int <= ActionManager.OnPickUpTrigger) {
  777. return true;
  778. }
  779. }
  780. }
  781. return false;
  782. },
  783. enumerable: true,
  784. configurable: true
  785. });
  786. /**
  787. * Does exist one action manager that handles actions of a given trigger
  788. * @param trigger defines the trigger to be tested
  789. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  790. **/
  791. ActionManager.HasSpecificTrigger = function (trigger) {
  792. for (var t in ActionManager.Triggers) {
  793. if (ActionManager.Triggers.hasOwnProperty(t)) {
  794. var t_int = parseInt(t);
  795. if (t_int === trigger) {
  796. return true;
  797. }
  798. }
  799. }
  800. return false;
  801. };
  802. /**
  803. * Registers an action to this action manager
  804. * @param action defines the action to be registered
  805. * @return the action amended (prepared) after registration
  806. */
  807. ActionManager.prototype.registerAction = function (action) {
  808. if (action.trigger === ActionManager.OnEveryFrameTrigger) {
  809. if (this.getScene().actionManager !== this) {
  810. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Warn("OnEveryFrameTrigger can only be used with scene.actionManager");
  811. return null;
  812. }
  813. }
  814. this.actions.push(action);
  815. if (ActionManager.Triggers[action.trigger]) {
  816. ActionManager.Triggers[action.trigger]++;
  817. }
  818. else {
  819. ActionManager.Triggers[action.trigger] = 1;
  820. }
  821. action._actionManager = this;
  822. action._prepare();
  823. return action;
  824. };
  825. /**
  826. * Unregisters an action to this action manager
  827. * @param action defines the action to be unregistered
  828. * @return a boolean indicating whether the action has been unregistered
  829. */
  830. ActionManager.prototype.unregisterAction = function (action) {
  831. var index = this.actions.indexOf(action);
  832. if (index !== -1) {
  833. this.actions.splice(index, 1);
  834. ActionManager.Triggers[action.trigger] -= 1;
  835. if (ActionManager.Triggers[action.trigger] === 0) {
  836. delete ActionManager.Triggers[action.trigger];
  837. }
  838. delete action._actionManager;
  839. return true;
  840. }
  841. return false;
  842. };
  843. /**
  844. * Process a specific trigger
  845. * @param trigger defines the trigger to process
  846. * @param evt defines the event details to be processed
  847. */
  848. ActionManager.prototype.processTrigger = function (trigger, evt) {
  849. for (var index = 0; index < this.actions.length; index++) {
  850. var action = this.actions[index];
  851. if (action.trigger === trigger) {
  852. if (evt) {
  853. if (trigger === ActionManager.OnKeyUpTrigger
  854. || trigger === ActionManager.OnKeyDownTrigger) {
  855. var parameter = action.getTriggerParameter();
  856. if (parameter && parameter !== evt.sourceEvent.keyCode) {
  857. if (!parameter.toLowerCase) {
  858. continue;
  859. }
  860. var lowerCase = parameter.toLowerCase();
  861. if (lowerCase !== evt.sourceEvent.key) {
  862. var unicode = evt.sourceEvent.charCode ? evt.sourceEvent.charCode : evt.sourceEvent.keyCode;
  863. var actualkey = String.fromCharCode(unicode).toLowerCase();
  864. if (actualkey !== lowerCase) {
  865. continue;
  866. }
  867. }
  868. }
  869. }
  870. }
  871. action._executeCurrent(evt);
  872. }
  873. }
  874. };
  875. /** @hidden */
  876. ActionManager.prototype._getEffectiveTarget = function (target, propertyPath) {
  877. var properties = propertyPath.split(".");
  878. for (var index = 0; index < properties.length - 1; index++) {
  879. target = target[properties[index]];
  880. }
  881. return target;
  882. };
  883. /** @hidden */
  884. ActionManager.prototype._getProperty = function (propertyPath) {
  885. var properties = propertyPath.split(".");
  886. return properties[properties.length - 1];
  887. };
  888. /**
  889. * Serialize this manager to a JSON object
  890. * @param name defines the property name to store this manager
  891. * @returns a JSON representation of this manager
  892. */
  893. ActionManager.prototype.serialize = function (name) {
  894. var root = {
  895. children: new Array(),
  896. name: name,
  897. type: 3,
  898. properties: new Array() // Empty for root but required
  899. };
  900. for (var i = 0; i < this.actions.length; i++) {
  901. var triggerObject = {
  902. type: 0,
  903. children: new Array(),
  904. name: ActionManager.GetTriggerName(this.actions[i].trigger),
  905. properties: new Array()
  906. };
  907. var triggerOptions = this.actions[i].triggerOptions;
  908. if (triggerOptions && typeof triggerOptions !== "number") {
  909. if (triggerOptions.parameter instanceof Node) {
  910. triggerObject.properties.push(_action__WEBPACK_IMPORTED_MODULE_2__["Action"]._GetTargetProperty(triggerOptions.parameter));
  911. }
  912. else {
  913. var parameter = {};
  914. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__["DeepCopier"].DeepCopy(triggerOptions.parameter, parameter, ["mesh"]);
  915. if (triggerOptions.parameter && triggerOptions.parameter.mesh) {
  916. parameter._meshId = triggerOptions.parameter.mesh.id;
  917. }
  918. triggerObject.properties.push({ name: "parameter", targetType: null, value: parameter });
  919. }
  920. }
  921. // Serialize child action, recursively
  922. this.actions[i].serialize(triggerObject);
  923. // Add serialized trigger
  924. root.children.push(triggerObject);
  925. }
  926. return root;
  927. };
  928. /**
  929. * Creates a new ActionManager from a JSON data
  930. * @param parsedActions defines the JSON data to read from
  931. * @param object defines the hosting mesh
  932. * @param scene defines the hosting scene
  933. */
  934. ActionManager.Parse = function (parsedActions, object, scene) {
  935. var actionManager = new ActionManager(scene);
  936. if (object === null) {
  937. scene.actionManager = actionManager;
  938. }
  939. else {
  940. object.actionManager = actionManager;
  941. }
  942. // instanciate a new object
  943. var instanciate = function (name, params) {
  944. var internalClassType = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON." + name);
  945. if (internalClassType) {
  946. var newInstance = Object.create(internalClassType.prototype);
  947. newInstance.constructor.apply(newInstance, params);
  948. return newInstance;
  949. }
  950. };
  951. var parseParameter = function (name, value, target, propertyPath) {
  952. if (propertyPath === null) {
  953. // String, boolean or float
  954. var floatValue = parseFloat(value);
  955. if (value === "true" || value === "false") {
  956. return value === "true";
  957. }
  958. else {
  959. return isNaN(floatValue) ? value : floatValue;
  960. }
  961. }
  962. var effectiveTarget = propertyPath.split(".");
  963. var values = value.split(",");
  964. // Get effective Target
  965. for (var i = 0; i < effectiveTarget.length; i++) {
  966. target = target[effectiveTarget[i]];
  967. }
  968. // Return appropriate value with its type
  969. if (typeof (target) === "boolean") {
  970. return values[0] === "true";
  971. }
  972. if (typeof (target) === "string") {
  973. return values[0];
  974. }
  975. // Parameters with multiple values such as Vector3 etc.
  976. var split = new Array();
  977. for (var i = 0; i < values.length; i++) {
  978. split.push(parseFloat(values[i]));
  979. }
  980. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  981. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(split);
  982. }
  983. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"]) {
  984. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].FromArray(split);
  985. }
  986. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"]) {
  987. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(split);
  988. }
  989. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"]) {
  990. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].FromArray(split);
  991. }
  992. return parseFloat(values[0]);
  993. };
  994. // traverse graph per trigger
  995. var traverse = function (parsedAction, trigger, condition, action, combineArray) {
  996. if (combineArray === void 0) { combineArray = null; }
  997. if (parsedAction.detached) {
  998. return;
  999. }
  1000. var parameters = new Array();
  1001. var target = null;
  1002. var propertyPath = null;
  1003. var combine = parsedAction.combine && parsedAction.combine.length > 0;
  1004. // Parameters
  1005. if (parsedAction.type === 2) {
  1006. parameters.push(actionManager);
  1007. }
  1008. else {
  1009. parameters.push(trigger);
  1010. }
  1011. if (combine) {
  1012. var actions = new Array();
  1013. for (var j = 0; j < parsedAction.combine.length; j++) {
  1014. traverse(parsedAction.combine[j], ActionManager.NothingTrigger, condition, action, actions);
  1015. }
  1016. parameters.push(actions);
  1017. }
  1018. else {
  1019. for (var i = 0; i < parsedAction.properties.length; i++) {
  1020. var value = parsedAction.properties[i].value;
  1021. var name = parsedAction.properties[i].name;
  1022. var targetType = parsedAction.properties[i].targetType;
  1023. if (name === "target") {
  1024. if (targetType !== null && targetType === "SceneProperties") {
  1025. value = target = scene;
  1026. }
  1027. else {
  1028. value = target = scene.getNodeByName(value);
  1029. }
  1030. }
  1031. else if (name === "parent") {
  1032. value = scene.getNodeByName(value);
  1033. }
  1034. else if (name === "sound") {
  1035. // Can not externalize to component, so only checks for the presence off the API.
  1036. if (scene.getSoundByName) {
  1037. value = scene.getSoundByName(value);
  1038. }
  1039. }
  1040. else if (name !== "propertyPath") {
  1041. if (parsedAction.type === 2 && name === "operator") {
  1042. value = _condition__WEBPACK_IMPORTED_MODULE_1__["ValueCondition"][value];
  1043. }
  1044. else {
  1045. value = parseParameter(name, value, target, name === "value" ? propertyPath : null);
  1046. }
  1047. }
  1048. else {
  1049. propertyPath = value;
  1050. }
  1051. parameters.push(value);
  1052. }
  1053. }
  1054. if (combineArray === null) {
  1055. parameters.push(condition);
  1056. }
  1057. else {
  1058. parameters.push(null);
  1059. }
  1060. // If interpolate value action
  1061. if (parsedAction.name === "InterpolateValueAction") {
  1062. var param = parameters[parameters.length - 2];
  1063. parameters[parameters.length - 1] = param;
  1064. parameters[parameters.length - 2] = condition;
  1065. }
  1066. // Action or condition(s) and not CombineAction
  1067. var newAction = instanciate(parsedAction.name, parameters);
  1068. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_1__["Condition"] && condition !== null) {
  1069. var nothing = new _directActions__WEBPACK_IMPORTED_MODULE_3__["DoNothingAction"](trigger, condition);
  1070. if (action) {
  1071. action.then(nothing);
  1072. }
  1073. else {
  1074. actionManager.registerAction(nothing);
  1075. }
  1076. action = nothing;
  1077. }
  1078. if (combineArray === null) {
  1079. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_1__["Condition"]) {
  1080. condition = newAction;
  1081. newAction = action;
  1082. }
  1083. else {
  1084. condition = null;
  1085. if (action) {
  1086. action.then(newAction);
  1087. }
  1088. else {
  1089. actionManager.registerAction(newAction);
  1090. }
  1091. }
  1092. }
  1093. else {
  1094. combineArray.push(newAction);
  1095. }
  1096. for (var i = 0; i < parsedAction.children.length; i++) {
  1097. traverse(parsedAction.children[i], trigger, condition, newAction, null);
  1098. }
  1099. };
  1100. // triggers
  1101. for (var i = 0; i < parsedActions.children.length; i++) {
  1102. var triggerParams;
  1103. var trigger = parsedActions.children[i];
  1104. if (trigger.properties.length > 0) {
  1105. var param = trigger.properties[0].value;
  1106. var value = trigger.properties[0].targetType === null ? param : scene.getMeshByName(param);
  1107. if (value._meshId) {
  1108. value.mesh = scene.getMeshByID(value._meshId);
  1109. }
  1110. triggerParams = { trigger: ActionManager[trigger.name], parameter: value };
  1111. }
  1112. else {
  1113. triggerParams = ActionManager[trigger.name];
  1114. }
  1115. for (var j = 0; j < trigger.children.length; j++) {
  1116. if (!trigger.detached) {
  1117. traverse(trigger.children[j], triggerParams, null, null);
  1118. }
  1119. }
  1120. }
  1121. };
  1122. /**
  1123. * Get a trigger name by index
  1124. * @param trigger defines the trigger index
  1125. * @returns a trigger name
  1126. */
  1127. ActionManager.GetTriggerName = function (trigger) {
  1128. switch (trigger) {
  1129. case 0: return "NothingTrigger";
  1130. case 1: return "OnPickTrigger";
  1131. case 2: return "OnLeftPickTrigger";
  1132. case 3: return "OnRightPickTrigger";
  1133. case 4: return "OnCenterPickTrigger";
  1134. case 5: return "OnPickDownTrigger";
  1135. case 6: return "OnPickUpTrigger";
  1136. case 7: return "OnLongPressTrigger";
  1137. case 8: return "OnPointerOverTrigger";
  1138. case 9: return "OnPointerOutTrigger";
  1139. case 10: return "OnEveryFrameTrigger";
  1140. case 11: return "OnIntersectionEnterTrigger";
  1141. case 12: return "OnIntersectionExitTrigger";
  1142. case 13: return "OnKeyDownTrigger";
  1143. case 14: return "OnKeyUpTrigger";
  1144. case 15: return "OnPickOutTrigger";
  1145. default: return "";
  1146. }
  1147. };
  1148. /**
  1149. * Nothing
  1150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1151. */
  1152. ActionManager.NothingTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_NothingTrigger;
  1153. /**
  1154. * On pick
  1155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1156. */
  1157. ActionManager.OnPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnPickTrigger;
  1158. /**
  1159. * On left pick
  1160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1161. */
  1162. ActionManager.OnLeftPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnLeftPickTrigger;
  1163. /**
  1164. * On right pick
  1165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1166. */
  1167. ActionManager.OnRightPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnRightPickTrigger;
  1168. /**
  1169. * On center pick
  1170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1171. */
  1172. ActionManager.OnCenterPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnCenterPickTrigger;
  1173. /**
  1174. * On pick down
  1175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1176. */
  1177. ActionManager.OnPickDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnPickDownTrigger;
  1178. /**
  1179. * On double pick
  1180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1181. */
  1182. ActionManager.OnDoublePickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnDoublePickTrigger;
  1183. /**
  1184. * On pick up
  1185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1186. */
  1187. ActionManager.OnPickUpTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnPickUpTrigger;
  1188. /**
  1189. * On pick out.
  1190. * This trigger will only be raised if you also declared a OnPickDown
  1191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1192. */
  1193. ActionManager.OnPickOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnPickOutTrigger;
  1194. /**
  1195. * On long press
  1196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1197. */
  1198. ActionManager.OnLongPressTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnLongPressTrigger;
  1199. /**
  1200. * On pointer over
  1201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1202. */
  1203. ActionManager.OnPointerOverTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnPointerOverTrigger;
  1204. /**
  1205. * On pointer out
  1206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1207. */
  1208. ActionManager.OnPointerOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnPointerOutTrigger;
  1209. /**
  1210. * On every frame
  1211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1212. */
  1213. ActionManager.OnEveryFrameTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnEveryFrameTrigger;
  1214. /**
  1215. * On intersection enter
  1216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1217. */
  1218. ActionManager.OnIntersectionEnterTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnIntersectionEnterTrigger;
  1219. /**
  1220. * On intersection exit
  1221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1222. */
  1223. ActionManager.OnIntersectionExitTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnIntersectionExitTrigger;
  1224. /**
  1225. * On key down
  1226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1227. */
  1228. ActionManager.OnKeyDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_OnKeyDownTrigger;
  1229. /**
  1230. * On key up
  1231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1232. */
  1233. ActionManager.OnKeyUpTrigger = 15;
  1234. /** Gets the list of active triggers */
  1235. ActionManager.Triggers = {};
  1236. return ActionManager;
  1237. }());
  1238. /***/ }),
  1239. /***/ "./Actions/condition.ts":
  1240. /*!******************************!*\
  1241. !*** ./Actions/condition.ts ***!
  1242. \******************************/
  1243. /*! exports provided: Condition, ValueCondition, PredicateCondition, StateCondition */
  1244. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1245. "use strict";
  1246. __webpack_require__.r(__webpack_exports__);
  1247. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return Condition; });
  1248. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return ValueCondition; });
  1249. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return PredicateCondition; });
  1250. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return StateCondition; });
  1251. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1252. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1253. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1254. /**
  1255. * A Condition applied to an Action
  1256. */
  1257. var Condition = /** @class */ (function () {
  1258. /**
  1259. * Creates a new Condition
  1260. * @param actionManager the manager of the action the condition is applied to
  1261. */
  1262. function Condition(actionManager) {
  1263. this._actionManager = actionManager;
  1264. }
  1265. /**
  1266. * Check if the current condition is valid
  1267. * @returns a boolean
  1268. */
  1269. Condition.prototype.isValid = function () {
  1270. return true;
  1271. };
  1272. /**
  1273. * Internal only
  1274. * @hidden
  1275. */
  1276. Condition.prototype._getProperty = function (propertyPath) {
  1277. return this._actionManager._getProperty(propertyPath);
  1278. };
  1279. /**
  1280. * Internal only
  1281. * @hidden
  1282. */
  1283. Condition.prototype._getEffectiveTarget = function (target, propertyPath) {
  1284. return this._actionManager._getEffectiveTarget(target, propertyPath);
  1285. };
  1286. /**
  1287. * Serialize placeholder for child classes
  1288. * @returns the serialized object
  1289. */
  1290. Condition.prototype.serialize = function () {
  1291. };
  1292. /**
  1293. * Internal only
  1294. * @hidden
  1295. */
  1296. Condition.prototype._serialize = function (serializedCondition) {
  1297. return {
  1298. type: 2,
  1299. children: [],
  1300. name: serializedCondition.name,
  1301. properties: serializedCondition.properties
  1302. };
  1303. };
  1304. return Condition;
  1305. }());
  1306. /**
  1307. * Defines specific conditional operators as extensions of Condition
  1308. */
  1309. var ValueCondition = /** @class */ (function (_super) {
  1310. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ValueCondition, _super);
  1311. /**
  1312. * Creates a new ValueCondition
  1313. * @param actionManager manager for the action the condition applies to
  1314. * @param target for the action
  1315. * @param propertyPath path to specify the property of the target the conditional operator uses
  1316. * @param value the value compared by the conditional operator against the current value of the property
  1317. * @param operator the conditional operator, default ValueCondition.IsEqual
  1318. */
  1319. function ValueCondition(actionManager, target,
  1320. /** path to specify the property of the target the conditional operator uses */
  1321. propertyPath,
  1322. /** the value compared by the conditional operator against the current value of the property */
  1323. value,
  1324. /** the conditional operator, default ValueCondition.IsEqual */
  1325. operator) {
  1326. if (operator === void 0) { operator = ValueCondition.IsEqual; }
  1327. var _this = _super.call(this, actionManager) || this;
  1328. _this.propertyPath = propertyPath;
  1329. _this.value = value;
  1330. _this.operator = operator;
  1331. _this._target = target;
  1332. _this._effectiveTarget = _this._getEffectiveTarget(target, _this.propertyPath);
  1333. _this._property = _this._getProperty(_this.propertyPath);
  1334. return _this;
  1335. }
  1336. Object.defineProperty(ValueCondition, "IsEqual", {
  1337. /**
  1338. * returns the number for IsEqual
  1339. */
  1340. get: function () {
  1341. return ValueCondition._IsEqual;
  1342. },
  1343. enumerable: true,
  1344. configurable: true
  1345. });
  1346. Object.defineProperty(ValueCondition, "IsDifferent", {
  1347. /**
  1348. * Returns the number for IsDifferent
  1349. */
  1350. get: function () {
  1351. return ValueCondition._IsDifferent;
  1352. },
  1353. enumerable: true,
  1354. configurable: true
  1355. });
  1356. Object.defineProperty(ValueCondition, "IsGreater", {
  1357. /**
  1358. * Returns the number for IsGreater
  1359. */
  1360. get: function () {
  1361. return ValueCondition._IsGreater;
  1362. },
  1363. enumerable: true,
  1364. configurable: true
  1365. });
  1366. Object.defineProperty(ValueCondition, "IsLesser", {
  1367. /**
  1368. * Returns the number for IsLesser
  1369. */
  1370. get: function () {
  1371. return ValueCondition._IsLesser;
  1372. },
  1373. enumerable: true,
  1374. configurable: true
  1375. });
  1376. /**
  1377. * Compares the given value with the property value for the specified conditional operator
  1378. * @returns the result of the comparison
  1379. */
  1380. ValueCondition.prototype.isValid = function () {
  1381. switch (this.operator) {
  1382. case ValueCondition.IsGreater:
  1383. return this._effectiveTarget[this._property] > this.value;
  1384. case ValueCondition.IsLesser:
  1385. return this._effectiveTarget[this._property] < this.value;
  1386. case ValueCondition.IsEqual:
  1387. case ValueCondition.IsDifferent:
  1388. var check;
  1389. if (this.value.equals) {
  1390. check = this.value.equals(this._effectiveTarget[this._property]);
  1391. }
  1392. else {
  1393. check = this.value === this._effectiveTarget[this._property];
  1394. }
  1395. return this.operator === ValueCondition.IsEqual ? check : !check;
  1396. }
  1397. return false;
  1398. };
  1399. /**
  1400. * Serialize the ValueCondition into a JSON compatible object
  1401. * @returns serialization object
  1402. */
  1403. ValueCondition.prototype.serialize = function () {
  1404. return this._serialize({
  1405. name: "ValueCondition",
  1406. properties: [
  1407. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1408. { name: "propertyPath", value: this.propertyPath },
  1409. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  1410. { name: "operator", value: ValueCondition.GetOperatorName(this.operator) }
  1411. ]
  1412. });
  1413. };
  1414. /**
  1415. * Gets the name of the conditional operator for the ValueCondition
  1416. * @param operator the conditional operator
  1417. * @returns the name
  1418. */
  1419. ValueCondition.GetOperatorName = function (operator) {
  1420. switch (operator) {
  1421. case ValueCondition._IsEqual: return "IsEqual";
  1422. case ValueCondition._IsDifferent: return "IsDifferent";
  1423. case ValueCondition._IsGreater: return "IsGreater";
  1424. case ValueCondition._IsLesser: return "IsLesser";
  1425. default: return "";
  1426. }
  1427. };
  1428. /**
  1429. * Internal only
  1430. * @hidden
  1431. */
  1432. ValueCondition._IsEqual = 0;
  1433. /**
  1434. * Internal only
  1435. * @hidden
  1436. */
  1437. ValueCondition._IsDifferent = 1;
  1438. /**
  1439. * Internal only
  1440. * @hidden
  1441. */
  1442. ValueCondition._IsGreater = 2;
  1443. /**
  1444. * Internal only
  1445. * @hidden
  1446. */
  1447. ValueCondition._IsLesser = 3;
  1448. return ValueCondition;
  1449. }(Condition));
  1450. /**
  1451. * Defines a predicate condition as an extension of Condition
  1452. */
  1453. var PredicateCondition = /** @class */ (function (_super) {
  1454. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PredicateCondition, _super);
  1455. /**
  1456. * Creates a new PredicateCondition
  1457. * @param actionManager manager for the action the condition applies to
  1458. * @param predicate defines the predicate function used to validate the condition
  1459. */
  1460. function PredicateCondition(actionManager,
  1461. /** defines the predicate function used to validate the condition */
  1462. predicate) {
  1463. var _this = _super.call(this, actionManager) || this;
  1464. _this.predicate = predicate;
  1465. return _this;
  1466. }
  1467. /**
  1468. * @returns the validity of the predicate condition
  1469. */
  1470. PredicateCondition.prototype.isValid = function () {
  1471. return this.predicate();
  1472. };
  1473. return PredicateCondition;
  1474. }(Condition));
  1475. /**
  1476. * Defines a state condition as an extension of Condition
  1477. */
  1478. var StateCondition = /** @class */ (function (_super) {
  1479. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StateCondition, _super);
  1480. /**
  1481. * Creates a new StateCondition
  1482. * @param actionManager manager for the action the condition applies to
  1483. * @param target of the condition
  1484. * @param value to compare with target state
  1485. */
  1486. function StateCondition(actionManager, target,
  1487. /** Value to compare with target state */
  1488. value) {
  1489. var _this = _super.call(this, actionManager) || this;
  1490. _this.value = value;
  1491. _this._target = target;
  1492. return _this;
  1493. }
  1494. /**
  1495. * Gets a boolean indicating if the current condition is met
  1496. * @returns the validity of the state
  1497. */
  1498. StateCondition.prototype.isValid = function () {
  1499. return this._target.state === this.value;
  1500. };
  1501. /**
  1502. * Serialize the StateCondition into a JSON compatible object
  1503. * @returns serialization object
  1504. */
  1505. StateCondition.prototype.serialize = function () {
  1506. return this._serialize({
  1507. name: "StateCondition",
  1508. properties: [
  1509. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1510. { name: "value", value: this.value }
  1511. ]
  1512. });
  1513. };
  1514. return StateCondition;
  1515. }(Condition));
  1516. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.ValueCondition"] = ValueCondition;
  1517. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PredicateCondition"] = PredicateCondition;
  1518. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StateCondition"] = StateCondition;
  1519. /***/ }),
  1520. /***/ "./Actions/directActions.ts":
  1521. /*!**********************************!*\
  1522. !*** ./Actions/directActions.ts ***!
  1523. \**********************************/
  1524. /*! exports provided: SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction */
  1525. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1526. "use strict";
  1527. __webpack_require__.r(__webpack_exports__);
  1528. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return SwitchBooleanAction; });
  1529. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return SetStateAction; });
  1530. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return SetValueAction; });
  1531. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return IncrementValueAction; });
  1532. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return PlayAnimationAction; });
  1533. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return StopAnimationAction; });
  1534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return DoNothingAction; });
  1535. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return CombineAction; });
  1536. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return ExecuteCodeAction; });
  1537. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return SetParentAction; });
  1538. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1539. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  1540. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  1541. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1542. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  1543. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1544. /**
  1545. * This defines an action responsible to toggle a boolean once triggered.
  1546. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1547. */
  1548. var SwitchBooleanAction = /** @class */ (function (_super) {
  1549. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SwitchBooleanAction, _super);
  1550. /**
  1551. * Instantiate the action
  1552. * @param triggerOptions defines the trigger options
  1553. * @param target defines the object containing the boolean
  1554. * @param propertyPath defines the path to the boolean property in the target object
  1555. * @param condition defines the trigger related conditions
  1556. */
  1557. function SwitchBooleanAction(triggerOptions, target, propertyPath, condition) {
  1558. var _this = _super.call(this, triggerOptions, condition) || this;
  1559. _this.propertyPath = propertyPath;
  1560. _this._target = _this._effectiveTarget = target;
  1561. return _this;
  1562. }
  1563. /** @hidden */
  1564. SwitchBooleanAction.prototype._prepare = function () {
  1565. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1566. this._property = this._getProperty(this.propertyPath);
  1567. };
  1568. /**
  1569. * Execute the action toggle the boolean value.
  1570. */
  1571. SwitchBooleanAction.prototype.execute = function () {
  1572. this._effectiveTarget[this._property] = !this._effectiveTarget[this._property];
  1573. };
  1574. /**
  1575. * Serializes the actions and its related information.
  1576. * @param parent defines the object to serialize in
  1577. * @returns the serialized object
  1578. */
  1579. SwitchBooleanAction.prototype.serialize = function (parent) {
  1580. return _super.prototype._serialize.call(this, {
  1581. name: "SwitchBooleanAction",
  1582. properties: [
  1583. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1584. { name: "propertyPath", value: this.propertyPath }
  1585. ]
  1586. }, parent);
  1587. };
  1588. return SwitchBooleanAction;
  1589. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1590. /**
  1591. * This defines an action responsible to set a the state field of the target
  1592. * to a desired value once triggered.
  1593. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1594. */
  1595. var SetStateAction = /** @class */ (function (_super) {
  1596. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetStateAction, _super);
  1597. /**
  1598. * Instantiate the action
  1599. * @param triggerOptions defines the trigger options
  1600. * @param target defines the object containing the state property
  1601. * @param value defines the value to store in the state field
  1602. * @param condition defines the trigger related conditions
  1603. */
  1604. function SetStateAction(triggerOptions, target, value, condition) {
  1605. var _this = _super.call(this, triggerOptions, condition) || this;
  1606. _this.value = value;
  1607. _this._target = target;
  1608. return _this;
  1609. }
  1610. /**
  1611. * Execute the action and store the value on the target state property.
  1612. */
  1613. SetStateAction.prototype.execute = function () {
  1614. this._target.state = this.value;
  1615. };
  1616. /**
  1617. * Serializes the actions and its related information.
  1618. * @param parent defines the object to serialize in
  1619. * @returns the serialized object
  1620. */
  1621. SetStateAction.prototype.serialize = function (parent) {
  1622. return _super.prototype._serialize.call(this, {
  1623. name: "SetStateAction",
  1624. properties: [
  1625. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1626. { name: "value", value: this.value }
  1627. ]
  1628. }, parent);
  1629. };
  1630. return SetStateAction;
  1631. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1632. /**
  1633. * This defines an action responsible to set a property of the target
  1634. * to a desired value once triggered.
  1635. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1636. */
  1637. var SetValueAction = /** @class */ (function (_super) {
  1638. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetValueAction, _super);
  1639. /**
  1640. * Instantiate the action
  1641. * @param triggerOptions defines the trigger options
  1642. * @param target defines the object containing the property
  1643. * @param propertyPath defines the path of the property to set in the target
  1644. * @param value defines the value to set in the property
  1645. * @param condition defines the trigger related conditions
  1646. */
  1647. function SetValueAction(triggerOptions, target, propertyPath, value, condition) {
  1648. var _this = _super.call(this, triggerOptions, condition) || this;
  1649. _this.propertyPath = propertyPath;
  1650. _this.value = value;
  1651. _this._target = _this._effectiveTarget = target;
  1652. return _this;
  1653. }
  1654. /** @hidden */
  1655. SetValueAction.prototype._prepare = function () {
  1656. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1657. this._property = this._getProperty(this.propertyPath);
  1658. };
  1659. /**
  1660. * Execute the action and set the targetted property to the desired value.
  1661. */
  1662. SetValueAction.prototype.execute = function () {
  1663. this._effectiveTarget[this._property] = this.value;
  1664. if (this._target.markAsDirty) {
  1665. this._target.markAsDirty(this._property);
  1666. }
  1667. };
  1668. /**
  1669. * Serializes the actions and its related information.
  1670. * @param parent defines the object to serialize in
  1671. * @returns the serialized object
  1672. */
  1673. SetValueAction.prototype.serialize = function (parent) {
  1674. return _super.prototype._serialize.call(this, {
  1675. name: "SetValueAction",
  1676. properties: [
  1677. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1678. { name: "propertyPath", value: this.propertyPath },
  1679. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1680. ]
  1681. }, parent);
  1682. };
  1683. return SetValueAction;
  1684. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1685. /**
  1686. * This defines an action responsible to increment the target value
  1687. * to a desired value once triggered.
  1688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1689. */
  1690. var IncrementValueAction = /** @class */ (function (_super) {
  1691. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IncrementValueAction, _super);
  1692. /**
  1693. * Instantiate the action
  1694. * @param triggerOptions defines the trigger options
  1695. * @param target defines the object containing the property
  1696. * @param propertyPath defines the path of the property to increment in the target
  1697. * @param value defines the value value we should increment the property by
  1698. * @param condition defines the trigger related conditions
  1699. */
  1700. function IncrementValueAction(triggerOptions, target, propertyPath, value, condition) {
  1701. var _this = _super.call(this, triggerOptions, condition) || this;
  1702. _this.propertyPath = propertyPath;
  1703. _this.value = value;
  1704. _this._target = _this._effectiveTarget = target;
  1705. return _this;
  1706. }
  1707. /** @hidden */
  1708. IncrementValueAction.prototype._prepare = function () {
  1709. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1710. this._property = this._getProperty(this.propertyPath);
  1711. if (typeof this._effectiveTarget[this._property] !== "number") {
  1712. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Warning: IncrementValueAction can only be used with number values");
  1713. }
  1714. };
  1715. /**
  1716. * Execute the action and increment the target of the value amount.
  1717. */
  1718. IncrementValueAction.prototype.execute = function () {
  1719. this._effectiveTarget[this._property] += this.value;
  1720. if (this._target.markAsDirty) {
  1721. this._target.markAsDirty(this._property);
  1722. }
  1723. };
  1724. /**
  1725. * Serializes the actions and its related information.
  1726. * @param parent defines the object to serialize in
  1727. * @returns the serialized object
  1728. */
  1729. IncrementValueAction.prototype.serialize = function (parent) {
  1730. return _super.prototype._serialize.call(this, {
  1731. name: "IncrementValueAction",
  1732. properties: [
  1733. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1734. { name: "propertyPath", value: this.propertyPath },
  1735. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1736. ]
  1737. }, parent);
  1738. };
  1739. return IncrementValueAction;
  1740. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1741. /**
  1742. * This defines an action responsible to start an animation once triggered.
  1743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1744. */
  1745. var PlayAnimationAction = /** @class */ (function (_super) {
  1746. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlayAnimationAction, _super);
  1747. /**
  1748. * Instantiate the action
  1749. * @param triggerOptions defines the trigger options
  1750. * @param target defines the target animation or animation name
  1751. * @param from defines from where the animation should start (animation frame)
  1752. * @param end defines where the animation should stop (animation frame)
  1753. * @param loop defines if the animation should loop or stop after the first play
  1754. * @param condition defines the trigger related conditions
  1755. */
  1756. function PlayAnimationAction(triggerOptions, target, from, to, loop, condition) {
  1757. var _this = _super.call(this, triggerOptions, condition) || this;
  1758. _this.from = from;
  1759. _this.to = to;
  1760. _this.loop = loop;
  1761. _this._target = target;
  1762. return _this;
  1763. }
  1764. /** @hidden */
  1765. PlayAnimationAction.prototype._prepare = function () {
  1766. };
  1767. /**
  1768. * Execute the action and play the animation.
  1769. */
  1770. PlayAnimationAction.prototype.execute = function () {
  1771. var scene = this._actionManager.getScene();
  1772. scene.beginAnimation(this._target, this.from, this.to, this.loop);
  1773. };
  1774. /**
  1775. * Serializes the actions and its related information.
  1776. * @param parent defines the object to serialize in
  1777. * @returns the serialized object
  1778. */
  1779. PlayAnimationAction.prototype.serialize = function (parent) {
  1780. return _super.prototype._serialize.call(this, {
  1781. name: "PlayAnimationAction",
  1782. properties: [
  1783. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1784. { name: "from", value: String(this.from) },
  1785. { name: "to", value: String(this.to) },
  1786. { name: "loop", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.loop) || false }
  1787. ]
  1788. }, parent);
  1789. };
  1790. return PlayAnimationAction;
  1791. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1792. /**
  1793. * This defines an action responsible to stop an animation once triggered.
  1794. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1795. */
  1796. var StopAnimationAction = /** @class */ (function (_super) {
  1797. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopAnimationAction, _super);
  1798. /**
  1799. * Instantiate the action
  1800. * @param triggerOptions defines the trigger options
  1801. * @param target defines the target animation or animation name
  1802. * @param condition defines the trigger related conditions
  1803. */
  1804. function StopAnimationAction(triggerOptions, target, condition) {
  1805. var _this = _super.call(this, triggerOptions, condition) || this;
  1806. _this._target = target;
  1807. return _this;
  1808. }
  1809. /** @hidden */
  1810. StopAnimationAction.prototype._prepare = function () {
  1811. };
  1812. /**
  1813. * Execute the action and stop the animation.
  1814. */
  1815. StopAnimationAction.prototype.execute = function () {
  1816. var scene = this._actionManager.getScene();
  1817. scene.stopAnimation(this._target);
  1818. };
  1819. /**
  1820. * Serializes the actions and its related information.
  1821. * @param parent defines the object to serialize in
  1822. * @returns the serialized object
  1823. */
  1824. StopAnimationAction.prototype.serialize = function (parent) {
  1825. return _super.prototype._serialize.call(this, {
  1826. name: "StopAnimationAction",
  1827. properties: [_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target)]
  1828. }, parent);
  1829. };
  1830. return StopAnimationAction;
  1831. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1832. /**
  1833. * This defines an action responsible that does nothing once triggered.
  1834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1835. */
  1836. var DoNothingAction = /** @class */ (function (_super) {
  1837. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DoNothingAction, _super);
  1838. /**
  1839. * Instantiate the action
  1840. * @param triggerOptions defines the trigger options
  1841. * @param condition defines the trigger related conditions
  1842. */
  1843. function DoNothingAction(triggerOptions, condition) {
  1844. if (triggerOptions === void 0) { triggerOptions = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_NothingTrigger; }
  1845. return _super.call(this, triggerOptions, condition) || this;
  1846. }
  1847. /**
  1848. * Execute the action and do nothing.
  1849. */
  1850. DoNothingAction.prototype.execute = function () {
  1851. };
  1852. /**
  1853. * Serializes the actions and its related information.
  1854. * @param parent defines the object to serialize in
  1855. * @returns the serialized object
  1856. */
  1857. DoNothingAction.prototype.serialize = function (parent) {
  1858. return _super.prototype._serialize.call(this, {
  1859. name: "DoNothingAction",
  1860. properties: []
  1861. }, parent);
  1862. };
  1863. return DoNothingAction;
  1864. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1865. /**
  1866. * This defines an action responsible to trigger several actions once triggered.
  1867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1868. */
  1869. var CombineAction = /** @class */ (function (_super) {
  1870. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CombineAction, _super);
  1871. /**
  1872. * Instantiate the action
  1873. * @param triggerOptions defines the trigger options
  1874. * @param children defines the list of aggregated animations to run
  1875. * @param condition defines the trigger related conditions
  1876. */
  1877. function CombineAction(triggerOptions, children, condition) {
  1878. var _this = _super.call(this, triggerOptions, condition) || this;
  1879. _this.children = children;
  1880. return _this;
  1881. }
  1882. /** @hidden */
  1883. CombineAction.prototype._prepare = function () {
  1884. for (var index = 0; index < this.children.length; index++) {
  1885. this.children[index]._actionManager = this._actionManager;
  1886. this.children[index]._prepare();
  1887. }
  1888. };
  1889. /**
  1890. * Execute the action and executes all the aggregated actions.
  1891. */
  1892. CombineAction.prototype.execute = function (evt) {
  1893. for (var index = 0; index < this.children.length; index++) {
  1894. this.children[index].execute(evt);
  1895. }
  1896. };
  1897. /**
  1898. * Serializes the actions and its related information.
  1899. * @param parent defines the object to serialize in
  1900. * @returns the serialized object
  1901. */
  1902. CombineAction.prototype.serialize = function (parent) {
  1903. var serializationObject = _super.prototype._serialize.call(this, {
  1904. name: "CombineAction",
  1905. properties: [],
  1906. combine: []
  1907. }, parent);
  1908. for (var i = 0; i < this.children.length; i++) {
  1909. serializationObject.combine.push(this.children[i].serialize(null));
  1910. }
  1911. return serializationObject;
  1912. };
  1913. return CombineAction;
  1914. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1915. /**
  1916. * This defines an action responsible to run code (external event) once triggered.
  1917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1918. */
  1919. var ExecuteCodeAction = /** @class */ (function (_super) {
  1920. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExecuteCodeAction, _super);
  1921. /**
  1922. * Instantiate the action
  1923. * @param triggerOptions defines the trigger options
  1924. * @param func defines the callback function to run
  1925. * @param condition defines the trigger related conditions
  1926. */
  1927. function ExecuteCodeAction(triggerOptions, func, condition) {
  1928. var _this = _super.call(this, triggerOptions, condition) || this;
  1929. _this.func = func;
  1930. return _this;
  1931. }
  1932. /**
  1933. * Execute the action and run the attached code.
  1934. */
  1935. ExecuteCodeAction.prototype.execute = function (evt) {
  1936. this.func(evt);
  1937. };
  1938. return ExecuteCodeAction;
  1939. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1940. /**
  1941. * This defines an action responsible to set the parent property of the target once triggered.
  1942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1943. */
  1944. var SetParentAction = /** @class */ (function (_super) {
  1945. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetParentAction, _super);
  1946. /**
  1947. * Instantiate the action
  1948. * @param triggerOptions defines the trigger options
  1949. * @param target defines the target containing the parent property
  1950. * @param parent defines from where the animation should start (animation frame)
  1951. * @param condition defines the trigger related conditions
  1952. */
  1953. function SetParentAction(triggerOptions, target, parent, condition) {
  1954. var _this = _super.call(this, triggerOptions, condition) || this;
  1955. _this._target = target;
  1956. _this._parent = parent;
  1957. return _this;
  1958. }
  1959. /** @hidden */
  1960. SetParentAction.prototype._prepare = function () {
  1961. };
  1962. /**
  1963. * Execute the action and set the parent property.
  1964. */
  1965. SetParentAction.prototype.execute = function () {
  1966. if (this._target.parent === this._parent) {
  1967. return;
  1968. }
  1969. var invertParentWorldMatrix = this._parent.getWorldMatrix().clone();
  1970. invertParentWorldMatrix.invert();
  1971. this._target.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this._target.position, invertParentWorldMatrix);
  1972. this._target.parent = this._parent;
  1973. };
  1974. /**
  1975. * Serializes the actions and its related information.
  1976. * @param parent defines the object to serialize in
  1977. * @returns the serialized object
  1978. */
  1979. SetParentAction.prototype.serialize = function (parent) {
  1980. return _super.prototype._serialize.call(this, {
  1981. name: "SetParentAction",
  1982. properties: [
  1983. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1984. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._parent),
  1985. ]
  1986. }, parent);
  1987. };
  1988. return SetParentAction;
  1989. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1990. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  1991. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.ExecuteCodeAction"] = ExecuteCodeAction;
  1992. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.DoNothingAction"] = DoNothingAction;
  1993. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.StopAnimationAction"] = StopAnimationAction;
  1994. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PlayAnimationAction"] = PlayAnimationAction;
  1995. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.IncrementValueAction"] = IncrementValueAction;
  1996. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetValueAction"] = SetValueAction;
  1997. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetStateAction"] = SetStateAction;
  1998. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  1999. /***/ }),
  2000. /***/ "./Actions/directAudioActions.ts":
  2001. /*!***************************************!*\
  2002. !*** ./Actions/directAudioActions.ts ***!
  2003. \***************************************/
  2004. /*! exports provided: PlaySoundAction, StopSoundAction */
  2005. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2006. "use strict";
  2007. __webpack_require__.r(__webpack_exports__);
  2008. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return PlaySoundAction; });
  2009. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return StopSoundAction; });
  2010. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2011. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2012. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2013. /**
  2014. * This defines an action helpful to play a defined sound on a triggered action.
  2015. */
  2016. var PlaySoundAction = /** @class */ (function (_super) {
  2017. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaySoundAction, _super);
  2018. /**
  2019. * Instantiate the action
  2020. * @param triggerOptions defines the trigger options
  2021. * @param sound defines the sound to play
  2022. * @param condition defines the trigger related conditions
  2023. */
  2024. function PlaySoundAction(triggerOptions, sound, condition) {
  2025. var _this = _super.call(this, triggerOptions, condition) || this;
  2026. _this._sound = sound;
  2027. return _this;
  2028. }
  2029. /** @hidden */
  2030. PlaySoundAction.prototype._prepare = function () {
  2031. };
  2032. /**
  2033. * Execute the action and play the sound.
  2034. */
  2035. PlaySoundAction.prototype.execute = function () {
  2036. if (this._sound !== undefined) {
  2037. this._sound.play();
  2038. }
  2039. };
  2040. /**
  2041. * Serializes the actions and its related information.
  2042. * @param parent defines the object to serialize in
  2043. * @returns the serialized object
  2044. */
  2045. PlaySoundAction.prototype.serialize = function (parent) {
  2046. return _super.prototype._serialize.call(this, {
  2047. name: "PlaySoundAction",
  2048. properties: [{ name: "sound", value: this._sound.name }]
  2049. }, parent);
  2050. };
  2051. return PlaySoundAction;
  2052. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2053. /**
  2054. * This defines an action helpful to stop a defined sound on a triggered action.
  2055. */
  2056. var StopSoundAction = /** @class */ (function (_super) {
  2057. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopSoundAction, _super);
  2058. /**
  2059. * Instantiate the action
  2060. * @param triggerOptions defines the trigger options
  2061. * @param sound defines the sound to stop
  2062. * @param condition defines the trigger related conditions
  2063. */
  2064. function StopSoundAction(triggerOptions, sound, condition) {
  2065. var _this = _super.call(this, triggerOptions, condition) || this;
  2066. _this._sound = sound;
  2067. return _this;
  2068. }
  2069. /** @hidden */
  2070. StopSoundAction.prototype._prepare = function () {
  2071. };
  2072. /**
  2073. * Execute the action and stop the sound.
  2074. */
  2075. StopSoundAction.prototype.execute = function () {
  2076. if (this._sound !== undefined) {
  2077. this._sound.stop();
  2078. }
  2079. };
  2080. /**
  2081. * Serializes the actions and its related information.
  2082. * @param parent defines the object to serialize in
  2083. * @returns the serialized object
  2084. */
  2085. StopSoundAction.prototype.serialize = function (parent) {
  2086. return _super.prototype._serialize.call(this, {
  2087. name: "StopSoundAction",
  2088. properties: [{ name: "sound", value: this._sound.name }]
  2089. }, parent);
  2090. };
  2091. return StopSoundAction;
  2092. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2093. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PlaySoundAction"] = StopSoundAction;
  2094. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StopSoundAction"] = StopSoundAction;
  2095. /***/ }),
  2096. /***/ "./Actions/index.ts":
  2097. /*!**************************!*\
  2098. !*** ./Actions/index.ts ***!
  2099. \**************************/
  2100. /*! exports provided: Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction */
  2101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2102. "use strict";
  2103. __webpack_require__.r(__webpack_exports__);
  2104. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _action__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  2106. /* harmony import */ var _actionEvent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./actionEvent */ "./Actions/actionEvent.ts");
  2107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _actionEvent__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  2108. /* harmony import */ var _actionManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actionManager */ "./Actions/actionManager.ts");
  2109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _actionManager__WEBPACK_IMPORTED_MODULE_2__["ActionManager"]; });
  2110. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  2111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["Condition"]; });
  2112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["ValueCondition"]; });
  2113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["PredicateCondition"]; });
  2114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["StateCondition"]; });
  2115. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  2116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SwitchBooleanAction"]; });
  2117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetStateAction"]; });
  2118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetValueAction"]; });
  2119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["IncrementValueAction"]; });
  2120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["PlayAnimationAction"]; });
  2121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["StopAnimationAction"]; });
  2122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"]; });
  2123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["CombineAction"]; });
  2124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["ExecuteCodeAction"]; });
  2125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetParentAction"]; });
  2126. /* harmony import */ var _directAudioActions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./directAudioActions */ "./Actions/directAudioActions.ts");
  2127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["PlaySoundAction"]; });
  2128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["StopSoundAction"]; });
  2129. /* harmony import */ var _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./interpolateValueAction */ "./Actions/interpolateValueAction.ts");
  2130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__["InterpolateValueAction"]; });
  2131. /***/ }),
  2132. /***/ "./Actions/interpolateValueAction.ts":
  2133. /*!*******************************************!*\
  2134. !*** ./Actions/interpolateValueAction.ts ***!
  2135. \*******************************************/
  2136. /*! exports provided: InterpolateValueAction */
  2137. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2138. "use strict";
  2139. __webpack_require__.r(__webpack_exports__);
  2140. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return InterpolateValueAction; });
  2141. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2142. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2143. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  2144. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2145. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2146. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  2147. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2148. /**
  2149. * This defines an action responsible to change the value of a property
  2150. * by interpolating between its current value and the newly set one once triggered.
  2151. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2152. */
  2153. var InterpolateValueAction = /** @class */ (function (_super) {
  2154. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InterpolateValueAction, _super);
  2155. /**
  2156. * Instantiate the action
  2157. * @param triggerOptions defines the trigger options
  2158. * @param target defines the object containing the value to interpolate
  2159. * @param propertyPath defines the path to the property in the target object
  2160. * @param value defines the target value at the end of the interpolation
  2161. * @param duration deines the time it will take for the property to interpolate to the value.
  2162. * @param condition defines the trigger related conditions
  2163. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  2164. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  2165. */
  2166. function InterpolateValueAction(triggerOptions, target, propertyPath, value, duration, condition, stopOtherAnimations, onInterpolationDone) {
  2167. if (duration === void 0) { duration = 1000; }
  2168. var _this = _super.call(this, triggerOptions, condition) || this;
  2169. /**
  2170. * Defines the time it will take for the property to interpolate to the value.
  2171. */
  2172. _this.duration = 1000;
  2173. /**
  2174. * Observable triggered once the interpolation animation has been done.
  2175. */
  2176. _this.onInterpolationDoneObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  2177. _this.propertyPath = propertyPath;
  2178. _this.value = value;
  2179. _this.duration = duration;
  2180. _this.stopOtherAnimations = stopOtherAnimations;
  2181. _this.onInterpolationDone = onInterpolationDone;
  2182. _this._target = _this._effectiveTarget = target;
  2183. return _this;
  2184. }
  2185. /** @hidden */
  2186. InterpolateValueAction.prototype._prepare = function () {
  2187. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  2188. this._property = this._getProperty(this.propertyPath);
  2189. };
  2190. /**
  2191. * Execute the action starts the value interpolation.
  2192. */
  2193. InterpolateValueAction.prototype.execute = function () {
  2194. var _this = this;
  2195. var scene = this._actionManager.getScene();
  2196. var keys = [
  2197. {
  2198. frame: 0,
  2199. value: this._effectiveTarget[this._property]
  2200. }, {
  2201. frame: 100,
  2202. value: this.value
  2203. }
  2204. ];
  2205. var dataType;
  2206. if (typeof this.value === "number") {
  2207. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT;
  2208. }
  2209. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"]) {
  2210. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_COLOR3;
  2211. }
  2212. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"]) {
  2213. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3;
  2214. }
  2215. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]) {
  2216. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_MATRIX;
  2217. }
  2218. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]) {
  2219. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_QUATERNION;
  2220. }
  2221. else {
  2222. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
  2223. return;
  2224. }
  2225. 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);
  2226. animation.setKeys(keys);
  2227. if (this.stopOtherAnimations) {
  2228. scene.stopAnimation(this._effectiveTarget);
  2229. }
  2230. var wrapper = function () {
  2231. _this.onInterpolationDoneObservable.notifyObservers(_this);
  2232. if (_this.onInterpolationDone) {
  2233. _this.onInterpolationDone();
  2234. }
  2235. };
  2236. scene.beginDirectAnimation(this._effectiveTarget, [animation], 0, 100, false, 1, wrapper);
  2237. };
  2238. /**
  2239. * Serializes the actions and its related information.
  2240. * @param parent defines the object to serialize in
  2241. * @returns the serialized object
  2242. */
  2243. InterpolateValueAction.prototype.serialize = function (parent) {
  2244. return _super.prototype._serialize.call(this, {
  2245. name: "InterpolateValueAction",
  2246. properties: [
  2247. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  2248. { name: "propertyPath", value: this.propertyPath },
  2249. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  2250. { name: "duration", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.duration) },
  2251. { name: "stopOtherAnimations", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.stopOtherAnimations) || false }
  2252. ]
  2253. }, parent);
  2254. };
  2255. return InterpolateValueAction;
  2256. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2257. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__["_TypeStore"].RegisteredTypes["BABYLON.InterpolateValueAction"] = _action__WEBPACK_IMPORTED_MODULE_1__["Action"];
  2258. /***/ }),
  2259. /***/ "./Animations/animatable.ts":
  2260. /*!**********************************!*\
  2261. !*** ./Animations/animatable.ts ***!
  2262. \**********************************/
  2263. /*! exports provided: Animatable */
  2264. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2265. "use strict";
  2266. __webpack_require__.r(__webpack_exports__);
  2267. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return Animatable; });
  2268. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  2269. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2270. /**
  2271. * Class used to store an actual running animation
  2272. */
  2273. var Animatable = /** @class */ (function () {
  2274. /**
  2275. * Creates a new Animatable
  2276. * @param scene defines the hosting scene
  2277. * @param target defines the target object
  2278. * @param fromFrame defines the starting frame number (default is 0)
  2279. * @param toFrame defines the ending frame number (default is 100)
  2280. * @param loopAnimation defines if the animation must loop (default is false)
  2281. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  2282. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  2283. * @param animations defines a group of animation to add to the new Animatable
  2284. * @param onAnimationLoop defines a callback to call when animation loops
  2285. */
  2286. function Animatable(scene,
  2287. /** defines the target object */
  2288. target,
  2289. /** defines the starting frame number (default is 0) */
  2290. fromFrame,
  2291. /** defines the ending frame number (default is 100) */
  2292. toFrame,
  2293. /** defines if the animation must loop (default is false) */
  2294. loopAnimation, speedRatio,
  2295. /** defines a callback to call when animation ends if it is not looping */
  2296. onAnimationEnd, animations,
  2297. /** defines a callback to call when animation loops */
  2298. onAnimationLoop) {
  2299. if (fromFrame === void 0) { fromFrame = 0; }
  2300. if (toFrame === void 0) { toFrame = 100; }
  2301. if (loopAnimation === void 0) { loopAnimation = false; }
  2302. if (speedRatio === void 0) { speedRatio = 1.0; }
  2303. this.target = target;
  2304. this.fromFrame = fromFrame;
  2305. this.toFrame = toFrame;
  2306. this.loopAnimation = loopAnimation;
  2307. this.onAnimationEnd = onAnimationEnd;
  2308. this.onAnimationLoop = onAnimationLoop;
  2309. this._localDelayOffset = null;
  2310. this._pausedDelay = null;
  2311. this._runtimeAnimations = new Array();
  2312. this._paused = false;
  2313. this._speedRatio = 1;
  2314. this._weight = -1.0;
  2315. /**
  2316. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  2317. * This will only apply for non looping animation (default is true)
  2318. */
  2319. this.disposeOnEnd = true;
  2320. /**
  2321. * Gets a boolean indicating if the animation has started
  2322. */
  2323. this.animationStarted = false;
  2324. /**
  2325. * Observer raised when the animation ends
  2326. */
  2327. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  2328. /**
  2329. * Observer raised when the animation loops
  2330. */
  2331. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  2332. this._scene = scene;
  2333. if (animations) {
  2334. this.appendAnimations(target, animations);
  2335. }
  2336. this._speedRatio = speedRatio;
  2337. scene._activeAnimatables.push(this);
  2338. }
  2339. Object.defineProperty(Animatable.prototype, "syncRoot", {
  2340. /**
  2341. * Gets the root Animatable used to synchronize and normalize animations
  2342. */
  2343. get: function () {
  2344. return this._syncRoot;
  2345. },
  2346. enumerable: true,
  2347. configurable: true
  2348. });
  2349. Object.defineProperty(Animatable.prototype, "masterFrame", {
  2350. /**
  2351. * Gets the current frame of the first RuntimeAnimation
  2352. * Used to synchronize Animatables
  2353. */
  2354. get: function () {
  2355. if (this._runtimeAnimations.length === 0) {
  2356. return 0;
  2357. }
  2358. return this._runtimeAnimations[0].currentFrame;
  2359. },
  2360. enumerable: true,
  2361. configurable: true
  2362. });
  2363. Object.defineProperty(Animatable.prototype, "weight", {
  2364. /**
  2365. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2366. */
  2367. get: function () {
  2368. return this._weight;
  2369. },
  2370. set: function (value) {
  2371. if (value === -1) { // -1 is ok and means no weight
  2372. this._weight = -1;
  2373. return;
  2374. }
  2375. // Else weight must be in [0, 1] range
  2376. this._weight = Math.min(Math.max(value, 0), 1.0);
  2377. },
  2378. enumerable: true,
  2379. configurable: true
  2380. });
  2381. Object.defineProperty(Animatable.prototype, "speedRatio", {
  2382. /**
  2383. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2384. */
  2385. get: function () {
  2386. return this._speedRatio;
  2387. },
  2388. set: function (value) {
  2389. for (var index = 0; index < this._runtimeAnimations.length; index++) {
  2390. var animation = this._runtimeAnimations[index];
  2391. animation._prepareForSpeedRatioChange(value);
  2392. }
  2393. this._speedRatio = value;
  2394. },
  2395. enumerable: true,
  2396. configurable: true
  2397. });
  2398. // Methods
  2399. /**
  2400. * Synchronize and normalize current Animatable with a source Animatable
  2401. * This is useful when using animation weights and when animations are not of the same length
  2402. * @param root defines the root Animatable to synchronize with
  2403. * @returns the current Animatable
  2404. */
  2405. Animatable.prototype.syncWith = function (root) {
  2406. this._syncRoot = root;
  2407. if (root) {
  2408. // Make sure this animatable will animate after the root
  2409. var index = this._scene._activeAnimatables.indexOf(this);
  2410. if (index > -1) {
  2411. this._scene._activeAnimatables.splice(index, 1);
  2412. this._scene._activeAnimatables.push(this);
  2413. }
  2414. }
  2415. return this;
  2416. };
  2417. /**
  2418. * Gets the list of runtime animations
  2419. * @returns an array of RuntimeAnimation
  2420. */
  2421. Animatable.prototype.getAnimations = function () {
  2422. return this._runtimeAnimations;
  2423. };
  2424. /**
  2425. * Adds more animations to the current animatable
  2426. * @param target defines the target of the animations
  2427. * @param animations defines the new animations to add
  2428. */
  2429. Animatable.prototype.appendAnimations = function (target, animations) {
  2430. for (var index = 0; index < animations.length; index++) {
  2431. var animation = animations[index];
  2432. this._runtimeAnimations.push(new _runtimeAnimation__WEBPACK_IMPORTED_MODULE_0__["RuntimeAnimation"](target, animation, this._scene, this));
  2433. }
  2434. };
  2435. /**
  2436. * Gets the source animation for a specific property
  2437. * @param property defines the propertyu to look for
  2438. * @returns null or the source animation for the given property
  2439. */
  2440. Animatable.prototype.getAnimationByTargetProperty = function (property) {
  2441. var runtimeAnimations = this._runtimeAnimations;
  2442. for (var index = 0; index < runtimeAnimations.length; index++) {
  2443. if (runtimeAnimations[index].animation.targetProperty === property) {
  2444. return runtimeAnimations[index].animation;
  2445. }
  2446. }
  2447. return null;
  2448. };
  2449. /**
  2450. * Gets the runtime animation for a specific property
  2451. * @param property defines the propertyu to look for
  2452. * @returns null or the runtime animation for the given property
  2453. */
  2454. Animatable.prototype.getRuntimeAnimationByTargetProperty = function (property) {
  2455. var runtimeAnimations = this._runtimeAnimations;
  2456. for (var index = 0; index < runtimeAnimations.length; index++) {
  2457. if (runtimeAnimations[index].animation.targetProperty === property) {
  2458. return runtimeAnimations[index];
  2459. }
  2460. }
  2461. return null;
  2462. };
  2463. /**
  2464. * Resets the animatable to its original state
  2465. */
  2466. Animatable.prototype.reset = function () {
  2467. var runtimeAnimations = this._runtimeAnimations;
  2468. for (var index = 0; index < runtimeAnimations.length; index++) {
  2469. runtimeAnimations[index].reset(true);
  2470. }
  2471. this._localDelayOffset = null;
  2472. this._pausedDelay = null;
  2473. };
  2474. /**
  2475. * Allows the animatable to blend with current running animations
  2476. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2477. * @param blendingSpeed defines the blending speed to use
  2478. */
  2479. Animatable.prototype.enableBlending = function (blendingSpeed) {
  2480. var runtimeAnimations = this._runtimeAnimations;
  2481. for (var index = 0; index < runtimeAnimations.length; index++) {
  2482. runtimeAnimations[index].animation.enableBlending = true;
  2483. runtimeAnimations[index].animation.blendingSpeed = blendingSpeed;
  2484. }
  2485. };
  2486. /**
  2487. * Disable animation blending
  2488. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2489. */
  2490. Animatable.prototype.disableBlending = function () {
  2491. var runtimeAnimations = this._runtimeAnimations;
  2492. for (var index = 0; index < runtimeAnimations.length; index++) {
  2493. runtimeAnimations[index].animation.enableBlending = false;
  2494. }
  2495. };
  2496. /**
  2497. * Jump directly to a given frame
  2498. * @param frame defines the frame to jump to
  2499. */
  2500. Animatable.prototype.goToFrame = function (frame) {
  2501. var runtimeAnimations = this._runtimeAnimations;
  2502. if (runtimeAnimations[0]) {
  2503. var fps = runtimeAnimations[0].animation.framePerSecond;
  2504. var currentFrame = runtimeAnimations[0].currentFrame;
  2505. var adjustTime = frame - currentFrame;
  2506. var delay = adjustTime * 1000 / (fps * this.speedRatio);
  2507. if (this._localDelayOffset === null) {
  2508. this._localDelayOffset = 0;
  2509. }
  2510. this._localDelayOffset -= delay;
  2511. }
  2512. for (var index = 0; index < runtimeAnimations.length; index++) {
  2513. runtimeAnimations[index].goToFrame(frame);
  2514. }
  2515. };
  2516. /**
  2517. * Pause the animation
  2518. */
  2519. Animatable.prototype.pause = function () {
  2520. if (this._paused) {
  2521. return;
  2522. }
  2523. this._paused = true;
  2524. };
  2525. /**
  2526. * Restart the animation
  2527. */
  2528. Animatable.prototype.restart = function () {
  2529. this._paused = false;
  2530. };
  2531. Animatable.prototype._raiseOnAnimationEnd = function () {
  2532. if (this.onAnimationEnd) {
  2533. this.onAnimationEnd();
  2534. }
  2535. this.onAnimationEndObservable.notifyObservers(this);
  2536. };
  2537. /**
  2538. * Stop and delete the current animation
  2539. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  2540. * @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)
  2541. */
  2542. Animatable.prototype.stop = function (animationName, targetMask) {
  2543. if (animationName || targetMask) {
  2544. var idx = this._scene._activeAnimatables.indexOf(this);
  2545. if (idx > -1) {
  2546. var runtimeAnimations = this._runtimeAnimations;
  2547. for (var index = runtimeAnimations.length - 1; index >= 0; index--) {
  2548. var runtimeAnimation = runtimeAnimations[index];
  2549. if (animationName && runtimeAnimation.animation.name != animationName) {
  2550. continue;
  2551. }
  2552. if (targetMask && !targetMask(runtimeAnimation.target)) {
  2553. continue;
  2554. }
  2555. runtimeAnimation.dispose();
  2556. runtimeAnimations.splice(index, 1);
  2557. }
  2558. if (runtimeAnimations.length == 0) {
  2559. this._scene._activeAnimatables.splice(idx, 1);
  2560. this._raiseOnAnimationEnd();
  2561. }
  2562. }
  2563. }
  2564. else {
  2565. var index = this._scene._activeAnimatables.indexOf(this);
  2566. if (index > -1) {
  2567. this._scene._activeAnimatables.splice(index, 1);
  2568. var runtimeAnimations = this._runtimeAnimations;
  2569. for (var index = 0; index < runtimeAnimations.length; index++) {
  2570. runtimeAnimations[index].dispose();
  2571. }
  2572. this._raiseOnAnimationEnd();
  2573. }
  2574. }
  2575. };
  2576. /**
  2577. * Wait asynchronously for the animation to end
  2578. * @returns a promise which will be fullfilled when the animation ends
  2579. */
  2580. Animatable.prototype.waitAsync = function () {
  2581. var _this = this;
  2582. return new Promise(function (resolve, reject) {
  2583. _this.onAnimationEndObservable.add(function () {
  2584. resolve(_this);
  2585. }, undefined, undefined, _this, true);
  2586. });
  2587. };
  2588. /** @hidden */
  2589. Animatable.prototype._animate = function (delay) {
  2590. var _this = this;
  2591. if (this._paused) {
  2592. this.animationStarted = false;
  2593. if (this._pausedDelay === null) {
  2594. this._pausedDelay = delay;
  2595. }
  2596. return true;
  2597. }
  2598. if (this._localDelayOffset === null) {
  2599. this._localDelayOffset = delay;
  2600. this._pausedDelay = null;
  2601. }
  2602. else if (this._pausedDelay !== null) {
  2603. this._localDelayOffset += delay - this._pausedDelay;
  2604. this._pausedDelay = null;
  2605. }
  2606. if (this._weight === 0) { // We consider that an animation with a weight === 0 is "actively" paused
  2607. return true;
  2608. }
  2609. // Animating
  2610. var running = false;
  2611. var runtimeAnimations = this._runtimeAnimations;
  2612. var index;
  2613. for (index = 0; index < runtimeAnimations.length; index++) {
  2614. var animation = runtimeAnimations[index];
  2615. var isRunning = animation.animate(delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight, function () {
  2616. _this.onAnimationLoopObservable.notifyObservers(_this);
  2617. if (_this.onAnimationLoop) {
  2618. _this.onAnimationLoop();
  2619. }
  2620. });
  2621. running = running || isRunning;
  2622. }
  2623. this.animationStarted = running;
  2624. if (!running) {
  2625. if (this.disposeOnEnd) {
  2626. // Remove from active animatables
  2627. index = this._scene._activeAnimatables.indexOf(this);
  2628. this._scene._activeAnimatables.splice(index, 1);
  2629. // Dispose all runtime animations
  2630. for (index = 0; index < runtimeAnimations.length; index++) {
  2631. runtimeAnimations[index].dispose();
  2632. }
  2633. }
  2634. this._raiseOnAnimationEnd();
  2635. if (this.disposeOnEnd) {
  2636. this.onAnimationEnd = null;
  2637. this.onAnimationLoop = null;
  2638. this.onAnimationLoopObservable.clear();
  2639. this.onAnimationEndObservable.clear();
  2640. }
  2641. }
  2642. return running;
  2643. };
  2644. return Animatable;
  2645. }());
  2646. /***/ }),
  2647. /***/ "./Animations/animation.ts":
  2648. /*!*********************************!*\
  2649. !*** ./Animations/animation.ts ***!
  2650. \*********************************/
  2651. /*! exports provided: AnimationRange, AnimationEvent, PathCursor, AnimationKeyInterpolation, Animation */
  2652. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2653. "use strict";
  2654. __webpack_require__.r(__webpack_exports__);
  2655. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return AnimationRange; });
  2656. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return AnimationEvent; });
  2657. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PathCursor", function() { return PathCursor; });
  2658. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return AnimationKeyInterpolation; });
  2659. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return Animation; });
  2660. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2661. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  2662. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node */ "./node.ts");
  2663. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  2664. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  2665. /**
  2666. * Represents the range of an animation
  2667. */
  2668. var AnimationRange = /** @class */ (function () {
  2669. /**
  2670. * Initializes the range of an animation
  2671. * @param name The name of the animation range
  2672. * @param from The starting frame of the animation
  2673. * @param to The ending frame of the animation
  2674. */
  2675. function AnimationRange(
  2676. /**The name of the animation range**/
  2677. name,
  2678. /**The starting frame of the animation */
  2679. from,
  2680. /**The ending frame of the animation*/
  2681. to) {
  2682. this.name = name;
  2683. this.from = from;
  2684. this.to = to;
  2685. }
  2686. /**
  2687. * Makes a copy of the animation range
  2688. * @returns A copy of the animation range
  2689. */
  2690. AnimationRange.prototype.clone = function () {
  2691. return new AnimationRange(this.name, this.from, this.to);
  2692. };
  2693. return AnimationRange;
  2694. }());
  2695. /**
  2696. * Composed of a frame, and an action function
  2697. */
  2698. var AnimationEvent = /** @class */ (function () {
  2699. /**
  2700. * Initializes the animation event
  2701. * @param frame The frame for which the event is triggered
  2702. * @param action The event to perform when triggered
  2703. * @param onlyOnce Specifies if the event should be triggered only once
  2704. */
  2705. function AnimationEvent(
  2706. /** The frame for which the event is triggered **/
  2707. frame,
  2708. /** The event to perform when triggered **/
  2709. action,
  2710. /** Specifies if the event should be triggered only once**/
  2711. onlyOnce) {
  2712. this.frame = frame;
  2713. this.action = action;
  2714. this.onlyOnce = onlyOnce;
  2715. /**
  2716. * Specifies if the animation event is done
  2717. */
  2718. this.isDone = false;
  2719. }
  2720. /** @hidden */
  2721. AnimationEvent.prototype._clone = function () {
  2722. return new AnimationEvent(this.frame, this.action, this.onlyOnce);
  2723. };
  2724. return AnimationEvent;
  2725. }());
  2726. /**
  2727. * A cursor which tracks a point on a path
  2728. */
  2729. var PathCursor = /** @class */ (function () {
  2730. /**
  2731. * Initializes the path cursor
  2732. * @param path The path to track
  2733. */
  2734. function PathCursor(path) {
  2735. this.path = path;
  2736. /**
  2737. * Stores path cursor callbacks for when an onchange event is triggered
  2738. */
  2739. this._onchange = new Array();
  2740. /**
  2741. * The value of the path cursor
  2742. */
  2743. this.value = 0;
  2744. /**
  2745. * The animation array of the path cursor
  2746. */
  2747. this.animations = new Array();
  2748. }
  2749. /**
  2750. * Gets the cursor point on the path
  2751. * @returns A point on the path cursor at the cursor location
  2752. */
  2753. PathCursor.prototype.getPoint = function () {
  2754. var point = this.path.getPointAtLengthPosition(this.value);
  2755. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](point.x, 0, point.y);
  2756. };
  2757. /**
  2758. * Moves the cursor ahead by the step amount
  2759. * @param step The amount to move the cursor forward
  2760. * @returns This path cursor
  2761. */
  2762. PathCursor.prototype.moveAhead = function (step) {
  2763. if (step === void 0) { step = 0.002; }
  2764. this.move(step);
  2765. return this;
  2766. };
  2767. /**
  2768. * Moves the cursor behind by the step amount
  2769. * @param step The amount to move the cursor back
  2770. * @returns This path cursor
  2771. */
  2772. PathCursor.prototype.moveBack = function (step) {
  2773. if (step === void 0) { step = 0.002; }
  2774. this.move(-step);
  2775. return this;
  2776. };
  2777. /**
  2778. * Moves the cursor by the step amount
  2779. * If the step amount is greater than one, an exception is thrown
  2780. * @param step The amount to move the cursor
  2781. * @returns This path cursor
  2782. */
  2783. PathCursor.prototype.move = function (step) {
  2784. if (Math.abs(step) > 1) {
  2785. throw "step size should be less than 1.";
  2786. }
  2787. this.value += step;
  2788. this.ensureLimits();
  2789. this.raiseOnChange();
  2790. return this;
  2791. };
  2792. /**
  2793. * Ensures that the value is limited between zero and one
  2794. * @returns This path cursor
  2795. */
  2796. PathCursor.prototype.ensureLimits = function () {
  2797. while (this.value > 1) {
  2798. this.value -= 1;
  2799. }
  2800. while (this.value < 0) {
  2801. this.value += 1;
  2802. }
  2803. return this;
  2804. };
  2805. /**
  2806. * Runs onchange callbacks on change (used by the animation engine)
  2807. * @returns This path cursor
  2808. */
  2809. PathCursor.prototype.raiseOnChange = function () {
  2810. var _this = this;
  2811. this._onchange.forEach(function (f) { return f(_this); });
  2812. return this;
  2813. };
  2814. /**
  2815. * Executes a function on change
  2816. * @param f A path cursor onchange callback
  2817. * @returns This path cursor
  2818. */
  2819. PathCursor.prototype.onchange = function (f) {
  2820. this._onchange.push(f);
  2821. return this;
  2822. };
  2823. return PathCursor;
  2824. }());
  2825. /**
  2826. * Enum for the animation key frame interpolation type
  2827. */
  2828. var AnimationKeyInterpolation;
  2829. (function (AnimationKeyInterpolation) {
  2830. /**
  2831. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  2832. */
  2833. AnimationKeyInterpolation[AnimationKeyInterpolation["STEP"] = 1] = "STEP";
  2834. })(AnimationKeyInterpolation || (AnimationKeyInterpolation = {}));
  2835. /**
  2836. * Class used to store any kind of animation
  2837. */
  2838. var Animation = /** @class */ (function () {
  2839. /**
  2840. * Initializes the animation
  2841. * @param name Name of the animation
  2842. * @param targetProperty Property to animate
  2843. * @param framePerSecond The frames per second of the animation
  2844. * @param dataType The data type of the animation
  2845. * @param loopMode The loop mode of the animation
  2846. * @param enableBlendings Specifies if blending should be enabled
  2847. */
  2848. function Animation(
  2849. /**Name of the animation */
  2850. name,
  2851. /**Property to animate */
  2852. targetProperty,
  2853. /**The frames per second of the animation */
  2854. framePerSecond,
  2855. /**The data type of the animation */
  2856. dataType,
  2857. /**The loop mode of the animation */
  2858. loopMode,
  2859. /**Specifies if blending should be enabled */
  2860. enableBlending) {
  2861. this.name = name;
  2862. this.targetProperty = targetProperty;
  2863. this.framePerSecond = framePerSecond;
  2864. this.dataType = dataType;
  2865. this.loopMode = loopMode;
  2866. this.enableBlending = enableBlending;
  2867. /**
  2868. * @hidden Internal use only
  2869. */
  2870. this._runtimeAnimations = new Array();
  2871. /**
  2872. * The set of event that will be linked to this animation
  2873. */
  2874. this._events = new Array();
  2875. /**
  2876. * Stores the blending speed of the animation
  2877. */
  2878. this.blendingSpeed = 0.01;
  2879. /**
  2880. * Stores the animation ranges for the animation
  2881. */
  2882. this._ranges = {};
  2883. this.targetPropertyPath = targetProperty.split(".");
  2884. this.dataType = dataType;
  2885. this.loopMode = loopMode === undefined ? Animation.ANIMATIONLOOPMODE_CYCLE : loopMode;
  2886. }
  2887. /**
  2888. * @hidden Internal use
  2889. */
  2890. Animation._PrepareAnimation = function (name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction) {
  2891. var dataType = undefined;
  2892. if (!isNaN(parseFloat(from)) && isFinite(from)) {
  2893. dataType = Animation.ANIMATIONTYPE_FLOAT;
  2894. }
  2895. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]) {
  2896. dataType = Animation.ANIMATIONTYPE_QUATERNION;
  2897. }
  2898. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  2899. dataType = Animation.ANIMATIONTYPE_VECTOR3;
  2900. }
  2901. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"]) {
  2902. dataType = Animation.ANIMATIONTYPE_VECTOR2;
  2903. }
  2904. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"]) {
  2905. dataType = Animation.ANIMATIONTYPE_COLOR3;
  2906. }
  2907. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"]) {
  2908. dataType = Animation.ANIMATIONTYPE_SIZE;
  2909. }
  2910. if (dataType == undefined) {
  2911. return null;
  2912. }
  2913. var animation = new Animation(name, targetProperty, framePerSecond, dataType, loopMode);
  2914. var keys = [{ frame: 0, value: from }, { frame: totalFrame, value: to }];
  2915. animation.setKeys(keys);
  2916. if (easingFunction !== undefined) {
  2917. animation.setEasingFunction(easingFunction);
  2918. }
  2919. return animation;
  2920. };
  2921. /**
  2922. * Sets up an animation
  2923. * @param property The property to animate
  2924. * @param animationType The animation type to apply
  2925. * @param framePerSecond The frames per second of the animation
  2926. * @param easingFunction The easing function used in the animation
  2927. * @returns The created animation
  2928. */
  2929. Animation.CreateAnimation = function (property, animationType, framePerSecond, easingFunction) {
  2930. var animation = new Animation(property + "Animation", property, framePerSecond, animationType, Animation.ANIMATIONLOOPMODE_CONSTANT);
  2931. animation.setEasingFunction(easingFunction);
  2932. return animation;
  2933. };
  2934. /**
  2935. * Create and start an animation on a node
  2936. * @param name defines the name of the global animation that will be run on all nodes
  2937. * @param node defines the root node where the animation will take place
  2938. * @param targetProperty defines property to animate
  2939. * @param framePerSecond defines the number of frame per second yo use
  2940. * @param totalFrame defines the number of frames in total
  2941. * @param from defines the initial value
  2942. * @param to defines the final value
  2943. * @param loopMode defines which loop mode you want to use (off by default)
  2944. * @param easingFunction defines the easing function to use (linear by default)
  2945. * @param onAnimationEnd defines the callback to call when animation end
  2946. * @returns the animatable created for this animation
  2947. */
  2948. Animation.CreateAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  2949. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  2950. if (!animation) {
  2951. return null;
  2952. }
  2953. return node.getScene().beginDirectAnimation(node, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  2954. };
  2955. /**
  2956. * Create and start an animation on a node and its descendants
  2957. * @param name defines the name of the global animation that will be run on all nodes
  2958. * @param node defines the root node where the animation will take place
  2959. * @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
  2960. * @param targetProperty defines property to animate
  2961. * @param framePerSecond defines the number of frame per second to use
  2962. * @param totalFrame defines the number of frames in total
  2963. * @param from defines the initial value
  2964. * @param to defines the final value
  2965. * @param loopMode defines which loop mode you want to use (off by default)
  2966. * @param easingFunction defines the easing function to use (linear by default)
  2967. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  2968. * @returns the list of animatables created for all nodes
  2969. * @example https://www.babylonjs-playground.com/#MH0VLI
  2970. */
  2971. Animation.CreateAndStartHierarchyAnimation = function (name, node, directDescendantsOnly, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  2972. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  2973. if (!animation) {
  2974. return null;
  2975. }
  2976. var scene = node.getScene();
  2977. return scene.beginDirectHierarchyAnimation(node, directDescendantsOnly, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  2978. };
  2979. /**
  2980. * Creates a new animation, merges it with the existing animations and starts it
  2981. * @param name Name of the animation
  2982. * @param node Node which contains the scene that begins the animations
  2983. * @param targetProperty Specifies which property to animate
  2984. * @param framePerSecond The frames per second of the animation
  2985. * @param totalFrame The total number of frames
  2986. * @param from The frame at the beginning of the animation
  2987. * @param to The frame at the end of the animation
  2988. * @param loopMode Specifies the loop mode of the animation
  2989. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  2990. * @param onAnimationEnd Callback to run once the animation is complete
  2991. * @returns Nullable animation
  2992. */
  2993. Animation.CreateMergeAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  2994. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  2995. if (!animation) {
  2996. return null;
  2997. }
  2998. node.animations.push(animation);
  2999. return node.getScene().beginAnimation(node, 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3000. };
  3001. /**
  3002. * Transition property of an host to the target Value
  3003. * @param property The property to transition
  3004. * @param targetValue The target Value of the property
  3005. * @param host The object where the property to animate belongs
  3006. * @param scene Scene used to run the animation
  3007. * @param frameRate Framerate (in frame/s) to use
  3008. * @param transition The transition type we want to use
  3009. * @param duration The duration of the animation, in milliseconds
  3010. * @param onAnimationEnd Callback trigger at the end of the animation
  3011. * @returns Nullable animation
  3012. */
  3013. Animation.TransitionTo = function (property, targetValue, host, scene, frameRate, transition, duration, onAnimationEnd) {
  3014. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  3015. if (duration <= 0) {
  3016. host[property] = targetValue;
  3017. if (onAnimationEnd) {
  3018. onAnimationEnd();
  3019. }
  3020. return null;
  3021. }
  3022. var endFrame = frameRate * (duration / 1000);
  3023. transition.setKeys([{
  3024. frame: 0,
  3025. value: host[property].clone ? host[property].clone() : host[property]
  3026. },
  3027. {
  3028. frame: endFrame,
  3029. value: targetValue
  3030. }]);
  3031. if (!host.animations) {
  3032. host.animations = [];
  3033. }
  3034. host.animations.push(transition);
  3035. var animation = scene.beginAnimation(host, 0, endFrame, false);
  3036. animation.onAnimationEnd = onAnimationEnd;
  3037. return animation;
  3038. };
  3039. Object.defineProperty(Animation.prototype, "runtimeAnimations", {
  3040. /**
  3041. * Return the array of runtime animations currently using this animation
  3042. */
  3043. get: function () {
  3044. return this._runtimeAnimations;
  3045. },
  3046. enumerable: true,
  3047. configurable: true
  3048. });
  3049. Object.defineProperty(Animation.prototype, "hasRunningRuntimeAnimations", {
  3050. /**
  3051. * Specifies if any of the runtime animations are currently running
  3052. */
  3053. get: function () {
  3054. for (var _i = 0, _a = this._runtimeAnimations; _i < _a.length; _i++) {
  3055. var runtimeAnimation = _a[_i];
  3056. if (!runtimeAnimation.isStopped) {
  3057. return true;
  3058. }
  3059. }
  3060. return false;
  3061. },
  3062. enumerable: true,
  3063. configurable: true
  3064. });
  3065. // Methods
  3066. /**
  3067. * Converts the animation to a string
  3068. * @param fullDetails support for multiple levels of logging within scene loading
  3069. * @returns String form of the animation
  3070. */
  3071. Animation.prototype.toString = function (fullDetails) {
  3072. var ret = "Name: " + this.name + ", property: " + this.targetProperty;
  3073. ret += ", datatype: " + (["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"])[this.dataType];
  3074. ret += ", nKeys: " + (this._keys ? this._keys.length : "none");
  3075. ret += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  3076. if (fullDetails) {
  3077. ret += ", Ranges: {";
  3078. var first = true;
  3079. for (var name in this._ranges) {
  3080. if (first) {
  3081. ret += ", ";
  3082. first = false;
  3083. }
  3084. ret += name;
  3085. }
  3086. ret += "}";
  3087. }
  3088. return ret;
  3089. };
  3090. /**
  3091. * Add an event to this animation
  3092. * @param event Event to add
  3093. */
  3094. Animation.prototype.addEvent = function (event) {
  3095. this._events.push(event);
  3096. };
  3097. /**
  3098. * Remove all events found at the given frame
  3099. * @param frame The frame to remove events from
  3100. */
  3101. Animation.prototype.removeEvents = function (frame) {
  3102. for (var index = 0; index < this._events.length; index++) {
  3103. if (this._events[index].frame === frame) {
  3104. this._events.splice(index, 1);
  3105. index--;
  3106. }
  3107. }
  3108. };
  3109. /**
  3110. * Retrieves all the events from the animation
  3111. * @returns Events from the animation
  3112. */
  3113. Animation.prototype.getEvents = function () {
  3114. return this._events;
  3115. };
  3116. /**
  3117. * Creates an animation range
  3118. * @param name Name of the animation range
  3119. * @param from Starting frame of the animation range
  3120. * @param to Ending frame of the animation
  3121. */
  3122. Animation.prototype.createRange = function (name, from, to) {
  3123. // check name not already in use; could happen for bones after serialized
  3124. if (!this._ranges[name]) {
  3125. this._ranges[name] = new AnimationRange(name, from, to);
  3126. }
  3127. };
  3128. /**
  3129. * Deletes an animation range by name
  3130. * @param name Name of the animation range to delete
  3131. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3132. */
  3133. Animation.prototype.deleteRange = function (name, deleteFrames) {
  3134. if (deleteFrames === void 0) { deleteFrames = true; }
  3135. var range = this._ranges[name];
  3136. if (!range) {
  3137. return;
  3138. }
  3139. if (deleteFrames) {
  3140. var from = range.from;
  3141. var to = range.to;
  3142. // this loop MUST go high to low for multiple splices to work
  3143. for (var key = this._keys.length - 1; key >= 0; key--) {
  3144. if (this._keys[key].frame >= from && this._keys[key].frame <= to) {
  3145. this._keys.splice(key, 1);
  3146. }
  3147. }
  3148. }
  3149. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  3150. };
  3151. /**
  3152. * Gets the animation range by name, or null if not defined
  3153. * @param name Name of the animation range
  3154. * @returns Nullable animation range
  3155. */
  3156. Animation.prototype.getRange = function (name) {
  3157. return this._ranges[name];
  3158. };
  3159. /**
  3160. * Gets the key frames from the animation
  3161. * @returns The key frames of the animation
  3162. */
  3163. Animation.prototype.getKeys = function () {
  3164. return this._keys;
  3165. };
  3166. /**
  3167. * Gets the highest frame rate of the animation
  3168. * @returns Highest frame rate of the animation
  3169. */
  3170. Animation.prototype.getHighestFrame = function () {
  3171. var ret = 0;
  3172. for (var key = 0, nKeys = this._keys.length; key < nKeys; key++) {
  3173. if (ret < this._keys[key].frame) {
  3174. ret = this._keys[key].frame;
  3175. }
  3176. }
  3177. return ret;
  3178. };
  3179. /**
  3180. * Gets the easing function of the animation
  3181. * @returns Easing function of the animation
  3182. */
  3183. Animation.prototype.getEasingFunction = function () {
  3184. return this._easingFunction;
  3185. };
  3186. /**
  3187. * Sets the easing function of the animation
  3188. * @param easingFunction A custom mathematical formula for animation
  3189. */
  3190. Animation.prototype.setEasingFunction = function (easingFunction) {
  3191. this._easingFunction = easingFunction;
  3192. };
  3193. /**
  3194. * Interpolates a scalar linearly
  3195. * @param startValue Start value of the animation curve
  3196. * @param endValue End value of the animation curve
  3197. * @param gradient Scalar amount to interpolate
  3198. * @returns Interpolated scalar value
  3199. */
  3200. Animation.prototype.floatInterpolateFunction = function (startValue, endValue, gradient) {
  3201. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Lerp(startValue, endValue, gradient);
  3202. };
  3203. /**
  3204. * Interpolates a scalar cubically
  3205. * @param startValue Start value of the animation curve
  3206. * @param outTangent End tangent of the animation
  3207. * @param endValue End value of the animation curve
  3208. * @param inTangent Start tangent of the animation curve
  3209. * @param gradient Scalar amount to interpolate
  3210. * @returns Interpolated scalar value
  3211. */
  3212. Animation.prototype.floatInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3213. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3214. };
  3215. /**
  3216. * Interpolates a quaternion using a spherical linear interpolation
  3217. * @param startValue Start value of the animation curve
  3218. * @param endValue End value of the animation curve
  3219. * @param gradient Scalar amount to interpolate
  3220. * @returns Interpolated quaternion value
  3221. */
  3222. Animation.prototype.quaternionInterpolateFunction = function (startValue, endValue, gradient) {
  3223. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Slerp(startValue, endValue, gradient);
  3224. };
  3225. /**
  3226. * Interpolates a quaternion cubically
  3227. * @param startValue Start value of the animation curve
  3228. * @param outTangent End tangent of the animation curve
  3229. * @param endValue End value of the animation curve
  3230. * @param inTangent Start tangent of the animation curve
  3231. * @param gradient Scalar amount to interpolate
  3232. * @returns Interpolated quaternion value
  3233. */
  3234. Animation.prototype.quaternionInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3235. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Hermite(startValue, outTangent, endValue, inTangent, gradient).normalize();
  3236. };
  3237. /**
  3238. * Interpolates a Vector3 linearl
  3239. * @param startValue Start value of the animation curve
  3240. * @param endValue End value of the animation curve
  3241. * @param gradient Scalar amount to interpolate
  3242. * @returns Interpolated scalar value
  3243. */
  3244. Animation.prototype.vector3InterpolateFunction = function (startValue, endValue, gradient) {
  3245. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(startValue, endValue, gradient);
  3246. };
  3247. /**
  3248. * Interpolates a Vector3 cubically
  3249. * @param startValue Start value of the animation curve
  3250. * @param outTangent End tangent of the animation
  3251. * @param endValue End value of the animation curve
  3252. * @param inTangent Start tangent of the animation curve
  3253. * @param gradient Scalar amount to interpolate
  3254. * @returns InterpolatedVector3 value
  3255. */
  3256. Animation.prototype.vector3InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3257. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3258. };
  3259. /**
  3260. * Interpolates a Vector2 linearly
  3261. * @param startValue Start value of the animation curve
  3262. * @param endValue End value of the animation curve
  3263. * @param gradient Scalar amount to interpolate
  3264. * @returns Interpolated Vector2 value
  3265. */
  3266. Animation.prototype.vector2InterpolateFunction = function (startValue, endValue, gradient) {
  3267. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(startValue, endValue, gradient);
  3268. };
  3269. /**
  3270. * Interpolates a Vector2 cubically
  3271. * @param startValue Start value of the animation curve
  3272. * @param outTangent End tangent of the animation
  3273. * @param endValue End value of the animation curve
  3274. * @param inTangent Start tangent of the animation curve
  3275. * @param gradient Scalar amount to interpolate
  3276. * @returns Interpolated Vector2 value
  3277. */
  3278. Animation.prototype.vector2InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3279. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3280. };
  3281. /**
  3282. * Interpolates a size linearly
  3283. * @param startValue Start value of the animation curve
  3284. * @param endValue End value of the animation curve
  3285. * @param gradient Scalar amount to interpolate
  3286. * @returns Interpolated Size value
  3287. */
  3288. Animation.prototype.sizeInterpolateFunction = function (startValue, endValue, gradient) {
  3289. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Lerp(startValue, endValue, gradient);
  3290. };
  3291. /**
  3292. * Interpolates a Color3 linearly
  3293. * @param startValue Start value of the animation curve
  3294. * @param endValue End value of the animation curve
  3295. * @param gradient Scalar amount to interpolate
  3296. * @returns Interpolated Color3 value
  3297. */
  3298. Animation.prototype.color3InterpolateFunction = function (startValue, endValue, gradient) {
  3299. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Lerp(startValue, endValue, gradient);
  3300. };
  3301. /**
  3302. * @hidden Internal use only
  3303. */
  3304. Animation.prototype._getKeyValue = function (value) {
  3305. if (typeof value === "function") {
  3306. return value();
  3307. }
  3308. return value;
  3309. };
  3310. /**
  3311. * @hidden Internal use only
  3312. */
  3313. Animation.prototype._interpolate = function (currentFrame, repeatCount, workValue, loopMode, offsetValue, highLimitValue) {
  3314. if (loopMode === Animation.ANIMATIONLOOPMODE_CONSTANT && repeatCount > 0) {
  3315. return highLimitValue.clone ? highLimitValue.clone() : highLimitValue;
  3316. }
  3317. var keys = this.getKeys();
  3318. // Try to get a hash to find the right key
  3319. 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));
  3320. if (keys[startKeyIndex].frame >= currentFrame) {
  3321. while (startKeyIndex - 1 >= 0 && keys[startKeyIndex].frame >= currentFrame) {
  3322. startKeyIndex--;
  3323. }
  3324. }
  3325. for (var key = startKeyIndex; key < keys.length; key++) {
  3326. var endKey = keys[key + 1];
  3327. if (endKey.frame >= currentFrame) {
  3328. var startKey = keys[key];
  3329. var startValue = this._getKeyValue(startKey.value);
  3330. if (startKey.interpolation === AnimationKeyInterpolation.STEP) {
  3331. return startValue;
  3332. }
  3333. var endValue = this._getKeyValue(endKey.value);
  3334. var useTangent = startKey.outTangent !== undefined && endKey.inTangent !== undefined;
  3335. var frameDelta = endKey.frame - startKey.frame;
  3336. // gradient : percent of currentFrame between the frame inf and the frame sup
  3337. var gradient = (currentFrame - startKey.frame) / frameDelta;
  3338. // check for easingFunction and correction of gradient
  3339. var easingFunction = this.getEasingFunction();
  3340. if (easingFunction != null) {
  3341. gradient = easingFunction.ease(gradient);
  3342. }
  3343. switch (this.dataType) {
  3344. // Float
  3345. case Animation.ANIMATIONTYPE_FLOAT:
  3346. var floatValue = useTangent ? this.floatInterpolateFunctionWithTangents(startValue, startKey.outTangent * frameDelta, endValue, endKey.inTangent * frameDelta, gradient) : this.floatInterpolateFunction(startValue, endValue, gradient);
  3347. switch (loopMode) {
  3348. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3349. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3350. return floatValue;
  3351. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3352. return offsetValue * repeatCount + floatValue;
  3353. }
  3354. break;
  3355. // Quaternion
  3356. case Animation.ANIMATIONTYPE_QUATERNION:
  3357. var quatValue = useTangent ? this.quaternionInterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.quaternionInterpolateFunction(startValue, endValue, gradient);
  3358. switch (loopMode) {
  3359. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3360. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3361. return quatValue;
  3362. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3363. return quatValue.addInPlace(offsetValue.scale(repeatCount));
  3364. }
  3365. return quatValue;
  3366. // Vector3
  3367. case Animation.ANIMATIONTYPE_VECTOR3:
  3368. var vec3Value = useTangent ? this.vector3InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector3InterpolateFunction(startValue, endValue, gradient);
  3369. switch (loopMode) {
  3370. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3371. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3372. return vec3Value;
  3373. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3374. return vec3Value.add(offsetValue.scale(repeatCount));
  3375. }
  3376. // Vector2
  3377. case Animation.ANIMATIONTYPE_VECTOR2:
  3378. var vec2Value = useTangent ? this.vector2InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector2InterpolateFunction(startValue, endValue, gradient);
  3379. switch (loopMode) {
  3380. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3381. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3382. return vec2Value;
  3383. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3384. return vec2Value.add(offsetValue.scale(repeatCount));
  3385. }
  3386. // Size
  3387. case Animation.ANIMATIONTYPE_SIZE:
  3388. switch (loopMode) {
  3389. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3390. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3391. return this.sizeInterpolateFunction(startValue, endValue, gradient);
  3392. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3393. return this.sizeInterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3394. }
  3395. // Color3
  3396. case Animation.ANIMATIONTYPE_COLOR3:
  3397. switch (loopMode) {
  3398. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3399. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3400. return this.color3InterpolateFunction(startValue, endValue, gradient);
  3401. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3402. return this.color3InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3403. }
  3404. // Matrix
  3405. case Animation.ANIMATIONTYPE_MATRIX:
  3406. switch (loopMode) {
  3407. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3408. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3409. if (Animation.AllowMatricesInterpolation) {
  3410. return this.matrixInterpolateFunction(startValue, endValue, gradient, workValue);
  3411. }
  3412. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3413. return startValue;
  3414. }
  3415. default:
  3416. break;
  3417. }
  3418. break;
  3419. }
  3420. }
  3421. return this._getKeyValue(keys[keys.length - 1].value);
  3422. };
  3423. /**
  3424. * Defines the function to use to interpolate matrices
  3425. * @param startValue defines the start matrix
  3426. * @param endValue defines the end matrix
  3427. * @param gradient defines the gradient between both matrices
  3428. * @param result defines an optional target matrix where to store the interpolation
  3429. * @returns the interpolated matrix
  3430. */
  3431. Animation.prototype.matrixInterpolateFunction = function (startValue, endValue, gradient, result) {
  3432. if (Animation.AllowMatrixDecomposeForInterpolation) {
  3433. if (result) {
  3434. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(startValue, endValue, gradient, result);
  3435. return result;
  3436. }
  3437. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(startValue, endValue, gradient);
  3438. }
  3439. if (result) {
  3440. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(startValue, endValue, gradient, result);
  3441. return result;
  3442. }
  3443. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(startValue, endValue, gradient);
  3444. };
  3445. /**
  3446. * Makes a copy of the animation
  3447. * @returns Cloned animation
  3448. */
  3449. Animation.prototype.clone = function () {
  3450. var clone = new Animation(this.name, this.targetPropertyPath.join("."), this.framePerSecond, this.dataType, this.loopMode);
  3451. clone.enableBlending = this.enableBlending;
  3452. clone.blendingSpeed = this.blendingSpeed;
  3453. if (this._keys) {
  3454. clone.setKeys(this._keys);
  3455. }
  3456. if (this._ranges) {
  3457. clone._ranges = {};
  3458. for (var name in this._ranges) {
  3459. var range = this._ranges[name];
  3460. if (!range) {
  3461. continue;
  3462. }
  3463. clone._ranges[name] = range.clone();
  3464. }
  3465. }
  3466. return clone;
  3467. };
  3468. /**
  3469. * Sets the key frames of the animation
  3470. * @param values The animation key frames to set
  3471. */
  3472. Animation.prototype.setKeys = function (values) {
  3473. this._keys = values.slice(0);
  3474. };
  3475. /**
  3476. * Serializes the animation to an object
  3477. * @returns Serialized object
  3478. */
  3479. Animation.prototype.serialize = function () {
  3480. var serializationObject = {};
  3481. serializationObject.name = this.name;
  3482. serializationObject.property = this.targetProperty;
  3483. serializationObject.framePerSecond = this.framePerSecond;
  3484. serializationObject.dataType = this.dataType;
  3485. serializationObject.loopBehavior = this.loopMode;
  3486. serializationObject.enableBlending = this.enableBlending;
  3487. serializationObject.blendingSpeed = this.blendingSpeed;
  3488. var dataType = this.dataType;
  3489. serializationObject.keys = [];
  3490. var keys = this.getKeys();
  3491. for (var index = 0; index < keys.length; index++) {
  3492. var animationKey = keys[index];
  3493. var key = {};
  3494. key.frame = animationKey.frame;
  3495. switch (dataType) {
  3496. case Animation.ANIMATIONTYPE_FLOAT:
  3497. key.values = [animationKey.value];
  3498. break;
  3499. case Animation.ANIMATIONTYPE_QUATERNION:
  3500. case Animation.ANIMATIONTYPE_MATRIX:
  3501. case Animation.ANIMATIONTYPE_VECTOR3:
  3502. case Animation.ANIMATIONTYPE_COLOR3:
  3503. key.values = animationKey.value.asArray();
  3504. break;
  3505. }
  3506. serializationObject.keys.push(key);
  3507. }
  3508. serializationObject.ranges = [];
  3509. for (var name in this._ranges) {
  3510. var source = this._ranges[name];
  3511. if (!source) {
  3512. continue;
  3513. }
  3514. var range = {};
  3515. range.name = name;
  3516. range.from = source.from;
  3517. range.to = source.to;
  3518. serializationObject.ranges.push(range);
  3519. }
  3520. return serializationObject;
  3521. };
  3522. Object.defineProperty(Animation, "ANIMATIONTYPE_FLOAT", {
  3523. /**
  3524. * Get the float animation type
  3525. */
  3526. get: function () {
  3527. return Animation._ANIMATIONTYPE_FLOAT;
  3528. },
  3529. enumerable: true,
  3530. configurable: true
  3531. });
  3532. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR3", {
  3533. /**
  3534. * Get the Vector3 animation type
  3535. */
  3536. get: function () {
  3537. return Animation._ANIMATIONTYPE_VECTOR3;
  3538. },
  3539. enumerable: true,
  3540. configurable: true
  3541. });
  3542. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR2", {
  3543. /**
  3544. * Get the Vector2 animation type
  3545. */
  3546. get: function () {
  3547. return Animation._ANIMATIONTYPE_VECTOR2;
  3548. },
  3549. enumerable: true,
  3550. configurable: true
  3551. });
  3552. Object.defineProperty(Animation, "ANIMATIONTYPE_SIZE", {
  3553. /**
  3554. * Get the Size animation type
  3555. */
  3556. get: function () {
  3557. return Animation._ANIMATIONTYPE_SIZE;
  3558. },
  3559. enumerable: true,
  3560. configurable: true
  3561. });
  3562. Object.defineProperty(Animation, "ANIMATIONTYPE_QUATERNION", {
  3563. /**
  3564. * Get the Quaternion animation type
  3565. */
  3566. get: function () {
  3567. return Animation._ANIMATIONTYPE_QUATERNION;
  3568. },
  3569. enumerable: true,
  3570. configurable: true
  3571. });
  3572. Object.defineProperty(Animation, "ANIMATIONTYPE_MATRIX", {
  3573. /**
  3574. * Get the Matrix animation type
  3575. */
  3576. get: function () {
  3577. return Animation._ANIMATIONTYPE_MATRIX;
  3578. },
  3579. enumerable: true,
  3580. configurable: true
  3581. });
  3582. Object.defineProperty(Animation, "ANIMATIONTYPE_COLOR3", {
  3583. /**
  3584. * Get the Color3 animation type
  3585. */
  3586. get: function () {
  3587. return Animation._ANIMATIONTYPE_COLOR3;
  3588. },
  3589. enumerable: true,
  3590. configurable: true
  3591. });
  3592. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_RELATIVE", {
  3593. /**
  3594. * Get the Relative Loop Mode
  3595. */
  3596. get: function () {
  3597. return Animation._ANIMATIONLOOPMODE_RELATIVE;
  3598. },
  3599. enumerable: true,
  3600. configurable: true
  3601. });
  3602. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CYCLE", {
  3603. /**
  3604. * Get the Cycle Loop Mode
  3605. */
  3606. get: function () {
  3607. return Animation._ANIMATIONLOOPMODE_CYCLE;
  3608. },
  3609. enumerable: true,
  3610. configurable: true
  3611. });
  3612. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CONSTANT", {
  3613. /**
  3614. * Get the Constant Loop Mode
  3615. */
  3616. get: function () {
  3617. return Animation._ANIMATIONLOOPMODE_CONSTANT;
  3618. },
  3619. enumerable: true,
  3620. configurable: true
  3621. });
  3622. /** @hidden */
  3623. Animation._UniversalLerp = function (left, right, amount) {
  3624. var constructor = left.constructor;
  3625. if (constructor.Lerp) { // Lerp supported
  3626. return constructor.Lerp(left, right, amount);
  3627. }
  3628. else if (constructor.Slerp) { // Slerp supported
  3629. return constructor.Slerp(left, right, amount);
  3630. }
  3631. else if (left.toFixed) { // Number
  3632. return left * (1.0 - amount) + amount * right;
  3633. }
  3634. else { // Blending not supported
  3635. return right;
  3636. }
  3637. };
  3638. /**
  3639. * Parses an animation object and creates an animation
  3640. * @param parsedAnimation Parsed animation object
  3641. * @returns Animation object
  3642. */
  3643. Animation.Parse = function (parsedAnimation) {
  3644. var animation = new Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
  3645. var dataType = parsedAnimation.dataType;
  3646. var keys = [];
  3647. var data;
  3648. var index;
  3649. if (parsedAnimation.enableBlending) {
  3650. animation.enableBlending = parsedAnimation.enableBlending;
  3651. }
  3652. if (parsedAnimation.blendingSpeed) {
  3653. animation.blendingSpeed = parsedAnimation.blendingSpeed;
  3654. }
  3655. for (index = 0; index < parsedAnimation.keys.length; index++) {
  3656. var key = parsedAnimation.keys[index];
  3657. var inTangent;
  3658. var outTangent;
  3659. switch (dataType) {
  3660. case Animation.ANIMATIONTYPE_FLOAT:
  3661. data = key.values[0];
  3662. if (key.values.length >= 1) {
  3663. inTangent = key.values[1];
  3664. }
  3665. if (key.values.length >= 2) {
  3666. outTangent = key.values[2];
  3667. }
  3668. break;
  3669. case Animation.ANIMATIONTYPE_QUATERNION:
  3670. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values);
  3671. if (key.values.length >= 8) {
  3672. var _inTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(4, 8));
  3673. if (!_inTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3674. inTangent = _inTangent;
  3675. }
  3676. }
  3677. if (key.values.length >= 12) {
  3678. var _outTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(8, 12));
  3679. if (!_outTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3680. outTangent = _outTangent;
  3681. }
  3682. }
  3683. break;
  3684. case Animation.ANIMATIONTYPE_MATRIX:
  3685. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromArray(key.values);
  3686. break;
  3687. case Animation.ANIMATIONTYPE_COLOR3:
  3688. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(key.values);
  3689. break;
  3690. case Animation.ANIMATIONTYPE_VECTOR3:
  3691. default:
  3692. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(key.values);
  3693. break;
  3694. }
  3695. var keyData = {};
  3696. keyData.frame = key.frame;
  3697. keyData.value = data;
  3698. if (inTangent != undefined) {
  3699. keyData.inTangent = inTangent;
  3700. }
  3701. if (outTangent != undefined) {
  3702. keyData.outTangent = outTangent;
  3703. }
  3704. keys.push(keyData);
  3705. }
  3706. animation.setKeys(keys);
  3707. if (parsedAnimation.ranges) {
  3708. for (index = 0; index < parsedAnimation.ranges.length; index++) {
  3709. data = parsedAnimation.ranges[index];
  3710. animation.createRange(data.name, data.from, data.to);
  3711. }
  3712. }
  3713. return animation;
  3714. };
  3715. /**
  3716. * Appends the serialized animations from the source animations
  3717. * @param source Source containing the animations
  3718. * @param destination Target to store the animations
  3719. */
  3720. Animation.AppendSerializedAnimations = function (source, destination) {
  3721. _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["SerializationHelper"].AppendSerializedAnimations(source, destination);
  3722. };
  3723. /**
  3724. * Use matrix interpolation instead of using direct key value when animating matrices
  3725. */
  3726. Animation.AllowMatricesInterpolation = false;
  3727. /**
  3728. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3729. */
  3730. Animation.AllowMatrixDecomposeForInterpolation = true;
  3731. // Statics
  3732. /**
  3733. * Float animation type
  3734. */
  3735. Animation._ANIMATIONTYPE_FLOAT = 0;
  3736. /**
  3737. * Vector3 animation type
  3738. */
  3739. Animation._ANIMATIONTYPE_VECTOR3 = 1;
  3740. /**
  3741. * Quaternion animation type
  3742. */
  3743. Animation._ANIMATIONTYPE_QUATERNION = 2;
  3744. /**
  3745. * Matrix animation type
  3746. */
  3747. Animation._ANIMATIONTYPE_MATRIX = 3;
  3748. /**
  3749. * Color3 animation type
  3750. */
  3751. Animation._ANIMATIONTYPE_COLOR3 = 4;
  3752. /**
  3753. * Vector2 animation type
  3754. */
  3755. Animation._ANIMATIONTYPE_VECTOR2 = 5;
  3756. /**
  3757. * Size animation type
  3758. */
  3759. Animation._ANIMATIONTYPE_SIZE = 6;
  3760. /**
  3761. * Relative Loop Mode
  3762. */
  3763. Animation._ANIMATIONLOOPMODE_RELATIVE = 0;
  3764. /**
  3765. * Cycle Loop Mode
  3766. */
  3767. Animation._ANIMATIONLOOPMODE_CYCLE = 1;
  3768. /**
  3769. * Constant Loop Mode
  3770. */
  3771. Animation._ANIMATIONLOOPMODE_CONSTANT = 2;
  3772. return Animation;
  3773. }());
  3774. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"]._AnimationParser = Animation.Parse;
  3775. _node__WEBPACK_IMPORTED_MODULE_2__["Node"]._AnimationRangeFactory = function (name, from, to) { return new AnimationRange(name, from, to); };
  3776. /***/ }),
  3777. /***/ "./Animations/animationGroup.ts":
  3778. /*!**************************************!*\
  3779. !*** ./Animations/animationGroup.ts ***!
  3780. \**************************************/
  3781. /*! exports provided: TargetedAnimation, AnimationGroup */
  3782. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3783. "use strict";
  3784. __webpack_require__.r(__webpack_exports__);
  3785. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return TargetedAnimation; });
  3786. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return AnimationGroup; });
  3787. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  3788. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  3789. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  3790. /**
  3791. * This class defines the direct association between an animation and a target
  3792. */
  3793. var TargetedAnimation = /** @class */ (function () {
  3794. function TargetedAnimation() {
  3795. }
  3796. return TargetedAnimation;
  3797. }());
  3798. /**
  3799. * Use this class to create coordinated animations on multiple targets
  3800. */
  3801. var AnimationGroup = /** @class */ (function () {
  3802. /**
  3803. * Instantiates a new Animation Group.
  3804. * This helps managing several animations at once.
  3805. * @see http://doc.babylonjs.com/how_to/group
  3806. * @param name Defines the name of the group
  3807. * @param scene Defines the scene the group belongs to
  3808. */
  3809. function AnimationGroup(
  3810. /** The name of the animation group */
  3811. name, scene) {
  3812. if (scene === void 0) { scene = null; }
  3813. this.name = name;
  3814. this._targetedAnimations = new Array();
  3815. this._animatables = new Array();
  3816. this._from = Number.MAX_VALUE;
  3817. this._to = -Number.MAX_VALUE;
  3818. this._speedRatio = 1;
  3819. /**
  3820. * This observable will notify when one animation have ended
  3821. */
  3822. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3823. /**
  3824. * Observer raised when one animation loops
  3825. */
  3826. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3827. /**
  3828. * This observable will notify when all animations have ended.
  3829. */
  3830. this.onAnimationGroupEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3831. /**
  3832. * This observable will notify when all animations have paused.
  3833. */
  3834. this.onAnimationGroupPauseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3835. /**
  3836. * This observable will notify when all animations are playing.
  3837. */
  3838. this.onAnimationGroupPlayObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3839. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  3840. this.uniqueId = this._scene.getUniqueId();
  3841. this._scene.animationGroups.push(this);
  3842. }
  3843. Object.defineProperty(AnimationGroup.prototype, "from", {
  3844. /**
  3845. * Gets the first frame
  3846. */
  3847. get: function () {
  3848. return this._from;
  3849. },
  3850. enumerable: true,
  3851. configurable: true
  3852. });
  3853. Object.defineProperty(AnimationGroup.prototype, "to", {
  3854. /**
  3855. * Gets the last frame
  3856. */
  3857. get: function () {
  3858. return this._to;
  3859. },
  3860. enumerable: true,
  3861. configurable: true
  3862. });
  3863. Object.defineProperty(AnimationGroup.prototype, "isStarted", {
  3864. /**
  3865. * Define if the animations are started
  3866. */
  3867. get: function () {
  3868. return this._isStarted;
  3869. },
  3870. enumerable: true,
  3871. configurable: true
  3872. });
  3873. Object.defineProperty(AnimationGroup.prototype, "isPlaying", {
  3874. /**
  3875. * Gets a value indicating that the current group is playing
  3876. */
  3877. get: function () {
  3878. return this._isStarted && !this._isPaused;
  3879. },
  3880. enumerable: true,
  3881. configurable: true
  3882. });
  3883. Object.defineProperty(AnimationGroup.prototype, "speedRatio", {
  3884. /**
  3885. * Gets or sets the speed ratio to use for all animations
  3886. */
  3887. get: function () {
  3888. return this._speedRatio;
  3889. },
  3890. /**
  3891. * Gets or sets the speed ratio to use for all animations
  3892. */
  3893. set: function (value) {
  3894. if (this._speedRatio === value) {
  3895. return;
  3896. }
  3897. this._speedRatio = value;
  3898. for (var index = 0; index < this._animatables.length; index++) {
  3899. var animatable = this._animatables[index];
  3900. animatable.speedRatio = this._speedRatio;
  3901. }
  3902. },
  3903. enumerable: true,
  3904. configurable: true
  3905. });
  3906. Object.defineProperty(AnimationGroup.prototype, "targetedAnimations", {
  3907. /**
  3908. * Gets the targeted animations for this animation group
  3909. */
  3910. get: function () {
  3911. return this._targetedAnimations;
  3912. },
  3913. enumerable: true,
  3914. configurable: true
  3915. });
  3916. Object.defineProperty(AnimationGroup.prototype, "animatables", {
  3917. /**
  3918. * returning the list of animatables controlled by this animation group.
  3919. */
  3920. get: function () {
  3921. return this._animatables;
  3922. },
  3923. enumerable: true,
  3924. configurable: true
  3925. });
  3926. /**
  3927. * Add an animation (with its target) in the group
  3928. * @param animation defines the animation we want to add
  3929. * @param target defines the target of the animation
  3930. * @returns the TargetedAnimation object
  3931. */
  3932. AnimationGroup.prototype.addTargetedAnimation = function (animation, target) {
  3933. var targetedAnimation = {
  3934. animation: animation,
  3935. target: target
  3936. };
  3937. var keys = animation.getKeys();
  3938. if (this._from > keys[0].frame) {
  3939. this._from = keys[0].frame;
  3940. }
  3941. if (this._to < keys[keys.length - 1].frame) {
  3942. this._to = keys[keys.length - 1].frame;
  3943. }
  3944. this._targetedAnimations.push(targetedAnimation);
  3945. return targetedAnimation;
  3946. };
  3947. /**
  3948. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  3949. * It can add constant keys at begin or end
  3950. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  3951. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  3952. * @returns the animation group
  3953. */
  3954. AnimationGroup.prototype.normalize = function (beginFrame, endFrame) {
  3955. if (beginFrame === void 0) { beginFrame = null; }
  3956. if (endFrame === void 0) { endFrame = null; }
  3957. if (beginFrame == null) {
  3958. beginFrame = this._from;
  3959. }
  3960. if (endFrame == null) {
  3961. endFrame = this._to;
  3962. }
  3963. for (var index = 0; index < this._targetedAnimations.length; index++) {
  3964. var targetedAnimation = this._targetedAnimations[index];
  3965. var keys = targetedAnimation.animation.getKeys();
  3966. var startKey = keys[0];
  3967. var endKey = keys[keys.length - 1];
  3968. if (startKey.frame > beginFrame) {
  3969. var newKey = {
  3970. frame: beginFrame,
  3971. value: startKey.value,
  3972. inTangent: startKey.inTangent,
  3973. outTangent: startKey.outTangent,
  3974. interpolation: startKey.interpolation
  3975. };
  3976. keys.splice(0, 0, newKey);
  3977. }
  3978. if (endKey.frame < endFrame) {
  3979. var newKey = {
  3980. frame: endFrame,
  3981. value: endKey.value,
  3982. inTangent: endKey.outTangent,
  3983. outTangent: endKey.outTangent,
  3984. interpolation: endKey.interpolation
  3985. };
  3986. keys.push(newKey);
  3987. }
  3988. }
  3989. this._from = beginFrame;
  3990. this._to = endFrame;
  3991. return this;
  3992. };
  3993. /**
  3994. * Start all animations on given targets
  3995. * @param loop defines if animations must loop
  3996. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  3997. * @param from defines the from key (optional)
  3998. * @param to defines the to key (optional)
  3999. * @returns the current animation group
  4000. */
  4001. AnimationGroup.prototype.start = function (loop, speedRatio, from, to) {
  4002. var _this = this;
  4003. if (loop === void 0) { loop = false; }
  4004. if (speedRatio === void 0) { speedRatio = 1; }
  4005. if (this._isStarted || this._targetedAnimations.length === 0) {
  4006. return this;
  4007. }
  4008. var _loop_1 = function (targetedAnimation) {
  4009. var animatable = this_1._scene.beginDirectAnimation(targetedAnimation.target, [targetedAnimation.animation], from !== undefined ? from : this_1._from, to !== undefined ? to : this_1._to, loop, speedRatio);
  4010. animatable.onAnimationEnd = function () {
  4011. _this.onAnimationEndObservable.notifyObservers(targetedAnimation);
  4012. _this._checkAnimationGroupEnded(animatable);
  4013. };
  4014. animatable.onAnimationLoop = function () {
  4015. _this.onAnimationLoopObservable.notifyObservers(targetedAnimation);
  4016. };
  4017. this_1._animatables.push(animatable);
  4018. };
  4019. var this_1 = this;
  4020. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4021. var targetedAnimation = _a[_i];
  4022. _loop_1(targetedAnimation);
  4023. }
  4024. this._speedRatio = speedRatio;
  4025. if (from !== undefined && to !== undefined && from > to && this._speedRatio > 0) {
  4026. this._speedRatio = -speedRatio;
  4027. }
  4028. this._isStarted = true;
  4029. this._isPaused = false;
  4030. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4031. return this;
  4032. };
  4033. /**
  4034. * Pause all animations
  4035. * @returns the animation group
  4036. */
  4037. AnimationGroup.prototype.pause = function () {
  4038. if (!this._isStarted) {
  4039. return this;
  4040. }
  4041. this._isPaused = true;
  4042. for (var index = 0; index < this._animatables.length; index++) {
  4043. var animatable = this._animatables[index];
  4044. animatable.pause();
  4045. }
  4046. this.onAnimationGroupPauseObservable.notifyObservers(this);
  4047. return this;
  4048. };
  4049. /**
  4050. * Play all animations to initial state
  4051. * This function will start() the animations if they were not started or will restart() them if they were paused
  4052. * @param loop defines if animations must loop
  4053. * @returns the animation group
  4054. */
  4055. AnimationGroup.prototype.play = function (loop) {
  4056. // only if all animatables are ready and exist
  4057. if (this.isStarted && this._animatables.length === this._targetedAnimations.length) {
  4058. if (loop !== undefined) {
  4059. for (var index = 0; index < this._animatables.length; index++) {
  4060. var animatable = this._animatables[index];
  4061. animatable.loopAnimation = loop;
  4062. }
  4063. }
  4064. this.restart();
  4065. }
  4066. else {
  4067. this.stop();
  4068. this.start(loop, this._speedRatio);
  4069. }
  4070. this._isPaused = false;
  4071. return this;
  4072. };
  4073. /**
  4074. * Reset all animations to initial state
  4075. * @returns the animation group
  4076. */
  4077. AnimationGroup.prototype.reset = function () {
  4078. if (!this._isStarted) {
  4079. return this;
  4080. }
  4081. for (var index = 0; index < this._animatables.length; index++) {
  4082. var animatable = this._animatables[index];
  4083. animatable.reset();
  4084. }
  4085. return this;
  4086. };
  4087. /**
  4088. * Restart animations from key 0
  4089. * @returns the animation group
  4090. */
  4091. AnimationGroup.prototype.restart = function () {
  4092. if (!this._isStarted) {
  4093. return this;
  4094. }
  4095. for (var index = 0; index < this._animatables.length; index++) {
  4096. var animatable = this._animatables[index];
  4097. animatable.restart();
  4098. }
  4099. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4100. return this;
  4101. };
  4102. /**
  4103. * Stop all animations
  4104. * @returns the animation group
  4105. */
  4106. AnimationGroup.prototype.stop = function () {
  4107. if (!this._isStarted) {
  4108. return this;
  4109. }
  4110. var list = this._animatables.slice();
  4111. for (var index = 0; index < list.length; index++) {
  4112. list[index].stop();
  4113. }
  4114. this._isStarted = false;
  4115. return this;
  4116. };
  4117. /**
  4118. * Set animation weight for all animatables
  4119. * @param weight defines the weight to use
  4120. * @return the animationGroup
  4121. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4122. */
  4123. AnimationGroup.prototype.setWeightForAllAnimatables = function (weight) {
  4124. for (var index = 0; index < this._animatables.length; index++) {
  4125. var animatable = this._animatables[index];
  4126. animatable.weight = weight;
  4127. }
  4128. return this;
  4129. };
  4130. /**
  4131. * Synchronize and normalize all animatables with a source animatable
  4132. * @param root defines the root animatable to synchronize with
  4133. * @return the animationGroup
  4134. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4135. */
  4136. AnimationGroup.prototype.syncAllAnimationsWith = function (root) {
  4137. for (var index = 0; index < this._animatables.length; index++) {
  4138. var animatable = this._animatables[index];
  4139. animatable.syncWith(root);
  4140. }
  4141. return this;
  4142. };
  4143. /**
  4144. * Goes to a specific frame in this animation group
  4145. * @param frame the frame number to go to
  4146. * @return the animationGroup
  4147. */
  4148. AnimationGroup.prototype.goToFrame = function (frame) {
  4149. if (!this._isStarted) {
  4150. return this;
  4151. }
  4152. for (var index = 0; index < this._animatables.length; index++) {
  4153. var animatable = this._animatables[index];
  4154. animatable.goToFrame(frame);
  4155. }
  4156. return this;
  4157. };
  4158. /**
  4159. * Dispose all associated resources
  4160. */
  4161. AnimationGroup.prototype.dispose = function () {
  4162. this._targetedAnimations = [];
  4163. this._animatables = [];
  4164. var index = this._scene.animationGroups.indexOf(this);
  4165. if (index > -1) {
  4166. this._scene.animationGroups.splice(index, 1);
  4167. }
  4168. this.onAnimationEndObservable.clear();
  4169. this.onAnimationGroupEndObservable.clear();
  4170. this.onAnimationGroupPauseObservable.clear();
  4171. this.onAnimationGroupPlayObservable.clear();
  4172. this.onAnimationLoopObservable.clear();
  4173. };
  4174. AnimationGroup.prototype._checkAnimationGroupEnded = function (animatable) {
  4175. // animatable should be taken out of the array
  4176. var idx = this._animatables.indexOf(animatable);
  4177. if (idx > -1) {
  4178. this._animatables.splice(idx, 1);
  4179. }
  4180. // all animatables were removed? animation group ended!
  4181. if (this._animatables.length === 0) {
  4182. this._isStarted = false;
  4183. this.onAnimationGroupEndObservable.notifyObservers(this);
  4184. }
  4185. };
  4186. // Statics
  4187. /**
  4188. * Returns a new AnimationGroup object parsed from the source provided.
  4189. * @param parsedAnimationGroup defines the source
  4190. * @param scene defines the scene that will receive the animationGroup
  4191. * @returns a new AnimationGroup
  4192. */
  4193. AnimationGroup.Parse = function (parsedAnimationGroup, scene) {
  4194. var animationGroup = new AnimationGroup(parsedAnimationGroup.name, scene);
  4195. for (var i = 0; i < parsedAnimationGroup.targetedAnimations.length; i++) {
  4196. var targetedAnimation = parsedAnimationGroup.targetedAnimations[i];
  4197. var animation = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].Parse(targetedAnimation.animation);
  4198. var id = targetedAnimation.targetId;
  4199. if (targetedAnimation.animation.property === "influence") { // morph target animation
  4200. var morphTarget = scene.getMorphTargetById(id);
  4201. if (morphTarget) {
  4202. animationGroup.addTargetedAnimation(animation, morphTarget);
  4203. }
  4204. }
  4205. else {
  4206. var targetNode = scene.getNodeByID(id);
  4207. if (targetNode != null) {
  4208. animationGroup.addTargetedAnimation(animation, targetNode);
  4209. }
  4210. }
  4211. }
  4212. if (parsedAnimationGroup.from !== null && parsedAnimationGroup.from !== null) {
  4213. animationGroup.normalize(parsedAnimationGroup.from, parsedAnimationGroup.to);
  4214. }
  4215. return animationGroup;
  4216. };
  4217. /**
  4218. * Returns the string "AnimationGroup"
  4219. * @returns "AnimationGroup"
  4220. */
  4221. AnimationGroup.prototype.getClassName = function () {
  4222. return "AnimationGroup";
  4223. };
  4224. /**
  4225. * Creates a detailled string about the object
  4226. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4227. * @returns a string representing the object
  4228. */
  4229. AnimationGroup.prototype.toString = function (fullDetails) {
  4230. var ret = "Name: " + this.name;
  4231. ret += ", type: " + this.getClassName();
  4232. if (fullDetails) {
  4233. ret += ", from: " + this._from;
  4234. ret += ", to: " + this._to;
  4235. ret += ", isStarted: " + this._isStarted;
  4236. ret += ", speedRatio: " + this._speedRatio;
  4237. ret += ", targetedAnimations length: " + this._targetedAnimations.length;
  4238. ret += ", animatables length: " + this._animatables;
  4239. }
  4240. return ret;
  4241. };
  4242. return AnimationGroup;
  4243. }());
  4244. /***/ }),
  4245. /***/ "./Animations/animationPropertiesOverride.ts":
  4246. /*!***************************************************!*\
  4247. !*** ./Animations/animationPropertiesOverride.ts ***!
  4248. \***************************************************/
  4249. /*! exports provided: AnimationPropertiesOverride */
  4250. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4251. "use strict";
  4252. __webpack_require__.r(__webpack_exports__);
  4253. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return AnimationPropertiesOverride; });
  4254. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  4255. /**
  4256. * Class used to override all child animations of a given target
  4257. */
  4258. var AnimationPropertiesOverride = /** @class */ (function () {
  4259. function AnimationPropertiesOverride() {
  4260. /**
  4261. * Gets or sets a value indicating if animation blending must be used
  4262. */
  4263. this.enableBlending = false;
  4264. /**
  4265. * Gets or sets the blending speed to use when enableBlending is true
  4266. */
  4267. this.blendingSpeed = 0.01;
  4268. /**
  4269. * Gets or sets the default loop mode to use
  4270. */
  4271. this.loopMode = _Animations_animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONLOOPMODE_CYCLE;
  4272. }
  4273. return AnimationPropertiesOverride;
  4274. }());
  4275. /***/ }),
  4276. /***/ "./Animations/easing.ts":
  4277. /*!******************************!*\
  4278. !*** ./Animations/easing.ts ***!
  4279. \******************************/
  4280. /*! exports provided: EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase */
  4281. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4282. "use strict";
  4283. __webpack_require__.r(__webpack_exports__);
  4284. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return EasingFunction; });
  4285. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return CircleEase; });
  4286. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return BackEase; });
  4287. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return BounceEase; });
  4288. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return CubicEase; });
  4289. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return ElasticEase; });
  4290. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return ExponentialEase; });
  4291. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return PowerEase; });
  4292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return QuadraticEase; });
  4293. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return QuarticEase; });
  4294. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return QuinticEase; });
  4295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return SineEase; });
  4296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return BezierCurveEase; });
  4297. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  4298. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  4299. /**
  4300. * Base class used for every default easing function.
  4301. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4302. */
  4303. var EasingFunction = /** @class */ (function () {
  4304. function EasingFunction() {
  4305. this._easingMode = EasingFunction.EASINGMODE_EASEIN;
  4306. }
  4307. /**
  4308. * Sets the easing mode of the current function.
  4309. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4310. */
  4311. EasingFunction.prototype.setEasingMode = function (easingMode) {
  4312. var n = Math.min(Math.max(easingMode, 0), 2);
  4313. this._easingMode = n;
  4314. };
  4315. /**
  4316. * Gets the current easing mode.
  4317. * @returns the easing mode
  4318. */
  4319. EasingFunction.prototype.getEasingMode = function () {
  4320. return this._easingMode;
  4321. };
  4322. /**
  4323. * @hidden
  4324. */
  4325. EasingFunction.prototype.easeInCore = function (gradient) {
  4326. throw new Error('You must implement this method');
  4327. };
  4328. /**
  4329. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4330. * of the easing function.
  4331. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4332. * @returns the corresponding value on the curve defined by the easing function
  4333. */
  4334. EasingFunction.prototype.ease = function (gradient) {
  4335. switch (this._easingMode) {
  4336. case EasingFunction.EASINGMODE_EASEIN:
  4337. return this.easeInCore(gradient);
  4338. case EasingFunction.EASINGMODE_EASEOUT:
  4339. return (1 - this.easeInCore(1 - gradient));
  4340. }
  4341. if (gradient >= 0.5) {
  4342. return (((1 - this.easeInCore((1 - gradient) * 2)) * 0.5) + 0.5);
  4343. }
  4344. return (this.easeInCore(gradient * 2) * 0.5);
  4345. };
  4346. /**
  4347. * Interpolation follows the mathematical formula associated with the easing function.
  4348. */
  4349. EasingFunction.EASINGMODE_EASEIN = 0;
  4350. /**
  4351. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4352. */
  4353. EasingFunction.EASINGMODE_EASEOUT = 1;
  4354. /**
  4355. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4356. */
  4357. EasingFunction.EASINGMODE_EASEINOUT = 2;
  4358. return EasingFunction;
  4359. }());
  4360. /**
  4361. * Easing function with a circle shape (see link below).
  4362. * @see https://easings.net/#easeInCirc
  4363. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4364. */
  4365. var CircleEase = /** @class */ (function (_super) {
  4366. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleEase, _super);
  4367. function CircleEase() {
  4368. return _super !== null && _super.apply(this, arguments) || this;
  4369. }
  4370. /** @hidden */
  4371. CircleEase.prototype.easeInCore = function (gradient) {
  4372. gradient = Math.max(0, Math.min(1, gradient));
  4373. return (1.0 - Math.sqrt(1.0 - (gradient * gradient)));
  4374. };
  4375. return CircleEase;
  4376. }(EasingFunction));
  4377. /**
  4378. * Easing function with a ease back shape (see link below).
  4379. * @see https://easings.net/#easeInBack
  4380. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4381. */
  4382. var BackEase = /** @class */ (function (_super) {
  4383. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackEase, _super);
  4384. /**
  4385. * Instantiates a back ease easing
  4386. * @see https://easings.net/#easeInBack
  4387. * @param amplitude Defines the amplitude of the function
  4388. */
  4389. function BackEase(
  4390. /** Defines the amplitude of the function */
  4391. amplitude) {
  4392. if (amplitude === void 0) { amplitude = 1; }
  4393. var _this = _super.call(this) || this;
  4394. _this.amplitude = amplitude;
  4395. return _this;
  4396. }
  4397. /** @hidden */
  4398. BackEase.prototype.easeInCore = function (gradient) {
  4399. var num = Math.max(0, this.amplitude);
  4400. return (Math.pow(gradient, 3.0) - ((gradient * num) * Math.sin(3.1415926535897931 * gradient)));
  4401. };
  4402. return BackEase;
  4403. }(EasingFunction));
  4404. /**
  4405. * Easing function with a bouncing shape (see link below).
  4406. * @see https://easings.net/#easeInBounce
  4407. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4408. */
  4409. var BounceEase = /** @class */ (function (_super) {
  4410. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BounceEase, _super);
  4411. /**
  4412. * Instantiates a bounce easing
  4413. * @see https://easings.net/#easeInBounce
  4414. * @param bounces Defines the number of bounces
  4415. * @param bounciness Defines the amplitude of the bounce
  4416. */
  4417. function BounceEase(
  4418. /** Defines the number of bounces */
  4419. bounces,
  4420. /** Defines the amplitude of the bounce */
  4421. bounciness) {
  4422. if (bounces === void 0) { bounces = 3; }
  4423. if (bounciness === void 0) { bounciness = 2; }
  4424. var _this = _super.call(this) || this;
  4425. _this.bounces = bounces;
  4426. _this.bounciness = bounciness;
  4427. return _this;
  4428. }
  4429. /** @hidden */
  4430. BounceEase.prototype.easeInCore = function (gradient) {
  4431. var y = Math.max(0.0, this.bounces);
  4432. var bounciness = this.bounciness;
  4433. if (bounciness <= 1.0) {
  4434. bounciness = 1.001;
  4435. }
  4436. var num9 = Math.pow(bounciness, y);
  4437. var num5 = 1.0 - bounciness;
  4438. var num4 = ((1.0 - num9) / num5) + (num9 * 0.5);
  4439. var num15 = gradient * num4;
  4440. var num65 = Math.log((-num15 * (1.0 - bounciness)) + 1.0) / Math.log(bounciness);
  4441. var num3 = Math.floor(num65);
  4442. var num13 = num3 + 1.0;
  4443. var num8 = (1.0 - Math.pow(bounciness, num3)) / (num5 * num4);
  4444. var num12 = (1.0 - Math.pow(bounciness, num13)) / (num5 * num4);
  4445. var num7 = (num8 + num12) * 0.5;
  4446. var num6 = gradient - num7;
  4447. var num2 = num7 - num8;
  4448. return (((-Math.pow(1.0 / bounciness, y - num3) / (num2 * num2)) * (num6 - num2)) * (num6 + num2));
  4449. };
  4450. return BounceEase;
  4451. }(EasingFunction));
  4452. /**
  4453. * Easing function with a power of 3 shape (see link below).
  4454. * @see https://easings.net/#easeInCubic
  4455. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4456. */
  4457. var CubicEase = /** @class */ (function (_super) {
  4458. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubicEase, _super);
  4459. function CubicEase() {
  4460. return _super !== null && _super.apply(this, arguments) || this;
  4461. }
  4462. /** @hidden */
  4463. CubicEase.prototype.easeInCore = function (gradient) {
  4464. return (gradient * gradient * gradient);
  4465. };
  4466. return CubicEase;
  4467. }(EasingFunction));
  4468. /**
  4469. * Easing function with an elastic shape (see link below).
  4470. * @see https://easings.net/#easeInElastic
  4471. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4472. */
  4473. var ElasticEase = /** @class */ (function (_super) {
  4474. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ElasticEase, _super);
  4475. /**
  4476. * Instantiates an elastic easing function
  4477. * @see https://easings.net/#easeInElastic
  4478. * @param oscillations Defines the number of oscillations
  4479. * @param springiness Defines the amplitude of the oscillations
  4480. */
  4481. function ElasticEase(
  4482. /** Defines the number of oscillations*/
  4483. oscillations,
  4484. /** Defines the amplitude of the oscillations*/
  4485. springiness) {
  4486. if (oscillations === void 0) { oscillations = 3; }
  4487. if (springiness === void 0) { springiness = 3; }
  4488. var _this = _super.call(this) || this;
  4489. _this.oscillations = oscillations;
  4490. _this.springiness = springiness;
  4491. return _this;
  4492. }
  4493. /** @hidden */
  4494. ElasticEase.prototype.easeInCore = function (gradient) {
  4495. var num2;
  4496. var num3 = Math.max(0.0, this.oscillations);
  4497. var num = Math.max(0.0, this.springiness);
  4498. if (num == 0) {
  4499. num2 = gradient;
  4500. }
  4501. else {
  4502. num2 = (Math.exp(num * gradient) - 1.0) / (Math.exp(num) - 1.0);
  4503. }
  4504. return (num2 * Math.sin(((6.2831853071795862 * num3) + 1.5707963267948966) * gradient));
  4505. };
  4506. return ElasticEase;
  4507. }(EasingFunction));
  4508. /**
  4509. * Easing function with an exponential shape (see link below).
  4510. * @see https://easings.net/#easeInExpo
  4511. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4512. */
  4513. var ExponentialEase = /** @class */ (function (_super) {
  4514. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExponentialEase, _super);
  4515. /**
  4516. * Instantiates an exponential easing function
  4517. * @see https://easings.net/#easeInExpo
  4518. * @param exponent Defines the exponent of the function
  4519. */
  4520. function ExponentialEase(
  4521. /** Defines the exponent of the function */
  4522. exponent) {
  4523. if (exponent === void 0) { exponent = 2; }
  4524. var _this = _super.call(this) || this;
  4525. _this.exponent = exponent;
  4526. return _this;
  4527. }
  4528. /** @hidden */
  4529. ExponentialEase.prototype.easeInCore = function (gradient) {
  4530. if (this.exponent <= 0) {
  4531. return gradient;
  4532. }
  4533. return ((Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0));
  4534. };
  4535. return ExponentialEase;
  4536. }(EasingFunction));
  4537. /**
  4538. * Easing function with a power shape (see link below).
  4539. * @see https://easings.net/#easeInQuad
  4540. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4541. */
  4542. var PowerEase = /** @class */ (function (_super) {
  4543. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PowerEase, _super);
  4544. /**
  4545. * Instantiates an power base easing function
  4546. * @see https://easings.net/#easeInQuad
  4547. * @param power Defines the power of the function
  4548. */
  4549. function PowerEase(
  4550. /** Defines the power of the function */
  4551. power) {
  4552. if (power === void 0) { power = 2; }
  4553. var _this = _super.call(this) || this;
  4554. _this.power = power;
  4555. return _this;
  4556. }
  4557. /** @hidden */
  4558. PowerEase.prototype.easeInCore = function (gradient) {
  4559. var y = Math.max(0.0, this.power);
  4560. return Math.pow(gradient, y);
  4561. };
  4562. return PowerEase;
  4563. }(EasingFunction));
  4564. /**
  4565. * Easing function with a power of 2 shape (see link below).
  4566. * @see https://easings.net/#easeInQuad
  4567. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4568. */
  4569. var QuadraticEase = /** @class */ (function (_super) {
  4570. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuadraticEase, _super);
  4571. function QuadraticEase() {
  4572. return _super !== null && _super.apply(this, arguments) || this;
  4573. }
  4574. /** @hidden */
  4575. QuadraticEase.prototype.easeInCore = function (gradient) {
  4576. return (gradient * gradient);
  4577. };
  4578. return QuadraticEase;
  4579. }(EasingFunction));
  4580. /**
  4581. * Easing function with a power of 4 shape (see link below).
  4582. * @see https://easings.net/#easeInQuart
  4583. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4584. */
  4585. var QuarticEase = /** @class */ (function (_super) {
  4586. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuarticEase, _super);
  4587. function QuarticEase() {
  4588. return _super !== null && _super.apply(this, arguments) || this;
  4589. }
  4590. /** @hidden */
  4591. QuarticEase.prototype.easeInCore = function (gradient) {
  4592. return (gradient * gradient * gradient * gradient);
  4593. };
  4594. return QuarticEase;
  4595. }(EasingFunction));
  4596. /**
  4597. * Easing function with a power of 5 shape (see link below).
  4598. * @see https://easings.net/#easeInQuint
  4599. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4600. */
  4601. var QuinticEase = /** @class */ (function (_super) {
  4602. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuinticEase, _super);
  4603. function QuinticEase() {
  4604. return _super !== null && _super.apply(this, arguments) || this;
  4605. }
  4606. /** @hidden */
  4607. QuinticEase.prototype.easeInCore = function (gradient) {
  4608. return (gradient * gradient * gradient * gradient * gradient);
  4609. };
  4610. return QuinticEase;
  4611. }(EasingFunction));
  4612. /**
  4613. * Easing function with a sin shape (see link below).
  4614. * @see https://easings.net/#easeInSine
  4615. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4616. */
  4617. var SineEase = /** @class */ (function (_super) {
  4618. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SineEase, _super);
  4619. function SineEase() {
  4620. return _super !== null && _super.apply(this, arguments) || this;
  4621. }
  4622. /** @hidden */
  4623. SineEase.prototype.easeInCore = function (gradient) {
  4624. return (1.0 - Math.sin(1.5707963267948966 * (1.0 - gradient)));
  4625. };
  4626. return SineEase;
  4627. }(EasingFunction));
  4628. /**
  4629. * Easing function with a bezier shape (see link below).
  4630. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4631. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4632. */
  4633. var BezierCurveEase = /** @class */ (function (_super) {
  4634. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BezierCurveEase, _super);
  4635. /**
  4636. * Instantiates a bezier function
  4637. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4638. * @param x1 Defines the x component of the start tangent in the bezier curve
  4639. * @param y1 Defines the y component of the start tangent in the bezier curve
  4640. * @param x2 Defines the x component of the end tangent in the bezier curve
  4641. * @param y2 Defines the y component of the end tangent in the bezier curve
  4642. */
  4643. function BezierCurveEase(
  4644. /** Defines the x component of the start tangent in the bezier curve */
  4645. x1,
  4646. /** Defines the y component of the start tangent in the bezier curve */
  4647. y1,
  4648. /** Defines the x component of the end tangent in the bezier curve */
  4649. x2,
  4650. /** Defines the y component of the end tangent in the bezier curve */
  4651. y2) {
  4652. if (x1 === void 0) { x1 = 0; }
  4653. if (y1 === void 0) { y1 = 0; }
  4654. if (x2 === void 0) { x2 = 1; }
  4655. if (y2 === void 0) { y2 = 1; }
  4656. var _this = _super.call(this) || this;
  4657. _this.x1 = x1;
  4658. _this.y1 = y1;
  4659. _this.x2 = x2;
  4660. _this.y2 = y2;
  4661. return _this;
  4662. }
  4663. /** @hidden */
  4664. BezierCurveEase.prototype.easeInCore = function (gradient) {
  4665. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"].Interpolate(gradient, this.x1, this.y1, this.x2, this.y2);
  4666. };
  4667. return BezierCurveEase;
  4668. }(EasingFunction));
  4669. /***/ }),
  4670. /***/ "./Animations/index.ts":
  4671. /*!*****************************!*\
  4672. !*** ./Animations/index.ts ***!
  4673. \*****************************/
  4674. /*! exports provided: Animatable, AnimationRange, AnimationEvent, PathCursor, AnimationKeyInterpolation, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation */
  4675. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4676. "use strict";
  4677. __webpack_require__.r(__webpack_exports__);
  4678. /* harmony import */ var _animatable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animatable */ "./Animations/animatable.ts");
  4679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _animatable__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  4680. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  4681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["AnimationRange"]; });
  4682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["AnimationEvent"]; });
  4683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PathCursor", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["PathCursor"]; });
  4684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["AnimationKeyInterpolation"]; });
  4685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]; });
  4686. /* harmony import */ var _animationGroup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./animationGroup */ "./Animations/animationGroup.ts");
  4687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  4688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  4689. /* harmony import */ var _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./animationPropertiesOverride */ "./Animations/animationPropertiesOverride.ts");
  4690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__["AnimationPropertiesOverride"]; });
  4691. /* harmony import */ var _easing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./easing */ "./Animations/easing.ts");
  4692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["EasingFunction"]; });
  4693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CircleEase"]; });
  4694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BackEase"]; });
  4695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BounceEase"]; });
  4696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CubicEase"]; });
  4697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ElasticEase"]; });
  4698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ExponentialEase"]; });
  4699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["PowerEase"]; });
  4700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuadraticEase"]; });
  4701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuarticEase"]; });
  4702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuinticEase"]; });
  4703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["SineEase"]; });
  4704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BezierCurveEase"]; });
  4705. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  4706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__["RuntimeAnimation"]; });
  4707. /***/ }),
  4708. /***/ "./Animations/runtimeAnimation.ts":
  4709. /*!****************************************!*\
  4710. !*** ./Animations/runtimeAnimation.ts ***!
  4711. \****************************************/
  4712. /*! exports provided: RuntimeAnimation */
  4713. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4714. "use strict";
  4715. __webpack_require__.r(__webpack_exports__);
  4716. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return RuntimeAnimation; });
  4717. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  4718. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  4719. // Static values to help the garbage collector
  4720. // Quaternion
  4721. var _staticOffsetValueQuaternion = Object.freeze(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"](0, 0, 0, 0));
  4722. // Vector3
  4723. var _staticOffsetValueVector3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero());
  4724. // Vector2
  4725. var _staticOffsetValueVector2 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero());
  4726. // Size
  4727. var _staticOffsetValueSize = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Zero());
  4728. // Color3
  4729. var _staticOffsetValueColor3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black());
  4730. /**
  4731. * Defines a runtime animation
  4732. */
  4733. var RuntimeAnimation = /** @class */ (function () {
  4734. /**
  4735. * Create a new RuntimeAnimation object
  4736. * @param target defines the target of the animation
  4737. * @param animation defines the source animation object
  4738. * @param scene defines the hosting scene
  4739. * @param host defines the initiating Animatable
  4740. */
  4741. function RuntimeAnimation(target, animation, scene, host) {
  4742. var _this = this;
  4743. this._events = new Array();
  4744. /**
  4745. * The current frame of the runtime animation
  4746. */
  4747. this._currentFrame = 0;
  4748. /**
  4749. * The original value of the runtime animation
  4750. */
  4751. this._originalValue = new Array();
  4752. /**
  4753. * The offsets cache of the runtime animation
  4754. */
  4755. this._offsetsCache = {};
  4756. /**
  4757. * The high limits cache of the runtime animation
  4758. */
  4759. this._highLimitsCache = {};
  4760. /**
  4761. * Specifies if the runtime animation has been stopped
  4762. */
  4763. this._stopped = false;
  4764. /**
  4765. * The blending factor of the runtime animation
  4766. */
  4767. this._blendingFactor = 0;
  4768. /**
  4769. * The target path of the runtime animation
  4770. */
  4771. this._targetPath = "";
  4772. /**
  4773. * The weight of the runtime animation
  4774. */
  4775. this._weight = 1.0;
  4776. /**
  4777. * The ratio offset of the runtime animation
  4778. */
  4779. this._ratioOffset = 0;
  4780. /**
  4781. * The previous delay of the runtime animation
  4782. */
  4783. this._previousDelay = 0;
  4784. /**
  4785. * The previous ratio of the runtime animation
  4786. */
  4787. this._previousRatio = 0;
  4788. this._animation = animation;
  4789. this._target = target;
  4790. this._scene = scene;
  4791. this._host = host;
  4792. animation._runtimeAnimations.push(this);
  4793. // Cloning events locally
  4794. var events = animation.getEvents();
  4795. if (events && events.length > 0) {
  4796. events.forEach(function (e) {
  4797. _this._events.push(e._clone());
  4798. });
  4799. }
  4800. }
  4801. Object.defineProperty(RuntimeAnimation.prototype, "currentFrame", {
  4802. /**
  4803. * Gets the current frame of the runtime animation
  4804. */
  4805. get: function () {
  4806. return this._currentFrame;
  4807. },
  4808. enumerable: true,
  4809. configurable: true
  4810. });
  4811. Object.defineProperty(RuntimeAnimation.prototype, "weight", {
  4812. /**
  4813. * Gets the weight of the runtime animation
  4814. */
  4815. get: function () {
  4816. return this._weight;
  4817. },
  4818. enumerable: true,
  4819. configurable: true
  4820. });
  4821. Object.defineProperty(RuntimeAnimation.prototype, "currentValue", {
  4822. /**
  4823. * Gets the current value of the runtime animation
  4824. */
  4825. get: function () {
  4826. return this._currentValue;
  4827. },
  4828. enumerable: true,
  4829. configurable: true
  4830. });
  4831. Object.defineProperty(RuntimeAnimation.prototype, "targetPath", {
  4832. /**
  4833. * Gets the target path of the runtime animation
  4834. */
  4835. get: function () {
  4836. return this._targetPath;
  4837. },
  4838. enumerable: true,
  4839. configurable: true
  4840. });
  4841. Object.defineProperty(RuntimeAnimation.prototype, "target", {
  4842. /**
  4843. * Gets the actual target of the runtime animation
  4844. */
  4845. get: function () {
  4846. return this._activeTarget;
  4847. },
  4848. enumerable: true,
  4849. configurable: true
  4850. });
  4851. Object.defineProperty(RuntimeAnimation.prototype, "animation", {
  4852. /**
  4853. * Gets the animation from the runtime animation
  4854. */
  4855. get: function () {
  4856. return this._animation;
  4857. },
  4858. enumerable: true,
  4859. configurable: true
  4860. });
  4861. /**
  4862. * Resets the runtime animation to the beginning
  4863. * @param restoreOriginal defines whether to restore the target property to the original value
  4864. */
  4865. RuntimeAnimation.prototype.reset = function (restoreOriginal) {
  4866. if (restoreOriginal === void 0) { restoreOriginal = false; }
  4867. if (restoreOriginal) {
  4868. if (this._target instanceof Array) {
  4869. var index = 0;
  4870. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  4871. var target = _a[_i];
  4872. if (this._originalValue[index] !== undefined) {
  4873. this._setValue(target, this._originalValue[index], -1);
  4874. }
  4875. index++;
  4876. }
  4877. }
  4878. else {
  4879. if (this._originalValue[0] !== undefined) {
  4880. this._setValue(this._target, this._originalValue[0], -1);
  4881. }
  4882. }
  4883. }
  4884. this._offsetsCache = {};
  4885. this._highLimitsCache = {};
  4886. this._currentFrame = 0;
  4887. this._blendingFactor = 0;
  4888. this._originalValue = new Array();
  4889. // Events
  4890. for (var index = 0; index < this._events.length; index++) {
  4891. this._events[index].isDone = false;
  4892. }
  4893. };
  4894. /**
  4895. * Specifies if the runtime animation is stopped
  4896. * @returns Boolean specifying if the runtime animation is stopped
  4897. */
  4898. RuntimeAnimation.prototype.isStopped = function () {
  4899. return this._stopped;
  4900. };
  4901. /**
  4902. * Disposes of the runtime animation
  4903. */
  4904. RuntimeAnimation.prototype.dispose = function () {
  4905. var index = this._animation.runtimeAnimations.indexOf(this);
  4906. if (index > -1) {
  4907. this._animation.runtimeAnimations.splice(index, 1);
  4908. }
  4909. };
  4910. /**
  4911. * Interpolates the animation from the current frame
  4912. * @param currentFrame The frame to interpolate the animation to
  4913. * @param repeatCount The number of times that the animation should loop
  4914. * @param loopMode The type of looping mode to use
  4915. * @param offsetValue Animation offset value
  4916. * @param highLimitValue The high limit value
  4917. * @returns The interpolated value
  4918. */
  4919. RuntimeAnimation.prototype._interpolate = function (currentFrame, repeatCount, loopMode, offsetValue, highLimitValue) {
  4920. this._currentFrame = currentFrame;
  4921. if (this._animation.dataType === _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_MATRIX && !this._workValue) {
  4922. this._workValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Zero();
  4923. }
  4924. return this._animation._interpolate(currentFrame, repeatCount, this._workValue, loopMode, offsetValue, highLimitValue);
  4925. };
  4926. /**
  4927. * Apply the interpolated value to the target
  4928. * @param currentValue defines the value computed by the animation
  4929. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4930. */
  4931. RuntimeAnimation.prototype.setValue = function (currentValue, weight) {
  4932. if (weight === void 0) { weight = 1.0; }
  4933. if (this._target instanceof Array) {
  4934. var index = 0;
  4935. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  4936. var target = _a[_i];
  4937. this._setValue(target, currentValue, weight, index);
  4938. index++;
  4939. }
  4940. }
  4941. else {
  4942. this._setValue(this._target, currentValue, weight);
  4943. }
  4944. };
  4945. RuntimeAnimation.prototype._setValue = function (target, currentValue, weight, targetIndex) {
  4946. if (targetIndex === void 0) { targetIndex = 0; }
  4947. // Set value
  4948. var path;
  4949. var destination;
  4950. var targetPropertyPath = this._animation.targetPropertyPath;
  4951. if (targetPropertyPath.length > 1) {
  4952. var property = target[targetPropertyPath[0]];
  4953. for (var index = 1; index < targetPropertyPath.length - 1; index++) {
  4954. property = property[targetPropertyPath[index]];
  4955. }
  4956. path = targetPropertyPath[targetPropertyPath.length - 1];
  4957. destination = property;
  4958. }
  4959. else {
  4960. path = targetPropertyPath[0];
  4961. destination = target;
  4962. }
  4963. this._targetPath = path;
  4964. this._activeTarget = destination;
  4965. this._weight = weight;
  4966. if (this._originalValue[targetIndex] === undefined) {
  4967. var originalValue = void 0;
  4968. if (destination.getRestPose && path === "_matrix") { // For bones
  4969. originalValue = destination.getRestPose();
  4970. }
  4971. else {
  4972. originalValue = destination[path];
  4973. }
  4974. if (originalValue && originalValue.clone) {
  4975. this._originalValue[targetIndex] = originalValue.clone();
  4976. }
  4977. else {
  4978. this._originalValue[targetIndex] = originalValue;
  4979. }
  4980. }
  4981. // Blending
  4982. var enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
  4983. if (enableBlending && this._blendingFactor <= 1.0) {
  4984. if (!this._originalBlendValue) {
  4985. var originalValue = destination[path];
  4986. if (originalValue.clone) {
  4987. this._originalBlendValue = originalValue.clone();
  4988. }
  4989. else {
  4990. this._originalBlendValue = originalValue;
  4991. }
  4992. }
  4993. if (this._originalBlendValue.m) { // Matrix
  4994. if (_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].AllowMatrixDecomposeForInterpolation) {
  4995. if (this._currentValue) {
  4996. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  4997. }
  4998. else {
  4999. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5000. }
  5001. }
  5002. else {
  5003. if (this._currentValue) {
  5004. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5005. }
  5006. else {
  5007. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5008. }
  5009. }
  5010. }
  5011. else {
  5012. this._currentValue = _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]._UniversalLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5013. }
  5014. var blendingSpeed = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
  5015. this._blendingFactor += blendingSpeed;
  5016. }
  5017. else {
  5018. this._currentValue = currentValue;
  5019. }
  5020. if (weight !== -1.0) {
  5021. this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[targetIndex]);
  5022. }
  5023. else {
  5024. destination[path] = this._currentValue;
  5025. }
  5026. if (target.markAsDirty) {
  5027. target.markAsDirty(this._animation.targetProperty);
  5028. }
  5029. };
  5030. /**
  5031. * Gets the loop pmode of the runtime animation
  5032. * @returns Loop Mode
  5033. */
  5034. RuntimeAnimation.prototype._getCorrectLoopMode = function () {
  5035. if (this._target && this._target.animationPropertiesOverride) {
  5036. return this._target.animationPropertiesOverride.loopMode;
  5037. }
  5038. return this._animation.loopMode;
  5039. };
  5040. /**
  5041. * Move the current animation to a given frame
  5042. * @param frame defines the frame to move to
  5043. */
  5044. RuntimeAnimation.prototype.goToFrame = function (frame) {
  5045. var keys = this._animation.getKeys();
  5046. if (frame < keys[0].frame) {
  5047. frame = keys[0].frame;
  5048. }
  5049. else if (frame > keys[keys.length - 1].frame) {
  5050. frame = keys[keys.length - 1].frame;
  5051. }
  5052. var currentValue = this._interpolate(frame, 0, this._getCorrectLoopMode());
  5053. this.setValue(currentValue, -1);
  5054. };
  5055. /**
  5056. * @hidden Internal use only
  5057. */
  5058. RuntimeAnimation.prototype._prepareForSpeedRatioChange = function (newSpeedRatio) {
  5059. var newRatio = this._previousDelay * (this._animation.framePerSecond * newSpeedRatio) / 1000.0;
  5060. this._ratioOffset = this._previousRatio - newRatio;
  5061. };
  5062. /**
  5063. * Execute the current animation
  5064. * @param delay defines the delay to add to the current frame
  5065. * @param from defines the lower bound of the animation range
  5066. * @param to defines the upper bound of the animation range
  5067. * @param loop defines if the current animation must loop
  5068. * @param speedRatio defines the current speed ratio
  5069. * @param weight defines the weight of the animation (default is -1 so no weight)
  5070. * @param onLoop optional callback called when animation loops
  5071. * @returns a boolean indicating if the animation is running
  5072. */
  5073. RuntimeAnimation.prototype.animate = function (delay, from, to, loop, speedRatio, weight, onLoop) {
  5074. if (weight === void 0) { weight = -1.0; }
  5075. var targetPropertyPath = this._animation.targetPropertyPath;
  5076. if (!targetPropertyPath || targetPropertyPath.length < 1) {
  5077. this._stopped = true;
  5078. return false;
  5079. }
  5080. var returnValue = true;
  5081. var keys = this._animation.getKeys();
  5082. // Adding a start key at frame 0 if missing
  5083. if (keys[0].frame !== 0) {
  5084. var newKey = { frame: 0, value: keys[0].value };
  5085. keys.splice(0, 0, newKey);
  5086. }
  5087. // Adding a duplicate key when there is only one key at frame zero
  5088. else if (keys.length === 1) {
  5089. var newKey = { frame: 0.001, value: keys[0].value };
  5090. keys.push(newKey);
  5091. }
  5092. // Check limits
  5093. if (from < keys[0].frame || from > keys[keys.length - 1].frame) {
  5094. from = keys[0].frame;
  5095. }
  5096. if (to < keys[0].frame || to > keys[keys.length - 1].frame) {
  5097. to = keys[keys.length - 1].frame;
  5098. }
  5099. //to and from cannot be the same key
  5100. if (from === to) {
  5101. if (from > keys[0].frame) {
  5102. from--;
  5103. }
  5104. else if (to < keys[keys.length - 1].frame) {
  5105. to++;
  5106. }
  5107. }
  5108. // Compute ratio
  5109. var range = to - from;
  5110. var offsetValue;
  5111. // ratio represents the frame delta between from and to
  5112. var ratio = (delay * (this._animation.framePerSecond * speedRatio) / 1000.0) + this._ratioOffset;
  5113. var highLimitValue = 0;
  5114. this._previousDelay = delay;
  5115. this._previousRatio = ratio;
  5116. if (((to > from && ratio >= range) || (from > to && ratio <= range)) && !loop) { // If we are out of range and not looping get back to caller
  5117. returnValue = false;
  5118. highLimitValue = this._animation._getKeyValue(keys[keys.length - 1].value);
  5119. }
  5120. else {
  5121. // Get max value if required
  5122. if (this._getCorrectLoopMode() !== _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE) {
  5123. var keyOffset = to.toString() + from.toString();
  5124. if (!this._offsetsCache[keyOffset]) {
  5125. var fromValue = this._interpolate(from, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5126. var toValue = this._interpolate(to, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5127. switch (this._animation.dataType) {
  5128. // Float
  5129. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5130. this._offsetsCache[keyOffset] = toValue - fromValue;
  5131. break;
  5132. // Quaternion
  5133. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5134. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5135. break;
  5136. // Vector3
  5137. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5138. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5139. // Vector2
  5140. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5141. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5142. // Size
  5143. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5144. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5145. // Color3
  5146. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5147. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5148. default:
  5149. break;
  5150. }
  5151. this._highLimitsCache[keyOffset] = toValue;
  5152. }
  5153. highLimitValue = this._highLimitsCache[keyOffset];
  5154. offsetValue = this._offsetsCache[keyOffset];
  5155. }
  5156. }
  5157. if (offsetValue === undefined) {
  5158. switch (this._animation.dataType) {
  5159. // Float
  5160. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5161. offsetValue = 0;
  5162. break;
  5163. // Quaternion
  5164. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5165. offsetValue = _staticOffsetValueQuaternion;
  5166. break;
  5167. // Vector3
  5168. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5169. offsetValue = _staticOffsetValueVector3;
  5170. break;
  5171. // Vector2
  5172. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5173. offsetValue = _staticOffsetValueVector2;
  5174. break;
  5175. // Size
  5176. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5177. offsetValue = _staticOffsetValueSize;
  5178. break;
  5179. // Color3
  5180. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5181. offsetValue = _staticOffsetValueColor3;
  5182. }
  5183. }
  5184. // Compute value
  5185. var repeatCount = (ratio / range) >> 0;
  5186. var currentFrame = returnValue ? from + ratio % range : to;
  5187. // Need to normalize?
  5188. if (this._host && this._host.syncRoot) {
  5189. var syncRoot = this._host.syncRoot;
  5190. var hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);
  5191. currentFrame = from + (to - from) * hostNormalizedFrame;
  5192. }
  5193. // Reset events if looping
  5194. var events = this._events;
  5195. if (range > 0 && this.currentFrame > currentFrame ||
  5196. range < 0 && this.currentFrame < currentFrame) {
  5197. if (onLoop) {
  5198. onLoop();
  5199. }
  5200. // Need to reset animation events
  5201. for (var index = 0; index < events.length; index++) {
  5202. if (!events[index].onlyOnce) {
  5203. // reset event, the animation is looping
  5204. events[index].isDone = false;
  5205. }
  5206. }
  5207. }
  5208. var currentValue = this._interpolate(currentFrame, repeatCount, this._getCorrectLoopMode(), offsetValue, highLimitValue);
  5209. // Set value
  5210. this.setValue(currentValue, weight);
  5211. // Check events
  5212. for (var index = 0; index < events.length; index++) {
  5213. // Make sure current frame has passed event frame and that event frame is within the current range
  5214. // Also, handle both forward and reverse animations
  5215. if ((range > 0 && currentFrame >= events[index].frame && events[index].frame >= from) ||
  5216. (range < 0 && currentFrame <= events[index].frame && events[index].frame <= from)) {
  5217. var event = events[index];
  5218. if (!event.isDone) {
  5219. // If event should be done only once, remove it.
  5220. if (event.onlyOnce) {
  5221. events.splice(index, 1);
  5222. index--;
  5223. }
  5224. event.isDone = true;
  5225. event.action(currentFrame);
  5226. } // Don't do anything if the event has already be done.
  5227. }
  5228. }
  5229. if (!returnValue) {
  5230. this._stopped = true;
  5231. }
  5232. return returnValue;
  5233. };
  5234. return RuntimeAnimation;
  5235. }());
  5236. /***/ }),
  5237. /***/ "./Audio/analyser.ts":
  5238. /*!***************************!*\
  5239. !*** ./Audio/analyser.ts ***!
  5240. \***************************/
  5241. /*! exports provided: Analyser */
  5242. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5243. "use strict";
  5244. __webpack_require__.r(__webpack_exports__);
  5245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return Analyser; });
  5246. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5247. /**
  5248. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5250. */
  5251. var Analyser = /** @class */ (function () {
  5252. /**
  5253. * Creates a new analyser
  5254. * @param scene defines hosting scene
  5255. */
  5256. function Analyser(scene) {
  5257. /**
  5258. * Gets or sets the smoothing
  5259. * @ignorenaming
  5260. */
  5261. this.SMOOTHING = 0.75;
  5262. /**
  5263. * Gets or sets the FFT table size
  5264. * @ignorenaming
  5265. */
  5266. this.FFT_SIZE = 512;
  5267. /**
  5268. * Gets or sets the bar graph amplitude
  5269. * @ignorenaming
  5270. */
  5271. this.BARGRAPHAMPLITUDE = 256;
  5272. /**
  5273. * Gets or sets the position of the debug canvas
  5274. * @ignorenaming
  5275. */
  5276. this.DEBUGCANVASPOS = { x: 20, y: 20 };
  5277. /**
  5278. * Gets or sets the debug canvas size
  5279. * @ignorenaming
  5280. */
  5281. this.DEBUGCANVASSIZE = { width: 320, height: 200 };
  5282. this._scene = scene;
  5283. this._audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine;
  5284. if (this._audioEngine.canUseWebAudio && this._audioEngine.audioContext) {
  5285. this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser();
  5286. this._webAudioAnalyser.minDecibels = -140;
  5287. this._webAudioAnalyser.maxDecibels = 0;
  5288. this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5289. this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5290. this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount);
  5291. }
  5292. }
  5293. /**
  5294. * Get the number of data values you will have to play with for the visualization
  5295. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5296. * @returns a number
  5297. */
  5298. Analyser.prototype.getFrequencyBinCount = function () {
  5299. if (this._audioEngine.canUseWebAudio) {
  5300. return this._webAudioAnalyser.frequencyBinCount;
  5301. }
  5302. else {
  5303. return 0;
  5304. }
  5305. };
  5306. /**
  5307. * Gets the current frequency data as a byte array
  5308. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5309. * @returns a Uint8Array
  5310. */
  5311. Analyser.prototype.getByteFrequencyData = function () {
  5312. if (this._audioEngine.canUseWebAudio) {
  5313. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5314. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5315. this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);
  5316. }
  5317. return this._byteFreqs;
  5318. };
  5319. /**
  5320. * Gets the current waveform as a byte array
  5321. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5322. * @returns a Uint8Array
  5323. */
  5324. Analyser.prototype.getByteTimeDomainData = function () {
  5325. if (this._audioEngine.canUseWebAudio) {
  5326. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5327. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5328. this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);
  5329. }
  5330. return this._byteTime;
  5331. };
  5332. /**
  5333. * Gets the current frequency data as a float array
  5334. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5335. * @returns a Float32Array
  5336. */
  5337. Analyser.prototype.getFloatFrequencyData = function () {
  5338. if (this._audioEngine.canUseWebAudio) {
  5339. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5340. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5341. this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);
  5342. }
  5343. return this._floatFreqs;
  5344. };
  5345. /**
  5346. * Renders the debug canvas
  5347. */
  5348. Analyser.prototype.drawDebugCanvas = function () {
  5349. var _this = this;
  5350. if (this._audioEngine.canUseWebAudio) {
  5351. if (!this._debugCanvas) {
  5352. this._debugCanvas = document.createElement("canvas");
  5353. this._debugCanvas.width = this.DEBUGCANVASSIZE.width;
  5354. this._debugCanvas.height = this.DEBUGCANVASSIZE.height;
  5355. this._debugCanvas.style.position = "absolute";
  5356. this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px";
  5357. this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px";
  5358. this._debugCanvasContext = this._debugCanvas.getContext("2d");
  5359. document.body.appendChild(this._debugCanvas);
  5360. this._registerFunc = function () {
  5361. _this.drawDebugCanvas();
  5362. };
  5363. this._scene.registerBeforeRender(this._registerFunc);
  5364. }
  5365. if (this._registerFunc && this._debugCanvasContext) {
  5366. var workingArray = this.getByteFrequencyData();
  5367. this._debugCanvasContext.fillStyle = 'rgb(0, 0, 0)';
  5368. this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
  5369. // Draw the frequency domain chart.
  5370. for (var i = 0; i < this.getFrequencyBinCount(); i++) {
  5371. var value = workingArray[i];
  5372. var percent = value / this.BARGRAPHAMPLITUDE;
  5373. var height = this.DEBUGCANVASSIZE.height * percent;
  5374. var offset = this.DEBUGCANVASSIZE.height - height - 1;
  5375. var barWidth = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount();
  5376. var hue = i / this.getFrequencyBinCount() * 360;
  5377. this._debugCanvasContext.fillStyle = 'hsl(' + hue + ', 100%, 50%)';
  5378. this._debugCanvasContext.fillRect(i * barWidth, offset, barWidth, height);
  5379. }
  5380. }
  5381. }
  5382. };
  5383. /**
  5384. * Stops rendering the debug canvas and removes it
  5385. */
  5386. Analyser.prototype.stopDebugCanvas = function () {
  5387. if (this._debugCanvas) {
  5388. if (this._registerFunc) {
  5389. this._scene.unregisterBeforeRender(this._registerFunc);
  5390. this._registerFunc = null;
  5391. }
  5392. document.body.removeChild(this._debugCanvas);
  5393. this._debugCanvas = null;
  5394. this._debugCanvasContext = null;
  5395. }
  5396. };
  5397. /**
  5398. * Connects two audio nodes
  5399. * @param inputAudioNode defines first node to connect
  5400. * @param outputAudioNode defines second node to connect
  5401. */
  5402. Analyser.prototype.connectAudioNodes = function (inputAudioNode, outputAudioNode) {
  5403. if (this._audioEngine.canUseWebAudio) {
  5404. inputAudioNode.connect(this._webAudioAnalyser);
  5405. this._webAudioAnalyser.connect(outputAudioNode);
  5406. }
  5407. };
  5408. /**
  5409. * Releases all associated resources
  5410. */
  5411. Analyser.prototype.dispose = function () {
  5412. if (this._audioEngine.canUseWebAudio) {
  5413. this._webAudioAnalyser.disconnect();
  5414. }
  5415. };
  5416. return Analyser;
  5417. }());
  5418. /***/ }),
  5419. /***/ "./Audio/audioEngine.ts":
  5420. /*!******************************!*\
  5421. !*** ./Audio/audioEngine.ts ***!
  5422. \******************************/
  5423. /*! exports provided: AudioEngine */
  5424. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5425. "use strict";
  5426. __webpack_require__.r(__webpack_exports__);
  5427. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return AudioEngine; });
  5428. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  5429. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  5430. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5431. // Sets the default audio engine to Babylon.js
  5432. _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].AudioEngineFactory = function (hostElement) { return new AudioEngine(hostElement); };
  5433. /**
  5434. * This represents the default audio engine used in babylon.
  5435. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5436. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5437. */
  5438. var AudioEngine = /** @class */ (function () {
  5439. /**
  5440. * Instantiates a new audio engine.
  5441. *
  5442. * There should be only one per page as some browsers restrict the number
  5443. * of audio contexts you can create.
  5444. * @param hostElement defines the host element where to display the mute icon if necessary
  5445. */
  5446. function AudioEngine(hostElement) {
  5447. if (hostElement === void 0) { hostElement = null; }
  5448. var _this = this;
  5449. this._audioContext = null;
  5450. this._audioContextInitialized = false;
  5451. this._muteButton = null;
  5452. /**
  5453. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5454. */
  5455. this.canUseWebAudio = false;
  5456. /**
  5457. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5458. * @ignoreNaming
  5459. */
  5460. this.WarnedWebAudioUnsupported = false;
  5461. /**
  5462. * Gets whether or not mp3 are supported by your browser.
  5463. */
  5464. this.isMP3supported = false;
  5465. /**
  5466. * Gets whether or not ogg are supported by your browser.
  5467. */
  5468. this.isOGGsupported = false;
  5469. /**
  5470. * Gets whether audio has been unlocked on the device.
  5471. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5472. * a user interaction has happened.
  5473. */
  5474. this.unlocked = true;
  5475. /**
  5476. * Defines if the audio engine relies on a custom unlocked button.
  5477. * In this case, the embedded button will not be displayed.
  5478. */
  5479. this.useCustomUnlockedButton = false;
  5480. /**
  5481. * Event raised when audio has been unlocked on the browser.
  5482. */
  5483. this.onAudioUnlockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5484. /**
  5485. * Event raised when audio has been locked on the browser.
  5486. */
  5487. this.onAudioLockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5488. this._tryToRun = false;
  5489. this._onResize = function () {
  5490. _this._moveButtonToTopLeft();
  5491. };
  5492. if (typeof window.AudioContext !== 'undefined' || typeof window.webkitAudioContext !== 'undefined') {
  5493. window.AudioContext = window.AudioContext || window.webkitAudioContext;
  5494. this.canUseWebAudio = true;
  5495. }
  5496. var audioElem = document.createElement('audio');
  5497. this._hostElement = hostElement;
  5498. try {
  5499. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '')) {
  5500. this.isMP3supported = true;
  5501. }
  5502. }
  5503. catch (e) {
  5504. // protect error during capability check.
  5505. }
  5506. try {
  5507. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) {
  5508. this.isOGGsupported = true;
  5509. }
  5510. }
  5511. catch (e) {
  5512. // protect error during capability check.
  5513. }
  5514. }
  5515. Object.defineProperty(AudioEngine.prototype, "audioContext", {
  5516. /**
  5517. * Gets the current AudioContext if available.
  5518. */
  5519. get: function () {
  5520. if (!this._audioContextInitialized) {
  5521. this._initializeAudioContext();
  5522. }
  5523. else {
  5524. if (!this.unlocked && !this._muteButton) {
  5525. this._displayMuteButton();
  5526. }
  5527. }
  5528. return this._audioContext;
  5529. },
  5530. enumerable: true,
  5531. configurable: true
  5532. });
  5533. /**
  5534. * Flags the audio engine in Locked state.
  5535. * This happens due to new browser policies preventing audio to autoplay.
  5536. */
  5537. AudioEngine.prototype.lock = function () {
  5538. this._triggerSuspendedState();
  5539. };
  5540. /**
  5541. * Unlocks the audio engine once a user action has been done on the dom.
  5542. * This is helpful to resume play once browser policies have been satisfied.
  5543. */
  5544. AudioEngine.prototype.unlock = function () {
  5545. this._triggerRunningState();
  5546. };
  5547. AudioEngine.prototype._resumeAudioContext = function () {
  5548. var result;
  5549. if (this._audioContext.resume) {
  5550. result = this._audioContext.resume();
  5551. }
  5552. return result || Promise.resolve();
  5553. };
  5554. AudioEngine.prototype._initializeAudioContext = function () {
  5555. try {
  5556. if (this.canUseWebAudio) {
  5557. this._audioContext = new AudioContext();
  5558. // create a global volume gain node
  5559. this.masterGain = this._audioContext.createGain();
  5560. this.masterGain.gain.value = 1;
  5561. this.masterGain.connect(this._audioContext.destination);
  5562. this._audioContextInitialized = true;
  5563. if (this._audioContext.state === "running") {
  5564. // Do not wait for the promise to unlock.
  5565. this._triggerRunningState();
  5566. }
  5567. }
  5568. }
  5569. catch (e) {
  5570. this.canUseWebAudio = false;
  5571. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Web Audio: " + e.message);
  5572. }
  5573. };
  5574. AudioEngine.prototype._triggerRunningState = function () {
  5575. var _this = this;
  5576. if (this._tryToRun) {
  5577. return;
  5578. }
  5579. this._tryToRun = true;
  5580. this._resumeAudioContext()
  5581. .then(function () {
  5582. _this._tryToRun = false;
  5583. if (_this._muteButton) {
  5584. _this._hideMuteButton();
  5585. }
  5586. }).catch(function () {
  5587. _this._tryToRun = false;
  5588. _this.unlocked = false;
  5589. });
  5590. // Notify users that the audio stack is unlocked/unmuted
  5591. this.unlocked = true;
  5592. this.onAudioUnlockedObservable.notifyObservers(this);
  5593. };
  5594. AudioEngine.prototype._triggerSuspendedState = function () {
  5595. this.unlocked = false;
  5596. this.onAudioLockedObservable.notifyObservers(this);
  5597. this._displayMuteButton();
  5598. };
  5599. AudioEngine.prototype._displayMuteButton = function () {
  5600. var _this = this;
  5601. if (this.useCustomUnlockedButton) {
  5602. return;
  5603. }
  5604. this._muteButton = document.createElement("BUTTON");
  5605. this._muteButton.className = "babylonUnmuteIcon";
  5606. this._muteButton.id = "babylonUnmuteIconBtn";
  5607. this._muteButton.title = "Unmute";
  5608. 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) }";
  5609. var style = document.createElement('style');
  5610. style.appendChild(document.createTextNode(css));
  5611. document.getElementsByTagName('head')[0].appendChild(style);
  5612. document.body.appendChild(this._muteButton);
  5613. this._moveButtonToTopLeft();
  5614. this._muteButton.addEventListener('touchend', function () {
  5615. _this._triggerRunningState();
  5616. }, true);
  5617. this._muteButton.addEventListener('click', function () {
  5618. _this._triggerRunningState();
  5619. }, true);
  5620. window.addEventListener("resize", this._onResize);
  5621. };
  5622. AudioEngine.prototype._moveButtonToTopLeft = function () {
  5623. if (this._hostElement && this._muteButton) {
  5624. this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px";
  5625. this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px";
  5626. }
  5627. };
  5628. AudioEngine.prototype._hideMuteButton = function () {
  5629. if (this._muteButton) {
  5630. document.body.removeChild(this._muteButton);
  5631. this._muteButton = null;
  5632. }
  5633. };
  5634. /**
  5635. * Destroy and release the resources associated with the audio ccontext.
  5636. */
  5637. AudioEngine.prototype.dispose = function () {
  5638. if (this.canUseWebAudio && this._audioContextInitialized) {
  5639. if (this._connectedAnalyser && this._audioContext) {
  5640. this._connectedAnalyser.stopDebugCanvas();
  5641. this._connectedAnalyser.dispose();
  5642. this.masterGain.disconnect();
  5643. this.masterGain.connect(this._audioContext.destination);
  5644. this._connectedAnalyser = null;
  5645. }
  5646. this.masterGain.gain.value = 1;
  5647. }
  5648. this.WarnedWebAudioUnsupported = false;
  5649. this._hideMuteButton();
  5650. window.removeEventListener("resize", this._onResize);
  5651. this.onAudioUnlockedObservable.clear();
  5652. this.onAudioLockedObservable.clear();
  5653. };
  5654. /**
  5655. * Gets the global volume sets on the master gain.
  5656. * @returns the global volume if set or -1 otherwise
  5657. */
  5658. AudioEngine.prototype.getGlobalVolume = function () {
  5659. if (this.canUseWebAudio && this._audioContextInitialized) {
  5660. return this.masterGain.gain.value;
  5661. }
  5662. else {
  5663. return -1;
  5664. }
  5665. };
  5666. /**
  5667. * Sets the global volume of your experience (sets on the master gain).
  5668. * @param newVolume Defines the new global volume of the application
  5669. */
  5670. AudioEngine.prototype.setGlobalVolume = function (newVolume) {
  5671. if (this.canUseWebAudio && this._audioContextInitialized) {
  5672. this.masterGain.gain.value = newVolume;
  5673. }
  5674. };
  5675. /**
  5676. * Connect the audio engine to an audio analyser allowing some amazing
  5677. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5679. * @param analyser The analyser to connect to the engine
  5680. */
  5681. AudioEngine.prototype.connectToAnalyser = function (analyser) {
  5682. if (this._connectedAnalyser) {
  5683. this._connectedAnalyser.stopDebugCanvas();
  5684. }
  5685. if (this.canUseWebAudio && this._audioContextInitialized && this._audioContext) {
  5686. this._connectedAnalyser = analyser;
  5687. this.masterGain.disconnect();
  5688. this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination);
  5689. }
  5690. };
  5691. return AudioEngine;
  5692. }());
  5693. /***/ }),
  5694. /***/ "./Audio/audioSceneComponent.ts":
  5695. /*!**************************************!*\
  5696. !*** ./Audio/audioSceneComponent.ts ***!
  5697. \**************************************/
  5698. /*! exports provided: AudioSceneComponent */
  5699. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5700. "use strict";
  5701. __webpack_require__.r(__webpack_exports__);
  5702. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return AudioSceneComponent; });
  5703. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  5704. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  5705. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5706. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  5707. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  5708. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  5709. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  5710. // Adds the parser to the scene parsers.
  5711. _abstractScene__WEBPACK_IMPORTED_MODULE_6__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO, function (parsedData, scene, container, rootUrl) {
  5712. // TODO: add sound
  5713. var loadedSounds = [];
  5714. var loadedSound;
  5715. container.sounds = container.sounds || [];
  5716. if (parsedData.sounds !== undefined && parsedData.sounds !== null) {
  5717. for (var index = 0, cache = parsedData.sounds.length; index < cache; index++) {
  5718. var parsedSound = parsedData.sounds[index];
  5719. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine.canUseWebAudio) {
  5720. if (!parsedSound.url) {
  5721. parsedSound.url = parsedSound.name;
  5722. }
  5723. if (!loadedSounds[parsedSound.url]) {
  5724. loadedSound = _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl);
  5725. loadedSounds[parsedSound.url] = loadedSound;
  5726. container.sounds.push(loadedSound);
  5727. }
  5728. else {
  5729. container.sounds.push(_sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]));
  5730. }
  5731. }
  5732. else {
  5733. container.sounds.push(new _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"](parsedSound.name, null, scene));
  5734. }
  5735. }
  5736. }
  5737. loadedSounds = [];
  5738. });
  5739. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "mainSoundTrack", {
  5740. get: function () {
  5741. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  5742. if (!compo) {
  5743. compo = new AudioSceneComponent(this);
  5744. this._addComponent(compo);
  5745. }
  5746. if (!this._mainSoundTrack) {
  5747. this._mainSoundTrack = new _soundTrack__WEBPACK_IMPORTED_MODULE_1__["SoundTrack"](this, { mainTrack: true });
  5748. }
  5749. return this._mainSoundTrack;
  5750. },
  5751. enumerable: true,
  5752. configurable: true
  5753. });
  5754. _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype.getSoundByName = function (name) {
  5755. var index;
  5756. for (index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {
  5757. if (this.mainSoundTrack.soundCollection[index].name === name) {
  5758. return this.mainSoundTrack.soundCollection[index];
  5759. }
  5760. }
  5761. if (this.soundTracks) {
  5762. for (var sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {
  5763. for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {
  5764. if (this.soundTracks[sdIndex].soundCollection[index].name === name) {
  5765. return this.soundTracks[sdIndex].soundCollection[index];
  5766. }
  5767. }
  5768. }
  5769. }
  5770. return null;
  5771. };
  5772. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "audioEnabled", {
  5773. get: function () {
  5774. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  5775. if (!compo) {
  5776. compo = new AudioSceneComponent(this);
  5777. this._addComponent(compo);
  5778. }
  5779. return compo.audioEnabled;
  5780. },
  5781. set: function (value) {
  5782. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  5783. if (!compo) {
  5784. compo = new AudioSceneComponent(this);
  5785. this._addComponent(compo);
  5786. }
  5787. if (value) {
  5788. compo.enableAudio();
  5789. }
  5790. else {
  5791. compo.disableAudio();
  5792. }
  5793. },
  5794. enumerable: true,
  5795. configurable: true
  5796. });
  5797. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "headphone", {
  5798. get: function () {
  5799. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  5800. if (!compo) {
  5801. compo = new AudioSceneComponent(this);
  5802. this._addComponent(compo);
  5803. }
  5804. return compo.headphone;
  5805. },
  5806. set: function (value) {
  5807. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  5808. if (!compo) {
  5809. compo = new AudioSceneComponent(this);
  5810. this._addComponent(compo);
  5811. }
  5812. if (value) {
  5813. compo.switchAudioModeForHeadphones();
  5814. }
  5815. else {
  5816. compo.switchAudioModeForNormalSpeakers();
  5817. }
  5818. },
  5819. enumerable: true,
  5820. configurable: true
  5821. });
  5822. /**
  5823. * Defines the sound scene component responsible to manage any sounds
  5824. * in a given scene.
  5825. */
  5826. var AudioSceneComponent = /** @class */ (function () {
  5827. /**
  5828. * Creates a new instance of the component for the given scene
  5829. * @param scene Defines the scene to register the component in
  5830. */
  5831. function AudioSceneComponent(scene) {
  5832. /**
  5833. * The component name helpfull to identify the component in the list of scene components.
  5834. */
  5835. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO;
  5836. this._audioEnabled = true;
  5837. this._headphone = false;
  5838. this.scene = scene;
  5839. scene.soundTracks = new Array();
  5840. scene.sounds = new Array();
  5841. }
  5842. Object.defineProperty(AudioSceneComponent.prototype, "audioEnabled", {
  5843. /**
  5844. * Gets whether audio is enabled or not.
  5845. * Please use related enable/disable method to switch state.
  5846. */
  5847. get: function () {
  5848. return this._audioEnabled;
  5849. },
  5850. enumerable: true,
  5851. configurable: true
  5852. });
  5853. Object.defineProperty(AudioSceneComponent.prototype, "headphone", {
  5854. /**
  5855. * Gets whether audio is outputing to headphone or not.
  5856. * Please use the according Switch methods to change output.
  5857. */
  5858. get: function () {
  5859. return this._headphone;
  5860. },
  5861. enumerable: true,
  5862. configurable: true
  5863. });
  5864. /**
  5865. * Registers the component in a given scene
  5866. */
  5867. AudioSceneComponent.prototype.register = function () {
  5868. this.scene._afterRenderStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDER_AUDIO, this, this._afterRender);
  5869. };
  5870. /**
  5871. * Rebuilds the elements related to this component in case of
  5872. * context lost for instance.
  5873. */
  5874. AudioSceneComponent.prototype.rebuild = function () {
  5875. // Nothing to do here. (Not rendering related)
  5876. };
  5877. /**
  5878. * Serializes the component data to the specified json object
  5879. * @param serializationObject The object to serialize to
  5880. */
  5881. AudioSceneComponent.prototype.serialize = function (serializationObject) {
  5882. serializationObject.sounds = [];
  5883. if (this.scene.soundTracks) {
  5884. for (var index = 0; index < this.scene.soundTracks.length; index++) {
  5885. var soundtrack = this.scene.soundTracks[index];
  5886. for (var soundId = 0; soundId < soundtrack.soundCollection.length; soundId++) {
  5887. serializationObject.sounds.push(soundtrack.soundCollection[soundId].serialize());
  5888. }
  5889. }
  5890. }
  5891. };
  5892. /**
  5893. * Adds all the element from the container to the scene
  5894. * @param container the container holding the elements
  5895. */
  5896. AudioSceneComponent.prototype.addFromContainer = function (container) {
  5897. var _this = this;
  5898. if (!container.sounds) {
  5899. return;
  5900. }
  5901. container.sounds.forEach(function (sound) {
  5902. sound.play();
  5903. sound.autoplay = true;
  5904. _this.scene.mainSoundTrack.AddSound(sound);
  5905. });
  5906. };
  5907. /**
  5908. * Removes all the elements in the container from the scene
  5909. * @param container contains the elements to remove
  5910. */
  5911. AudioSceneComponent.prototype.removeFromContainer = function (container) {
  5912. var _this = this;
  5913. if (!container.sounds) {
  5914. return;
  5915. }
  5916. container.sounds.forEach(function (sound) {
  5917. sound.stop();
  5918. sound.autoplay = false;
  5919. _this.scene.mainSoundTrack.RemoveSound(sound);
  5920. });
  5921. };
  5922. /**
  5923. * Disposes the component and the associated ressources.
  5924. */
  5925. AudioSceneComponent.prototype.dispose = function () {
  5926. var scene = this.scene;
  5927. if (scene._mainSoundTrack) {
  5928. scene.mainSoundTrack.dispose();
  5929. }
  5930. if (scene.soundTracks) {
  5931. for (var scIndex = 0; scIndex < scene.soundTracks.length; scIndex++) {
  5932. scene.soundTracks[scIndex].dispose();
  5933. }
  5934. }
  5935. };
  5936. /**
  5937. * Disables audio in the associated scene.
  5938. */
  5939. AudioSceneComponent.prototype.disableAudio = function () {
  5940. var scene = this.scene;
  5941. this._audioEnabled = false;
  5942. var i;
  5943. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  5944. scene.mainSoundTrack.soundCollection[i].pause();
  5945. }
  5946. if (scene.soundTracks) {
  5947. for (i = 0; i < scene.soundTracks.length; i++) {
  5948. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  5949. scene.soundTracks[i].soundCollection[j].pause();
  5950. }
  5951. }
  5952. }
  5953. };
  5954. /**
  5955. * Enables audio in the associated scene.
  5956. */
  5957. AudioSceneComponent.prototype.enableAudio = function () {
  5958. var scene = this.scene;
  5959. this._audioEnabled = true;
  5960. var i;
  5961. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  5962. if (scene.mainSoundTrack.soundCollection[i].isPaused) {
  5963. scene.mainSoundTrack.soundCollection[i].play();
  5964. }
  5965. }
  5966. if (scene.soundTracks) {
  5967. for (i = 0; i < scene.soundTracks.length; i++) {
  5968. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  5969. if (scene.soundTracks[i].soundCollection[j].isPaused) {
  5970. scene.soundTracks[i].soundCollection[j].play();
  5971. }
  5972. }
  5973. }
  5974. }
  5975. };
  5976. /**
  5977. * Switch audio to headphone output.
  5978. */
  5979. AudioSceneComponent.prototype.switchAudioModeForHeadphones = function () {
  5980. var scene = this.scene;
  5981. this._headphone = true;
  5982. scene.mainSoundTrack.switchPanningModelToHRTF();
  5983. if (scene.soundTracks) {
  5984. for (var i = 0; i < scene.soundTracks.length; i++) {
  5985. scene.soundTracks[i].switchPanningModelToHRTF();
  5986. }
  5987. }
  5988. };
  5989. /**
  5990. * Switch audio to normal speakers.
  5991. */
  5992. AudioSceneComponent.prototype.switchAudioModeForNormalSpeakers = function () {
  5993. var scene = this.scene;
  5994. this._headphone = false;
  5995. scene.mainSoundTrack.switchPanningModelToEqualPower();
  5996. if (scene.soundTracks) {
  5997. for (var i = 0; i < scene.soundTracks.length; i++) {
  5998. scene.soundTracks[i].switchPanningModelToEqualPower();
  5999. }
  6000. }
  6001. };
  6002. AudioSceneComponent.prototype._afterRender = function () {
  6003. var scene = this.scene;
  6004. if (!this._audioEnabled || !scene._mainSoundTrack || !scene.soundTracks || (scene._mainSoundTrack.soundCollection.length === 0 && scene.soundTracks.length === 1)) {
  6005. return;
  6006. }
  6007. var listeningCamera;
  6008. var audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine;
  6009. if (scene.activeCameras.length > 0) {
  6010. listeningCamera = scene.activeCameras[0];
  6011. }
  6012. else {
  6013. listeningCamera = scene.activeCamera;
  6014. }
  6015. if (listeningCamera && audioEngine.audioContext) {
  6016. audioEngine.audioContext.listener.setPosition(listeningCamera.position.x, listeningCamera.position.y, listeningCamera.position.z);
  6017. // for VR cameras
  6018. if (listeningCamera.rigCameras && listeningCamera.rigCameras.length > 0) {
  6019. listeningCamera = listeningCamera.rigCameras[0];
  6020. }
  6021. var mat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(listeningCamera.getViewMatrix());
  6022. var cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1), mat);
  6023. cameraDirection.normalize();
  6024. // To avoid some errors on GearVR
  6025. if (!isNaN(cameraDirection.x) && !isNaN(cameraDirection.y) && !isNaN(cameraDirection.z)) {
  6026. audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
  6027. }
  6028. var i;
  6029. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6030. var sound = scene.mainSoundTrack.soundCollection[i];
  6031. if (sound.useCustomAttenuation) {
  6032. sound.updateDistanceFromListener();
  6033. }
  6034. }
  6035. if (scene.soundTracks) {
  6036. for (i = 0; i < scene.soundTracks.length; i++) {
  6037. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6038. sound = scene.soundTracks[i].soundCollection[j];
  6039. if (sound.useCustomAttenuation) {
  6040. sound.updateDistanceFromListener();
  6041. }
  6042. }
  6043. }
  6044. }
  6045. }
  6046. };
  6047. return AudioSceneComponent;
  6048. }());
  6049. _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"]._SceneComponentInitialization = function (scene) {
  6050. var compo = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6051. if (!compo) {
  6052. compo = new AudioSceneComponent(scene);
  6053. scene._addComponent(compo);
  6054. }
  6055. };
  6056. /***/ }),
  6057. /***/ "./Audio/index.ts":
  6058. /*!************************!*\
  6059. !*** ./Audio/index.ts ***!
  6060. \************************/
  6061. /*! exports provided: Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound */
  6062. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6063. "use strict";
  6064. __webpack_require__.r(__webpack_exports__);
  6065. /* harmony import */ var _analyser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./analyser */ "./Audio/analyser.ts");
  6066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _analyser__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  6067. /* harmony import */ var _audioEngine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./audioEngine */ "./Audio/audioEngine.ts");
  6068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _audioEngine__WEBPACK_IMPORTED_MODULE_1__["AudioEngine"]; });
  6069. /* harmony import */ var _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./audioSceneComponent */ "./Audio/audioSceneComponent.ts");
  6070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__["AudioSceneComponent"]; });
  6071. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _sound__WEBPACK_IMPORTED_MODULE_3__["Sound"]; });
  6073. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _soundTrack__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  6075. /* harmony import */ var _weightedsound__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./weightedsound */ "./Audio/weightedsound.ts");
  6076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _weightedsound__WEBPACK_IMPORTED_MODULE_5__["WeightedSound"]; });
  6077. /***/ }),
  6078. /***/ "./Audio/sound.ts":
  6079. /*!************************!*\
  6080. !*** ./Audio/sound.ts ***!
  6081. \************************/
  6082. /*! exports provided: Sound */
  6083. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6084. "use strict";
  6085. __webpack_require__.r(__webpack_exports__);
  6086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return Sound; });
  6087. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  6088. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  6089. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6090. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6091. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  6092. /**
  6093. * Defines a sound that can be played in the application.
  6094. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  6095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6096. */
  6097. var Sound = /** @class */ (function () {
  6098. /**
  6099. * Create a sound and attach it to a scene
  6100. * @param name Name of your sound
  6101. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  6102. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  6103. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  6104. */
  6105. function Sound(name, urlOrArrayBuffer, scene, readyToPlayCallback, options) {
  6106. if (readyToPlayCallback === void 0) { readyToPlayCallback = null; }
  6107. var _this = this;
  6108. /**
  6109. * Does the sound autoplay once loaded.
  6110. */
  6111. this.autoplay = false;
  6112. /**
  6113. * Does the sound loop after it finishes playing once.
  6114. */
  6115. this.loop = false;
  6116. /**
  6117. * Does the sound use a custom attenuation curve to simulate the falloff
  6118. * happening when the source gets further away from the camera.
  6119. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6120. */
  6121. this.useCustomAttenuation = false;
  6122. /**
  6123. * Is this sound currently played.
  6124. */
  6125. this.isPlaying = false;
  6126. /**
  6127. * Is this sound currently paused.
  6128. */
  6129. this.isPaused = false;
  6130. /**
  6131. * Does this sound enables spatial sound.
  6132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6133. */
  6134. this.spatialSound = false;
  6135. /**
  6136. * Define the reference distance the sound should be heard perfectly.
  6137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6138. */
  6139. this.refDistance = 1;
  6140. /**
  6141. * Define the roll off factor of spatial sounds.
  6142. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6143. */
  6144. this.rolloffFactor = 1;
  6145. /**
  6146. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  6147. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6148. */
  6149. this.maxDistance = 100;
  6150. /**
  6151. * Define the distance attenuation model the sound will follow.
  6152. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6153. */
  6154. this.distanceModel = "linear";
  6155. /**
  6156. * Observable event when the current playing sound finishes.
  6157. */
  6158. this.onEndedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6159. this._panningModel = "equalpower";
  6160. this._playbackRate = 1;
  6161. this._streaming = false;
  6162. this._startTime = 0;
  6163. this._startOffset = 0;
  6164. this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  6165. /** @hidden */
  6166. this._positionInEmitterSpace = false;
  6167. this._localDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 0, 0);
  6168. this._volume = 1;
  6169. this._isReadyToPlay = false;
  6170. this._isDirectional = false;
  6171. // Used if you'd like to create a directional sound.
  6172. // If not set, the sound will be omnidirectional
  6173. this._coneInnerAngle = 360;
  6174. this._coneOuterAngle = 360;
  6175. this._coneOuterGain = 0;
  6176. this._isOutputConnected = false;
  6177. this._urlType = "Unknown";
  6178. this.name = name;
  6179. this._scene = scene;
  6180. Sound._SceneComponentInitialization(scene);
  6181. this._readyToPlayCallback = readyToPlayCallback;
  6182. // Default custom attenuation function is a linear attenuation
  6183. this._customAttenuationFunction = function (currentVolume, currentDistance, maxDistance, refDistance, rolloffFactor) {
  6184. if (currentDistance < maxDistance) {
  6185. return currentVolume * (1 - currentDistance / maxDistance);
  6186. }
  6187. else {
  6188. return 0;
  6189. }
  6190. };
  6191. if (options) {
  6192. this.autoplay = options.autoplay || false;
  6193. this.loop = options.loop || false;
  6194. // if volume === 0, we need another way to check this option
  6195. if (options.volume !== undefined) {
  6196. this._volume = options.volume;
  6197. }
  6198. this.spatialSound = options.spatialSound || false;
  6199. this.maxDistance = options.maxDistance || 100;
  6200. this.useCustomAttenuation = options.useCustomAttenuation || false;
  6201. this.rolloffFactor = options.rolloffFactor || 1;
  6202. this.refDistance = options.refDistance || 1;
  6203. this.distanceModel = options.distanceModel || "linear";
  6204. this._playbackRate = options.playbackRate || 1;
  6205. this._streaming = options.streaming || false;
  6206. }
  6207. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6208. this._soundGain = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createGain();
  6209. this._soundGain.gain.value = this._volume;
  6210. this._inputAudioNode = this._soundGain;
  6211. this._outputAudioNode = this._soundGain;
  6212. if (this.spatialSound) {
  6213. this._createSpatialParameters();
  6214. }
  6215. this._scene.mainSoundTrack.AddSound(this);
  6216. var validParameter = true;
  6217. // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound
  6218. if (urlOrArrayBuffer) {
  6219. try {
  6220. if (typeof (urlOrArrayBuffer) === "string") {
  6221. this._urlType = "String";
  6222. }
  6223. else if (urlOrArrayBuffer instanceof ArrayBuffer) {
  6224. this._urlType = "ArrayBuffer";
  6225. }
  6226. else if (urlOrArrayBuffer instanceof MediaStream) {
  6227. this._urlType = "MediaStream";
  6228. }
  6229. else if (Array.isArray(urlOrArrayBuffer)) {
  6230. this._urlType = "Array";
  6231. }
  6232. var urls = [];
  6233. var codecSupportedFound = false;
  6234. switch (this._urlType) {
  6235. case "MediaStream":
  6236. this._streaming = true;
  6237. this._isReadyToPlay = true;
  6238. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);
  6239. if (this.autoplay) {
  6240. this.play();
  6241. }
  6242. if (this._readyToPlayCallback) {
  6243. this._readyToPlayCallback();
  6244. }
  6245. break;
  6246. case "ArrayBuffer":
  6247. if (urlOrArrayBuffer.byteLength > 0) {
  6248. codecSupportedFound = true;
  6249. this._soundLoaded(urlOrArrayBuffer);
  6250. }
  6251. break;
  6252. case "String":
  6253. urls.push(urlOrArrayBuffer);
  6254. case "Array":
  6255. if (urls.length === 0) {
  6256. urls = urlOrArrayBuffer;
  6257. }
  6258. // If we found a supported format, we load it immediately and stop the loop
  6259. for (var i = 0; i < urls.length; i++) {
  6260. var url = urls[i];
  6261. if (url.indexOf(".mp3", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isMP3supported) {
  6262. codecSupportedFound = true;
  6263. }
  6264. if (url.indexOf(".ogg", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isOGGsupported) {
  6265. codecSupportedFound = true;
  6266. }
  6267. if (url.indexOf(".wav", url.length - 4) !== -1) {
  6268. codecSupportedFound = true;
  6269. }
  6270. if (url.indexOf("blob:") !== -1) {
  6271. codecSupportedFound = true;
  6272. }
  6273. if (codecSupportedFound) {
  6274. // Loading sound using XHR2
  6275. if (!this._streaming) {
  6276. this._scene._loadFile(url, function (data) {
  6277. _this._soundLoaded(data);
  6278. }, undefined, true, true, function (exception) {
  6279. if (exception) {
  6280. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("XHR " + exception.status + " error on: " + url + ".");
  6281. }
  6282. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Sound creation aborted.");
  6283. _this._scene.mainSoundTrack.RemoveSound(_this);
  6284. });
  6285. }
  6286. // Streaming sound using HTML5 Audio tag
  6287. else {
  6288. this._htmlAudioElement = new Audio(url);
  6289. this._htmlAudioElement.controls = false;
  6290. this._htmlAudioElement.loop = this.loop;
  6291. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetCorsBehavior(url, this._htmlAudioElement);
  6292. this._htmlAudioElement.preload = "auto";
  6293. this._htmlAudioElement.addEventListener("canplaythrough", function () {
  6294. _this._isReadyToPlay = true;
  6295. if (_this.autoplay) {
  6296. _this.play();
  6297. }
  6298. if (_this._readyToPlayCallback) {
  6299. _this._readyToPlayCallback();
  6300. }
  6301. });
  6302. document.body.appendChild(this._htmlAudioElement);
  6303. this._htmlAudioElement.load();
  6304. }
  6305. break;
  6306. }
  6307. }
  6308. break;
  6309. default:
  6310. validParameter = false;
  6311. break;
  6312. }
  6313. if (!validParameter) {
  6314. _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.");
  6315. }
  6316. else {
  6317. if (!codecSupportedFound) {
  6318. this._isReadyToPlay = true;
  6319. // Simulating a ready to play event to avoid breaking code path
  6320. if (this._readyToPlayCallback) {
  6321. window.setTimeout(function () {
  6322. if (_this._readyToPlayCallback) {
  6323. _this._readyToPlayCallback();
  6324. }
  6325. }, 1000);
  6326. }
  6327. }
  6328. }
  6329. }
  6330. catch (ex) {
  6331. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Unexpected error. Sound creation aborted.");
  6332. this._scene.mainSoundTrack.RemoveSound(this);
  6333. }
  6334. }
  6335. }
  6336. else {
  6337. // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers
  6338. this._scene.mainSoundTrack.AddSound(this);
  6339. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported) {
  6340. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Web Audio is not supported by your browser.");
  6341. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported = true;
  6342. }
  6343. // Simulating a ready to play event to avoid breaking code for non web audio browsers
  6344. if (this._readyToPlayCallback) {
  6345. window.setTimeout(function () {
  6346. if (_this._readyToPlayCallback) {
  6347. _this._readyToPlayCallback();
  6348. }
  6349. }, 1000);
  6350. }
  6351. }
  6352. }
  6353. /**
  6354. * Release the sound and its associated resources
  6355. */
  6356. Sound.prototype.dispose = function () {
  6357. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6358. if (this.isPlaying) {
  6359. this.stop();
  6360. }
  6361. this._isReadyToPlay = false;
  6362. if (this.soundTrackId === -1) {
  6363. this._scene.mainSoundTrack.RemoveSound(this);
  6364. }
  6365. else if (this._scene.soundTracks) {
  6366. this._scene.soundTracks[this.soundTrackId].RemoveSound(this);
  6367. }
  6368. if (this._soundGain) {
  6369. this._soundGain.disconnect();
  6370. this._soundGain = null;
  6371. }
  6372. if (this._soundPanner) {
  6373. this._soundPanner.disconnect();
  6374. this._soundPanner = null;
  6375. }
  6376. if (this._soundSource) {
  6377. this._soundSource.disconnect();
  6378. this._soundSource = null;
  6379. }
  6380. this._audioBuffer = null;
  6381. if (this._htmlAudioElement) {
  6382. this._htmlAudioElement.pause();
  6383. this._htmlAudioElement.src = "";
  6384. document.body.removeChild(this._htmlAudioElement);
  6385. }
  6386. if (this._streamingSource) {
  6387. this._streamingSource.disconnect();
  6388. }
  6389. if (this._connectedTransformNode && this._registerFunc) {
  6390. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6391. this._connectedTransformNode = null;
  6392. }
  6393. }
  6394. };
  6395. /**
  6396. * Gets if the sounds is ready to be played or not.
  6397. * @returns true if ready, otherwise false
  6398. */
  6399. Sound.prototype.isReady = function () {
  6400. return this._isReadyToPlay;
  6401. };
  6402. Sound.prototype._soundLoaded = function (audioData) {
  6403. var _this = this;
  6404. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6405. return;
  6406. }
  6407. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.decodeAudioData(audioData, function (buffer) {
  6408. _this._audioBuffer = buffer;
  6409. _this._isReadyToPlay = true;
  6410. if (_this.autoplay) {
  6411. _this.play();
  6412. }
  6413. if (_this._readyToPlayCallback) {
  6414. _this._readyToPlayCallback();
  6415. }
  6416. }, function (err) { _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while decoding audio data for: " + _this.name + " / Error: " + err); });
  6417. };
  6418. /**
  6419. * Sets the data of the sound from an audiobuffer
  6420. * @param audioBuffer The audioBuffer containing the data
  6421. */
  6422. Sound.prototype.setAudioBuffer = function (audioBuffer) {
  6423. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6424. this._audioBuffer = audioBuffer;
  6425. this._isReadyToPlay = true;
  6426. }
  6427. };
  6428. /**
  6429. * Updates the current sounds options such as maxdistance, loop...
  6430. * @param options A JSON object containing values named as the object properties
  6431. */
  6432. Sound.prototype.updateOptions = function (options) {
  6433. if (options) {
  6434. this.loop = options.loop || this.loop;
  6435. this.maxDistance = options.maxDistance || this.maxDistance;
  6436. this.useCustomAttenuation = options.useCustomAttenuation || this.useCustomAttenuation;
  6437. this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
  6438. this.refDistance = options.refDistance || this.refDistance;
  6439. this.distanceModel = options.distanceModel || this.distanceModel;
  6440. this._playbackRate = options.playbackRate || this._playbackRate;
  6441. this._updateSpatialParameters();
  6442. if (this.isPlaying) {
  6443. if (this._streaming && this._htmlAudioElement) {
  6444. this._htmlAudioElement.playbackRate = this._playbackRate;
  6445. }
  6446. else {
  6447. if (this._soundSource) {
  6448. this._soundSource.playbackRate.value = this._playbackRate;
  6449. }
  6450. }
  6451. }
  6452. }
  6453. };
  6454. Sound.prototype._createSpatialParameters = function () {
  6455. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6456. if (this._scene.headphone) {
  6457. this._panningModel = "HRTF";
  6458. }
  6459. this._soundPanner = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createPanner();
  6460. this._updateSpatialParameters();
  6461. this._soundPanner.connect(this._outputAudioNode);
  6462. this._inputAudioNode = this._soundPanner;
  6463. }
  6464. };
  6465. Sound.prototype._updateSpatialParameters = function () {
  6466. if (this.spatialSound && this._soundPanner) {
  6467. if (this.useCustomAttenuation) {
  6468. // Tricks to disable in a way embedded Web Audio attenuation
  6469. this._soundPanner.distanceModel = "linear";
  6470. this._soundPanner.maxDistance = Number.MAX_VALUE;
  6471. this._soundPanner.refDistance = 1;
  6472. this._soundPanner.rolloffFactor = 1;
  6473. this._soundPanner.panningModel = this._panningModel;
  6474. }
  6475. else {
  6476. this._soundPanner.distanceModel = this.distanceModel;
  6477. this._soundPanner.maxDistance = this.maxDistance;
  6478. this._soundPanner.refDistance = this.refDistance;
  6479. this._soundPanner.rolloffFactor = this.rolloffFactor;
  6480. this._soundPanner.panningModel = this._panningModel;
  6481. }
  6482. }
  6483. };
  6484. /**
  6485. * Switch the panning model to HRTF:
  6486. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  6487. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6488. */
  6489. Sound.prototype.switchPanningModelToHRTF = function () {
  6490. this._panningModel = "HRTF";
  6491. this._switchPanningModel();
  6492. };
  6493. /**
  6494. * Switch the panning model to Equal Power:
  6495. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  6496. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6497. */
  6498. Sound.prototype.switchPanningModelToEqualPower = function () {
  6499. this._panningModel = "equalpower";
  6500. this._switchPanningModel();
  6501. };
  6502. Sound.prototype._switchPanningModel = function () {
  6503. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6504. this._soundPanner.panningModel = this._panningModel;
  6505. }
  6506. };
  6507. /**
  6508. * Connect this sound to a sound track audio node like gain...
  6509. * @param soundTrackAudioNode the sound track audio node to connect to
  6510. */
  6511. Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {
  6512. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6513. if (this._isOutputConnected) {
  6514. this._outputAudioNode.disconnect();
  6515. }
  6516. this._outputAudioNode.connect(soundTrackAudioNode);
  6517. this._isOutputConnected = true;
  6518. }
  6519. };
  6520. /**
  6521. * Transform this sound into a directional source
  6522. * @param coneInnerAngle Size of the inner cone in degree
  6523. * @param coneOuterAngle Size of the outer cone in degree
  6524. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  6525. */
  6526. Sound.prototype.setDirectionalCone = function (coneInnerAngle, coneOuterAngle, coneOuterGain) {
  6527. if (coneOuterAngle < coneInnerAngle) {
  6528. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
  6529. return;
  6530. }
  6531. this._coneInnerAngle = coneInnerAngle;
  6532. this._coneOuterAngle = coneOuterAngle;
  6533. this._coneOuterGain = coneOuterGain;
  6534. this._isDirectional = true;
  6535. if (this.isPlaying && this.loop) {
  6536. this.stop();
  6537. this.play();
  6538. }
  6539. };
  6540. Object.defineProperty(Sound.prototype, "directionalConeInnerAngle", {
  6541. /**
  6542. * Gets or sets the inner angle for the directional cone.
  6543. */
  6544. get: function () {
  6545. return this._coneInnerAngle;
  6546. },
  6547. /**
  6548. * Gets or sets the inner angle for the directional cone.
  6549. */
  6550. set: function (value) {
  6551. if (value != this._coneInnerAngle) {
  6552. if (this._coneOuterAngle < value) {
  6553. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6554. return;
  6555. }
  6556. this._coneInnerAngle = value;
  6557. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6558. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6559. }
  6560. }
  6561. },
  6562. enumerable: true,
  6563. configurable: true
  6564. });
  6565. Object.defineProperty(Sound.prototype, "directionalConeOuterAngle", {
  6566. /**
  6567. * Gets or sets the outer angle for the directional cone.
  6568. */
  6569. get: function () {
  6570. return this._coneOuterAngle;
  6571. },
  6572. /**
  6573. * Gets or sets the outer angle for the directional cone.
  6574. */
  6575. set: function (value) {
  6576. if (value != this._coneOuterAngle) {
  6577. if (value < this._coneInnerAngle) {
  6578. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6579. return;
  6580. }
  6581. this._coneOuterAngle = value;
  6582. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6583. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6584. }
  6585. }
  6586. },
  6587. enumerable: true,
  6588. configurable: true
  6589. });
  6590. /**
  6591. * Sets the position of the emitter if spatial sound is enabled
  6592. * @param newPosition Defines the new posisiton
  6593. */
  6594. Sound.prototype.setPosition = function (newPosition) {
  6595. this._position = newPosition;
  6596. 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)) {
  6597. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6598. }
  6599. };
  6600. /**
  6601. * Sets the local direction of the emitter if spatial sound is enabled
  6602. * @param newLocalDirection Defines the new local direction
  6603. */
  6604. Sound.prototype.setLocalDirectionToMesh = function (newLocalDirection) {
  6605. this._localDirection = newLocalDirection;
  6606. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {
  6607. this._updateDirection();
  6608. }
  6609. };
  6610. Sound.prototype._updateDirection = function () {
  6611. if (!this._connectedTransformNode || !this._soundPanner) {
  6612. return;
  6613. }
  6614. var mat = this._connectedTransformNode.getWorldMatrix();
  6615. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(this._localDirection, mat);
  6616. direction.normalize();
  6617. this._soundPanner.setOrientation(direction.x, direction.y, direction.z);
  6618. };
  6619. /** @hidden */
  6620. Sound.prototype.updateDistanceFromListener = function () {
  6621. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
  6622. var distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
  6623. this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);
  6624. }
  6625. };
  6626. /**
  6627. * Sets a new custom attenuation function for the sound.
  6628. * @param callback Defines the function used for the attenuation
  6629. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6630. */
  6631. Sound.prototype.setAttenuationFunction = function (callback) {
  6632. this._customAttenuationFunction = callback;
  6633. };
  6634. /**
  6635. * Play the sound
  6636. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  6637. * @param offset (optional) Start the sound setting it at a specific time
  6638. */
  6639. Sound.prototype.play = function (time, offset) {
  6640. var _this = this;
  6641. if (this._isReadyToPlay && this._scene.audioEnabled && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6642. try {
  6643. if (this._startOffset < 0) {
  6644. time = -this._startOffset;
  6645. this._startOffset = 0;
  6646. }
  6647. var startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  6648. if (!this._soundSource || !this._streamingSource) {
  6649. if (this.spatialSound && this._soundPanner) {
  6650. if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  6651. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6652. }
  6653. if (this._isDirectional) {
  6654. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6655. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6656. this._soundPanner.coneOuterGain = this._coneOuterGain;
  6657. if (this._connectedTransformNode) {
  6658. this._updateDirection();
  6659. }
  6660. else {
  6661. this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);
  6662. }
  6663. }
  6664. }
  6665. }
  6666. if (this._streaming) {
  6667. if (!this._streamingSource) {
  6668. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);
  6669. this._htmlAudioElement.onended = function () { _this._onended(); };
  6670. this._htmlAudioElement.playbackRate = this._playbackRate;
  6671. }
  6672. this._streamingSource.disconnect();
  6673. this._streamingSource.connect(this._inputAudioNode);
  6674. if (this._htmlAudioElement) {
  6675. // required to manage properly the new suspended default state of Chrome
  6676. // When the option 'streaming: true' is used, we need first to wait for
  6677. // the audio engine to be unlocked by a user gesture before trying to play
  6678. // an HTML Audio elememt
  6679. var tryToPlay = function () {
  6680. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.unlocked) {
  6681. var playPromise = _this._htmlAudioElement.play();
  6682. // In browsers that don’t yet support this functionality,
  6683. // playPromise won’t be defined.
  6684. if (playPromise !== undefined) {
  6685. playPromise.catch(function (error) {
  6686. // Automatic playback failed.
  6687. // Waiting for the audio engine to be unlocked by user click on unmute
  6688. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  6689. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  6690. });
  6691. }
  6692. }
  6693. else {
  6694. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  6695. }
  6696. };
  6697. tryToPlay();
  6698. }
  6699. }
  6700. else {
  6701. this._soundSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createBufferSource();
  6702. this._soundSource.buffer = this._audioBuffer;
  6703. this._soundSource.connect(this._inputAudioNode);
  6704. this._soundSource.loop = this.loop;
  6705. this._soundSource.playbackRate.value = this._playbackRate;
  6706. this._soundSource.onended = function () { _this._onended(); };
  6707. if (this._soundSource.buffer) {
  6708. this._soundSource.start(startTime, this.isPaused ? this._startOffset % this._soundSource.buffer.duration : offset ? offset : 0);
  6709. }
  6710. }
  6711. this._startTime = startTime;
  6712. this.isPlaying = true;
  6713. this.isPaused = false;
  6714. }
  6715. catch (ex) {
  6716. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while trying to play audio: " + this.name + ", " + ex.message);
  6717. }
  6718. }
  6719. };
  6720. Sound.prototype._onended = function () {
  6721. this.isPlaying = false;
  6722. if (this.onended) {
  6723. this.onended();
  6724. }
  6725. this.onEndedObservable.notifyObservers(this);
  6726. };
  6727. /**
  6728. * Stop the sound
  6729. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  6730. */
  6731. Sound.prototype.stop = function (time) {
  6732. if (this.isPlaying) {
  6733. if (this._streaming) {
  6734. if (this._htmlAudioElement) {
  6735. this._htmlAudioElement.pause();
  6736. // Test needed for Firefox or it will generate an Invalid State Error
  6737. if (this._htmlAudioElement.currentTime > 0) {
  6738. this._htmlAudioElement.currentTime = 0;
  6739. }
  6740. }
  6741. else {
  6742. this._streamingSource.disconnect();
  6743. }
  6744. }
  6745. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext && this._soundSource) {
  6746. var stopTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  6747. this._soundSource.stop(stopTime);
  6748. this._soundSource.onended = function () { };
  6749. if (!this.isPaused) {
  6750. this._startOffset = 0;
  6751. }
  6752. }
  6753. this.isPlaying = false;
  6754. }
  6755. };
  6756. /**
  6757. * Put the sound in pause
  6758. */
  6759. Sound.prototype.pause = function () {
  6760. if (this.isPlaying) {
  6761. this.isPaused = true;
  6762. if (this._streaming) {
  6763. if (this._htmlAudioElement) {
  6764. this._htmlAudioElement.pause();
  6765. }
  6766. else {
  6767. this._streamingSource.disconnect();
  6768. }
  6769. }
  6770. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6771. this.stop(0);
  6772. this._startOffset += _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime - this._startTime;
  6773. }
  6774. }
  6775. };
  6776. /**
  6777. * Sets a dedicated volume for this sounds
  6778. * @param newVolume Define the new volume of the sound
  6779. * @param time Define in how long the sound should be at this value
  6780. */
  6781. Sound.prototype.setVolume = function (newVolume, time) {
  6782. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._soundGain) {
  6783. if (time && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6784. this._soundGain.gain.cancelScheduledValues(_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  6785. this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  6786. this._soundGain.gain.linearRampToValueAtTime(newVolume, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time);
  6787. }
  6788. else {
  6789. this._soundGain.gain.value = newVolume;
  6790. }
  6791. }
  6792. this._volume = newVolume;
  6793. };
  6794. /**
  6795. * Set the sound play back rate
  6796. * @param newPlaybackRate Define the playback rate the sound should be played at
  6797. */
  6798. Sound.prototype.setPlaybackRate = function (newPlaybackRate) {
  6799. this._playbackRate = newPlaybackRate;
  6800. if (this.isPlaying) {
  6801. if (this._streaming && this._htmlAudioElement) {
  6802. this._htmlAudioElement.playbackRate = this._playbackRate;
  6803. }
  6804. else if (this._soundSource) {
  6805. this._soundSource.playbackRate.value = this._playbackRate;
  6806. }
  6807. }
  6808. };
  6809. /**
  6810. * Gets the volume of the sound.
  6811. * @returns the volume of the sound
  6812. */
  6813. Sound.prototype.getVolume = function () {
  6814. return this._volume;
  6815. };
  6816. /**
  6817. * Attach the sound to a dedicated mesh
  6818. * @param transformNode The transform node to connect the sound with
  6819. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  6820. */
  6821. Sound.prototype.attachToMesh = function (transformNode) {
  6822. var _this = this;
  6823. if (this._connectedTransformNode && this._registerFunc) {
  6824. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6825. this._registerFunc = null;
  6826. }
  6827. this._connectedTransformNode = transformNode;
  6828. if (!this.spatialSound) {
  6829. this.spatialSound = true;
  6830. this._createSpatialParameters();
  6831. if (this.isPlaying && this.loop) {
  6832. this.stop();
  6833. this.play();
  6834. }
  6835. }
  6836. this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);
  6837. this._registerFunc = function (transformNode) { return _this._onRegisterAfterWorldMatrixUpdate(transformNode); };
  6838. this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);
  6839. };
  6840. /**
  6841. * Detach the sound from the previously attached mesh
  6842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  6843. */
  6844. Sound.prototype.detachFromMesh = function () {
  6845. if (this._connectedTransformNode && this._registerFunc) {
  6846. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6847. this._registerFunc = null;
  6848. this._connectedTransformNode = null;
  6849. }
  6850. };
  6851. Sound.prototype._onRegisterAfterWorldMatrixUpdate = function (node) {
  6852. if (!node.getBoundingInfo) {
  6853. return;
  6854. }
  6855. var mesh = node;
  6856. if (this._positionInEmitterSpace) {
  6857. mesh.worldMatrixFromCache.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0]);
  6858. this.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0].getTranslation());
  6859. }
  6860. else {
  6861. var boundingInfo = mesh.getBoundingInfo();
  6862. this.setPosition(boundingInfo.boundingSphere.centerWorld);
  6863. }
  6864. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._isDirectional && this.isPlaying) {
  6865. this._updateDirection();
  6866. }
  6867. };
  6868. /**
  6869. * Clone the current sound in the scene.
  6870. * @returns the new sound clone
  6871. */
  6872. Sound.prototype.clone = function () {
  6873. var _this = this;
  6874. if (!this._streaming) {
  6875. var setBufferAndRun = function () {
  6876. if (_this._isReadyToPlay) {
  6877. clonedSound._audioBuffer = _this.getAudioBuffer();
  6878. clonedSound._isReadyToPlay = true;
  6879. if (clonedSound.autoplay) {
  6880. clonedSound.play();
  6881. }
  6882. }
  6883. else {
  6884. window.setTimeout(setBufferAndRun, 300);
  6885. }
  6886. };
  6887. var currentOptions = {
  6888. autoplay: this.autoplay, loop: this.loop,
  6889. volume: this._volume, spatialSound: this.spatialSound, maxDistance: this.maxDistance,
  6890. useCustomAttenuation: this.useCustomAttenuation, rolloffFactor: this.rolloffFactor,
  6891. refDistance: this.refDistance, distanceModel: this.distanceModel
  6892. };
  6893. var clonedSound = new Sound(this.name + "_cloned", new ArrayBuffer(0), this._scene, null, currentOptions);
  6894. if (this.useCustomAttenuation) {
  6895. clonedSound.setAttenuationFunction(this._customAttenuationFunction);
  6896. }
  6897. clonedSound.setPosition(this._position);
  6898. clonedSound.setPlaybackRate(this._playbackRate);
  6899. setBufferAndRun();
  6900. return clonedSound;
  6901. }
  6902. // Can't clone a streaming sound
  6903. else {
  6904. return null;
  6905. }
  6906. };
  6907. /**
  6908. * Gets the current underlying audio buffer containing the data
  6909. * @returns the audio buffer
  6910. */
  6911. Sound.prototype.getAudioBuffer = function () {
  6912. return this._audioBuffer;
  6913. };
  6914. /**
  6915. * Serializes the Sound in a JSON representation
  6916. * @returns the JSON representation of the sound
  6917. */
  6918. Sound.prototype.serialize = function () {
  6919. var serializationObject = {
  6920. name: this.name,
  6921. url: this.name,
  6922. autoplay: this.autoplay,
  6923. loop: this.loop,
  6924. volume: this._volume,
  6925. spatialSound: this.spatialSound,
  6926. maxDistance: this.maxDistance,
  6927. rolloffFactor: this.rolloffFactor,
  6928. refDistance: this.refDistance,
  6929. distanceModel: this.distanceModel,
  6930. playbackRate: this._playbackRate,
  6931. panningModel: this._panningModel,
  6932. soundTrackId: this.soundTrackId
  6933. };
  6934. if (this.spatialSound) {
  6935. if (this._connectedTransformNode) {
  6936. serializationObject.connectedMeshId = this._connectedTransformNode.id;
  6937. }
  6938. serializationObject.position = this._position.asArray();
  6939. serializationObject.refDistance = this.refDistance;
  6940. serializationObject.distanceModel = this.distanceModel;
  6941. serializationObject.isDirectional = this._isDirectional;
  6942. serializationObject.localDirectionToMesh = this._localDirection.asArray();
  6943. serializationObject.coneInnerAngle = this._coneInnerAngle;
  6944. serializationObject.coneOuterAngle = this._coneOuterAngle;
  6945. serializationObject.coneOuterGain = this._coneOuterGain;
  6946. }
  6947. return serializationObject;
  6948. };
  6949. /**
  6950. * Parse a JSON representation of a sound to innstantiate in a given scene
  6951. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  6952. * @param scene Define the scene the new parsed sound should be created in
  6953. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  6954. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  6955. * @returns the newly parsed sound
  6956. */
  6957. Sound.Parse = function (parsedSound, scene, rootUrl, sourceSound) {
  6958. var soundName = parsedSound.name;
  6959. var soundUrl;
  6960. if (parsedSound.url) {
  6961. soundUrl = rootUrl + parsedSound.url;
  6962. }
  6963. else {
  6964. soundUrl = rootUrl + soundName;
  6965. }
  6966. var options = {
  6967. autoplay: parsedSound.autoplay, loop: parsedSound.loop, volume: parsedSound.volume,
  6968. spatialSound: parsedSound.spatialSound, maxDistance: parsedSound.maxDistance,
  6969. rolloffFactor: parsedSound.rolloffFactor,
  6970. refDistance: parsedSound.refDistance,
  6971. distanceModel: parsedSound.distanceModel,
  6972. playbackRate: parsedSound.playbackRate
  6973. };
  6974. var newSound;
  6975. if (!sourceSound) {
  6976. newSound = new Sound(soundName, soundUrl, scene, function () { scene._removePendingData(newSound); }, options);
  6977. scene._addPendingData(newSound);
  6978. }
  6979. else {
  6980. var setBufferAndRun = function () {
  6981. if (sourceSound._isReadyToPlay) {
  6982. newSound._audioBuffer = sourceSound.getAudioBuffer();
  6983. newSound._isReadyToPlay = true;
  6984. if (newSound.autoplay) {
  6985. newSound.play();
  6986. }
  6987. }
  6988. else {
  6989. window.setTimeout(setBufferAndRun, 300);
  6990. }
  6991. };
  6992. newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);
  6993. setBufferAndRun();
  6994. }
  6995. if (parsedSound.position) {
  6996. var soundPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.position);
  6997. newSound.setPosition(soundPosition);
  6998. }
  6999. if (parsedSound.isDirectional) {
  7000. newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);
  7001. if (parsedSound.localDirectionToMesh) {
  7002. var localDirectionToMesh = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.localDirectionToMesh);
  7003. newSound.setLocalDirectionToMesh(localDirectionToMesh);
  7004. }
  7005. }
  7006. if (parsedSound.connectedMeshId) {
  7007. var connectedMesh = scene.getMeshByID(parsedSound.connectedMeshId);
  7008. if (connectedMesh) {
  7009. newSound.attachToMesh(connectedMesh);
  7010. }
  7011. }
  7012. return newSound;
  7013. };
  7014. /** @hidden */
  7015. Sound._SceneComponentInitialization = function (_) {
  7016. throw "Import AudioSceneComponent before creating sound.";
  7017. };
  7018. return Sound;
  7019. }());
  7020. /***/ }),
  7021. /***/ "./Audio/soundTrack.ts":
  7022. /*!*****************************!*\
  7023. !*** ./Audio/soundTrack.ts ***!
  7024. \*****************************/
  7025. /*! exports provided: SoundTrack */
  7026. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7027. "use strict";
  7028. __webpack_require__.r(__webpack_exports__);
  7029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return SoundTrack; });
  7030. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  7031. /**
  7032. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  7033. * It will be also used in a future release to apply effects on a specific track.
  7034. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7035. */
  7036. var SoundTrack = /** @class */ (function () {
  7037. /**
  7038. * Creates a new sound track.
  7039. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7040. * @param scene Define the scene the sound track belongs to
  7041. * @param options
  7042. */
  7043. function SoundTrack(scene, options) {
  7044. if (options === void 0) { options = {}; }
  7045. /**
  7046. * The unique identifier of the sound track in the scene.
  7047. */
  7048. this.id = -1;
  7049. this._isMainTrack = false;
  7050. this._isInitialized = false;
  7051. this._scene = scene;
  7052. this.soundCollection = new Array();
  7053. this._options = options;
  7054. if (!this._isMainTrack && this._scene.soundTracks) {
  7055. this._scene.soundTracks.push(this);
  7056. this.id = this._scene.soundTracks.length - 1;
  7057. }
  7058. }
  7059. SoundTrack.prototype._initializeSoundTrackAudioGraph = function () {
  7060. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext) {
  7061. this._outputAudioNode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext.createGain();
  7062. this._outputAudioNode.connect(_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7063. if (this._options) {
  7064. if (this._options.volume) {
  7065. this._outputAudioNode.gain.value = this._options.volume;
  7066. }
  7067. if (this._options.mainTrack) {
  7068. this._isMainTrack = this._options.mainTrack;
  7069. }
  7070. }
  7071. this._isInitialized = true;
  7072. }
  7073. };
  7074. /**
  7075. * Release the sound track and its associated resources
  7076. */
  7077. SoundTrack.prototype.dispose = function () {
  7078. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7079. if (this._connectedAnalyser) {
  7080. this._connectedAnalyser.stopDebugCanvas();
  7081. }
  7082. while (this.soundCollection.length) {
  7083. this.soundCollection[0].dispose();
  7084. }
  7085. if (this._outputAudioNode) {
  7086. this._outputAudioNode.disconnect();
  7087. }
  7088. this._outputAudioNode = null;
  7089. }
  7090. };
  7091. /**
  7092. * Adds a sound to this sound track
  7093. * @param sound define the cound to add
  7094. * @ignoreNaming
  7095. */
  7096. SoundTrack.prototype.AddSound = function (sound) {
  7097. if (!this._isInitialized) {
  7098. this._initializeSoundTrackAudioGraph();
  7099. }
  7100. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7101. sound.connectToSoundTrackAudioNode(this._outputAudioNode);
  7102. }
  7103. if (sound.soundTrackId) {
  7104. if (sound.soundTrackId === -1) {
  7105. this._scene.mainSoundTrack.RemoveSound(sound);
  7106. }
  7107. else if (this._scene.soundTracks) {
  7108. this._scene.soundTracks[sound.soundTrackId].RemoveSound(sound);
  7109. }
  7110. }
  7111. this.soundCollection.push(sound);
  7112. sound.soundTrackId = this.id;
  7113. };
  7114. /**
  7115. * Removes a sound to this sound track
  7116. * @param sound define the cound to remove
  7117. * @ignoreNaming
  7118. */
  7119. SoundTrack.prototype.RemoveSound = function (sound) {
  7120. var index = this.soundCollection.indexOf(sound);
  7121. if (index !== -1) {
  7122. this.soundCollection.splice(index, 1);
  7123. }
  7124. };
  7125. /**
  7126. * Set a global volume for the full sound track.
  7127. * @param newVolume Define the new volume of the sound track
  7128. */
  7129. SoundTrack.prototype.setVolume = function (newVolume) {
  7130. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7131. this._outputAudioNode.gain.value = newVolume;
  7132. }
  7133. };
  7134. /**
  7135. * Switch the panning model to HRTF:
  7136. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  7137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7138. */
  7139. SoundTrack.prototype.switchPanningModelToHRTF = function () {
  7140. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7141. for (var i = 0; i < this.soundCollection.length; i++) {
  7142. this.soundCollection[i].switchPanningModelToHRTF();
  7143. }
  7144. }
  7145. };
  7146. /**
  7147. * Switch the panning model to Equal Power:
  7148. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  7149. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7150. */
  7151. SoundTrack.prototype.switchPanningModelToEqualPower = function () {
  7152. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7153. for (var i = 0; i < this.soundCollection.length; i++) {
  7154. this.soundCollection[i].switchPanningModelToEqualPower();
  7155. }
  7156. }
  7157. };
  7158. /**
  7159. * Connect the sound track to an audio analyser allowing some amazing
  7160. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  7161. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  7162. * @param analyser The analyser to connect to the engine
  7163. */
  7164. SoundTrack.prototype.connectToAnalyser = function (analyser) {
  7165. if (this._connectedAnalyser) {
  7166. this._connectedAnalyser.stopDebugCanvas();
  7167. }
  7168. this._connectedAnalyser = analyser;
  7169. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7170. this._outputAudioNode.disconnect();
  7171. this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7172. }
  7173. };
  7174. return SoundTrack;
  7175. }());
  7176. /***/ }),
  7177. /***/ "./Audio/weightedsound.ts":
  7178. /*!********************************!*\
  7179. !*** ./Audio/weightedsound.ts ***!
  7180. \********************************/
  7181. /*! exports provided: WeightedSound */
  7182. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7183. "use strict";
  7184. __webpack_require__.r(__webpack_exports__);
  7185. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return WeightedSound; });
  7186. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  7187. /**
  7188. * Wraps one or more Sound objects and selects one with random weight for playback.
  7189. */
  7190. var WeightedSound = /** @class */ (function () {
  7191. /**
  7192. * Creates a new WeightedSound from the list of sounds given.
  7193. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  7194. * @param sounds Array of Sounds that will be selected from.
  7195. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  7196. */
  7197. function WeightedSound(loop, sounds, weights) {
  7198. var _this = this;
  7199. /** When true a Sound will be selected and played when the current playing Sound completes. */
  7200. this.loop = false;
  7201. this._coneInnerAngle = 360;
  7202. this._coneOuterAngle = 360;
  7203. this._volume = 1;
  7204. /** A Sound is currently playing. */
  7205. this.isPlaying = false;
  7206. /** A Sound is currently paused. */
  7207. this.isPaused = false;
  7208. this._sounds = [];
  7209. this._weights = [];
  7210. if (sounds.length !== weights.length) {
  7211. throw new Error('Sounds length does not equal weights length');
  7212. }
  7213. this.loop = loop;
  7214. this._weights = weights;
  7215. // Normalize the weights
  7216. var weightSum = 0;
  7217. for (var _i = 0, weights_1 = weights; _i < weights_1.length; _i++) {
  7218. var weight = weights_1[_i];
  7219. weightSum += weight;
  7220. }
  7221. var invWeightSum = weightSum > 0 ? 1 / weightSum : 0;
  7222. for (var i = 0; i < this._weights.length; i++) {
  7223. this._weights[i] *= invWeightSum;
  7224. }
  7225. this._sounds = sounds;
  7226. for (var _a = 0, _b = this._sounds; _a < _b.length; _a++) {
  7227. var sound = _b[_a];
  7228. sound.onEndedObservable.add(function () { _this._onended(); });
  7229. }
  7230. }
  7231. Object.defineProperty(WeightedSound.prototype, "directionalConeInnerAngle", {
  7232. /**
  7233. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  7234. */
  7235. get: function () {
  7236. return this._coneInnerAngle;
  7237. },
  7238. /**
  7239. * The size of cone in degress for a directional sound in which there will be no attenuation.
  7240. */
  7241. set: function (value) {
  7242. if (value !== this._coneInnerAngle) {
  7243. if (this._coneOuterAngle < value) {
  7244. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7245. return;
  7246. }
  7247. this._coneInnerAngle = value;
  7248. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7249. var sound = _a[_i];
  7250. sound.directionalConeInnerAngle = value;
  7251. }
  7252. }
  7253. },
  7254. enumerable: true,
  7255. configurable: true
  7256. });
  7257. Object.defineProperty(WeightedSound.prototype, "directionalConeOuterAngle", {
  7258. /**
  7259. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7260. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7261. */
  7262. get: function () {
  7263. return this._coneOuterAngle;
  7264. },
  7265. /**
  7266. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7267. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7268. */
  7269. set: function (value) {
  7270. if (value !== this._coneOuterAngle) {
  7271. if (value < this._coneInnerAngle) {
  7272. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7273. return;
  7274. }
  7275. this._coneOuterAngle = value;
  7276. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7277. var sound = _a[_i];
  7278. sound.directionalConeOuterAngle = value;
  7279. }
  7280. }
  7281. },
  7282. enumerable: true,
  7283. configurable: true
  7284. });
  7285. Object.defineProperty(WeightedSound.prototype, "volume", {
  7286. /**
  7287. * Playback volume.
  7288. */
  7289. get: function () {
  7290. return this._volume;
  7291. },
  7292. /**
  7293. * Playback volume.
  7294. */
  7295. set: function (value) {
  7296. if (value !== this._volume) {
  7297. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7298. var sound = _a[_i];
  7299. sound.setVolume(value);
  7300. }
  7301. }
  7302. },
  7303. enumerable: true,
  7304. configurable: true
  7305. });
  7306. WeightedSound.prototype._onended = function () {
  7307. if (this._currentIndex !== undefined) {
  7308. this._sounds[this._currentIndex].autoplay = false;
  7309. }
  7310. if (this.loop && this.isPlaying) {
  7311. this.play();
  7312. }
  7313. else {
  7314. this.isPlaying = false;
  7315. }
  7316. };
  7317. /**
  7318. * Suspend playback
  7319. */
  7320. WeightedSound.prototype.pause = function () {
  7321. this.isPaused = true;
  7322. if (this._currentIndex !== undefined) {
  7323. this._sounds[this._currentIndex].pause();
  7324. }
  7325. };
  7326. /**
  7327. * Stop playback
  7328. */
  7329. WeightedSound.prototype.stop = function () {
  7330. this.isPlaying = false;
  7331. if (this._currentIndex !== undefined) {
  7332. this._sounds[this._currentIndex].stop();
  7333. }
  7334. };
  7335. /**
  7336. * Start playback.
  7337. * @param startOffset Position the clip head at a specific time in seconds.
  7338. */
  7339. WeightedSound.prototype.play = function (startOffset) {
  7340. if (!this.isPaused) {
  7341. this.stop();
  7342. var randomValue = Math.random();
  7343. var total = 0;
  7344. for (var i = 0; i < this._weights.length; i++) {
  7345. total += this._weights[i];
  7346. if (randomValue <= total) {
  7347. this._currentIndex = i;
  7348. break;
  7349. }
  7350. }
  7351. }
  7352. var sound = this._sounds[this._currentIndex];
  7353. if (sound.isReady()) {
  7354. sound.play(0, this.isPaused ? undefined : startOffset);
  7355. }
  7356. else {
  7357. sound.autoplay = true;
  7358. }
  7359. this.isPlaying = true;
  7360. this.isPaused = false;
  7361. };
  7362. return WeightedSound;
  7363. }());
  7364. /***/ }),
  7365. /***/ "./Behaviors/Cameras/autoRotationBehavior.ts":
  7366. /*!***************************************************!*\
  7367. !*** ./Behaviors/Cameras/autoRotationBehavior.ts ***!
  7368. \***************************************************/
  7369. /*! exports provided: AutoRotationBehavior */
  7370. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7371. "use strict";
  7372. __webpack_require__.r(__webpack_exports__);
  7373. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return AutoRotationBehavior; });
  7374. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  7375. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  7376. /**
  7377. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  7378. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7379. */
  7380. var AutoRotationBehavior = /** @class */ (function () {
  7381. function AutoRotationBehavior() {
  7382. this._zoomStopsAnimation = false;
  7383. this._idleRotationSpeed = 0.05;
  7384. this._idleRotationWaitTime = 2000;
  7385. this._idleRotationSpinupTime = 2000;
  7386. this._isPointerDown = false;
  7387. this._lastFrameTime = null;
  7388. this._lastInteractionTime = -Infinity;
  7389. this._cameraRotationSpeed = 0;
  7390. this._lastFrameRadius = 0;
  7391. }
  7392. Object.defineProperty(AutoRotationBehavior.prototype, "name", {
  7393. /**
  7394. * Gets the name of the behavior.
  7395. */
  7396. get: function () {
  7397. return "AutoRotation";
  7398. },
  7399. enumerable: true,
  7400. configurable: true
  7401. });
  7402. Object.defineProperty(AutoRotationBehavior.prototype, "zoomStopsAnimation", {
  7403. /**
  7404. * Gets the flag that indicates if user zooming should stop animation.
  7405. */
  7406. get: function () {
  7407. return this._zoomStopsAnimation;
  7408. },
  7409. /**
  7410. * Sets the flag that indicates if user zooming should stop animation.
  7411. */
  7412. set: function (flag) {
  7413. this._zoomStopsAnimation = flag;
  7414. },
  7415. enumerable: true,
  7416. configurable: true
  7417. });
  7418. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpeed", {
  7419. /**
  7420. * Gets the default speed at which the camera rotates around the model.
  7421. */
  7422. get: function () {
  7423. return this._idleRotationSpeed;
  7424. },
  7425. /**
  7426. * Sets the default speed at which the camera rotates around the model.
  7427. */
  7428. set: function (speed) {
  7429. this._idleRotationSpeed = speed;
  7430. },
  7431. enumerable: true,
  7432. configurable: true
  7433. });
  7434. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationWaitTime", {
  7435. /**
  7436. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  7437. */
  7438. get: function () {
  7439. return this._idleRotationWaitTime;
  7440. },
  7441. /**
  7442. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  7443. */
  7444. set: function (time) {
  7445. this._idleRotationWaitTime = time;
  7446. },
  7447. enumerable: true,
  7448. configurable: true
  7449. });
  7450. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpinupTime", {
  7451. /**
  7452. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7453. */
  7454. get: function () {
  7455. return this._idleRotationSpinupTime;
  7456. },
  7457. /**
  7458. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7459. */
  7460. set: function (time) {
  7461. this._idleRotationSpinupTime = time;
  7462. },
  7463. enumerable: true,
  7464. configurable: true
  7465. });
  7466. Object.defineProperty(AutoRotationBehavior.prototype, "rotationInProgress", {
  7467. /**
  7468. * Gets a value indicating if the camera is currently rotating because of this behavior
  7469. */
  7470. get: function () {
  7471. return Math.abs(this._cameraRotationSpeed) > 0;
  7472. },
  7473. enumerable: true,
  7474. configurable: true
  7475. });
  7476. /**
  7477. * Initializes the behavior.
  7478. */
  7479. AutoRotationBehavior.prototype.init = function () {
  7480. // Do notihng
  7481. };
  7482. /**
  7483. * Attaches the behavior to its arc rotate camera.
  7484. * @param camera Defines the camera to attach the behavior to
  7485. */
  7486. AutoRotationBehavior.prototype.attach = function (camera) {
  7487. var _this = this;
  7488. this._attachedCamera = camera;
  7489. var scene = this._attachedCamera.getScene();
  7490. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  7491. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  7492. _this._isPointerDown = true;
  7493. return;
  7494. }
  7495. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  7496. _this._isPointerDown = false;
  7497. }
  7498. });
  7499. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7500. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7501. var dt = 0;
  7502. if (_this._lastFrameTime != null) {
  7503. dt = now - _this._lastFrameTime;
  7504. }
  7505. _this._lastFrameTime = now;
  7506. // Stop the animation if there is user interaction and the animation should stop for this interaction
  7507. _this._applyUserInteraction();
  7508. var timeToRotation = now - _this._lastInteractionTime - _this._idleRotationWaitTime;
  7509. var scale = Math.max(Math.min(timeToRotation / (_this._idleRotationSpinupTime), 1), 0);
  7510. _this._cameraRotationSpeed = _this._idleRotationSpeed * scale;
  7511. // Step camera rotation by rotation speed
  7512. if (_this._attachedCamera) {
  7513. _this._attachedCamera.alpha -= _this._cameraRotationSpeed * (dt / 1000);
  7514. }
  7515. });
  7516. };
  7517. /**
  7518. * Detaches the behavior from its current arc rotate camera.
  7519. */
  7520. AutoRotationBehavior.prototype.detach = function () {
  7521. if (!this._attachedCamera) {
  7522. return;
  7523. }
  7524. var scene = this._attachedCamera.getScene();
  7525. if (this._onPrePointerObservableObserver) {
  7526. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  7527. }
  7528. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  7529. this._attachedCamera = null;
  7530. };
  7531. /**
  7532. * Returns true if user is scrolling.
  7533. * @return true if user is scrolling.
  7534. */
  7535. AutoRotationBehavior.prototype._userIsZooming = function () {
  7536. if (!this._attachedCamera) {
  7537. return false;
  7538. }
  7539. return this._attachedCamera.inertialRadiusOffset !== 0;
  7540. };
  7541. AutoRotationBehavior.prototype._shouldAnimationStopForInteraction = function () {
  7542. if (!this._attachedCamera) {
  7543. return false;
  7544. }
  7545. var zoomHasHitLimit = false;
  7546. if (this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0) {
  7547. zoomHasHitLimit = true;
  7548. }
  7549. // Update the record of previous radius - works as an approx. indicator of hitting radius limits
  7550. this._lastFrameRadius = this._attachedCamera.radius;
  7551. return this._zoomStopsAnimation ? zoomHasHitLimit : this._userIsZooming();
  7552. };
  7553. /**
  7554. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  7555. */
  7556. AutoRotationBehavior.prototype._applyUserInteraction = function () {
  7557. if (this._userIsMoving() && !this._shouldAnimationStopForInteraction()) {
  7558. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7559. }
  7560. };
  7561. // Tools
  7562. AutoRotationBehavior.prototype._userIsMoving = function () {
  7563. if (!this._attachedCamera) {
  7564. return false;
  7565. }
  7566. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  7567. this._attachedCamera.inertialBetaOffset !== 0 ||
  7568. this._attachedCamera.inertialRadiusOffset !== 0 ||
  7569. this._attachedCamera.inertialPanningX !== 0 ||
  7570. this._attachedCamera.inertialPanningY !== 0 ||
  7571. this._isPointerDown;
  7572. };
  7573. return AutoRotationBehavior;
  7574. }());
  7575. /***/ }),
  7576. /***/ "./Behaviors/Cameras/bouncingBehavior.ts":
  7577. /*!***********************************************!*\
  7578. !*** ./Behaviors/Cameras/bouncingBehavior.ts ***!
  7579. \***********************************************/
  7580. /*! exports provided: BouncingBehavior */
  7581. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7582. "use strict";
  7583. __webpack_require__.r(__webpack_exports__);
  7584. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return BouncingBehavior; });
  7585. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  7586. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  7587. /**
  7588. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  7589. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7590. */
  7591. var BouncingBehavior = /** @class */ (function () {
  7592. function BouncingBehavior() {
  7593. /**
  7594. * The duration of the animation, in milliseconds
  7595. */
  7596. this.transitionDuration = 450;
  7597. /**
  7598. * Length of the distance animated by the transition when lower radius is reached
  7599. */
  7600. this.lowerRadiusTransitionRange = 2;
  7601. /**
  7602. * Length of the distance animated by the transition when upper radius is reached
  7603. */
  7604. this.upperRadiusTransitionRange = -2;
  7605. this._autoTransitionRange = false;
  7606. // Animations
  7607. this._radiusIsAnimating = false;
  7608. this._radiusBounceTransition = null;
  7609. this._animatables = new Array();
  7610. }
  7611. Object.defineProperty(BouncingBehavior.prototype, "name", {
  7612. /**
  7613. * Gets the name of the behavior.
  7614. */
  7615. get: function () {
  7616. return "Bouncing";
  7617. },
  7618. enumerable: true,
  7619. configurable: true
  7620. });
  7621. Object.defineProperty(BouncingBehavior.prototype, "autoTransitionRange", {
  7622. /**
  7623. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7624. */
  7625. get: function () {
  7626. return this._autoTransitionRange;
  7627. },
  7628. /**
  7629. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7630. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  7631. */
  7632. set: function (value) {
  7633. var _this = this;
  7634. if (this._autoTransitionRange === value) {
  7635. return;
  7636. }
  7637. this._autoTransitionRange = value;
  7638. var camera = this._attachedCamera;
  7639. if (!camera) {
  7640. return;
  7641. }
  7642. if (value) {
  7643. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  7644. if (!mesh) {
  7645. return;
  7646. }
  7647. mesh.computeWorldMatrix(true);
  7648. var diagonal = mesh.getBoundingInfo().diagonalLength;
  7649. _this.lowerRadiusTransitionRange = diagonal * 0.05;
  7650. _this.upperRadiusTransitionRange = diagonal * 0.05;
  7651. });
  7652. }
  7653. else if (this._onMeshTargetChangedObserver) {
  7654. camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  7655. }
  7656. },
  7657. enumerable: true,
  7658. configurable: true
  7659. });
  7660. /**
  7661. * Initializes the behavior.
  7662. */
  7663. BouncingBehavior.prototype.init = function () {
  7664. // Do notihng
  7665. };
  7666. /**
  7667. * Attaches the behavior to its arc rotate camera.
  7668. * @param camera Defines the camera to attach the behavior to
  7669. */
  7670. BouncingBehavior.prototype.attach = function (camera) {
  7671. var _this = this;
  7672. this._attachedCamera = camera;
  7673. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7674. if (!_this._attachedCamera) {
  7675. return;
  7676. }
  7677. // Add the bounce animation to the lower radius limit
  7678. if (_this._isRadiusAtLimit(_this._attachedCamera.lowerRadiusLimit)) {
  7679. _this._applyBoundRadiusAnimation(_this.lowerRadiusTransitionRange);
  7680. }
  7681. // Add the bounce animation to the upper radius limit
  7682. if (_this._isRadiusAtLimit(_this._attachedCamera.upperRadiusLimit)) {
  7683. _this._applyBoundRadiusAnimation(_this.upperRadiusTransitionRange);
  7684. }
  7685. });
  7686. };
  7687. /**
  7688. * Detaches the behavior from its current arc rotate camera.
  7689. */
  7690. BouncingBehavior.prototype.detach = function () {
  7691. if (!this._attachedCamera) {
  7692. return;
  7693. }
  7694. if (this._onAfterCheckInputsObserver) {
  7695. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  7696. }
  7697. if (this._onMeshTargetChangedObserver) {
  7698. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  7699. }
  7700. this._attachedCamera = null;
  7701. };
  7702. /**
  7703. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  7704. * @param radiusLimit The limit to check against.
  7705. * @return Bool to indicate if at limit.
  7706. */
  7707. BouncingBehavior.prototype._isRadiusAtLimit = function (radiusLimit) {
  7708. if (!this._attachedCamera) {
  7709. return false;
  7710. }
  7711. if (this._attachedCamera.radius === radiusLimit && !this._radiusIsAnimating) {
  7712. return true;
  7713. }
  7714. return false;
  7715. };
  7716. /**
  7717. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  7718. * @param radiusDelta The delta by which to animate to. Can be negative.
  7719. */
  7720. BouncingBehavior.prototype._applyBoundRadiusAnimation = function (radiusDelta) {
  7721. var _this = this;
  7722. if (!this._attachedCamera) {
  7723. return;
  7724. }
  7725. if (!this._radiusBounceTransition) {
  7726. BouncingBehavior.EasingFunction.setEasingMode(BouncingBehavior.EasingMode);
  7727. this._radiusBounceTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT, 60, BouncingBehavior.EasingFunction);
  7728. }
  7729. // Prevent zoom until bounce has completed
  7730. this._cachedWheelPrecision = this._attachedCamera.wheelPrecision;
  7731. this._attachedCamera.wheelPrecision = Infinity;
  7732. this._attachedCamera.inertialRadiusOffset = 0;
  7733. // Animate to the radius limit
  7734. this.stopAllAnimations();
  7735. this._radiusIsAnimating = true;
  7736. 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(); });
  7737. if (animatable) {
  7738. this._animatables.push(animatable);
  7739. }
  7740. };
  7741. /**
  7742. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  7743. */
  7744. BouncingBehavior.prototype._clearAnimationLocks = function () {
  7745. this._radiusIsAnimating = false;
  7746. if (this._attachedCamera) {
  7747. this._attachedCamera.wheelPrecision = this._cachedWheelPrecision;
  7748. }
  7749. };
  7750. /**
  7751. * Stops and removes all animations that have been applied to the camera
  7752. */
  7753. BouncingBehavior.prototype.stopAllAnimations = function () {
  7754. if (this._attachedCamera) {
  7755. this._attachedCamera.animations = [];
  7756. }
  7757. while (this._animatables.length) {
  7758. this._animatables[0].onAnimationEnd = null;
  7759. this._animatables[0].stop();
  7760. this._animatables.shift();
  7761. }
  7762. };
  7763. /**
  7764. * The easing function used by animations
  7765. */
  7766. BouncingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["BackEase"](0.3);
  7767. /**
  7768. * The easing mode used by animations
  7769. */
  7770. BouncingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEOUT;
  7771. return BouncingBehavior;
  7772. }());
  7773. /***/ }),
  7774. /***/ "./Behaviors/Cameras/framingBehavior.ts":
  7775. /*!**********************************************!*\
  7776. !*** ./Behaviors/Cameras/framingBehavior.ts ***!
  7777. \**********************************************/
  7778. /*! exports provided: FramingBehavior */
  7779. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7780. "use strict";
  7781. __webpack_require__.r(__webpack_exports__);
  7782. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return FramingBehavior; });
  7783. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  7784. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  7785. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  7786. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  7787. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  7788. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  7789. /**
  7790. * 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.
  7791. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7792. */
  7793. var FramingBehavior = /** @class */ (function () {
  7794. function FramingBehavior() {
  7795. this._mode = FramingBehavior.FitFrustumSidesMode;
  7796. this._radiusScale = 1.0;
  7797. this._positionScale = 0.5;
  7798. this._defaultElevation = 0.3;
  7799. this._elevationReturnTime = 1500;
  7800. this._elevationReturnWaitTime = 1000;
  7801. this._zoomStopsAnimation = false;
  7802. this._framingTime = 1500;
  7803. /**
  7804. * Define if the behavior should automatically change the configured
  7805. * camera limits and sensibilities.
  7806. */
  7807. this.autoCorrectCameraLimitsAndSensibility = true;
  7808. this._isPointerDown = false;
  7809. this._lastInteractionTime = -Infinity;
  7810. // Framing control
  7811. this._animatables = new Array();
  7812. this._betaIsAnimating = false;
  7813. }
  7814. Object.defineProperty(FramingBehavior.prototype, "name", {
  7815. /**
  7816. * Gets the name of the behavior.
  7817. */
  7818. get: function () {
  7819. return "Framing";
  7820. },
  7821. enumerable: true,
  7822. configurable: true
  7823. });
  7824. Object.defineProperty(FramingBehavior.prototype, "mode", {
  7825. /**
  7826. * Gets current mode used by the behavior.
  7827. */
  7828. get: function () {
  7829. return this._mode;
  7830. },
  7831. /**
  7832. * Sets the current mode used by the behavior
  7833. */
  7834. set: function (mode) {
  7835. this._mode = mode;
  7836. },
  7837. enumerable: true,
  7838. configurable: true
  7839. });
  7840. Object.defineProperty(FramingBehavior.prototype, "radiusScale", {
  7841. /**
  7842. * Gets the scale applied to the radius
  7843. */
  7844. get: function () {
  7845. return this._radiusScale;
  7846. },
  7847. /**
  7848. * Sets the scale applied to the radius (1 by default)
  7849. */
  7850. set: function (radius) {
  7851. this._radiusScale = radius;
  7852. },
  7853. enumerable: true,
  7854. configurable: true
  7855. });
  7856. Object.defineProperty(FramingBehavior.prototype, "positionScale", {
  7857. /**
  7858. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  7859. */
  7860. get: function () {
  7861. return this._positionScale;
  7862. },
  7863. /**
  7864. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  7865. */
  7866. set: function (scale) {
  7867. this._positionScale = scale;
  7868. },
  7869. enumerable: true,
  7870. configurable: true
  7871. });
  7872. Object.defineProperty(FramingBehavior.prototype, "defaultElevation", {
  7873. /**
  7874. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  7875. * behaviour is triggered, in radians.
  7876. */
  7877. get: function () {
  7878. return this._defaultElevation;
  7879. },
  7880. /**
  7881. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  7882. * behaviour is triggered, in radians.
  7883. */
  7884. set: function (elevation) {
  7885. this._defaultElevation = elevation;
  7886. },
  7887. enumerable: true,
  7888. configurable: true
  7889. });
  7890. Object.defineProperty(FramingBehavior.prototype, "elevationReturnTime", {
  7891. /**
  7892. * Gets the time (in milliseconds) taken to return to the default beta position.
  7893. * Negative value indicates camera should not return to default.
  7894. */
  7895. get: function () {
  7896. return this._elevationReturnTime;
  7897. },
  7898. /**
  7899. * Sets the time (in milliseconds) taken to return to the default beta position.
  7900. * Negative value indicates camera should not return to default.
  7901. */
  7902. set: function (speed) {
  7903. this._elevationReturnTime = speed;
  7904. },
  7905. enumerable: true,
  7906. configurable: true
  7907. });
  7908. Object.defineProperty(FramingBehavior.prototype, "elevationReturnWaitTime", {
  7909. /**
  7910. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  7911. */
  7912. get: function () {
  7913. return this._elevationReturnWaitTime;
  7914. },
  7915. /**
  7916. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  7917. */
  7918. set: function (time) {
  7919. this._elevationReturnWaitTime = time;
  7920. },
  7921. enumerable: true,
  7922. configurable: true
  7923. });
  7924. Object.defineProperty(FramingBehavior.prototype, "zoomStopsAnimation", {
  7925. /**
  7926. * Gets the flag that indicates if user zooming should stop animation.
  7927. */
  7928. get: function () {
  7929. return this._zoomStopsAnimation;
  7930. },
  7931. /**
  7932. * Sets the flag that indicates if user zooming should stop animation.
  7933. */
  7934. set: function (flag) {
  7935. this._zoomStopsAnimation = flag;
  7936. },
  7937. enumerable: true,
  7938. configurable: true
  7939. });
  7940. Object.defineProperty(FramingBehavior.prototype, "framingTime", {
  7941. /**
  7942. * Gets the transition time when framing the mesh, in milliseconds
  7943. */
  7944. get: function () {
  7945. return this._framingTime;
  7946. },
  7947. /**
  7948. * Sets the transition time when framing the mesh, in milliseconds
  7949. */
  7950. set: function (time) {
  7951. this._framingTime = time;
  7952. },
  7953. enumerable: true,
  7954. configurable: true
  7955. });
  7956. /**
  7957. * Initializes the behavior.
  7958. */
  7959. FramingBehavior.prototype.init = function () {
  7960. // Do notihng
  7961. };
  7962. /**
  7963. * Attaches the behavior to its arc rotate camera.
  7964. * @param camera Defines the camera to attach the behavior to
  7965. */
  7966. FramingBehavior.prototype.attach = function (camera) {
  7967. var _this = this;
  7968. this._attachedCamera = camera;
  7969. var scene = this._attachedCamera.getScene();
  7970. FramingBehavior.EasingFunction.setEasingMode(FramingBehavior.EasingMode);
  7971. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  7972. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  7973. _this._isPointerDown = true;
  7974. return;
  7975. }
  7976. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  7977. _this._isPointerDown = false;
  7978. }
  7979. });
  7980. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  7981. if (mesh) {
  7982. _this.zoomOnMesh(mesh);
  7983. }
  7984. });
  7985. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7986. // Stop the animation if there is user interaction and the animation should stop for this interaction
  7987. _this._applyUserInteraction();
  7988. // Maintain the camera above the ground. If the user pulls the camera beneath the ground plane, lift it
  7989. // back to the default position after a given timeout
  7990. _this._maintainCameraAboveGround();
  7991. });
  7992. };
  7993. /**
  7994. * Detaches the behavior from its current arc rotate camera.
  7995. */
  7996. FramingBehavior.prototype.detach = function () {
  7997. if (!this._attachedCamera) {
  7998. return;
  7999. }
  8000. var scene = this._attachedCamera.getScene();
  8001. if (this._onPrePointerObservableObserver) {
  8002. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  8003. }
  8004. if (this._onAfterCheckInputsObserver) {
  8005. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8006. }
  8007. if (this._onMeshTargetChangedObserver) {
  8008. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8009. }
  8010. this._attachedCamera = null;
  8011. };
  8012. /**
  8013. * Targets the given mesh and updates zoom level accordingly.
  8014. * @param mesh The mesh to target.
  8015. * @param radius Optional. If a cached radius position already exists, overrides default.
  8016. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8017. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8018. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8019. */
  8020. FramingBehavior.prototype.zoomOnMesh = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8021. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8022. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8023. mesh.computeWorldMatrix(true);
  8024. var boundingBox = mesh.getBoundingInfo().boundingBox;
  8025. this.zoomOnBoundingInfo(boundingBox.minimumWorld, boundingBox.maximumWorld, focusOnOriginXZ, onAnimationEnd);
  8026. };
  8027. /**
  8028. * Targets the given mesh with its children and updates zoom level accordingly.
  8029. * @param mesh The mesh to target.
  8030. * @param radius Optional. If a cached radius position already exists, overrides default.
  8031. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8032. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8033. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8034. */
  8035. FramingBehavior.prototype.zoomOnMeshHierarchy = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8036. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8037. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8038. mesh.computeWorldMatrix(true);
  8039. var boundingBox = mesh.getHierarchyBoundingVectors(true);
  8040. this.zoomOnBoundingInfo(boundingBox.min, boundingBox.max, focusOnOriginXZ, onAnimationEnd);
  8041. };
  8042. /**
  8043. * Targets the given meshes with their children and updates zoom level accordingly.
  8044. * @param meshes The mesh to target.
  8045. * @param radius Optional. If a cached radius position already exists, overrides default.
  8046. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8047. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8048. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8049. */
  8050. FramingBehavior.prototype.zoomOnMeshesHierarchy = function (meshes, focusOnOriginXZ, onAnimationEnd) {
  8051. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8052. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8053. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  8054. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  8055. for (var i = 0; i < meshes.length; i++) {
  8056. var boundingInfo = meshes[i].getHierarchyBoundingVectors(true);
  8057. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.min, min, max);
  8058. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.max, min, max);
  8059. }
  8060. this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);
  8061. };
  8062. /**
  8063. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  8064. * @param minimumWorld Determines the smaller position of the bounding box extend
  8065. * @param maximumWorld Determines the bigger position of the bounding box extend
  8066. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8067. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8068. */
  8069. FramingBehavior.prototype.zoomOnBoundingInfo = function (minimumWorld, maximumWorld, focusOnOriginXZ, onAnimationEnd) {
  8070. var _this = this;
  8071. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8072. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8073. var zoomTarget;
  8074. if (!this._attachedCamera) {
  8075. return;
  8076. }
  8077. // Find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
  8078. var bottom = minimumWorld.y;
  8079. var top = maximumWorld.y;
  8080. var zoomTargetY = bottom + (top - bottom) * this._positionScale;
  8081. var radiusWorld = maximumWorld.subtract(minimumWorld).scale(0.5);
  8082. if (focusOnOriginXZ) {
  8083. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, zoomTargetY, 0);
  8084. }
  8085. else {
  8086. var centerWorld = minimumWorld.add(radiusWorld);
  8087. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](centerWorld.x, zoomTargetY, centerWorld.z);
  8088. }
  8089. if (!this._vectorTransition) {
  8090. this._vectorTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("target", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
  8091. }
  8092. this._betaIsAnimating = true;
  8093. var animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
  8094. if (animatable) {
  8095. this._animatables.push(animatable);
  8096. }
  8097. // sets the radius and lower radius bounds
  8098. // Small delta ensures camera is not always at lower zoom limit.
  8099. var radius = 0;
  8100. if (this._mode === FramingBehavior.FitFrustumSidesMode) {
  8101. var position = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8102. if (this.autoCorrectCameraLimitsAndSensibility) {
  8103. this._attachedCamera.lowerRadiusLimit = radiusWorld.length() + this._attachedCamera.minZ;
  8104. }
  8105. radius = position;
  8106. }
  8107. else if (this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8108. radius = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8109. if (this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null) {
  8110. this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ;
  8111. }
  8112. }
  8113. // Set sensibilities
  8114. if (this.autoCorrectCameraLimitsAndSensibility) {
  8115. var extend = maximumWorld.subtract(minimumWorld).length();
  8116. this._attachedCamera.panningSensibility = 5000 / extend;
  8117. this._attachedCamera.wheelPrecision = 100 / radius;
  8118. }
  8119. // transition to new radius
  8120. if (!this._radiusTransition) {
  8121. this._radiusTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8122. }
  8123. animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
  8124. _this.stopAllAnimations();
  8125. if (onAnimationEnd) {
  8126. onAnimationEnd();
  8127. }
  8128. if (_this._attachedCamera && _this._attachedCamera.useInputToRestoreState) {
  8129. _this._attachedCamera.storeState();
  8130. }
  8131. });
  8132. if (animatable) {
  8133. this._animatables.push(animatable);
  8134. }
  8135. };
  8136. /**
  8137. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  8138. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  8139. * frustum width.
  8140. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  8141. * to fully enclose the mesh in the viewing frustum.
  8142. */
  8143. FramingBehavior.prototype._calculateLowerRadiusFromModelBoundingSphere = function (minimumWorld, maximumWorld) {
  8144. var size = maximumWorld.subtract(minimumWorld);
  8145. var boxVectorGlobalDiagonal = size.length();
  8146. var frustumSlope = this._getFrustumSlope();
  8147. // Formula for setting distance
  8148. // (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
  8149. var radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
  8150. // Horizon distance
  8151. var radius = radiusWithoutFraming * this._radiusScale;
  8152. var distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
  8153. var distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
  8154. var distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
  8155. var camera = this._attachedCamera;
  8156. if (!camera) {
  8157. return 0;
  8158. }
  8159. if (camera.lowerRadiusLimit && this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8160. // Don't exceed the requested limit
  8161. distance = distance < camera.lowerRadiusLimit ? camera.lowerRadiusLimit : distance;
  8162. }
  8163. // Don't exceed the upper radius limit
  8164. if (camera.upperRadiusLimit) {
  8165. distance = distance > camera.upperRadiusLimit ? camera.upperRadiusLimit : distance;
  8166. }
  8167. return distance;
  8168. };
  8169. /**
  8170. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  8171. * is automatically returned to its default position (expected to be above ground plane).
  8172. */
  8173. FramingBehavior.prototype._maintainCameraAboveGround = function () {
  8174. var _this = this;
  8175. if (this._elevationReturnTime < 0) {
  8176. return;
  8177. }
  8178. var timeSinceInteraction = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now - this._lastInteractionTime;
  8179. var defaultBeta = Math.PI * 0.5 - this._defaultElevation;
  8180. var limitBeta = Math.PI * 0.5;
  8181. // Bring the camera back up if below the ground plane
  8182. if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {
  8183. this._betaIsAnimating = true;
  8184. //Transition to new position
  8185. this.stopAllAnimations();
  8186. if (!this._betaTransition) {
  8187. this._betaTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("beta", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8188. }
  8189. var animatabe = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("beta", defaultBeta, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function () {
  8190. _this._clearAnimationLocks();
  8191. _this.stopAllAnimations();
  8192. });
  8193. if (animatabe) {
  8194. this._animatables.push(animatabe);
  8195. }
  8196. }
  8197. };
  8198. /**
  8199. * Returns the frustum slope based on the canvas ratio and camera FOV
  8200. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  8201. */
  8202. FramingBehavior.prototype._getFrustumSlope = function () {
  8203. // Calculate the viewport ratio
  8204. // Aspect Ratio is Height/Width.
  8205. var camera = this._attachedCamera;
  8206. if (!camera) {
  8207. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"].Zero();
  8208. }
  8209. var engine = camera.getScene().getEngine();
  8210. var aspectRatio = engine.getAspectRatio(camera);
  8211. // Camera FOV is the vertical field of view (top-bottom) in radians.
  8212. // Slope of the frustum top/bottom planes in view space, relative to the forward vector.
  8213. var frustumSlopeY = Math.tan(camera.fov / 2);
  8214. // Slope of the frustum left/right planes in view space, relative to the forward vector.
  8215. // Provides the amount that one side (e.g. left) of the frustum gets wider for every unit
  8216. // along the forward vector.
  8217. var frustumSlopeX = frustumSlopeY * aspectRatio;
  8218. return new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](frustumSlopeX, frustumSlopeY);
  8219. };
  8220. /**
  8221. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  8222. */
  8223. FramingBehavior.prototype._clearAnimationLocks = function () {
  8224. this._betaIsAnimating = false;
  8225. };
  8226. /**
  8227. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  8228. */
  8229. FramingBehavior.prototype._applyUserInteraction = function () {
  8230. if (this.isUserIsMoving) {
  8231. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now;
  8232. this.stopAllAnimations();
  8233. this._clearAnimationLocks();
  8234. }
  8235. };
  8236. /**
  8237. * Stops and removes all animations that have been applied to the camera
  8238. */
  8239. FramingBehavior.prototype.stopAllAnimations = function () {
  8240. if (this._attachedCamera) {
  8241. this._attachedCamera.animations = [];
  8242. }
  8243. while (this._animatables.length) {
  8244. if (this._animatables[0]) {
  8245. this._animatables[0].onAnimationEnd = null;
  8246. this._animatables[0].stop();
  8247. }
  8248. this._animatables.shift();
  8249. }
  8250. };
  8251. Object.defineProperty(FramingBehavior.prototype, "isUserIsMoving", {
  8252. /**
  8253. * Gets a value indicating if the user is moving the camera
  8254. */
  8255. get: function () {
  8256. if (!this._attachedCamera) {
  8257. return false;
  8258. }
  8259. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  8260. this._attachedCamera.inertialBetaOffset !== 0 ||
  8261. this._attachedCamera.inertialRadiusOffset !== 0 ||
  8262. this._attachedCamera.inertialPanningX !== 0 ||
  8263. this._attachedCamera.inertialPanningY !== 0 ||
  8264. this._isPointerDown;
  8265. },
  8266. enumerable: true,
  8267. configurable: true
  8268. });
  8269. /**
  8270. * The easing function used by animations
  8271. */
  8272. FramingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]();
  8273. /**
  8274. * The easing mode used by animations
  8275. */
  8276. FramingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEINOUT;
  8277. // Statics
  8278. /**
  8279. * The camera can move all the way towards the mesh.
  8280. */
  8281. FramingBehavior.IgnoreBoundsSizeMode = 0;
  8282. /**
  8283. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  8284. */
  8285. FramingBehavior.FitFrustumSidesMode = 1;
  8286. return FramingBehavior;
  8287. }());
  8288. /***/ }),
  8289. /***/ "./Behaviors/Cameras/index.ts":
  8290. /*!************************************!*\
  8291. !*** ./Behaviors/Cameras/index.ts ***!
  8292. \************************************/
  8293. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior */
  8294. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8295. "use strict";
  8296. __webpack_require__.r(__webpack_exports__);
  8297. /* harmony import */ var _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  8298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  8299. /* harmony import */ var _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  8300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__["BouncingBehavior"]; });
  8301. /* harmony import */ var _framingBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  8302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _framingBehavior__WEBPACK_IMPORTED_MODULE_2__["FramingBehavior"]; });
  8303. /***/ }),
  8304. /***/ "./Behaviors/Meshes/attachToBoxBehavior.ts":
  8305. /*!*************************************************!*\
  8306. !*** ./Behaviors/Meshes/attachToBoxBehavior.ts ***!
  8307. \*************************************************/
  8308. /*! exports provided: AttachToBoxBehavior */
  8309. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8310. "use strict";
  8311. __webpack_require__.r(__webpack_exports__);
  8312. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return AttachToBoxBehavior; });
  8313. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8314. /**
  8315. * @hidden
  8316. */
  8317. var FaceDirectionInfo = /** @class */ (function () {
  8318. function FaceDirectionInfo(direction, rotatedDirection, diff, ignore) {
  8319. if (rotatedDirection === void 0) { rotatedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](); }
  8320. if (diff === void 0) { diff = 0; }
  8321. if (ignore === void 0) { ignore = false; }
  8322. this.direction = direction;
  8323. this.rotatedDirection = rotatedDirection;
  8324. this.diff = diff;
  8325. this.ignore = ignore;
  8326. }
  8327. return FaceDirectionInfo;
  8328. }());
  8329. /**
  8330. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  8331. */
  8332. var AttachToBoxBehavior = /** @class */ (function () {
  8333. /**
  8334. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  8335. * @param ui The transform node that should be attched to the mesh
  8336. */
  8337. function AttachToBoxBehavior(ui) {
  8338. this.ui = ui;
  8339. /**
  8340. * The name of the behavior
  8341. */
  8342. this.name = "AttachToBoxBehavior";
  8343. /**
  8344. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  8345. */
  8346. this.distanceAwayFromFace = 0.15;
  8347. /**
  8348. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  8349. */
  8350. this.distanceAwayFromBottomOfFace = 0.15;
  8351. 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))];
  8352. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8353. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  8354. this._zeroVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  8355. this._lookAtTmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8356. /* Does nothing */
  8357. }
  8358. /**
  8359. * Initializes the behavior
  8360. */
  8361. AttachToBoxBehavior.prototype.init = function () {
  8362. /* Does nothing */
  8363. };
  8364. AttachToBoxBehavior.prototype._closestFace = function (targetDirection) {
  8365. var _this = this;
  8366. // Go over each face and calculate the angle between the face's normal and targetDirection
  8367. this._faceVectors.forEach(function (v) {
  8368. if (!_this._target.rotationQuaternion) {
  8369. _this._target.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this._target.rotation.y, _this._target.rotation.x, _this._target.rotation.z);
  8370. }
  8371. _this._target.rotationQuaternion.toRotationMatrix(_this._tmpMatrix);
  8372. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(v.direction, _this._tmpMatrix, v.rotatedDirection);
  8373. v.diff = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetAngleBetweenVectors(v.rotatedDirection, targetDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v.rotatedDirection, targetDirection));
  8374. });
  8375. // Return the face information of the one with the normal closeset to target direction
  8376. return this._faceVectors.reduce(function (min, p) {
  8377. if (min.ignore) {
  8378. return p;
  8379. }
  8380. else if (p.ignore) {
  8381. return min;
  8382. }
  8383. else {
  8384. return min.diff < p.diff ? min : p;
  8385. }
  8386. }, this._faceVectors[0]);
  8387. };
  8388. AttachToBoxBehavior.prototype._lookAtToRef = function (pos, up, ref) {
  8389. if (up === void 0) { up = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0); }
  8390. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LookAtLHToRef(this._zeroVector, pos, up, this._lookAtTmpMatrix);
  8391. this._lookAtTmpMatrix.invert();
  8392. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._lookAtTmpMatrix, ref);
  8393. };
  8394. /**
  8395. * Attaches the AttachToBoxBehavior to the passed in mesh
  8396. * @param target The mesh that the specified node will be attached to
  8397. */
  8398. AttachToBoxBehavior.prototype.attach = function (target) {
  8399. var _this = this;
  8400. this._target = target;
  8401. this._scene = this._target.getScene();
  8402. // Every frame, update the app bars position
  8403. this._onRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  8404. if (!_this._scene.activeCamera) {
  8405. return;
  8406. }
  8407. // Find the face closest to the cameras position
  8408. var cameraPos = _this._scene.activeCamera.position;
  8409. if (_this._scene.activeCamera.devicePosition) {
  8410. cameraPos = _this._scene.activeCamera.devicePosition;
  8411. }
  8412. var facing = _this._closestFace(cameraPos.subtract(target.position));
  8413. if (_this._scene.activeCamera.leftCamera) {
  8414. _this._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8415. }
  8416. else {
  8417. _this._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8418. }
  8419. // Get camera up direction
  8420. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), _this._tmpMatrix, _this._tmpVector);
  8421. // Ignore faces to not select a parrelel face for the up vector of the UI
  8422. _this._faceVectors.forEach(function (v) {
  8423. if (facing.direction.x && v.direction.x) {
  8424. v.ignore = true;
  8425. }
  8426. if (facing.direction.y && v.direction.y) {
  8427. v.ignore = true;
  8428. }
  8429. if (facing.direction.z && v.direction.z) {
  8430. v.ignore = true;
  8431. }
  8432. });
  8433. var facingUp = _this._closestFace(_this._tmpVector);
  8434. // Unignore faces
  8435. _this._faceVectors.forEach(function (v) {
  8436. v.ignore = false;
  8437. });
  8438. // Position the app bar on that face
  8439. _this.ui.position.copyFrom(target.position);
  8440. if (facing.direction.x) {
  8441. facing.rotatedDirection.scaleToRef((target.scaling.x / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8442. _this.ui.position.addInPlace(_this._tmpVector);
  8443. }
  8444. if (facing.direction.y) {
  8445. facing.rotatedDirection.scaleToRef((target.scaling.y / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8446. _this.ui.position.addInPlace(_this._tmpVector);
  8447. }
  8448. if (facing.direction.z) {
  8449. facing.rotatedDirection.scaleToRef((target.scaling.z / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8450. _this.ui.position.addInPlace(_this._tmpVector);
  8451. }
  8452. // Rotate to be oriented properly to the camera
  8453. if (!_this.ui.rotationQuaternion) {
  8454. _this.ui.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this.ui.rotation.y, _this.ui.rotation.x, _this.ui.rotation.z);
  8455. }
  8456. facing.rotatedDirection.scaleToRef(-1, _this._tmpVector);
  8457. _this._lookAtToRef(_this._tmpVector, facingUp.rotatedDirection, _this.ui.rotationQuaternion);
  8458. // Place ui the correct distance from the bottom of the mesh
  8459. if (facingUp.direction.x) {
  8460. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.x / 2, _this._tmpVector);
  8461. }
  8462. if (facingUp.direction.y) {
  8463. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.y / 2, _this._tmpVector);
  8464. }
  8465. if (facingUp.direction.z) {
  8466. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.z / 2, _this._tmpVector);
  8467. }
  8468. _this.ui.position.addInPlace(_this._tmpVector);
  8469. });
  8470. };
  8471. /**
  8472. * Detaches the behavior from the mesh
  8473. */
  8474. AttachToBoxBehavior.prototype.detach = function () {
  8475. this._scene.onBeforeRenderObservable.remove(this._onRenderObserver);
  8476. };
  8477. return AttachToBoxBehavior;
  8478. }());
  8479. /***/ }),
  8480. /***/ "./Behaviors/Meshes/fadeInOutBehavior.ts":
  8481. /*!***********************************************!*\
  8482. !*** ./Behaviors/Meshes/fadeInOutBehavior.ts ***!
  8483. \***********************************************/
  8484. /*! exports provided: FadeInOutBehavior */
  8485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8486. "use strict";
  8487. __webpack_require__.r(__webpack_exports__);
  8488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return FadeInOutBehavior; });
  8489. /**
  8490. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  8491. */
  8492. var FadeInOutBehavior = /** @class */ (function () {
  8493. /**
  8494. * Instatiates the FadeInOutBehavior
  8495. */
  8496. function FadeInOutBehavior() {
  8497. var _this = this;
  8498. /**
  8499. * Time in milliseconds to delay before fading in (Default: 0)
  8500. */
  8501. this.delay = 0;
  8502. /**
  8503. * Time in milliseconds for the mesh to fade in (Default: 300)
  8504. */
  8505. this.fadeInTime = 300;
  8506. this._millisecondsPerFrame = 1000 / 60;
  8507. this._hovered = false;
  8508. this._hoverValue = 0;
  8509. this._ownerNode = null;
  8510. this._update = function () {
  8511. if (_this._ownerNode) {
  8512. _this._hoverValue += _this._hovered ? _this._millisecondsPerFrame : -_this._millisecondsPerFrame;
  8513. _this._setAllVisibility(_this._ownerNode, (_this._hoverValue - _this.delay) / _this.fadeInTime);
  8514. if (_this._ownerNode.visibility > 1) {
  8515. _this._setAllVisibility(_this._ownerNode, 1);
  8516. _this._hoverValue = _this.fadeInTime + _this.delay;
  8517. return;
  8518. }
  8519. else if (_this._ownerNode.visibility < 0) {
  8520. _this._setAllVisibility(_this._ownerNode, 0);
  8521. if (_this._hoverValue < 0) {
  8522. _this._hoverValue = 0;
  8523. return;
  8524. }
  8525. }
  8526. setTimeout(_this._update, _this._millisecondsPerFrame);
  8527. }
  8528. };
  8529. }
  8530. Object.defineProperty(FadeInOutBehavior.prototype, "name", {
  8531. /**
  8532. * The name of the behavior
  8533. */
  8534. get: function () {
  8535. return "FadeInOut";
  8536. },
  8537. enumerable: true,
  8538. configurable: true
  8539. });
  8540. /**
  8541. * Initializes the behavior
  8542. */
  8543. FadeInOutBehavior.prototype.init = function () {
  8544. };
  8545. /**
  8546. * Attaches the fade behavior on the passed in mesh
  8547. * @param ownerNode The mesh that will be faded in/out once attached
  8548. */
  8549. FadeInOutBehavior.prototype.attach = function (ownerNode) {
  8550. this._ownerNode = ownerNode;
  8551. this._setAllVisibility(this._ownerNode, 0);
  8552. };
  8553. /**
  8554. * Detaches the behavior from the mesh
  8555. */
  8556. FadeInOutBehavior.prototype.detach = function () {
  8557. this._ownerNode = null;
  8558. };
  8559. /**
  8560. * Triggers the mesh to begin fading in or out
  8561. * @param value if the object should fade in or out (true to fade in)
  8562. */
  8563. FadeInOutBehavior.prototype.fadeIn = function (value) {
  8564. this._hovered = value;
  8565. this._update();
  8566. };
  8567. FadeInOutBehavior.prototype._setAllVisibility = function (mesh, value) {
  8568. var _this = this;
  8569. mesh.visibility = value;
  8570. mesh.getChildMeshes().forEach(function (c) {
  8571. _this._setAllVisibility(c, value);
  8572. });
  8573. };
  8574. return FadeInOutBehavior;
  8575. }());
  8576. /***/ }),
  8577. /***/ "./Behaviors/Meshes/index.ts":
  8578. /*!***********************************!*\
  8579. !*** ./Behaviors/Meshes/index.ts ***!
  8580. \***********************************/
  8581. /*! exports provided: AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  8582. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8583. "use strict";
  8584. __webpack_require__.r(__webpack_exports__);
  8585. /* harmony import */ var _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./attachToBoxBehavior */ "./Behaviors/Meshes/attachToBoxBehavior.ts");
  8586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  8587. /* harmony import */ var _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fadeInOutBehavior */ "./Behaviors/Meshes/fadeInOutBehavior.ts");
  8588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  8589. /* harmony import */ var _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./multiPointerScaleBehavior */ "./Behaviors/Meshes/multiPointerScaleBehavior.ts");
  8590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__["MultiPointerScaleBehavior"]; });
  8591. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__["PointerDragBehavior"]; });
  8593. /* harmony import */ var _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  8594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__["SixDofDragBehavior"]; });
  8595. /***/ }),
  8596. /***/ "./Behaviors/Meshes/multiPointerScaleBehavior.ts":
  8597. /*!*******************************************************!*\
  8598. !*** ./Behaviors/Meshes/multiPointerScaleBehavior.ts ***!
  8599. \*******************************************************/
  8600. /*! exports provided: MultiPointerScaleBehavior */
  8601. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8602. "use strict";
  8603. __webpack_require__.r(__webpack_exports__);
  8604. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return MultiPointerScaleBehavior; });
  8605. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8606. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8607. /**
  8608. * A behavior that when attached to a mesh will allow the mesh to be scaled
  8609. */
  8610. var MultiPointerScaleBehavior = /** @class */ (function () {
  8611. /**
  8612. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  8613. */
  8614. function MultiPointerScaleBehavior() {
  8615. this._startDistance = 0;
  8616. this._initialScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8617. this._targetScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8618. this._sceneRenderObserver = null;
  8619. this._dragBehaviorA = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8620. this._dragBehaviorA.moveAttached = false;
  8621. this._dragBehaviorB = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8622. this._dragBehaviorB.moveAttached = false;
  8623. }
  8624. Object.defineProperty(MultiPointerScaleBehavior.prototype, "name", {
  8625. /**
  8626. * The name of the behavior
  8627. */
  8628. get: function () {
  8629. return "MultiPointerScale";
  8630. },
  8631. enumerable: true,
  8632. configurable: true
  8633. });
  8634. /**
  8635. * Initializes the behavior
  8636. */
  8637. MultiPointerScaleBehavior.prototype.init = function () { };
  8638. MultiPointerScaleBehavior.prototype._getCurrentDistance = function () {
  8639. return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length();
  8640. };
  8641. /**
  8642. * Attaches the scale behavior the passed in mesh
  8643. * @param ownerNode The mesh that will be scaled around once attached
  8644. */
  8645. MultiPointerScaleBehavior.prototype.attach = function (ownerNode) {
  8646. var _this = this;
  8647. this._ownerNode = ownerNode;
  8648. // Create 2 drag behaviors such that each will only be triggered by a separate pointer
  8649. this._dragBehaviorA.onDragStartObservable.add(function (e) {
  8650. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  8651. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  8652. _this._dragBehaviorA.releaseDrag();
  8653. }
  8654. else {
  8655. _this._initialScale.copyFrom(ownerNode.scaling);
  8656. _this._startDistance = _this._getCurrentDistance();
  8657. }
  8658. }
  8659. });
  8660. this._dragBehaviorB.onDragStartObservable.add(function (e) {
  8661. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  8662. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  8663. _this._dragBehaviorB.releaseDrag();
  8664. }
  8665. else {
  8666. _this._initialScale.copyFrom(ownerNode.scaling);
  8667. _this._startDistance = _this._getCurrentDistance();
  8668. }
  8669. }
  8670. });
  8671. // Once both drag behaviors are active scale based on the distance between the two pointers
  8672. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  8673. behavior.onDragObservable.add(function () {
  8674. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  8675. var ratio = _this._getCurrentDistance() / _this._startDistance;
  8676. _this._initialScale.scaleToRef(ratio, _this._targetScale);
  8677. }
  8678. });
  8679. });
  8680. ownerNode.addBehavior(this._dragBehaviorA);
  8681. ownerNode.addBehavior(this._dragBehaviorB);
  8682. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  8683. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  8684. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  8685. var change = _this._targetScale.subtract(ownerNode.scaling).scaleInPlace(0.1);
  8686. if (change.length() > 0.01) {
  8687. ownerNode.scaling.addInPlace(change);
  8688. }
  8689. }
  8690. });
  8691. };
  8692. /**
  8693. * Detaches the behavior from the mesh
  8694. */
  8695. MultiPointerScaleBehavior.prototype.detach = function () {
  8696. var _this = this;
  8697. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  8698. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  8699. behavior.onDragStartObservable.clear();
  8700. behavior.onDragObservable.clear();
  8701. _this._ownerNode.removeBehavior(behavior);
  8702. });
  8703. };
  8704. return MultiPointerScaleBehavior;
  8705. }());
  8706. /***/ }),
  8707. /***/ "./Behaviors/Meshes/pointerDragBehavior.ts":
  8708. /*!*************************************************!*\
  8709. !*** ./Behaviors/Meshes/pointerDragBehavior.ts ***!
  8710. \*************************************************/
  8711. /*! exports provided: PointerDragBehavior */
  8712. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8713. "use strict";
  8714. __webpack_require__.r(__webpack_exports__);
  8715. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return PointerDragBehavior; });
  8716. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  8717. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  8718. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  8719. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8720. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  8721. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  8722. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  8723. /**
  8724. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  8725. */
  8726. var PointerDragBehavior = /** @class */ (function () {
  8727. /**
  8728. * Creates a pointer drag behavior that can be attached to a mesh
  8729. * @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)
  8730. */
  8731. function PointerDragBehavior(options) {
  8732. /**
  8733. * 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)
  8734. */
  8735. this.maxDragAngle = 0;
  8736. /**
  8737. * @hidden
  8738. */
  8739. this._useAlternatePickedPointAboveMaxDragAngle = false;
  8740. /**
  8741. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  8742. */
  8743. this.currentDraggingPointerID = -1;
  8744. /**
  8745. * If the behavior is currently in a dragging state
  8746. */
  8747. this.dragging = false;
  8748. /**
  8749. * 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)
  8750. */
  8751. this.dragDeltaRatio = 0.2;
  8752. /**
  8753. * If the drag plane orientation should be updated during the dragging (Default: true)
  8754. */
  8755. this.updateDragPlane = true;
  8756. // Debug mode will display drag planes to help visualize behavior
  8757. this._debugMode = false;
  8758. this._moving = false;
  8759. /**
  8760. * Fires each time the attached mesh is dragged with the pointer
  8761. * * delta between last drag position and current drag position in world space
  8762. * * dragDistance along the drag axis
  8763. * * dragPlaneNormal normal of the current drag plane used during the drag
  8764. * * dragPlanePoint in world space where the drag intersects the drag plane
  8765. */
  8766. this.onDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  8767. /**
  8768. * Fires each time a drag begins (eg. mouse down on mesh)
  8769. */
  8770. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  8771. /**
  8772. * Fires each time a drag ends (eg. mouse release after drag)
  8773. */
  8774. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  8775. /**
  8776. * If the attached mesh should be moved when dragged
  8777. */
  8778. this.moveAttached = true;
  8779. /**
  8780. * If the drag behavior will react to drag events (Default: true)
  8781. */
  8782. this.enabled = true;
  8783. /**
  8784. * If camera controls should be detached during the drag
  8785. */
  8786. this.detachCameraControls = true;
  8787. /**
  8788. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  8789. */
  8790. this.useObjectOrienationForDragging = true;
  8791. /**
  8792. * Predicate to determine if it is valid to move the object to a new position when it is moved
  8793. */
  8794. this.validateDrag = function (targetPosition) { return true; };
  8795. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8796. this._alternatePickedPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8797. this._worldDragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8798. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8799. this._attachedElement = null;
  8800. 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"]());
  8801. this._lastPointerRay = {};
  8802. this._dragDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  8803. // Variables to avoid instantiation in the below method
  8804. this._pointA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8805. this._pointB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8806. this._pointC = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8807. this._lineA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8808. this._lineB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8809. this._localAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8810. this._lookAt = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8811. this._options = options ? options : {};
  8812. var optionCount = 0;
  8813. if (this._options.dragAxis) {
  8814. optionCount++;
  8815. }
  8816. if (this._options.dragPlaneNormal) {
  8817. optionCount++;
  8818. }
  8819. if (optionCount > 1) {
  8820. throw "Multiple drag modes specified in dragBehavior options. Only one expected";
  8821. }
  8822. }
  8823. Object.defineProperty(PointerDragBehavior.prototype, "name", {
  8824. /**
  8825. * The name of the behavior
  8826. */
  8827. get: function () {
  8828. return "PointerDrag";
  8829. },
  8830. enumerable: true,
  8831. configurable: true
  8832. });
  8833. /**
  8834. * Initializes the behavior
  8835. */
  8836. PointerDragBehavior.prototype.init = function () { };
  8837. /**
  8838. * Attaches the drag behavior the passed in mesh
  8839. * @param ownerNode The mesh that will be dragged around once attached
  8840. */
  8841. PointerDragBehavior.prototype.attach = function (ownerNode) {
  8842. var _this = this;
  8843. this._scene = ownerNode.getScene();
  8844. this._attachedNode = ownerNode;
  8845. // Initialize drag plane to not interfere with existing scene
  8846. if (!PointerDragBehavior._planeScene) {
  8847. if (this._debugMode) {
  8848. PointerDragBehavior._planeScene = this._scene;
  8849. }
  8850. else {
  8851. PointerDragBehavior._planeScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  8852. PointerDragBehavior._planeScene.detachControl();
  8853. this._scene.getEngine().scenes.pop();
  8854. this._scene.onDisposeObservable.addOnce(function () {
  8855. PointerDragBehavior._planeScene.dispose();
  8856. PointerDragBehavior._planeScene = null;
  8857. });
  8858. }
  8859. }
  8860. 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);
  8861. // State of the drag
  8862. this.lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  8863. var pickPredicate = function (m) {
  8864. return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
  8865. };
  8866. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  8867. if (!_this.enabled) {
  8868. return;
  8869. }
  8870. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN) {
  8871. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.pickedPoint && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  8872. _this._startDrag(pointerInfo.event.pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);
  8873. }
  8874. }
  8875. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP) {
  8876. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  8877. _this.releaseDrag();
  8878. }
  8879. }
  8880. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  8881. var pointerId = pointerInfo.event.pointerId;
  8882. // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved
  8883. if (_this.currentDraggingPointerID === PointerDragBehavior._AnyMouseID && pointerId !== PointerDragBehavior._AnyMouseID && pointerInfo.event.pointerType == "mouse") {
  8884. if (_this._lastPointerRay[_this.currentDraggingPointerID]) {
  8885. _this._lastPointerRay[pointerId] = _this._lastPointerRay[_this.currentDraggingPointerID];
  8886. delete _this._lastPointerRay[_this.currentDraggingPointerID];
  8887. }
  8888. _this.currentDraggingPointerID = pointerId;
  8889. }
  8890. // Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()
  8891. if (!_this._lastPointerRay[pointerId]) {
  8892. _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"]());
  8893. }
  8894. if (pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {
  8895. _this._lastPointerRay[pointerId].origin.copyFrom(pointerInfo.pickInfo.ray.origin);
  8896. _this._lastPointerRay[pointerId].direction.copyFrom(pointerInfo.pickInfo.ray.direction);
  8897. if (_this.currentDraggingPointerID == pointerId && _this.dragging) {
  8898. _this._moveDrag(pointerInfo.pickInfo.ray);
  8899. }
  8900. }
  8901. }
  8902. });
  8903. this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  8904. if (_this._moving && _this.moveAttached) {
  8905. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(_this._attachedNode);
  8906. // Slowly move mesh to avoid jitter
  8907. _this._targetPosition.subtractToRef((_this._attachedNode).absolutePosition, _this._tmpVector);
  8908. _this._tmpVector.scaleInPlace(_this.dragDeltaRatio);
  8909. (_this._attachedNode).getAbsolutePosition().addToRef(_this._tmpVector, _this._tmpVector);
  8910. if (_this.validateDrag(_this._tmpVector)) {
  8911. (_this._attachedNode).setAbsolutePosition(_this._tmpVector);
  8912. }
  8913. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(_this._attachedNode);
  8914. }
  8915. });
  8916. };
  8917. /**
  8918. * Force relase the drag action by code.
  8919. */
  8920. PointerDragBehavior.prototype.releaseDrag = function () {
  8921. this.dragging = false;
  8922. this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerID });
  8923. this.currentDraggingPointerID = -1;
  8924. this._moving = false;
  8925. // Reattach camera controls
  8926. if (this.detachCameraControls && this._attachedElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  8927. this._scene.activeCamera.attachControl(this._attachedElement, true);
  8928. }
  8929. };
  8930. /**
  8931. * Simulates the start of a pointer drag event on the behavior
  8932. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  8933. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  8934. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  8935. */
  8936. PointerDragBehavior.prototype.startDrag = function (pointerId, fromRay, startPickedPoint) {
  8937. if (pointerId === void 0) { pointerId = PointerDragBehavior._AnyMouseID; }
  8938. this._startDrag(pointerId, fromRay, startPickedPoint);
  8939. var lastRay = this._lastPointerRay[pointerId];
  8940. if (pointerId === PointerDragBehavior._AnyMouseID) {
  8941. lastRay = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]];
  8942. }
  8943. if (lastRay) {
  8944. // if there was a last pointer ray drag the object there
  8945. this._moveDrag(lastRay);
  8946. }
  8947. };
  8948. PointerDragBehavior.prototype._startDrag = function (pointerId, fromRay, startPickedPoint) {
  8949. if (!this._scene.activeCamera || this.dragging || !this._attachedNode) {
  8950. return;
  8951. }
  8952. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(this._attachedNode);
  8953. // Create start ray from the camera to the object
  8954. if (fromRay) {
  8955. this._startDragRay.direction.copyFrom(fromRay.direction);
  8956. this._startDragRay.origin.copyFrom(fromRay.origin);
  8957. }
  8958. else {
  8959. this._startDragRay.origin.copyFrom(this._scene.activeCamera.position);
  8960. this._attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector);
  8961. this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction);
  8962. }
  8963. this._updateDragPlanePosition(this._startDragRay, startPickedPoint ? startPickedPoint : this._tmpVector);
  8964. var pickedPoint = this._pickWithRayOnDragPlane(this._startDragRay);
  8965. if (pickedPoint) {
  8966. this.dragging = true;
  8967. this.currentDraggingPointerID = pointerId;
  8968. this.lastDragPosition.copyFrom(pickedPoint);
  8969. this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: this.currentDraggingPointerID });
  8970. this._targetPosition.copyFrom((this._attachedNode).absolutePosition);
  8971. // Detatch camera controls
  8972. if (this.detachCameraControls && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  8973. if (this._scene.activeCamera.inputs.attachedElement) {
  8974. this._attachedElement = this._scene.activeCamera.inputs.attachedElement;
  8975. this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement);
  8976. }
  8977. else {
  8978. this._attachedElement = null;
  8979. }
  8980. }
  8981. }
  8982. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(this._attachedNode);
  8983. };
  8984. PointerDragBehavior.prototype._moveDrag = function (ray) {
  8985. this._moving = true;
  8986. var pickedPoint = this._pickWithRayOnDragPlane(ray);
  8987. if (pickedPoint) {
  8988. if (this.updateDragPlane) {
  8989. this._updateDragPlanePosition(ray, pickedPoint);
  8990. }
  8991. var dragLength = 0;
  8992. // depending on the drag mode option drag accordingly
  8993. if (this._options.dragAxis) {
  8994. // Convert local drag axis to world
  8995. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis);
  8996. // Project delta drag from the drag plane onto the drag axis
  8997. pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector);
  8998. dragLength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._tmpVector, this._worldDragAxis);
  8999. this._worldDragAxis.scaleToRef(dragLength, this._dragDelta);
  9000. }
  9001. else {
  9002. dragLength = this._dragDelta.length();
  9003. pickedPoint.subtractToRef(this.lastDragPosition, this._dragDelta);
  9004. }
  9005. this._targetPosition.addInPlace(this._dragDelta);
  9006. this.onDragObservable.notifyObservers({ dragDistance: dragLength, delta: this._dragDelta, dragPlanePoint: pickedPoint, dragPlaneNormal: this._dragPlane.forward, pointerId: this.currentDraggingPointerID });
  9007. this.lastDragPosition.copyFrom(pickedPoint);
  9008. }
  9009. };
  9010. PointerDragBehavior.prototype._pickWithRayOnDragPlane = function (ray) {
  9011. var _this = this;
  9012. if (!ray) {
  9013. return null;
  9014. }
  9015. // Calculate angle between plane normal and ray
  9016. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, ray.direction));
  9017. // Correct if ray is casted from oposite side
  9018. if (angle > Math.PI / 2) {
  9019. angle = Math.PI - angle;
  9020. }
  9021. // If the angle is too perpendicular to the plane pick another point on the plane where it is looking
  9022. if (this.maxDragAngle > 0 && angle > this.maxDragAngle) {
  9023. if (this._useAlternatePickedPointAboveMaxDragAngle) {
  9024. // Invert ray direction along the towards object axis
  9025. this._tmpVector.copyFrom(ray.direction);
  9026. (this._attachedNode).absolutePosition.subtractToRef(ray.origin, this._alternatePickedPoint);
  9027. this._alternatePickedPoint.normalize();
  9028. this._alternatePickedPoint.scaleInPlace(-2 * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._alternatePickedPoint, this._tmpVector));
  9029. this._tmpVector.addInPlace(this._alternatePickedPoint);
  9030. // Project resulting vector onto the drag plane and add it to the attached nodes absolute position to get a picked point
  9031. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, this._tmpVector);
  9032. this._dragPlane.forward.scaleToRef(-dot, this._alternatePickedPoint);
  9033. this._alternatePickedPoint.addInPlace(this._tmpVector);
  9034. this._alternatePickedPoint.addInPlace((this._attachedNode).absolutePosition);
  9035. return this._alternatePickedPoint;
  9036. }
  9037. else {
  9038. return null;
  9039. }
  9040. }
  9041. var pickResult = PointerDragBehavior._planeScene.pickWithRay(ray, function (m) { return m == _this._dragPlane; });
  9042. if (pickResult && pickResult.hit && pickResult.pickedMesh && pickResult.pickedPoint) {
  9043. return pickResult.pickedPoint;
  9044. }
  9045. else {
  9046. return null;
  9047. }
  9048. };
  9049. // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera
  9050. PointerDragBehavior.prototype._updateDragPlanePosition = function (ray, dragPlanePosition) {
  9051. this._pointA.copyFrom(dragPlanePosition);
  9052. if (this._options.dragAxis) {
  9053. 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);
  9054. // Calculate plane normal in direction of camera but perpendicular to drag axis
  9055. this._pointA.addToRef(this._localAxis, this._pointB); // towards drag axis
  9056. ray.origin.subtractToRef(this._pointA, this._pointC);
  9057. this._pointA.addToRef(this._pointC.normalize(), this._pointC); // towards camera
  9058. // Get perpendicular line from direction to camera and drag axis
  9059. this._pointB.subtractToRef(this._pointA, this._lineA);
  9060. this._pointC.subtractToRef(this._pointA, this._lineB);
  9061. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lineB, this._lookAt);
  9062. // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendiculat to camera
  9063. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lookAt, this._lookAt);
  9064. this._lookAt.normalize();
  9065. this._dragPlane.position.copyFrom(this._pointA);
  9066. this._pointA.addToRef(this._lookAt, this._lookAt);
  9067. this._dragPlane.lookAt(this._lookAt);
  9068. }
  9069. else if (this._options.dragPlaneNormal) {
  9070. 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);
  9071. this._dragPlane.position.copyFrom(this._pointA);
  9072. this._pointA.addToRef(this._localAxis, this._lookAt);
  9073. this._dragPlane.lookAt(this._lookAt);
  9074. }
  9075. else {
  9076. this._dragPlane.position.copyFrom(this._pointA);
  9077. this._dragPlane.lookAt(ray.origin);
  9078. }
  9079. this._dragPlane.computeWorldMatrix(true);
  9080. };
  9081. /**
  9082. * Detaches the behavior from the mesh
  9083. */
  9084. PointerDragBehavior.prototype.detach = function () {
  9085. if (this._pointerObserver) {
  9086. this._scene.onPointerObservable.remove(this._pointerObserver);
  9087. }
  9088. if (this._beforeRenderObserver) {
  9089. this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  9090. }
  9091. };
  9092. PointerDragBehavior._AnyMouseID = -2;
  9093. return PointerDragBehavior;
  9094. }());
  9095. /***/ }),
  9096. /***/ "./Behaviors/Meshes/sixDofDragBehavior.ts":
  9097. /*!************************************************!*\
  9098. !*** ./Behaviors/Meshes/sixDofDragBehavior.ts ***!
  9099. \************************************************/
  9100. /*! exports provided: SixDofDragBehavior */
  9101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9102. "use strict";
  9103. __webpack_require__.r(__webpack_exports__);
  9104. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return SixDofDragBehavior; });
  9105. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  9106. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9107. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9108. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9109. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9110. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  9111. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9112. /**
  9113. * 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
  9114. */
  9115. var SixDofDragBehavior = /** @class */ (function () {
  9116. /**
  9117. * 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
  9118. */
  9119. function SixDofDragBehavior() {
  9120. this._sceneRenderObserver = null;
  9121. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9122. this._moving = false;
  9123. this._startingOrientation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9124. /**
  9125. * 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)
  9126. */
  9127. this.zDragFactor = 3;
  9128. /**
  9129. * If the object should rotate to face the drag origin
  9130. */
  9131. this.rotateDraggedObject = true;
  9132. /**
  9133. * If the behavior is currently in a dragging state
  9134. */
  9135. this.dragging = false;
  9136. /**
  9137. * 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)
  9138. */
  9139. this.dragDeltaRatio = 0.2;
  9140. /**
  9141. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9142. */
  9143. this.currentDraggingPointerID = -1;
  9144. /**
  9145. * If camera controls should be detached during the drag
  9146. */
  9147. this.detachCameraControls = true;
  9148. /**
  9149. * Fires each time a drag starts
  9150. */
  9151. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9152. /**
  9153. * Fires each time a drag ends (eg. mouse release after drag)
  9154. */
  9155. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9156. }
  9157. Object.defineProperty(SixDofDragBehavior.prototype, "name", {
  9158. /**
  9159. * The name of the behavior
  9160. */
  9161. get: function () {
  9162. return "SixDofDrag";
  9163. },
  9164. enumerable: true,
  9165. configurable: true
  9166. });
  9167. /**
  9168. * Initializes the behavior
  9169. */
  9170. SixDofDragBehavior.prototype.init = function () { };
  9171. /**
  9172. * Attaches the scale behavior the passed in mesh
  9173. * @param ownerNode The mesh that will be scaled around once attached
  9174. */
  9175. SixDofDragBehavior.prototype.attach = function (ownerNode) {
  9176. var _this = this;
  9177. this._ownerNode = ownerNode;
  9178. this._scene = this._ownerNode.getScene();
  9179. if (!SixDofDragBehavior._virtualScene) {
  9180. SixDofDragBehavior._virtualScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9181. SixDofDragBehavior._virtualScene.detachControl();
  9182. this._scene.getEngine().scenes.pop();
  9183. }
  9184. var pickedMesh = null;
  9185. var lastSixDofOriginPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9186. // Setup virtual meshes to be used for dragging without dirtying the existing scene
  9187. this._virtualOriginMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9188. this._virtualOriginMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9189. this._virtualDragMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9190. this._virtualDragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9191. var pickPredicate = function (m) {
  9192. return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
  9193. };
  9194. var attachedElement = null;
  9195. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9196. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  9197. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9198. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9199. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9200. }
  9201. pickedMesh = _this._ownerNode;
  9202. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9203. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9204. // Set position and orientation of the controller
  9205. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9206. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9207. // Attach the virtual drag mesh to the virtual origin mesh so it can be dragged
  9208. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9209. pickedMesh.computeWorldMatrix();
  9210. _this._virtualDragMesh.position.copyFrom(pickedMesh.absolutePosition);
  9211. if (!pickedMesh.rotationQuaternion) {
  9212. pickedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(pickedMesh.rotation.y, pickedMesh.rotation.x, pickedMesh.rotation.z);
  9213. }
  9214. var oldParent = pickedMesh.parent;
  9215. pickedMesh.setParent(null);
  9216. _this._virtualDragMesh.rotationQuaternion.copyFrom(pickedMesh.rotationQuaternion);
  9217. pickedMesh.setParent(oldParent);
  9218. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9219. // Update state
  9220. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9221. _this.dragging = true;
  9222. _this.currentDraggingPointerID = pointerInfo.event.pointerId;
  9223. // Detatch camera controls
  9224. if (_this.detachCameraControls && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9225. if (_this._scene.activeCamera.inputs.attachedElement) {
  9226. attachedElement = _this._scene.activeCamera.inputs.attachedElement;
  9227. _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
  9228. }
  9229. else {
  9230. attachedElement = null;
  9231. }
  9232. }
  9233. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9234. _this.onDragStartObservable.notifyObservers({});
  9235. }
  9236. }
  9237. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP) {
  9238. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9239. _this.dragging = false;
  9240. _this._moving = false;
  9241. _this.currentDraggingPointerID = -1;
  9242. pickedMesh = null;
  9243. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9244. // Reattach camera controls
  9245. if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9246. _this._scene.activeCamera.attachControl(attachedElement, true);
  9247. }
  9248. _this.onDragEndObservable.notifyObservers({});
  9249. }
  9250. }
  9251. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE) {
  9252. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
  9253. var zDragFactor = _this.zDragFactor;
  9254. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9255. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9256. zDragFactor = 0;
  9257. }
  9258. // Calculate controller drag distance in controller space
  9259. var originDragDifference = pointerInfo.pickInfo.ray.origin.subtract(lastSixDofOriginPosition);
  9260. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9261. var localOriginDragDifference = -_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(originDragDifference, pointerInfo.pickInfo.ray.direction);
  9262. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9263. // Determine how much the controller moved to/away towards the dragged object and use this to move the object further when its further away
  9264. _this._virtualDragMesh.position.z -= _this._virtualDragMesh.position.z < 1 ? localOriginDragDifference * _this.zDragFactor : localOriginDragDifference * zDragFactor * _this._virtualDragMesh.position.z;
  9265. if (_this._virtualDragMesh.position.z < 0) {
  9266. _this._virtualDragMesh.position.z = 0;
  9267. }
  9268. // Update the controller position
  9269. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9270. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9271. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9272. // Move the virtualObjectsPosition into the picked mesh's space if needed
  9273. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9274. if (pickedMesh.parent) {
  9275. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._targetPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(pickedMesh.parent.getWorldMatrix()), _this._targetPosition);
  9276. }
  9277. if (!_this._moving) {
  9278. _this._startingOrientation.copyFrom(_this._virtualDragMesh.rotationQuaternion);
  9279. }
  9280. _this._moving = true;
  9281. }
  9282. }
  9283. });
  9284. var tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9285. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9286. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9287. if (_this.dragging && _this._moving && pickedMesh) {
  9288. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9289. // Slowly move mesh to avoid jitter
  9290. pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
  9291. if (_this.rotateDraggedObject) {
  9292. // Get change in rotation
  9293. tmpQuaternion.copyFrom(_this._startingOrientation);
  9294. tmpQuaternion.x = -tmpQuaternion.x;
  9295. tmpQuaternion.y = -tmpQuaternion.y;
  9296. tmpQuaternion.z = -tmpQuaternion.z;
  9297. _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
  9298. // Convert change in rotation to only y axis rotation
  9299. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
  9300. tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
  9301. // Slowly move mesh to avoid jitter
  9302. var oldParent = pickedMesh.parent;
  9303. // Only rotate the mesh if it's parent has uniform scaling
  9304. if (!oldParent || (oldParent.scaling && !oldParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  9305. pickedMesh.setParent(null);
  9306. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
  9307. pickedMesh.setParent(oldParent);
  9308. }
  9309. }
  9310. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9311. }
  9312. });
  9313. };
  9314. /**
  9315. * Detaches the behavior from the mesh
  9316. */
  9317. SixDofDragBehavior.prototype.detach = function () {
  9318. if (this._scene) {
  9319. this._scene.onPointerObservable.remove(this._pointerObserver);
  9320. }
  9321. if (this._ownerNode) {
  9322. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9323. }
  9324. if (this._virtualOriginMesh) {
  9325. this._virtualOriginMesh.dispose();
  9326. }
  9327. if (this._virtualDragMesh) {
  9328. this._virtualDragMesh.dispose();
  9329. }
  9330. this.onDragEndObservable.clear();
  9331. this.onDragStartObservable.clear();
  9332. };
  9333. return SixDofDragBehavior;
  9334. }());
  9335. /***/ }),
  9336. /***/ "./Behaviors/index.ts":
  9337. /*!****************************!*\
  9338. !*** ./Behaviors/index.ts ***!
  9339. \****************************/
  9340. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  9341. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9342. "use strict";
  9343. __webpack_require__.r(__webpack_exports__);
  9344. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Cameras/index */ "./Behaviors/Cameras/index.ts");
  9345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  9346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  9347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  9348. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Meshes/index */ "./Behaviors/Meshes/index.ts");
  9349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["AttachToBoxBehavior"]; });
  9350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  9351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["MultiPointerScaleBehavior"]; });
  9352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["PointerDragBehavior"]; });
  9353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["SixDofDragBehavior"]; });
  9354. /***/ }),
  9355. /***/ "./Bones/bone.ts":
  9356. /*!***********************!*\
  9357. !*** ./Bones/bone.ts ***!
  9358. \***********************/
  9359. /*! exports provided: Bone */
  9360. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9361. "use strict";
  9362. __webpack_require__.r(__webpack_exports__);
  9363. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return Bone; });
  9364. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  9365. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  9366. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  9367. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  9368. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  9369. /**
  9370. * Class used to store bone information
  9371. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9372. */
  9373. var Bone = /** @class */ (function (_super) {
  9374. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Bone, _super);
  9375. /**
  9376. * Create a new bone
  9377. * @param name defines the bone name
  9378. * @param skeleton defines the parent skeleton
  9379. * @param parentBone defines the parent (can be null if the bone is the root)
  9380. * @param localMatrix defines the local matrix
  9381. * @param restPose defines the rest pose matrix
  9382. * @param baseMatrix defines the base matrix
  9383. * @param index defines index of the bone in the hiearchy
  9384. */
  9385. function Bone(
  9386. /**
  9387. * defines the bone name
  9388. */
  9389. name, skeleton, parentBone, localMatrix, restPose, baseMatrix, index) {
  9390. if (parentBone === void 0) { parentBone = null; }
  9391. if (localMatrix === void 0) { localMatrix = null; }
  9392. if (restPose === void 0) { restPose = null; }
  9393. if (baseMatrix === void 0) { baseMatrix = null; }
  9394. if (index === void 0) { index = null; }
  9395. var _this = _super.call(this, name, skeleton.getScene(), false) || this;
  9396. _this.name = name;
  9397. /**
  9398. * Gets the list of child bones
  9399. */
  9400. _this.children = new Array();
  9401. /** Gets the animations associated with this bone */
  9402. _this.animations = new Array();
  9403. /**
  9404. * @hidden Internal only
  9405. * Set this value to map this bone to a different index in the transform matrices
  9406. * Set this value to -1 to exclude the bone from the transform matrices
  9407. */
  9408. _this._index = null;
  9409. _this._absoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9410. _this._invertedAbsoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9411. _this._scalingDeterminant = 1;
  9412. _this._worldTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9413. _this._needToDecompose = true;
  9414. _this._needToCompose = false;
  9415. /** @hidden */
  9416. _this._linkedTransformNode = null;
  9417. _this._skeleton = skeleton;
  9418. _this._localMatrix = localMatrix ? localMatrix.clone() : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  9419. _this._restPose = restPose ? restPose : _this._localMatrix.clone();
  9420. _this._baseMatrix = baseMatrix ? baseMatrix : _this._localMatrix.clone();
  9421. _this._index = index;
  9422. skeleton.bones.push(_this);
  9423. _this.setParent(parentBone, false);
  9424. if (baseMatrix || localMatrix) {
  9425. _this._updateDifferenceMatrix();
  9426. }
  9427. return _this;
  9428. }
  9429. Object.defineProperty(Bone.prototype, "_matrix", {
  9430. /** @hidden */
  9431. get: function () {
  9432. this._compose();
  9433. return this._localMatrix;
  9434. },
  9435. /** @hidden */
  9436. set: function (value) {
  9437. this._localMatrix.copyFrom(value);
  9438. this._needToDecompose = true;
  9439. },
  9440. enumerable: true,
  9441. configurable: true
  9442. });
  9443. // Members
  9444. /**
  9445. * Gets the parent skeleton
  9446. * @returns a skeleton
  9447. */
  9448. Bone.prototype.getSkeleton = function () {
  9449. return this._skeleton;
  9450. };
  9451. /**
  9452. * Gets parent bone
  9453. * @returns a bone or null if the bone is the root of the bone hierarchy
  9454. */
  9455. Bone.prototype.getParent = function () {
  9456. return this._parent;
  9457. };
  9458. /**
  9459. * Sets the parent bone
  9460. * @param parent defines the parent (can be null if the bone is the root)
  9461. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9462. */
  9463. Bone.prototype.setParent = function (parent, updateDifferenceMatrix) {
  9464. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9465. if (this._parent === parent) {
  9466. return;
  9467. }
  9468. if (this._parent) {
  9469. var index = this._parent.children.indexOf(this);
  9470. if (index !== -1) {
  9471. this._parent.children.splice(index, 1);
  9472. }
  9473. }
  9474. this._parent = parent;
  9475. if (this._parent) {
  9476. this._parent.children.push(this);
  9477. }
  9478. if (updateDifferenceMatrix) {
  9479. this._updateDifferenceMatrix();
  9480. }
  9481. this.markAsDirty();
  9482. };
  9483. /**
  9484. * Gets the local matrix
  9485. * @returns a matrix
  9486. */
  9487. Bone.prototype.getLocalMatrix = function () {
  9488. this._compose();
  9489. return this._localMatrix;
  9490. };
  9491. /**
  9492. * Gets the base matrix (initial matrix which remains unchanged)
  9493. * @returns a matrix
  9494. */
  9495. Bone.prototype.getBaseMatrix = function () {
  9496. return this._baseMatrix;
  9497. };
  9498. /**
  9499. * Gets the rest pose matrix
  9500. * @returns a matrix
  9501. */
  9502. Bone.prototype.getRestPose = function () {
  9503. return this._restPose;
  9504. };
  9505. /**
  9506. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9507. */
  9508. Bone.prototype.getWorldMatrix = function () {
  9509. return this._worldTransform;
  9510. };
  9511. /**
  9512. * Sets the local matrix to rest pose matrix
  9513. */
  9514. Bone.prototype.returnToRest = function () {
  9515. this.updateMatrix(this._restPose.clone());
  9516. };
  9517. /**
  9518. * Gets the inverse of the absolute transform matrix.
  9519. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9520. * @returns a matrix
  9521. */
  9522. Bone.prototype.getInvertedAbsoluteTransform = function () {
  9523. return this._invertedAbsoluteTransform;
  9524. };
  9525. /**
  9526. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9527. * @returns a matrix
  9528. */
  9529. Bone.prototype.getAbsoluteTransform = function () {
  9530. return this._absoluteTransform;
  9531. };
  9532. /**
  9533. * Links with the given transform node.
  9534. * The local matrix of this bone is copied from the transform node every frame.
  9535. * @param transformNode defines the transform node to link to
  9536. */
  9537. Bone.prototype.linkTransformNode = function (transformNode) {
  9538. if (this._linkedTransformNode) {
  9539. this._skeleton._numBonesWithLinkedTransformNode--;
  9540. }
  9541. this._linkedTransformNode = transformNode;
  9542. if (this._linkedTransformNode) {
  9543. this._skeleton._numBonesWithLinkedTransformNode++;
  9544. }
  9545. };
  9546. Object.defineProperty(Bone.prototype, "position", {
  9547. // Properties (matches AbstractMesh properties)
  9548. /** Gets or sets current position (in local space) */
  9549. get: function () {
  9550. this._decompose();
  9551. return this._localPosition;
  9552. },
  9553. set: function (newPosition) {
  9554. this._decompose();
  9555. this._localPosition.copyFrom(newPosition);
  9556. this._markAsDirtyAndCompose();
  9557. },
  9558. enumerable: true,
  9559. configurable: true
  9560. });
  9561. Object.defineProperty(Bone.prototype, "rotation", {
  9562. /** Gets or sets current rotation (in local space) */
  9563. get: function () {
  9564. return this.getRotation();
  9565. },
  9566. set: function (newRotation) {
  9567. this.setRotation(newRotation);
  9568. },
  9569. enumerable: true,
  9570. configurable: true
  9571. });
  9572. Object.defineProperty(Bone.prototype, "rotationQuaternion", {
  9573. /** Gets or sets current rotation quaternion (in local space) */
  9574. get: function () {
  9575. this._decompose();
  9576. return this._localRotation;
  9577. },
  9578. set: function (newRotation) {
  9579. this.setRotationQuaternion(newRotation);
  9580. },
  9581. enumerable: true,
  9582. configurable: true
  9583. });
  9584. Object.defineProperty(Bone.prototype, "scaling", {
  9585. /** Gets or sets current scaling (in local space) */
  9586. get: function () {
  9587. return this.getScale();
  9588. },
  9589. set: function (newScaling) {
  9590. this.setScale(newScaling);
  9591. },
  9592. enumerable: true,
  9593. configurable: true
  9594. });
  9595. Object.defineProperty(Bone.prototype, "animationPropertiesOverride", {
  9596. /**
  9597. * Gets the animation properties override
  9598. */
  9599. get: function () {
  9600. return this._skeleton.animationPropertiesOverride;
  9601. },
  9602. enumerable: true,
  9603. configurable: true
  9604. });
  9605. // Methods
  9606. Bone.prototype._decompose = function () {
  9607. if (!this._needToDecompose) {
  9608. return;
  9609. }
  9610. this._needToDecompose = false;
  9611. if (!this._localScaling) {
  9612. this._localScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9613. this._localRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Zero();
  9614. this._localPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9615. }
  9616. this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition);
  9617. };
  9618. Bone.prototype._compose = function () {
  9619. if (!this._needToCompose) {
  9620. return;
  9621. }
  9622. this._needToCompose = false;
  9623. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix);
  9624. };
  9625. /**
  9626. * Update the base and local matrices
  9627. * @param matrix defines the new base or local matrix
  9628. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9629. * @param updateLocalMatrix defines if the local matrix should be updated
  9630. */
  9631. Bone.prototype.updateMatrix = function (matrix, updateDifferenceMatrix, updateLocalMatrix) {
  9632. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9633. if (updateLocalMatrix === void 0) { updateLocalMatrix = true; }
  9634. this._baseMatrix.copyFrom(matrix);
  9635. if (updateDifferenceMatrix) {
  9636. this._updateDifferenceMatrix();
  9637. }
  9638. if (updateLocalMatrix) {
  9639. this._localMatrix.copyFrom(matrix);
  9640. this._markAsDirtyAndDecompose();
  9641. }
  9642. else {
  9643. this.markAsDirty();
  9644. }
  9645. };
  9646. /** @hidden */
  9647. Bone.prototype._updateDifferenceMatrix = function (rootMatrix, updateChildren) {
  9648. if (updateChildren === void 0) { updateChildren = true; }
  9649. if (!rootMatrix) {
  9650. rootMatrix = this._baseMatrix;
  9651. }
  9652. if (this._parent) {
  9653. rootMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  9654. }
  9655. else {
  9656. this._absoluteTransform.copyFrom(rootMatrix);
  9657. }
  9658. this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);
  9659. if (updateChildren) {
  9660. for (var index = 0; index < this.children.length; index++) {
  9661. this.children[index]._updateDifferenceMatrix();
  9662. }
  9663. }
  9664. this._scalingDeterminant = (this._absoluteTransform.determinant() < 0 ? -1 : 1);
  9665. };
  9666. /**
  9667. * Flag the bone as dirty (Forcing it to update everything)
  9668. */
  9669. Bone.prototype.markAsDirty = function () {
  9670. this._currentRenderId++;
  9671. this._childRenderId++;
  9672. this._skeleton._markAsDirty();
  9673. };
  9674. Bone.prototype._markAsDirtyAndCompose = function () {
  9675. this.markAsDirty();
  9676. this._needToCompose = true;
  9677. };
  9678. Bone.prototype._markAsDirtyAndDecompose = function () {
  9679. this.markAsDirty();
  9680. this._needToDecompose = true;
  9681. };
  9682. /**
  9683. * Copy an animation range from another bone
  9684. * @param source defines the source bone
  9685. * @param rangeName defines the range name to copy
  9686. * @param frameOffset defines the frame offset
  9687. * @param rescaleAsRequired defines if rescaling must be applied if required
  9688. * @param skelDimensionsRatio defines the scaling ratio
  9689. * @returns true if operation was successful
  9690. */
  9691. Bone.prototype.copyAnimationRange = function (source, rangeName, frameOffset, rescaleAsRequired, skelDimensionsRatio) {
  9692. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  9693. if (skelDimensionsRatio === void 0) { skelDimensionsRatio = null; }
  9694. // all animation may be coming from a library skeleton, so may need to create animation
  9695. if (this.animations.length === 0) {
  9696. this.animations.push(new _Animations_animation__WEBPACK_IMPORTED_MODULE_3__["Animation"](this.name, "_matrix", source.animations[0].framePerSecond, _Animations_animation__WEBPACK_IMPORTED_MODULE_3__["Animation"].ANIMATIONTYPE_MATRIX, 0));
  9697. this.animations[0].setKeys([]);
  9698. }
  9699. // get animation info / verify there is such a range from the source bone
  9700. var sourceRange = source.animations[0].getRange(rangeName);
  9701. if (!sourceRange) {
  9702. return false;
  9703. }
  9704. var from = sourceRange.from;
  9705. var to = sourceRange.to;
  9706. var sourceKeys = source.animations[0].getKeys();
  9707. // rescaling prep
  9708. var sourceBoneLength = source.length;
  9709. var sourceParent = source.getParent();
  9710. var parent = this.getParent();
  9711. var parentScalingReqd = rescaleAsRequired && sourceParent && sourceBoneLength && this.length && sourceBoneLength !== this.length;
  9712. var parentRatio = parentScalingReqd && parent && sourceParent ? parent.length / sourceParent.length : 1;
  9713. var dimensionsScalingReqd = rescaleAsRequired && !parent && skelDimensionsRatio && (skelDimensionsRatio.x !== 1 || skelDimensionsRatio.y !== 1 || skelDimensionsRatio.z !== 1);
  9714. var destKeys = this.animations[0].getKeys();
  9715. // loop vars declaration
  9716. var orig;
  9717. var origTranslation;
  9718. var mat;
  9719. for (var key = 0, nKeys = sourceKeys.length; key < nKeys; key++) {
  9720. orig = sourceKeys[key];
  9721. if (orig.frame >= from && orig.frame <= to) {
  9722. if (rescaleAsRequired) {
  9723. mat = orig.value.clone();
  9724. // scale based on parent ratio, when bone has parent
  9725. if (parentScalingReqd) {
  9726. origTranslation = mat.getTranslation();
  9727. mat.setTranslation(origTranslation.scaleInPlace(parentRatio));
  9728. // scale based on skeleton dimension ratio when root bone, and value is passed
  9729. }
  9730. else if (dimensionsScalingReqd && skelDimensionsRatio) {
  9731. origTranslation = mat.getTranslation();
  9732. mat.setTranslation(origTranslation.multiplyInPlace(skelDimensionsRatio));
  9733. // use original when root bone, and no data for skelDimensionsRatio
  9734. }
  9735. else {
  9736. mat = orig.value;
  9737. }
  9738. }
  9739. else {
  9740. mat = orig.value;
  9741. }
  9742. destKeys.push({ frame: orig.frame + frameOffset, value: mat });
  9743. }
  9744. }
  9745. this.animations[0].createRange(rangeName, from + frameOffset, to + frameOffset);
  9746. return true;
  9747. };
  9748. /**
  9749. * Translate the bone in local or world space
  9750. * @param vec The amount to translate the bone
  9751. * @param space The space that the translation is in
  9752. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9753. */
  9754. Bone.prototype.translate = function (vec, space, mesh) {
  9755. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9756. var lm = this.getLocalMatrix();
  9757. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  9758. lm.addAtIndex(12, vec.x);
  9759. lm.addAtIndex(13, vec.y);
  9760. lm.addAtIndex(14, vec.z);
  9761. }
  9762. else {
  9763. var wm = null;
  9764. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  9765. if (mesh) {
  9766. wm = mesh.getWorldMatrix();
  9767. }
  9768. this._skeleton.computeAbsoluteTransforms();
  9769. var tmat = Bone._tmpMats[0];
  9770. var tvec = Bone._tmpVecs[0];
  9771. if (this._parent) {
  9772. if (mesh && wm) {
  9773. tmat.copyFrom(this._parent.getAbsoluteTransform());
  9774. tmat.multiplyToRef(wm, tmat);
  9775. }
  9776. else {
  9777. tmat.copyFrom(this._parent.getAbsoluteTransform());
  9778. }
  9779. }
  9780. tmat.setTranslationFromFloats(0, 0, 0);
  9781. tmat.invert();
  9782. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vec, tmat, tvec);
  9783. lm.addAtIndex(12, tvec.x);
  9784. lm.addAtIndex(13, tvec.y);
  9785. lm.addAtIndex(14, tvec.z);
  9786. }
  9787. this._markAsDirtyAndDecompose();
  9788. };
  9789. /**
  9790. * Set the postion of the bone in local or world space
  9791. * @param position The position to set the bone
  9792. * @param space The space that the position is in
  9793. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9794. */
  9795. Bone.prototype.setPosition = function (position, space, mesh) {
  9796. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9797. var lm = this.getLocalMatrix();
  9798. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  9799. lm.setTranslationFromFloats(position.x, position.y, position.z);
  9800. }
  9801. else {
  9802. var wm = null;
  9803. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  9804. if (mesh) {
  9805. wm = mesh.getWorldMatrix();
  9806. }
  9807. this._skeleton.computeAbsoluteTransforms();
  9808. var tmat = Bone._tmpMats[0];
  9809. var vec = Bone._tmpVecs[0];
  9810. if (this._parent) {
  9811. if (mesh && wm) {
  9812. tmat.copyFrom(this._parent.getAbsoluteTransform());
  9813. tmat.multiplyToRef(wm, tmat);
  9814. }
  9815. else {
  9816. tmat.copyFrom(this._parent.getAbsoluteTransform());
  9817. }
  9818. }
  9819. tmat.invert();
  9820. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, vec);
  9821. lm.setTranslationFromFloats(vec.x, vec.y, vec.z);
  9822. }
  9823. this._markAsDirtyAndDecompose();
  9824. };
  9825. /**
  9826. * Set the absolute position of the bone (world space)
  9827. * @param position The position to set the bone
  9828. * @param mesh The mesh that this bone is attached to
  9829. */
  9830. Bone.prototype.setAbsolutePosition = function (position, mesh) {
  9831. this.setPosition(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh);
  9832. };
  9833. /**
  9834. * Scale the bone on the x, y and z axes (in local space)
  9835. * @param x The amount to scale the bone on the x axis
  9836. * @param y The amount to scale the bone on the y axis
  9837. * @param z The amount to scale the bone on the z axis
  9838. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9839. */
  9840. Bone.prototype.scale = function (x, y, z, scaleChildren) {
  9841. if (scaleChildren === void 0) { scaleChildren = false; }
  9842. var locMat = this.getLocalMatrix();
  9843. // Apply new scaling on top of current local matrix
  9844. var scaleMat = Bone._tmpMats[0];
  9845. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(x, y, z, scaleMat);
  9846. scaleMat.multiplyToRef(locMat, locMat);
  9847. // Invert scaling matrix and apply the inverse to all children
  9848. scaleMat.invert();
  9849. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9850. var child = _a[_i];
  9851. var cm = child.getLocalMatrix();
  9852. cm.multiplyToRef(scaleMat, cm);
  9853. cm.multiplyAtIndex(12, x);
  9854. cm.multiplyAtIndex(13, y);
  9855. cm.multiplyAtIndex(14, z);
  9856. child._markAsDirtyAndDecompose();
  9857. }
  9858. this._markAsDirtyAndDecompose();
  9859. if (scaleChildren) {
  9860. for (var _b = 0, _c = this.children; _b < _c.length; _b++) {
  9861. var child = _c[_b];
  9862. child.scale(x, y, z, scaleChildren);
  9863. }
  9864. }
  9865. };
  9866. /**
  9867. * Set the bone scaling in local space
  9868. * @param scale defines the scaling vector
  9869. */
  9870. Bone.prototype.setScale = function (scale) {
  9871. this._decompose();
  9872. this._localScaling.copyFrom(scale);
  9873. this._markAsDirtyAndCompose();
  9874. };
  9875. /**
  9876. * Gets the current scaling in local space
  9877. * @returns the current scaling vector
  9878. */
  9879. Bone.prototype.getScale = function () {
  9880. this._decompose();
  9881. return this._localScaling;
  9882. };
  9883. /**
  9884. * Gets the current scaling in local space and stores it in a target vector
  9885. * @param result defines the target vector
  9886. */
  9887. Bone.prototype.getScaleToRef = function (result) {
  9888. this._decompose();
  9889. result.copyFrom(this._localScaling);
  9890. };
  9891. /**
  9892. * Set the yaw, pitch, and roll of the bone in local or world space
  9893. * @param yaw The rotation of the bone on the y axis
  9894. * @param pitch The rotation of the bone on the x axis
  9895. * @param roll The rotation of the bone on the z axis
  9896. * @param space The space that the axes of rotation are in
  9897. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9898. */
  9899. Bone.prototype.setYawPitchRoll = function (yaw, pitch, roll, space, mesh) {
  9900. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9901. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  9902. var quat = Bone._tmpQuat;
  9903. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationYawPitchRollToRef(yaw, pitch, roll, quat);
  9904. this.setRotationQuaternion(quat, space, mesh);
  9905. return;
  9906. }
  9907. var rotMatInv = Bone._tmpMats[0];
  9908. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  9909. return;
  9910. }
  9911. var rotMat = Bone._tmpMats[1];
  9912. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yaw, pitch, roll, rotMat);
  9913. rotMatInv.multiplyToRef(rotMat, rotMat);
  9914. this._rotateWithMatrix(rotMat, space, mesh);
  9915. };
  9916. /**
  9917. * Add a rotation to the bone on an axis in local or world space
  9918. * @param axis The axis to rotate the bone on
  9919. * @param amount The amount to rotate the bone
  9920. * @param space The space that the axis is in
  9921. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9922. */
  9923. Bone.prototype.rotate = function (axis, amount, space, mesh) {
  9924. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9925. var rmat = Bone._tmpMats[0];
  9926. rmat.setTranslationFromFloats(0, 0, 0);
  9927. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, amount, rmat);
  9928. this._rotateWithMatrix(rmat, space, mesh);
  9929. };
  9930. /**
  9931. * Set the rotation of the bone to a particular axis angle in local or world space
  9932. * @param axis The axis to rotate the bone on
  9933. * @param angle The angle that the bone should be rotated to
  9934. * @param space The space that the axis is in
  9935. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9936. */
  9937. Bone.prototype.setAxisAngle = function (axis, angle, space, mesh) {
  9938. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9939. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  9940. var quat = Bone._tmpQuat;
  9941. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationAxisToRef(axis, angle, quat);
  9942. this.setRotationQuaternion(quat, space, mesh);
  9943. return;
  9944. }
  9945. var rotMatInv = Bone._tmpMats[0];
  9946. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  9947. return;
  9948. }
  9949. var rotMat = Bone._tmpMats[1];
  9950. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, angle, rotMat);
  9951. rotMatInv.multiplyToRef(rotMat, rotMat);
  9952. this._rotateWithMatrix(rotMat, space, mesh);
  9953. };
  9954. /**
  9955. * Set the euler rotation of the bone in local of world space
  9956. * @param rotation The euler rotation that the bone should be set to
  9957. * @param space The space that the rotation is in
  9958. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9959. */
  9960. Bone.prototype.setRotation = function (rotation, space, mesh) {
  9961. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9962. this.setYawPitchRoll(rotation.y, rotation.x, rotation.z, space, mesh);
  9963. };
  9964. /**
  9965. * Set the quaternion rotation of the bone in local of world space
  9966. * @param quat The quaternion rotation that the bone should be set to
  9967. * @param space The space that the rotation is in
  9968. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9969. */
  9970. Bone.prototype.setRotationQuaternion = function (quat, space, mesh) {
  9971. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9972. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  9973. this._decompose();
  9974. this._localRotation.copyFrom(quat);
  9975. this._markAsDirtyAndCompose();
  9976. return;
  9977. }
  9978. var rotMatInv = Bone._tmpMats[0];
  9979. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  9980. return;
  9981. }
  9982. var rotMat = Bone._tmpMats[1];
  9983. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromQuaternionToRef(quat, rotMat);
  9984. rotMatInv.multiplyToRef(rotMat, rotMat);
  9985. this._rotateWithMatrix(rotMat, space, mesh);
  9986. };
  9987. /**
  9988. * Set the rotation matrix of the bone in local of world space
  9989. * @param rotMat The rotation matrix that the bone should be set to
  9990. * @param space The space that the rotation is in
  9991. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9992. */
  9993. Bone.prototype.setRotationMatrix = function (rotMat, space, mesh) {
  9994. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  9995. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  9996. var quat = Bone._tmpQuat;
  9997. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(rotMat, quat);
  9998. this.setRotationQuaternion(quat, space, mesh);
  9999. return;
  10000. }
  10001. var rotMatInv = Bone._tmpMats[0];
  10002. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10003. return;
  10004. }
  10005. var rotMat2 = Bone._tmpMats[1];
  10006. rotMat2.copyFrom(rotMat);
  10007. rotMatInv.multiplyToRef(rotMat, rotMat2);
  10008. this._rotateWithMatrix(rotMat2, space, mesh);
  10009. };
  10010. Bone.prototype._rotateWithMatrix = function (rmat, space, mesh) {
  10011. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10012. var lmat = this.getLocalMatrix();
  10013. var lx = lmat.m[12];
  10014. var ly = lmat.m[13];
  10015. var lz = lmat.m[14];
  10016. var parent = this.getParent();
  10017. var parentScale = Bone._tmpMats[3];
  10018. var parentScaleInv = Bone._tmpMats[4];
  10019. if (parent && space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD) {
  10020. if (mesh) {
  10021. parentScale.copyFrom(mesh.getWorldMatrix());
  10022. parent.getAbsoluteTransform().multiplyToRef(parentScale, parentScale);
  10023. }
  10024. else {
  10025. parentScale.copyFrom(parent.getAbsoluteTransform());
  10026. }
  10027. parentScaleInv.copyFrom(parentScale);
  10028. parentScaleInv.invert();
  10029. lmat.multiplyToRef(parentScale, lmat);
  10030. lmat.multiplyToRef(rmat, lmat);
  10031. lmat.multiplyToRef(parentScaleInv, lmat);
  10032. }
  10033. else {
  10034. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD && mesh) {
  10035. parentScale.copyFrom(mesh.getWorldMatrix());
  10036. parentScaleInv.copyFrom(parentScale);
  10037. parentScaleInv.invert();
  10038. lmat.multiplyToRef(parentScale, lmat);
  10039. lmat.multiplyToRef(rmat, lmat);
  10040. lmat.multiplyToRef(parentScaleInv, lmat);
  10041. }
  10042. else {
  10043. lmat.multiplyToRef(rmat, lmat);
  10044. }
  10045. }
  10046. lmat.setTranslationFromFloats(lx, ly, lz);
  10047. this.computeAbsoluteTransforms();
  10048. this._markAsDirtyAndDecompose();
  10049. };
  10050. Bone.prototype._getNegativeRotationToRef = function (rotMatInv, mesh) {
  10051. var scaleMatrix = Bone._tmpMats[2];
  10052. rotMatInv.copyFrom(this.getAbsoluteTransform());
  10053. if (mesh) {
  10054. rotMatInv.multiplyToRef(mesh.getWorldMatrix(), rotMatInv);
  10055. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(mesh.scaling.x, mesh.scaling.y, mesh.scaling.z, scaleMatrix);
  10056. }
  10057. rotMatInv.invert();
  10058. if (isNaN(rotMatInv.m[0])) {
  10059. // Matrix failed to invert.
  10060. // This can happen if scale is zero for example.
  10061. return false;
  10062. }
  10063. scaleMatrix.multiplyAtIndex(0, this._scalingDeterminant);
  10064. rotMatInv.multiplyToRef(scaleMatrix, rotMatInv);
  10065. return true;
  10066. };
  10067. /**
  10068. * Get the position of the bone in local or world space
  10069. * @param space The space that the returned position is in
  10070. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10071. * @returns The position of the bone
  10072. */
  10073. Bone.prototype.getPosition = function (space, mesh) {
  10074. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10075. if (mesh === void 0) { mesh = null; }
  10076. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10077. this.getPositionToRef(space, mesh, pos);
  10078. return pos;
  10079. };
  10080. /**
  10081. * Copy the position of the bone to a vector3 in local or world space
  10082. * @param space The space that the returned position is in
  10083. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10084. * @param result The vector3 to copy the position to
  10085. */
  10086. Bone.prototype.getPositionToRef = function (space, mesh, result) {
  10087. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10088. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10089. var lm = this.getLocalMatrix();
  10090. result.x = lm.m[12];
  10091. result.y = lm.m[13];
  10092. result.z = lm.m[14];
  10093. }
  10094. else {
  10095. var wm = null;
  10096. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10097. if (mesh) {
  10098. wm = mesh.getWorldMatrix();
  10099. }
  10100. this._skeleton.computeAbsoluteTransforms();
  10101. var tmat = Bone._tmpMats[0];
  10102. if (mesh && wm) {
  10103. tmat.copyFrom(this.getAbsoluteTransform());
  10104. tmat.multiplyToRef(wm, tmat);
  10105. }
  10106. else {
  10107. tmat = this.getAbsoluteTransform();
  10108. }
  10109. result.x = tmat.m[12];
  10110. result.y = tmat.m[13];
  10111. result.z = tmat.m[14];
  10112. }
  10113. };
  10114. /**
  10115. * Get the absolute position of the bone (world space)
  10116. * @param mesh The mesh that this bone is attached to
  10117. * @returns The absolute position of the bone
  10118. */
  10119. Bone.prototype.getAbsolutePosition = function (mesh) {
  10120. if (mesh === void 0) { mesh = null; }
  10121. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10122. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, pos);
  10123. return pos;
  10124. };
  10125. /**
  10126. * Copy the absolute position of the bone (world space) to the result param
  10127. * @param mesh The mesh that this bone is attached to
  10128. * @param result The vector3 to copy the absolute position to
  10129. */
  10130. Bone.prototype.getAbsolutePositionToRef = function (mesh, result) {
  10131. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, result);
  10132. };
  10133. /**
  10134. * Compute the absolute transforms of this bone and its children
  10135. */
  10136. Bone.prototype.computeAbsoluteTransforms = function () {
  10137. this._compose();
  10138. if (this._parent) {
  10139. this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10140. }
  10141. else {
  10142. this._absoluteTransform.copyFrom(this._localMatrix);
  10143. var poseMatrix = this._skeleton.getPoseMatrix();
  10144. if (poseMatrix) {
  10145. this._absoluteTransform.multiplyToRef(poseMatrix, this._absoluteTransform);
  10146. }
  10147. }
  10148. var children = this.children;
  10149. var len = children.length;
  10150. for (var i = 0; i < len; i++) {
  10151. children[i].computeAbsoluteTransforms();
  10152. }
  10153. };
  10154. /**
  10155. * Get the world direction from an axis that is in the local space of the bone
  10156. * @param localAxis The local direction that is used to compute the world direction
  10157. * @param mesh The mesh that this bone is attached to
  10158. * @returns The world direction
  10159. */
  10160. Bone.prototype.getDirection = function (localAxis, mesh) {
  10161. if (mesh === void 0) { mesh = null; }
  10162. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10163. this.getDirectionToRef(localAxis, mesh, result);
  10164. return result;
  10165. };
  10166. /**
  10167. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  10168. * @param localAxis The local direction that is used to compute the world direction
  10169. * @param mesh The mesh that this bone is attached to
  10170. * @param result The vector3 that the world direction will be copied to
  10171. */
  10172. Bone.prototype.getDirectionToRef = function (localAxis, mesh, result) {
  10173. if (mesh === void 0) { mesh = null; }
  10174. var wm = null;
  10175. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10176. if (mesh) {
  10177. wm = mesh.getWorldMatrix();
  10178. }
  10179. this._skeleton.computeAbsoluteTransforms();
  10180. var mat = Bone._tmpMats[0];
  10181. mat.copyFrom(this.getAbsoluteTransform());
  10182. if (mesh && wm) {
  10183. mat.multiplyToRef(wm, mat);
  10184. }
  10185. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(localAxis, mat, result);
  10186. result.normalize();
  10187. };
  10188. /**
  10189. * Get the euler rotation of the bone in local or world space
  10190. * @param space The space that the rotation should be in
  10191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10192. * @returns The euler rotation
  10193. */
  10194. Bone.prototype.getRotation = function (space, mesh) {
  10195. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10196. if (mesh === void 0) { mesh = null; }
  10197. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10198. this.getRotationToRef(space, mesh, result);
  10199. return result;
  10200. };
  10201. /**
  10202. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  10203. * @param space The space that the rotation should be in
  10204. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10205. * @param result The vector3 that the rotation should be copied to
  10206. */
  10207. Bone.prototype.getRotationToRef = function (space, mesh, result) {
  10208. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10209. if (mesh === void 0) { mesh = null; }
  10210. var quat = Bone._tmpQuat;
  10211. this.getRotationQuaternionToRef(space, mesh, quat);
  10212. quat.toEulerAnglesToRef(result);
  10213. };
  10214. /**
  10215. * Get the quaternion rotation of the bone in either local or world space
  10216. * @param space The space that the rotation should be in
  10217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10218. * @returns The quaternion rotation
  10219. */
  10220. Bone.prototype.getRotationQuaternion = function (space, mesh) {
  10221. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10222. if (mesh === void 0) { mesh = null; }
  10223. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10224. this.getRotationQuaternionToRef(space, mesh, result);
  10225. return result;
  10226. };
  10227. /**
  10228. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  10229. * @param space The space that the rotation should be in
  10230. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10231. * @param result The quaternion that the rotation should be copied to
  10232. */
  10233. Bone.prototype.getRotationQuaternionToRef = function (space, mesh, result) {
  10234. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10235. if (mesh === void 0) { mesh = null; }
  10236. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10237. this._decompose();
  10238. result.copyFrom(this._localRotation);
  10239. }
  10240. else {
  10241. var mat = Bone._tmpMats[0];
  10242. var amat = this.getAbsoluteTransform();
  10243. if (mesh) {
  10244. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10245. }
  10246. else {
  10247. mat.copyFrom(amat);
  10248. }
  10249. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10250. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10251. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10252. mat.decompose(undefined, result, undefined);
  10253. }
  10254. };
  10255. /**
  10256. * Get the rotation matrix of the bone in local or world space
  10257. * @param space The space that the rotation should be in
  10258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10259. * @returns The rotation matrix
  10260. */
  10261. Bone.prototype.getRotationMatrix = function (space, mesh) {
  10262. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10263. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  10264. this.getRotationMatrixToRef(space, mesh, result);
  10265. return result;
  10266. };
  10267. /**
  10268. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  10269. * @param space The space that the rotation should be in
  10270. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10271. * @param result The quaternion that the rotation should be copied to
  10272. */
  10273. Bone.prototype.getRotationMatrixToRef = function (space, mesh, result) {
  10274. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10275. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10276. this.getLocalMatrix().getRotationMatrixToRef(result);
  10277. }
  10278. else {
  10279. var mat = Bone._tmpMats[0];
  10280. var amat = this.getAbsoluteTransform();
  10281. if (mesh) {
  10282. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10283. }
  10284. else {
  10285. mat.copyFrom(amat);
  10286. }
  10287. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10288. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10289. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10290. mat.getRotationMatrixToRef(result);
  10291. }
  10292. };
  10293. /**
  10294. * Get the world position of a point that is in the local space of the bone
  10295. * @param position The local position
  10296. * @param mesh The mesh that this bone is attached to
  10297. * @returns The world position
  10298. */
  10299. Bone.prototype.getAbsolutePositionFromLocal = function (position, mesh) {
  10300. if (mesh === void 0) { mesh = null; }
  10301. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10302. this.getAbsolutePositionFromLocalToRef(position, mesh, result);
  10303. return result;
  10304. };
  10305. /**
  10306. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  10307. * @param position The local position
  10308. * @param mesh The mesh that this bone is attached to
  10309. * @param result The vector3 that the world position should be copied to
  10310. */
  10311. Bone.prototype.getAbsolutePositionFromLocalToRef = function (position, mesh, result) {
  10312. if (mesh === void 0) { mesh = null; }
  10313. var wm = null;
  10314. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10315. if (mesh) {
  10316. wm = mesh.getWorldMatrix();
  10317. }
  10318. this._skeleton.computeAbsoluteTransforms();
  10319. var tmat = Bone._tmpMats[0];
  10320. if (mesh && wm) {
  10321. tmat.copyFrom(this.getAbsoluteTransform());
  10322. tmat.multiplyToRef(wm, tmat);
  10323. }
  10324. else {
  10325. tmat = this.getAbsoluteTransform();
  10326. }
  10327. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10328. };
  10329. /**
  10330. * Get the local position of a point that is in world space
  10331. * @param position The world position
  10332. * @param mesh The mesh that this bone is attached to
  10333. * @returns The local position
  10334. */
  10335. Bone.prototype.getLocalPositionFromAbsolute = function (position, mesh) {
  10336. if (mesh === void 0) { mesh = null; }
  10337. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10338. this.getLocalPositionFromAbsoluteToRef(position, mesh, result);
  10339. return result;
  10340. };
  10341. /**
  10342. * Get the local position of a point that is in world space and copy it to the result param
  10343. * @param position The world position
  10344. * @param mesh The mesh that this bone is attached to
  10345. * @param result The vector3 that the local position should be copied to
  10346. */
  10347. Bone.prototype.getLocalPositionFromAbsoluteToRef = function (position, mesh, result) {
  10348. if (mesh === void 0) { mesh = null; }
  10349. var wm = null;
  10350. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10351. if (mesh) {
  10352. wm = mesh.getWorldMatrix();
  10353. }
  10354. this._skeleton.computeAbsoluteTransforms();
  10355. var tmat = Bone._tmpMats[0];
  10356. tmat.copyFrom(this.getAbsoluteTransform());
  10357. if (mesh && wm) {
  10358. tmat.multiplyToRef(wm, tmat);
  10359. }
  10360. tmat.invert();
  10361. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10362. };
  10363. Bone._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  10364. Bone._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10365. Bone._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  10366. return Bone;
  10367. }(_node__WEBPACK_IMPORTED_MODULE_4__["Node"]));
  10368. /***/ }),
  10369. /***/ "./Bones/boneIKController.ts":
  10370. /*!***********************************!*\
  10371. !*** ./Bones/boneIKController.ts ***!
  10372. \***********************************/
  10373. /*! exports provided: BoneIKController */
  10374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10375. "use strict";
  10376. __webpack_require__.r(__webpack_exports__);
  10377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return BoneIKController; });
  10378. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10379. /**
  10380. * Class used to apply inverse kinematics to bones
  10381. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  10382. */
  10383. var BoneIKController = /** @class */ (function () {
  10384. /**
  10385. * Creates a new BoneIKController
  10386. * @param mesh defines the mesh to control
  10387. * @param bone defines the bone to control
  10388. * @param options defines options to set up the controller
  10389. */
  10390. function BoneIKController(mesh, bone, options) {
  10391. /**
  10392. * Gets or sets the target position
  10393. */
  10394. this.targetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10395. /**
  10396. * Gets or sets the pole target position
  10397. */
  10398. this.poleTargetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10399. /**
  10400. * Gets or sets the pole target local offset
  10401. */
  10402. this.poleTargetLocalOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10403. /**
  10404. * Gets or sets the pole angle
  10405. */
  10406. this.poleAngle = 0;
  10407. /**
  10408. * 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)
  10409. */
  10410. this.slerpAmount = 1;
  10411. this._bone1Quat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10412. this._bone1Mat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  10413. this._bone2Ang = Math.PI;
  10414. this._maxAngle = Math.PI;
  10415. this._rightHandedSystem = false;
  10416. this._bendAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right();
  10417. this._slerping = false;
  10418. this._adjustRoll = 0;
  10419. this._bone2 = bone;
  10420. this._bone1 = bone.getParent();
  10421. if (!this._bone1) {
  10422. return;
  10423. }
  10424. this.mesh = mesh;
  10425. var bonePos = bone.getPosition();
  10426. if (bone.getAbsoluteTransform().determinant() > 0) {
  10427. this._rightHandedSystem = true;
  10428. this._bendAxis.x = 0;
  10429. this._bendAxis.y = 0;
  10430. this._bendAxis.z = -1;
  10431. if (bonePos.x > bonePos.y && bonePos.x > bonePos.z) {
  10432. this._adjustRoll = Math.PI * .5;
  10433. this._bendAxis.z = 1;
  10434. }
  10435. }
  10436. if (this._bone1.length) {
  10437. var boneScale1 = this._bone1.getScale();
  10438. var boneScale2 = this._bone2.getScale();
  10439. this._bone1Length = this._bone1.length * boneScale1.y * this.mesh.scaling.y;
  10440. this._bone2Length = this._bone2.length * boneScale2.y * this.mesh.scaling.y;
  10441. }
  10442. else if (this._bone1.children[0]) {
  10443. mesh.computeWorldMatrix(true);
  10444. var pos1 = this._bone2.children[0].getAbsolutePosition(mesh);
  10445. var pos2 = this._bone2.getAbsolutePosition(mesh);
  10446. var pos3 = this._bone1.getAbsolutePosition(mesh);
  10447. this._bone1Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos1, pos2);
  10448. this._bone2Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos2, pos3);
  10449. }
  10450. this._bone1.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, mesh, this._bone1Mat);
  10451. this.maxAngle = Math.PI;
  10452. if (options) {
  10453. if (options.targetMesh) {
  10454. this.targetMesh = options.targetMesh;
  10455. this.targetMesh.computeWorldMatrix(true);
  10456. }
  10457. if (options.poleTargetMesh) {
  10458. this.poleTargetMesh = options.poleTargetMesh;
  10459. this.poleTargetMesh.computeWorldMatrix(true);
  10460. }
  10461. else if (options.poleTargetBone) {
  10462. this.poleTargetBone = options.poleTargetBone;
  10463. }
  10464. else if (this._bone1.getParent()) {
  10465. this.poleTargetBone = this._bone1.getParent();
  10466. }
  10467. if (options.poleTargetLocalOffset) {
  10468. this.poleTargetLocalOffset.copyFrom(options.poleTargetLocalOffset);
  10469. }
  10470. if (options.poleAngle) {
  10471. this.poleAngle = options.poleAngle;
  10472. }
  10473. if (options.bendAxis) {
  10474. this._bendAxis.copyFrom(options.bendAxis);
  10475. }
  10476. if (options.maxAngle) {
  10477. this.maxAngle = options.maxAngle;
  10478. }
  10479. if (options.slerpAmount) {
  10480. this.slerpAmount = options.slerpAmount;
  10481. }
  10482. }
  10483. }
  10484. Object.defineProperty(BoneIKController.prototype, "maxAngle", {
  10485. /**
  10486. * Gets or sets maximum allowed angle
  10487. */
  10488. get: function () {
  10489. return this._maxAngle;
  10490. },
  10491. set: function (value) {
  10492. this._setMaxAngle(value);
  10493. },
  10494. enumerable: true,
  10495. configurable: true
  10496. });
  10497. BoneIKController.prototype._setMaxAngle = function (ang) {
  10498. if (ang < 0) {
  10499. ang = 0;
  10500. }
  10501. if (ang > Math.PI || ang == undefined) {
  10502. ang = Math.PI;
  10503. }
  10504. this._maxAngle = ang;
  10505. var a = this._bone1Length;
  10506. var b = this._bone2Length;
  10507. this._maxReach = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(ang));
  10508. };
  10509. /**
  10510. * Force the controller to update the bones
  10511. */
  10512. BoneIKController.prototype.update = function () {
  10513. var bone1 = this._bone1;
  10514. if (!bone1) {
  10515. return;
  10516. }
  10517. var target = this.targetPosition;
  10518. var poleTarget = this.poleTargetPosition;
  10519. var mat1 = BoneIKController._tmpMats[0];
  10520. var mat2 = BoneIKController._tmpMats[1];
  10521. if (this.targetMesh) {
  10522. target.copyFrom(this.targetMesh.getAbsolutePosition());
  10523. }
  10524. if (this.poleTargetBone) {
  10525. this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, poleTarget);
  10526. }
  10527. else if (this.poleTargetMesh) {
  10528. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), poleTarget);
  10529. }
  10530. var bonePos = BoneIKController._tmpVecs[0];
  10531. var zaxis = BoneIKController._tmpVecs[1];
  10532. var xaxis = BoneIKController._tmpVecs[2];
  10533. var yaxis = BoneIKController._tmpVecs[3];
  10534. var upAxis = BoneIKController._tmpVecs[4];
  10535. var _tmpQuat = BoneIKController._tmpQuat;
  10536. bone1.getAbsolutePositionToRef(this.mesh, bonePos);
  10537. poleTarget.subtractToRef(bonePos, upAxis);
  10538. if (upAxis.x == 0 && upAxis.y == 0 && upAxis.z == 0) {
  10539. upAxis.y = 1;
  10540. }
  10541. else {
  10542. upAxis.normalize();
  10543. }
  10544. target.subtractToRef(bonePos, yaxis);
  10545. yaxis.normalize();
  10546. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, upAxis, zaxis);
  10547. zaxis.normalize();
  10548. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, zaxis, xaxis);
  10549. xaxis.normalize();
  10550. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, mat1);
  10551. var a = this._bone1Length;
  10552. var b = this._bone2Length;
  10553. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(bonePos, target);
  10554. if (this._maxReach > 0) {
  10555. c = Math.min(this._maxReach, c);
  10556. }
  10557. var acosa = (b * b + c * c - a * a) / (2 * b * c);
  10558. var acosb = (c * c + a * a - b * b) / (2 * c * a);
  10559. if (acosa > 1) {
  10560. acosa = 1;
  10561. }
  10562. if (acosb > 1) {
  10563. acosb = 1;
  10564. }
  10565. if (acosa < -1) {
  10566. acosa = -1;
  10567. }
  10568. if (acosb < -1) {
  10569. acosb = -1;
  10570. }
  10571. var angA = Math.acos(acosa);
  10572. var angB = Math.acos(acosb);
  10573. var angC = -angA - angB;
  10574. if (this._rightHandedSystem) {
  10575. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRollToRef(0, 0, this._adjustRoll, mat2);
  10576. mat2.multiplyToRef(mat1, mat1);
  10577. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(this._bendAxis, angB, mat2);
  10578. mat2.multiplyToRef(mat1, mat1);
  10579. }
  10580. else {
  10581. var _tmpVec = BoneIKController._tmpVecs[5];
  10582. _tmpVec.copyFrom(this._bendAxis);
  10583. _tmpVec.x *= -1;
  10584. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(_tmpVec, -angB, mat2);
  10585. mat2.multiplyToRef(mat1, mat1);
  10586. }
  10587. if (this.poleAngle) {
  10588. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(yaxis, this.poleAngle, mat2);
  10589. mat1.multiplyToRef(mat2, mat1);
  10590. }
  10591. if (this._bone1) {
  10592. if (this.slerpAmount < 1) {
  10593. if (!this._slerping) {
  10594. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat);
  10595. }
  10596. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(mat1, _tmpQuat);
  10597. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].SlerpToRef(this._bone1Quat, _tmpQuat, this.slerpAmount, this._bone1Quat);
  10598. angC = this._bone2Ang * (1.0 - this.slerpAmount) + angC * this.slerpAmount;
  10599. this._bone1.setRotationQuaternion(this._bone1Quat, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10600. this._slerping = true;
  10601. }
  10602. else {
  10603. this._bone1.setRotationMatrix(mat1, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10604. this._bone1Mat.copyFrom(mat1);
  10605. this._slerping = false;
  10606. }
  10607. }
  10608. this._bone2.setAxisAngle(this._bendAxis, angC, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].LOCAL);
  10609. this._bone2Ang = angC;
  10610. };
  10611. 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()];
  10612. BoneIKController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10613. BoneIKController._tmpMats = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity()];
  10614. return BoneIKController;
  10615. }());
  10616. /***/ }),
  10617. /***/ "./Bones/boneLookController.ts":
  10618. /*!*************************************!*\
  10619. !*** ./Bones/boneLookController.ts ***!
  10620. \*************************************/
  10621. /*! exports provided: BoneLookController */
  10622. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10623. "use strict";
  10624. __webpack_require__.r(__webpack_exports__);
  10625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return BoneLookController; });
  10626. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  10627. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10628. /**
  10629. * Class used to make a bone look toward a point in space
  10630. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  10631. */
  10632. var BoneLookController = /** @class */ (function () {
  10633. /**
  10634. * Create a BoneLookController
  10635. * @param mesh the mesh that the bone belongs to
  10636. * @param bone the bone that will be looking to the target
  10637. * @param target the target Vector3 to look at
  10638. * @param settings optional settings:
  10639. * * maxYaw: the maximum angle the bone will yaw to
  10640. * * minYaw: the minimum angle the bone will yaw to
  10641. * * maxPitch: the maximum angle the bone will pitch to
  10642. * * minPitch: the minimum angle the bone will yaw to
  10643. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  10644. * * upAxis: the up axis of the coordinate system
  10645. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  10646. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  10647. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  10648. * * adjustYaw: used to make an adjustment to the yaw of the bone
  10649. * * adjustPitch: used to make an adjustment to the pitch of the bone
  10650. * * adjustRoll: used to make an adjustment to the roll of the bone
  10651. **/
  10652. function BoneLookController(mesh, bone, target, options) {
  10653. /**
  10654. * The up axis of the coordinate system that is used when the bone is rotated
  10655. */
  10656. this.upAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up();
  10657. /**
  10658. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  10659. */
  10660. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  10661. /**
  10662. * Used to make an adjustment to the yaw of the bone
  10663. */
  10664. this.adjustYaw = 0;
  10665. /**
  10666. * Used to make an adjustment to the pitch of the bone
  10667. */
  10668. this.adjustPitch = 0;
  10669. /**
  10670. * Used to make an adjustment to the roll of the bone
  10671. */
  10672. this.adjustRoll = 0;
  10673. /**
  10674. * 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)
  10675. */
  10676. this.slerpAmount = 1;
  10677. this._boneQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10678. this._slerping = false;
  10679. this._firstFrameSkipped = false;
  10680. this._fowardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Forward();
  10681. this.mesh = mesh;
  10682. this.bone = bone;
  10683. this.target = target;
  10684. if (options) {
  10685. if (options.adjustYaw) {
  10686. this.adjustYaw = options.adjustYaw;
  10687. }
  10688. if (options.adjustPitch) {
  10689. this.adjustPitch = options.adjustPitch;
  10690. }
  10691. if (options.adjustRoll) {
  10692. this.adjustRoll = options.adjustRoll;
  10693. }
  10694. if (options.maxYaw != null) {
  10695. this.maxYaw = options.maxYaw;
  10696. }
  10697. else {
  10698. this.maxYaw = Math.PI;
  10699. }
  10700. if (options.minYaw != null) {
  10701. this.minYaw = options.minYaw;
  10702. }
  10703. else {
  10704. this.minYaw = -Math.PI;
  10705. }
  10706. if (options.maxPitch != null) {
  10707. this.maxPitch = options.maxPitch;
  10708. }
  10709. else {
  10710. this.maxPitch = Math.PI;
  10711. }
  10712. if (options.minPitch != null) {
  10713. this.minPitch = options.minPitch;
  10714. }
  10715. else {
  10716. this.minPitch = -Math.PI;
  10717. }
  10718. if (options.slerpAmount != null) {
  10719. this.slerpAmount = options.slerpAmount;
  10720. }
  10721. if (options.upAxis != null) {
  10722. this.upAxis = options.upAxis;
  10723. }
  10724. if (options.upAxisSpace != null) {
  10725. this.upAxisSpace = options.upAxisSpace;
  10726. }
  10727. if (options.yawAxis != null || options.pitchAxis != null) {
  10728. var newYawAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y;
  10729. var newPitchAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].X;
  10730. if (options.yawAxis != null) {
  10731. newYawAxis = options.yawAxis.clone();
  10732. newYawAxis.normalize();
  10733. }
  10734. if (options.pitchAxis != null) {
  10735. newPitchAxis = options.pitchAxis.clone();
  10736. newPitchAxis.normalize();
  10737. }
  10738. var newRollAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(newPitchAxis, newYawAxis);
  10739. this._transformYawPitch = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  10740. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(newPitchAxis, newYawAxis, newRollAxis, this._transformYawPitch);
  10741. this._transformYawPitchInv = this._transformYawPitch.clone();
  10742. this._transformYawPitch.invert();
  10743. }
  10744. }
  10745. if (!bone.getParent() && this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE) {
  10746. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  10747. }
  10748. }
  10749. Object.defineProperty(BoneLookController.prototype, "minYaw", {
  10750. /**
  10751. * Gets or sets the minimum yaw angle that the bone can look to
  10752. */
  10753. get: function () {
  10754. return this._minYaw;
  10755. },
  10756. set: function (value) {
  10757. this._minYaw = value;
  10758. this._minYawSin = Math.sin(value);
  10759. this._minYawCos = Math.cos(value);
  10760. if (this._maxYaw != null) {
  10761. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  10762. this._yawRange = this._maxYaw - this._minYaw;
  10763. }
  10764. },
  10765. enumerable: true,
  10766. configurable: true
  10767. });
  10768. Object.defineProperty(BoneLookController.prototype, "maxYaw", {
  10769. /**
  10770. * Gets or sets the maximum yaw angle that the bone can look to
  10771. */
  10772. get: function () {
  10773. return this._maxYaw;
  10774. },
  10775. set: function (value) {
  10776. this._maxYaw = value;
  10777. this._maxYawSin = Math.sin(value);
  10778. this._maxYawCos = Math.cos(value);
  10779. if (this._minYaw != null) {
  10780. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  10781. this._yawRange = this._maxYaw - this._minYaw;
  10782. }
  10783. },
  10784. enumerable: true,
  10785. configurable: true
  10786. });
  10787. Object.defineProperty(BoneLookController.prototype, "minPitch", {
  10788. /**
  10789. * Gets or sets the minimum pitch angle that the bone can look to
  10790. */
  10791. get: function () {
  10792. return this._minPitch;
  10793. },
  10794. set: function (value) {
  10795. this._minPitch = value;
  10796. this._minPitchTan = Math.tan(value);
  10797. },
  10798. enumerable: true,
  10799. configurable: true
  10800. });
  10801. Object.defineProperty(BoneLookController.prototype, "maxPitch", {
  10802. /**
  10803. * Gets or sets the maximum pitch angle that the bone can look to
  10804. */
  10805. get: function () {
  10806. return this._maxPitch;
  10807. },
  10808. set: function (value) {
  10809. this._maxPitch = value;
  10810. this._maxPitchTan = Math.tan(value);
  10811. },
  10812. enumerable: true,
  10813. configurable: true
  10814. });
  10815. /**
  10816. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  10817. */
  10818. BoneLookController.prototype.update = function () {
  10819. //skip the first frame when slerping so that the mesh rotation is correct
  10820. if (this.slerpAmount < 1 && !this._firstFrameSkipped) {
  10821. this._firstFrameSkipped = true;
  10822. return;
  10823. }
  10824. var bone = this.bone;
  10825. var bonePos = BoneLookController._tmpVecs[0];
  10826. bone.getAbsolutePositionToRef(this.mesh, bonePos);
  10827. var target = this.target;
  10828. var _tmpMat1 = BoneLookController._tmpMats[0];
  10829. var _tmpMat2 = BoneLookController._tmpMats[1];
  10830. var mesh = this.mesh;
  10831. var parentBone = bone.getParent();
  10832. var upAxis = BoneLookController._tmpVecs[1];
  10833. upAxis.copyFrom(this.upAxis);
  10834. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && parentBone) {
  10835. if (this._transformYawPitch) {
  10836. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(upAxis, this._transformYawPitchInv, upAxis);
  10837. }
  10838. parentBone.getDirectionToRef(upAxis, this.mesh, upAxis);
  10839. }
  10840. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10841. mesh.getDirectionToRef(upAxis, upAxis);
  10842. if (mesh.scaling.x != 1 || mesh.scaling.y != 1 || mesh.scaling.z != 1) {
  10843. upAxis.normalize();
  10844. }
  10845. }
  10846. var checkYaw = false;
  10847. var checkPitch = false;
  10848. if (this._maxYaw != Math.PI || this._minYaw != -Math.PI) {
  10849. checkYaw = true;
  10850. }
  10851. if (this._maxPitch != Math.PI || this._minPitch != -Math.PI) {
  10852. checkPitch = true;
  10853. }
  10854. if (checkYaw || checkPitch) {
  10855. var spaceMat = BoneLookController._tmpMats[2];
  10856. var spaceMatInv = BoneLookController._tmpMats[3];
  10857. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && upAxis.y == 1 && parentBone) {
  10858. parentBone.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, spaceMat);
  10859. }
  10860. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL && upAxis.y == 1 && !parentBone) {
  10861. spaceMat.copyFrom(mesh.getWorldMatrix());
  10862. }
  10863. else {
  10864. var forwardAxis = BoneLookController._tmpVecs[2];
  10865. forwardAxis.copyFrom(this._fowardAxis);
  10866. if (this._transformYawPitch) {
  10867. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(forwardAxis, this._transformYawPitchInv, forwardAxis);
  10868. }
  10869. if (parentBone) {
  10870. parentBone.getDirectionToRef(forwardAxis, this.mesh, forwardAxis);
  10871. }
  10872. else {
  10873. mesh.getDirectionToRef(forwardAxis, forwardAxis);
  10874. }
  10875. var rightAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(upAxis, forwardAxis);
  10876. rightAxis.normalize();
  10877. var forwardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(rightAxis, upAxis);
  10878. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(rightAxis, upAxis, forwardAxis, spaceMat);
  10879. }
  10880. spaceMat.invertToRef(spaceMatInv);
  10881. var xzlen = null;
  10882. if (checkPitch) {
  10883. var localTarget = BoneLookController._tmpVecs[3];
  10884. target.subtractToRef(bonePos, localTarget);
  10885. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  10886. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  10887. var pitch = Math.atan2(localTarget.y, xzlen);
  10888. var newPitch = pitch;
  10889. if (pitch > this._maxPitch) {
  10890. localTarget.y = this._maxPitchTan * xzlen;
  10891. newPitch = this._maxPitch;
  10892. }
  10893. else if (pitch < this._minPitch) {
  10894. localTarget.y = this._minPitchTan * xzlen;
  10895. newPitch = this._minPitch;
  10896. }
  10897. if (pitch != newPitch) {
  10898. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  10899. localTarget.addInPlace(bonePos);
  10900. target = localTarget;
  10901. }
  10902. }
  10903. if (checkYaw) {
  10904. var localTarget = BoneLookController._tmpVecs[4];
  10905. target.subtractToRef(bonePos, localTarget);
  10906. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  10907. var yaw = Math.atan2(localTarget.x, localTarget.z);
  10908. var newYaw = yaw;
  10909. if (yaw > this._maxYaw || yaw < this._minYaw) {
  10910. if (xzlen == null) {
  10911. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  10912. }
  10913. if (this._yawRange > Math.PI) {
  10914. if (this._isAngleBetween(yaw, this._maxYaw, this._midYawConstraint)) {
  10915. localTarget.z = this._maxYawCos * xzlen;
  10916. localTarget.x = this._maxYawSin * xzlen;
  10917. newYaw = this._maxYaw;
  10918. }
  10919. else if (this._isAngleBetween(yaw, this._midYawConstraint, this._minYaw)) {
  10920. localTarget.z = this._minYawCos * xzlen;
  10921. localTarget.x = this._minYawSin * xzlen;
  10922. newYaw = this._minYaw;
  10923. }
  10924. }
  10925. else {
  10926. if (yaw > this._maxYaw) {
  10927. localTarget.z = this._maxYawCos * xzlen;
  10928. localTarget.x = this._maxYawSin * xzlen;
  10929. newYaw = this._maxYaw;
  10930. }
  10931. else if (yaw < this._minYaw) {
  10932. localTarget.z = this._minYawCos * xzlen;
  10933. localTarget.x = this._minYawSin * xzlen;
  10934. newYaw = this._minYaw;
  10935. }
  10936. }
  10937. }
  10938. if (this._slerping && this._yawRange > Math.PI) {
  10939. //are we going to be crossing into the min/max region?
  10940. var boneFwd = BoneLookController._tmpVecs[8];
  10941. boneFwd.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Z);
  10942. if (this._transformYawPitch) {
  10943. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, this._transformYawPitchInv, boneFwd);
  10944. }
  10945. var boneRotMat = BoneLookController._tmpMats[4];
  10946. this._boneQuat.toRotationMatrix(boneRotMat);
  10947. this.mesh.getWorldMatrix().multiplyToRef(boneRotMat, boneRotMat);
  10948. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, boneRotMat, boneFwd);
  10949. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, spaceMatInv, boneFwd);
  10950. var boneYaw = Math.atan2(boneFwd.x, boneFwd.z);
  10951. var angBtwTar = this._getAngleBetween(boneYaw, yaw);
  10952. var angBtwMidYaw = this._getAngleBetween(boneYaw, this._midYawConstraint);
  10953. if (angBtwTar > angBtwMidYaw) {
  10954. if (xzlen == null) {
  10955. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  10956. }
  10957. var angBtwMax = this._getAngleBetween(boneYaw, this._maxYaw);
  10958. var angBtwMin = this._getAngleBetween(boneYaw, this._minYaw);
  10959. if (angBtwMin < angBtwMax) {
  10960. newYaw = boneYaw + Math.PI * .75;
  10961. localTarget.z = Math.cos(newYaw) * xzlen;
  10962. localTarget.x = Math.sin(newYaw) * xzlen;
  10963. }
  10964. else {
  10965. newYaw = boneYaw - Math.PI * .75;
  10966. localTarget.z = Math.cos(newYaw) * xzlen;
  10967. localTarget.x = Math.sin(newYaw) * xzlen;
  10968. }
  10969. }
  10970. }
  10971. if (yaw != newYaw) {
  10972. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  10973. localTarget.addInPlace(bonePos);
  10974. target = localTarget;
  10975. }
  10976. }
  10977. }
  10978. var zaxis = BoneLookController._tmpVecs[5];
  10979. var xaxis = BoneLookController._tmpVecs[6];
  10980. var yaxis = BoneLookController._tmpVecs[7];
  10981. var _tmpQuat = BoneLookController._tmpQuat;
  10982. target.subtractToRef(bonePos, zaxis);
  10983. zaxis.normalize();
  10984. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(upAxis, zaxis, xaxis);
  10985. xaxis.normalize();
  10986. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(zaxis, xaxis, yaxis);
  10987. yaxis.normalize();
  10988. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, _tmpMat1);
  10989. if (xaxis.x === 0 && xaxis.y === 0 && xaxis.z === 0) {
  10990. return;
  10991. }
  10992. if (yaxis.x === 0 && yaxis.y === 0 && yaxis.z === 0) {
  10993. return;
  10994. }
  10995. if (zaxis.x === 0 && zaxis.y === 0 && zaxis.z === 0) {
  10996. return;
  10997. }
  10998. if (this.adjustYaw || this.adjustPitch || this.adjustRoll) {
  10999. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, _tmpMat2);
  11000. _tmpMat2.multiplyToRef(_tmpMat1, _tmpMat1);
  11001. }
  11002. if (this.slerpAmount < 1) {
  11003. if (!this._slerping) {
  11004. this.bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, this._boneQuat);
  11005. }
  11006. if (this._transformYawPitch) {
  11007. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11008. }
  11009. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(_tmpMat1, _tmpQuat);
  11010. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].SlerpToRef(this._boneQuat, _tmpQuat, this.slerpAmount, this._boneQuat);
  11011. this.bone.setRotationQuaternion(this._boneQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11012. this._slerping = true;
  11013. }
  11014. else {
  11015. if (this._transformYawPitch) {
  11016. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11017. }
  11018. this.bone.setRotationMatrix(_tmpMat1, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11019. this._slerping = false;
  11020. }
  11021. };
  11022. BoneLookController.prototype._getAngleDiff = function (ang1, ang2) {
  11023. var angDiff = ang2 - ang1;
  11024. angDiff %= Math.PI * 2;
  11025. if (angDiff > Math.PI) {
  11026. angDiff -= Math.PI * 2;
  11027. }
  11028. else if (angDiff < -Math.PI) {
  11029. angDiff += Math.PI * 2;
  11030. }
  11031. return angDiff;
  11032. };
  11033. BoneLookController.prototype._getAngleBetween = function (ang1, ang2) {
  11034. ang1 %= (2 * Math.PI);
  11035. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11036. ang2 %= (2 * Math.PI);
  11037. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11038. var ab = 0;
  11039. if (ang1 < ang2) {
  11040. ab = ang2 - ang1;
  11041. }
  11042. else {
  11043. ab = ang1 - ang2;
  11044. }
  11045. if (ab > Math.PI) {
  11046. ab = Math.PI * 2 - ab;
  11047. }
  11048. return ab;
  11049. };
  11050. BoneLookController.prototype._isAngleBetween = function (ang, ang1, ang2) {
  11051. ang %= (2 * Math.PI);
  11052. ang = (ang < 0) ? ang + (2 * Math.PI) : ang;
  11053. ang1 %= (2 * Math.PI);
  11054. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11055. ang2 %= (2 * Math.PI);
  11056. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11057. if (ang1 < ang2) {
  11058. if (ang > ang1 && ang < ang2) {
  11059. return true;
  11060. }
  11061. }
  11062. else {
  11063. if (ang > ang2 && ang < ang1) {
  11064. return true;
  11065. }
  11066. }
  11067. return false;
  11068. };
  11069. BoneLookController._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(10, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  11070. BoneLookController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11071. BoneLookController._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  11072. return BoneLookController;
  11073. }());
  11074. /***/ }),
  11075. /***/ "./Bones/index.ts":
  11076. /*!************************!*\
  11077. !*** ./Bones/index.ts ***!
  11078. \************************/
  11079. /*! exports provided: Bone, BoneIKController, BoneLookController, Skeleton */
  11080. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11081. "use strict";
  11082. __webpack_require__.r(__webpack_exports__);
  11083. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  11085. /* harmony import */ var _boneIKController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneIKController */ "./Bones/boneIKController.ts");
  11086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _boneIKController__WEBPACK_IMPORTED_MODULE_1__["BoneIKController"]; });
  11087. /* harmony import */ var _boneLookController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boneLookController */ "./Bones/boneLookController.ts");
  11088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _boneLookController__WEBPACK_IMPORTED_MODULE_2__["BoneLookController"]; });
  11089. /* harmony import */ var _skeleton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./skeleton */ "./Bones/skeleton.ts");
  11090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _skeleton__WEBPACK_IMPORTED_MODULE_3__["Skeleton"]; });
  11091. /***/ }),
  11092. /***/ "./Bones/skeleton.ts":
  11093. /*!***************************!*\
  11094. !*** ./Bones/skeleton.ts ***!
  11095. \***************************/
  11096. /*! exports provided: Skeleton */
  11097. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11098. "use strict";
  11099. __webpack_require__.r(__webpack_exports__);
  11100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return Skeleton; });
  11101. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11102. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  11103. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  11104. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  11105. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  11106. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  11107. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  11108. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  11109. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  11110. /**
  11111. * Class used to handle skinning animations
  11112. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  11113. */
  11114. var Skeleton = /** @class */ (function () {
  11115. /**
  11116. * Creates a new skeleton
  11117. * @param name defines the skeleton name
  11118. * @param id defines the skeleton Id
  11119. * @param scene defines the hosting scene
  11120. */
  11121. function Skeleton(
  11122. /** defines the skeleton name */
  11123. name,
  11124. /** defines the skeleton Id */
  11125. id, scene) {
  11126. this.name = name;
  11127. this.id = id;
  11128. /**
  11129. * Defines the list of child bones
  11130. */
  11131. this.bones = new Array();
  11132. /**
  11133. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  11134. */
  11135. this.needInitialSkinMatrix = false;
  11136. /**
  11137. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  11138. */
  11139. this.overrideMesh = null;
  11140. this._isDirty = true;
  11141. this._meshesWithPoseMatrix = new Array();
  11142. this._identity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  11143. this._ranges = {};
  11144. this._lastAbsoluteTransformsUpdateId = -1;
  11145. this._canUseTextureForBones = false;
  11146. /** @hidden */
  11147. this._numBonesWithLinkedTransformNode = 0;
  11148. /**
  11149. * Specifies if the skeleton should be serialized
  11150. */
  11151. this.doNotSerialize = false;
  11152. /**
  11153. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  11154. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  11155. */
  11156. this.useTextureToStoreBoneMatrices = true;
  11157. this._animationPropertiesOverride = null;
  11158. // Events
  11159. /**
  11160. * An observable triggered before computing the skeleton's matrices
  11161. */
  11162. this.onBeforeComputeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11163. this.bones = [];
  11164. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  11165. this._scene.skeletons.push(this);
  11166. //make sure it will recalculate the matrix next time prepare is called.
  11167. this._isDirty = true;
  11168. var engineCaps = this._scene.getEngine().getCaps();
  11169. this._canUseTextureForBones = engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0;
  11170. }
  11171. Object.defineProperty(Skeleton.prototype, "animationPropertiesOverride", {
  11172. /**
  11173. * Gets or sets the animation properties override
  11174. */
  11175. get: function () {
  11176. if (!this._animationPropertiesOverride) {
  11177. return this._scene.animationPropertiesOverride;
  11178. }
  11179. return this._animationPropertiesOverride;
  11180. },
  11181. set: function (value) {
  11182. this._animationPropertiesOverride = value;
  11183. },
  11184. enumerable: true,
  11185. configurable: true
  11186. });
  11187. Object.defineProperty(Skeleton.prototype, "isUsingTextureForMatrices", {
  11188. /**
  11189. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  11190. */
  11191. get: function () {
  11192. return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones && !this.needInitialSkinMatrix;
  11193. },
  11194. enumerable: true,
  11195. configurable: true
  11196. });
  11197. // Members
  11198. /**
  11199. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  11200. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  11201. * @returns a Float32Array containing matrices data
  11202. */
  11203. Skeleton.prototype.getTransformMatrices = function (mesh) {
  11204. if (this.needInitialSkinMatrix && mesh._bonesTransformMatrices) {
  11205. return mesh._bonesTransformMatrices;
  11206. }
  11207. if (!this._transformMatrices) {
  11208. this.prepare();
  11209. }
  11210. return this._transformMatrices;
  11211. };
  11212. /**
  11213. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  11214. * @returns a raw texture containing the data
  11215. */
  11216. Skeleton.prototype.getTransformMatrixTexture = function () {
  11217. return this._transformMatrixTexture;
  11218. };
  11219. /**
  11220. * Gets the current hosting scene
  11221. * @returns a scene object
  11222. */
  11223. Skeleton.prototype.getScene = function () {
  11224. return this._scene;
  11225. };
  11226. // Methods
  11227. /**
  11228. * Gets a string representing the current skeleton data
  11229. * @param fullDetails defines a boolean indicating if we want a verbose version
  11230. * @returns a string representing the current skeleton data
  11231. */
  11232. Skeleton.prototype.toString = function (fullDetails) {
  11233. var ret = "Name: " + this.name + ", nBones: " + this.bones.length;
  11234. ret += ", nAnimationRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  11235. if (fullDetails) {
  11236. ret += ", Ranges: {";
  11237. var first = true;
  11238. for (var name_1 in this._ranges) {
  11239. if (first) {
  11240. ret += ", ";
  11241. first = false;
  11242. }
  11243. ret += name_1;
  11244. }
  11245. ret += "}";
  11246. }
  11247. return ret;
  11248. };
  11249. /**
  11250. * Get bone's index searching by name
  11251. * @param name defines bone's name to search for
  11252. * @return the indice of the bone. Returns -1 if not found
  11253. */
  11254. Skeleton.prototype.getBoneIndexByName = function (name) {
  11255. for (var boneIndex = 0, cache = this.bones.length; boneIndex < cache; boneIndex++) {
  11256. if (this.bones[boneIndex].name === name) {
  11257. return boneIndex;
  11258. }
  11259. }
  11260. return -1;
  11261. };
  11262. /**
  11263. * Creater a new animation range
  11264. * @param name defines the name of the range
  11265. * @param from defines the start key
  11266. * @param to defines the end key
  11267. */
  11268. Skeleton.prototype.createAnimationRange = function (name, from, to) {
  11269. // check name not already in use
  11270. if (!this._ranges[name]) {
  11271. this._ranges[name] = new _Animations_animation__WEBPACK_IMPORTED_MODULE_4__["AnimationRange"](name, from, to);
  11272. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11273. if (this.bones[i].animations[0]) {
  11274. this.bones[i].animations[0].createRange(name, from, to);
  11275. }
  11276. }
  11277. }
  11278. };
  11279. /**
  11280. * Delete a specific animation range
  11281. * @param name defines the name of the range
  11282. * @param deleteFrames defines if frames must be removed as well
  11283. */
  11284. Skeleton.prototype.deleteAnimationRange = function (name, deleteFrames) {
  11285. if (deleteFrames === void 0) { deleteFrames = true; }
  11286. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11287. if (this.bones[i].animations[0]) {
  11288. this.bones[i].animations[0].deleteRange(name, deleteFrames);
  11289. }
  11290. }
  11291. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  11292. };
  11293. /**
  11294. * Gets a specific animation range
  11295. * @param name defines the name of the range to look for
  11296. * @returns the requested animation range or null if not found
  11297. */
  11298. Skeleton.prototype.getAnimationRange = function (name) {
  11299. return this._ranges[name];
  11300. };
  11301. /**
  11302. * Gets the list of all animation ranges defined on this skeleton
  11303. * @returns an array
  11304. */
  11305. Skeleton.prototype.getAnimationRanges = function () {
  11306. var animationRanges = [];
  11307. var name;
  11308. var i = 0;
  11309. for (name in this._ranges) {
  11310. animationRanges[i] = this._ranges[name];
  11311. i++;
  11312. }
  11313. return animationRanges;
  11314. };
  11315. /**
  11316. * Copy animation range from a source skeleton.
  11317. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  11318. * @param source defines the source skeleton
  11319. * @param name defines the name of the range to copy
  11320. * @param rescaleAsRequired defines if rescaling must be applied if required
  11321. * @returns true if operation was successful
  11322. */
  11323. Skeleton.prototype.copyAnimationRange = function (source, name, rescaleAsRequired) {
  11324. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  11325. if (this._ranges[name] || !source.getAnimationRange(name)) {
  11326. return false;
  11327. }
  11328. var ret = true;
  11329. var frameOffset = this._getHighestAnimationFrame() + 1;
  11330. // make a dictionary of source skeleton's bones, so exact same order or doublely nested loop is not required
  11331. var boneDict = {};
  11332. var sourceBones = source.bones;
  11333. var nBones;
  11334. var i;
  11335. for (i = 0, nBones = sourceBones.length; i < nBones; i++) {
  11336. boneDict[sourceBones[i].name] = sourceBones[i];
  11337. }
  11338. if (this.bones.length !== sourceBones.length) {
  11339. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + sourceBones.length);
  11340. ret = false;
  11341. }
  11342. var skelDimensionsRatio = (rescaleAsRequired && this.dimensionsAtRest && source.dimensionsAtRest) ? this.dimensionsAtRest.divide(source.dimensionsAtRest) : null;
  11343. for (i = 0, nBones = this.bones.length; i < nBones; i++) {
  11344. var boneName = this.bones[i].name;
  11345. var sourceBone = boneDict[boneName];
  11346. if (sourceBone) {
  11347. ret = ret && this.bones[i].copyAnimationRange(sourceBone, name, frameOffset, rescaleAsRequired, skelDimensionsRatio);
  11348. }
  11349. else {
  11350. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn("copyAnimationRange: not same rig, missing source bone " + boneName);
  11351. ret = false;
  11352. }
  11353. }
  11354. // do not call createAnimationRange(), since it also is done to bones, which was already done
  11355. var range = source.getAnimationRange(name);
  11356. if (range) {
  11357. this._ranges[name] = new _Animations_animation__WEBPACK_IMPORTED_MODULE_4__["AnimationRange"](name, range.from + frameOffset, range.to + frameOffset);
  11358. }
  11359. return ret;
  11360. };
  11361. /**
  11362. * Forces the skeleton to go to rest pose
  11363. */
  11364. Skeleton.prototype.returnToRest = function () {
  11365. for (var index = 0; index < this.bones.length; index++) {
  11366. this.bones[index].returnToRest();
  11367. }
  11368. };
  11369. Skeleton.prototype._getHighestAnimationFrame = function () {
  11370. var ret = 0;
  11371. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11372. if (this.bones[i].animations[0]) {
  11373. var highest = this.bones[i].animations[0].getHighestFrame();
  11374. if (ret < highest) {
  11375. ret = highest;
  11376. }
  11377. }
  11378. }
  11379. return ret;
  11380. };
  11381. /**
  11382. * Begin a specific animation range
  11383. * @param name defines the name of the range to start
  11384. * @param loop defines if looping must be turned on (false by default)
  11385. * @param speedRatio defines the speed ratio to apply (1 by default)
  11386. * @param onAnimationEnd defines a callback which will be called when animation will end
  11387. * @returns a new animatable
  11388. */
  11389. Skeleton.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  11390. var range = this.getAnimationRange(name);
  11391. if (!range) {
  11392. return null;
  11393. }
  11394. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  11395. };
  11396. /** @hidden */
  11397. Skeleton.prototype._markAsDirty = function () {
  11398. this._isDirty = true;
  11399. };
  11400. /** @hidden */
  11401. Skeleton.prototype._registerMeshWithPoseMatrix = function (mesh) {
  11402. this._meshesWithPoseMatrix.push(mesh);
  11403. };
  11404. /** @hidden */
  11405. Skeleton.prototype._unregisterMeshWithPoseMatrix = function (mesh) {
  11406. var index = this._meshesWithPoseMatrix.indexOf(mesh);
  11407. if (index > -1) {
  11408. this._meshesWithPoseMatrix.splice(index, 1);
  11409. }
  11410. };
  11411. Skeleton.prototype._computeTransformMatrices = function (targetMatrix, initialSkinMatrix) {
  11412. this.onBeforeComputeObservable.notifyObservers(this);
  11413. for (var index = 0; index < this.bones.length; index++) {
  11414. var bone = this.bones[index];
  11415. var parentBone = bone.getParent();
  11416. if (parentBone) {
  11417. bone.getLocalMatrix().multiplyToRef(parentBone.getWorldMatrix(), bone.getWorldMatrix());
  11418. }
  11419. else {
  11420. if (initialSkinMatrix) {
  11421. bone.getLocalMatrix().multiplyToRef(initialSkinMatrix, bone.getWorldMatrix());
  11422. }
  11423. else {
  11424. bone.getWorldMatrix().copyFrom(bone.getLocalMatrix());
  11425. }
  11426. }
  11427. if (bone._index !== -1) {
  11428. var mappedIndex = bone._index === null ? index : bone._index;
  11429. bone.getInvertedAbsoluteTransform().multiplyToArray(bone.getWorldMatrix(), targetMatrix, mappedIndex * 16);
  11430. }
  11431. }
  11432. this._identity.copyToArray(targetMatrix, this.bones.length * 16);
  11433. };
  11434. /**
  11435. * Build all resources required to render a skeleton
  11436. */
  11437. Skeleton.prototype.prepare = function () {
  11438. // Update the local matrix of bones with linked transform nodes.
  11439. if (this._numBonesWithLinkedTransformNode > 0) {
  11440. for (var _i = 0, _a = this.bones; _i < _a.length; _i++) {
  11441. var bone_1 = _a[_i];
  11442. if (bone_1._linkedTransformNode) {
  11443. // Computing the world matrix also computes the local matrix.
  11444. bone_1._linkedTransformNode.computeWorldMatrix();
  11445. bone_1._matrix = bone_1._linkedTransformNode._localMatrix;
  11446. bone_1.markAsDirty();
  11447. }
  11448. }
  11449. }
  11450. if (!this._isDirty) {
  11451. return;
  11452. }
  11453. if (this.needInitialSkinMatrix) {
  11454. for (var index = 0; index < this._meshesWithPoseMatrix.length; index++) {
  11455. var mesh = this._meshesWithPoseMatrix[index];
  11456. var poseMatrix = mesh.getPoseMatrix();
  11457. if (!mesh._bonesTransformMatrices || mesh._bonesTransformMatrices.length !== 16 * (this.bones.length + 1)) {
  11458. mesh._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11459. }
  11460. if (this._synchronizedWithMesh !== mesh) {
  11461. this._synchronizedWithMesh = mesh;
  11462. // Prepare bones
  11463. for (var boneIndex = 0; boneIndex < this.bones.length; boneIndex++) {
  11464. var bone = this.bones[boneIndex];
  11465. if (!bone.getParent()) {
  11466. var matrix = bone.getBaseMatrix();
  11467. matrix.multiplyToRef(poseMatrix, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11468. bone._updateDifferenceMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11469. }
  11470. }
  11471. }
  11472. this._computeTransformMatrices(mesh._bonesTransformMatrices, poseMatrix);
  11473. }
  11474. }
  11475. else {
  11476. if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
  11477. this._transformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11478. if (this.isUsingTextureForMatrices) {
  11479. if (this._transformMatrixTexture) {
  11480. this._transformMatrixTexture.dispose();
  11481. }
  11482. 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_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT);
  11483. }
  11484. }
  11485. this._computeTransformMatrices(this._transformMatrices, null);
  11486. if (this.isUsingTextureForMatrices && this._transformMatrixTexture) {
  11487. this._transformMatrixTexture.update(this._transformMatrices);
  11488. }
  11489. }
  11490. this._isDirty = false;
  11491. this._scene._activeBones.addCount(this.bones.length, false);
  11492. };
  11493. /**
  11494. * Gets the list of animatables currently running for this skeleton
  11495. * @returns an array of animatables
  11496. */
  11497. Skeleton.prototype.getAnimatables = function () {
  11498. if (!this._animatables || this._animatables.length !== this.bones.length) {
  11499. this._animatables = [];
  11500. for (var index = 0; index < this.bones.length; index++) {
  11501. this._animatables.push(this.bones[index]);
  11502. }
  11503. }
  11504. return this._animatables;
  11505. };
  11506. /**
  11507. * Clone the current skeleton
  11508. * @param name defines the name of the new skeleton
  11509. * @param id defines the id of the enw skeleton
  11510. * @returns the new skeleton
  11511. */
  11512. Skeleton.prototype.clone = function (name, id) {
  11513. var result = new Skeleton(name, id || name, this._scene);
  11514. result.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11515. for (var index = 0; index < this.bones.length; index++) {
  11516. var source = this.bones[index];
  11517. var parentBone = null;
  11518. var parent_1 = source.getParent();
  11519. if (parent_1) {
  11520. var parentIndex = this.bones.indexOf(parent_1);
  11521. parentBone = result.bones[parentIndex];
  11522. }
  11523. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](source.name, result, parentBone, source.getBaseMatrix().clone(), source.getRestPose().clone());
  11524. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_8__["DeepCopier"].DeepCopy(source.animations, bone.animations);
  11525. }
  11526. if (this._ranges) {
  11527. result._ranges = {};
  11528. for (var rangeName in this._ranges) {
  11529. var range = this._ranges[rangeName];
  11530. if (range) {
  11531. result._ranges[rangeName] = range.clone();
  11532. }
  11533. }
  11534. }
  11535. this._isDirty = true;
  11536. return result;
  11537. };
  11538. /**
  11539. * Enable animation blending for this skeleton
  11540. * @param blendingSpeed defines the blending speed to apply
  11541. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  11542. */
  11543. Skeleton.prototype.enableBlending = function (blendingSpeed) {
  11544. if (blendingSpeed === void 0) { blendingSpeed = 0.01; }
  11545. this.bones.forEach(function (bone) {
  11546. bone.animations.forEach(function (animation) {
  11547. animation.enableBlending = true;
  11548. animation.blendingSpeed = blendingSpeed;
  11549. });
  11550. });
  11551. };
  11552. /**
  11553. * Releases all resources associated with the current skeleton
  11554. */
  11555. Skeleton.prototype.dispose = function () {
  11556. this._meshesWithPoseMatrix = [];
  11557. // Animations
  11558. this.getScene().stopAnimation(this);
  11559. // Remove from scene
  11560. this.getScene().removeSkeleton(this);
  11561. if (this._transformMatrixTexture) {
  11562. this._transformMatrixTexture.dispose();
  11563. this._transformMatrixTexture = null;
  11564. }
  11565. };
  11566. /**
  11567. * Serialize the skeleton in a JSON object
  11568. * @returns a JSON object
  11569. */
  11570. Skeleton.prototype.serialize = function () {
  11571. var serializationObject = {};
  11572. serializationObject.name = this.name;
  11573. serializationObject.id = this.id;
  11574. if (this.dimensionsAtRest) {
  11575. serializationObject.dimensionsAtRest = this.dimensionsAtRest.asArray();
  11576. }
  11577. serializationObject.bones = [];
  11578. serializationObject.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11579. for (var index = 0; index < this.bones.length; index++) {
  11580. var bone = this.bones[index];
  11581. var parent_2 = bone.getParent();
  11582. var serializedBone = {
  11583. parentBoneIndex: parent_2 ? this.bones.indexOf(parent_2) : -1,
  11584. name: bone.name,
  11585. matrix: bone.getBaseMatrix().toArray(),
  11586. rest: bone.getRestPose().toArray()
  11587. };
  11588. serializationObject.bones.push(serializedBone);
  11589. if (bone.length) {
  11590. serializedBone.length = bone.length;
  11591. }
  11592. if (bone.metadata) {
  11593. serializedBone.metadata = bone.metadata;
  11594. }
  11595. if (bone.animations && bone.animations.length > 0) {
  11596. serializedBone.animation = bone.animations[0].serialize();
  11597. }
  11598. serializationObject.ranges = [];
  11599. for (var name in this._ranges) {
  11600. var source = this._ranges[name];
  11601. if (!source) {
  11602. continue;
  11603. }
  11604. var range = {};
  11605. range.name = name;
  11606. range.from = source.from;
  11607. range.to = source.to;
  11608. serializationObject.ranges.push(range);
  11609. }
  11610. }
  11611. return serializationObject;
  11612. };
  11613. /**
  11614. * Creates a new skeleton from serialized data
  11615. * @param parsedSkeleton defines the serialized data
  11616. * @param scene defines the hosting scene
  11617. * @returns a new skeleton
  11618. */
  11619. Skeleton.Parse = function (parsedSkeleton, scene) {
  11620. var skeleton = new Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
  11621. if (parsedSkeleton.dimensionsAtRest) {
  11622. skeleton.dimensionsAtRest = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSkeleton.dimensionsAtRest);
  11623. }
  11624. skeleton.needInitialSkinMatrix = parsedSkeleton.needInitialSkinMatrix;
  11625. var index;
  11626. for (index = 0; index < parsedSkeleton.bones.length; index++) {
  11627. var parsedBone = parsedSkeleton.bones[index];
  11628. var parentBone = null;
  11629. if (parsedBone.parentBoneIndex > -1) {
  11630. parentBone = skeleton.bones[parsedBone.parentBoneIndex];
  11631. }
  11632. var rest = parsedBone.rest ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.rest) : null;
  11633. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](parsedBone.name, skeleton, parentBone, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.matrix), rest);
  11634. if (parsedBone.id !== undefined && parsedBone.id !== null) {
  11635. bone.id = parsedBone.id;
  11636. }
  11637. if (parsedBone.length) {
  11638. bone.length = parsedBone.length;
  11639. }
  11640. if (parsedBone.metadata) {
  11641. bone.metadata = parsedBone.metadata;
  11642. }
  11643. if (parsedBone.animation) {
  11644. bone.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].Parse(parsedBone.animation));
  11645. }
  11646. }
  11647. // placed after bones, so createAnimationRange can cascade down
  11648. if (parsedSkeleton.ranges) {
  11649. for (index = 0; index < parsedSkeleton.ranges.length; index++) {
  11650. var data = parsedSkeleton.ranges[index];
  11651. skeleton.createAnimationRange(data.name, data.from, data.to);
  11652. }
  11653. }
  11654. return skeleton;
  11655. };
  11656. /**
  11657. * Compute all node absolute transforms
  11658. * @param forceUpdate defines if computation must be done even if cache is up to date
  11659. */
  11660. Skeleton.prototype.computeAbsoluteTransforms = function (forceUpdate) {
  11661. if (forceUpdate === void 0) { forceUpdate = false; }
  11662. var renderId = this._scene.getRenderId();
  11663. if (this._lastAbsoluteTransformsUpdateId != renderId || forceUpdate) {
  11664. this.bones[0].computeAbsoluteTransforms();
  11665. this._lastAbsoluteTransformsUpdateId = renderId;
  11666. }
  11667. };
  11668. /**
  11669. * Gets the root pose matrix
  11670. * @returns a matrix
  11671. */
  11672. Skeleton.prototype.getPoseMatrix = function () {
  11673. var poseMatrix = null;
  11674. if (this._meshesWithPoseMatrix.length > 0) {
  11675. poseMatrix = this._meshesWithPoseMatrix[0].getPoseMatrix();
  11676. }
  11677. return poseMatrix;
  11678. };
  11679. /**
  11680. * Sorts bones per internal index
  11681. */
  11682. Skeleton.prototype.sortBones = function () {
  11683. var bones = new Array();
  11684. var visited = new Array(this.bones.length);
  11685. for (var index = 0; index < this.bones.length; index++) {
  11686. this._sortBones(index, bones, visited);
  11687. }
  11688. this.bones = bones;
  11689. };
  11690. Skeleton.prototype._sortBones = function (index, bones, visited) {
  11691. if (visited[index]) {
  11692. return;
  11693. }
  11694. visited[index] = true;
  11695. var bone = this.bones[index];
  11696. if (bone._index === undefined) {
  11697. bone._index = index;
  11698. }
  11699. var parentBone = bone.getParent();
  11700. if (parentBone) {
  11701. this._sortBones(this.bones.indexOf(parentBone), bones, visited);
  11702. }
  11703. bones.push(bone);
  11704. };
  11705. return Skeleton;
  11706. }());
  11707. /***/ }),
  11708. /***/ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts":
  11709. /*!*******************************************************!*\
  11710. !*** ./Cameras/Inputs/arcRotateCameraGamepadInput.ts ***!
  11711. \*******************************************************/
  11712. /*! exports provided: ArcRotateCameraGamepadInput */
  11713. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11714. "use strict";
  11715. __webpack_require__.r(__webpack_exports__);
  11716. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return ArcRotateCameraGamepadInput; });
  11717. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  11718. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  11719. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  11720. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  11721. /**
  11722. * Manage the gamepad inputs to control an arc rotate camera.
  11723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11724. */
  11725. var ArcRotateCameraGamepadInput = /** @class */ (function () {
  11726. function ArcRotateCameraGamepadInput() {
  11727. /**
  11728. * Defines the gamepad rotation sensiblity.
  11729. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  11730. */
  11731. this.gamepadRotationSensibility = 80;
  11732. /**
  11733. * Defines the gamepad move sensiblity.
  11734. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  11735. */
  11736. this.gamepadMoveSensibility = 40;
  11737. }
  11738. /**
  11739. * Attach the input controls to a specific dom element to get the input from.
  11740. * @param element Defines the element the controls should be listened from
  11741. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11742. */
  11743. ArcRotateCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  11744. var _this = this;
  11745. var manager = this.camera.getScene().gamepadManager;
  11746. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  11747. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].POSE_ENABLED) {
  11748. // prioritize XBOX gamepads.
  11749. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX) {
  11750. _this.gamepad = gamepad;
  11751. }
  11752. }
  11753. });
  11754. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  11755. if (_this.gamepad === gamepad) {
  11756. _this.gamepad = null;
  11757. }
  11758. });
  11759. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX);
  11760. };
  11761. /**
  11762. * Detach the current controls from the specified dom element.
  11763. * @param element Defines the element to stop listening the inputs from
  11764. */
  11765. ArcRotateCameraGamepadInput.prototype.detachControl = function (element) {
  11766. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  11767. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  11768. this.gamepad = null;
  11769. };
  11770. /**
  11771. * Update the current camera state depending on the inputs that have been used this frame.
  11772. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11773. */
  11774. ArcRotateCameraGamepadInput.prototype.checkInputs = function () {
  11775. if (this.gamepad) {
  11776. var camera = this.camera;
  11777. var RSValues = this.gamepad.rightStick;
  11778. if (RSValues) {
  11779. if (RSValues.x != 0) {
  11780. var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
  11781. if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
  11782. camera.inertialAlphaOffset += normalizedRX;
  11783. }
  11784. }
  11785. if (RSValues.y != 0) {
  11786. var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
  11787. if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
  11788. camera.inertialBetaOffset += normalizedRY;
  11789. }
  11790. }
  11791. }
  11792. var LSValues = this.gamepad.leftStick;
  11793. if (LSValues && LSValues.y != 0) {
  11794. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  11795. if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {
  11796. this.camera.inertialRadiusOffset -= normalizedLY;
  11797. }
  11798. }
  11799. }
  11800. };
  11801. /**
  11802. * Gets the class name of the current intput.
  11803. * @returns the class name
  11804. */
  11805. ArcRotateCameraGamepadInput.prototype.getClassName = function () {
  11806. return "ArcRotateCameraGamepadInput";
  11807. };
  11808. /**
  11809. * Get the friendly name associated with the input class.
  11810. * @returns the input friendly name
  11811. */
  11812. ArcRotateCameraGamepadInput.prototype.getSimpleName = function () {
  11813. return "gamepad";
  11814. };
  11815. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  11816. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11817. ], ArcRotateCameraGamepadInput.prototype, "gamepadRotationSensibility", void 0);
  11818. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  11819. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11820. ], ArcRotateCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  11821. return ArcRotateCameraGamepadInput;
  11822. }());
  11823. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraGamepadInput"] = ArcRotateCameraGamepadInput;
  11824. /***/ }),
  11825. /***/ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts":
  11826. /*!************************************************************!*\
  11827. !*** ./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts ***!
  11828. \************************************************************/
  11829. /*! exports provided: ArcRotateCameraKeyboardMoveInput */
  11830. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11831. "use strict";
  11832. __webpack_require__.r(__webpack_exports__);
  11833. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return ArcRotateCameraKeyboardMoveInput; });
  11834. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  11835. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  11836. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  11837. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  11838. /**
  11839. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  11840. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11841. */
  11842. var ArcRotateCameraKeyboardMoveInput = /** @class */ (function () {
  11843. function ArcRotateCameraKeyboardMoveInput() {
  11844. /**
  11845. * Defines the list of key codes associated with the up action (increase alpha)
  11846. */
  11847. this.keysUp = [38];
  11848. /**
  11849. * Defines the list of key codes associated with the down action (decrease alpha)
  11850. */
  11851. this.keysDown = [40];
  11852. /**
  11853. * Defines the list of key codes associated with the left action (increase beta)
  11854. */
  11855. this.keysLeft = [37];
  11856. /**
  11857. * Defines the list of key codes associated with the right action (decrease beta)
  11858. */
  11859. this.keysRight = [39];
  11860. /**
  11861. * Defines the list of key codes associated with the reset action.
  11862. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  11863. */
  11864. this.keysReset = [220];
  11865. /**
  11866. * Defines the panning sensibility of the inputs.
  11867. * (How fast is the camera paning)
  11868. */
  11869. this.panningSensibility = 50.0;
  11870. /**
  11871. * Defines the zooming sensibility of the inputs.
  11872. * (How fast is the camera zooming)
  11873. */
  11874. this.zoomingSensibility = 25.0;
  11875. /**
  11876. * Defines wether maintaining the alt key down switch the movement mode from
  11877. * orientation to zoom.
  11878. */
  11879. this.useAltToZoom = true;
  11880. /**
  11881. * Rotation speed of the camera
  11882. */
  11883. this.angularSpeed = 0.01;
  11884. this._keys = new Array();
  11885. }
  11886. /**
  11887. * Attach the input controls to a specific dom element to get the input from.
  11888. * @param element Defines the element the controls should be listened from
  11889. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11890. */
  11891. ArcRotateCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  11892. var _this = this;
  11893. if (this._onCanvasBlurObserver) {
  11894. return;
  11895. }
  11896. this._scene = this.camera.getScene();
  11897. this._engine = this._scene.getEngine();
  11898. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  11899. _this._keys = [];
  11900. });
  11901. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  11902. var evt = info.event;
  11903. if (!evt.metaKey) {
  11904. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  11905. _this._ctrlPressed = evt.ctrlKey;
  11906. _this._altPressed = evt.altKey;
  11907. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  11908. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  11909. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  11910. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  11911. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  11912. var index = _this._keys.indexOf(evt.keyCode);
  11913. if (index === -1) {
  11914. _this._keys.push(evt.keyCode);
  11915. }
  11916. if (evt.preventDefault) {
  11917. if (!noPreventDefault) {
  11918. evt.preventDefault();
  11919. }
  11920. }
  11921. }
  11922. }
  11923. else {
  11924. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  11925. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  11926. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  11927. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  11928. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  11929. var index = _this._keys.indexOf(evt.keyCode);
  11930. if (index >= 0) {
  11931. _this._keys.splice(index, 1);
  11932. }
  11933. if (evt.preventDefault) {
  11934. if (!noPreventDefault) {
  11935. evt.preventDefault();
  11936. }
  11937. }
  11938. }
  11939. }
  11940. }
  11941. });
  11942. };
  11943. /**
  11944. * Detach the current controls from the specified dom element.
  11945. * @param element Defines the element to stop listening the inputs from
  11946. */
  11947. ArcRotateCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  11948. if (this._scene) {
  11949. if (this._onKeyboardObserver) {
  11950. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  11951. }
  11952. if (this._onCanvasBlurObserver) {
  11953. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  11954. }
  11955. this._onKeyboardObserver = null;
  11956. this._onCanvasBlurObserver = null;
  11957. }
  11958. this._keys = [];
  11959. };
  11960. /**
  11961. * Update the current camera state depending on the inputs that have been used this frame.
  11962. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11963. */
  11964. ArcRotateCameraKeyboardMoveInput.prototype.checkInputs = function () {
  11965. if (this._onKeyboardObserver) {
  11966. var camera = this.camera;
  11967. for (var index = 0; index < this._keys.length; index++) {
  11968. var keyCode = this._keys[index];
  11969. if (this.keysLeft.indexOf(keyCode) !== -1) {
  11970. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  11971. camera.inertialPanningX -= 1 / this.panningSensibility;
  11972. }
  11973. else {
  11974. camera.inertialAlphaOffset -= this.angularSpeed;
  11975. }
  11976. }
  11977. else if (this.keysUp.indexOf(keyCode) !== -1) {
  11978. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  11979. camera.inertialPanningY += 1 / this.panningSensibility;
  11980. }
  11981. else if (this._altPressed && this.useAltToZoom) {
  11982. camera.inertialRadiusOffset += 1 / this.zoomingSensibility;
  11983. }
  11984. else {
  11985. camera.inertialBetaOffset -= this.angularSpeed;
  11986. }
  11987. }
  11988. else if (this.keysRight.indexOf(keyCode) !== -1) {
  11989. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  11990. camera.inertialPanningX += 1 / this.panningSensibility;
  11991. }
  11992. else {
  11993. camera.inertialAlphaOffset += this.angularSpeed;
  11994. }
  11995. }
  11996. else if (this.keysDown.indexOf(keyCode) !== -1) {
  11997. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  11998. camera.inertialPanningY -= 1 / this.panningSensibility;
  11999. }
  12000. else if (this._altPressed && this.useAltToZoom) {
  12001. camera.inertialRadiusOffset -= 1 / this.zoomingSensibility;
  12002. }
  12003. else {
  12004. camera.inertialBetaOffset += this.angularSpeed;
  12005. }
  12006. }
  12007. else if (this.keysReset.indexOf(keyCode) !== -1) {
  12008. if (camera.useInputToRestoreState) {
  12009. camera.restoreState();
  12010. }
  12011. }
  12012. }
  12013. }
  12014. };
  12015. /**
  12016. * Gets the class name of the current intput.
  12017. * @returns the class name
  12018. */
  12019. ArcRotateCameraKeyboardMoveInput.prototype.getClassName = function () {
  12020. return "ArcRotateCameraKeyboardMoveInput";
  12021. };
  12022. /**
  12023. * Get the friendly name associated with the input class.
  12024. * @returns the input friendly name
  12025. */
  12026. ArcRotateCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  12027. return "keyboard";
  12028. };
  12029. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12030. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12031. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  12032. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12033. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12034. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  12035. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12036. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12037. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  12038. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12039. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12040. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  12041. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12042. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12043. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysReset", void 0);
  12044. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12045. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12046. ], ArcRotateCameraKeyboardMoveInput.prototype, "panningSensibility", void 0);
  12047. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12048. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12049. ], ArcRotateCameraKeyboardMoveInput.prototype, "zoomingSensibility", void 0);
  12050. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12051. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12052. ], ArcRotateCameraKeyboardMoveInput.prototype, "useAltToZoom", void 0);
  12053. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12054. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12055. ], ArcRotateCameraKeyboardMoveInput.prototype, "angularSpeed", void 0);
  12056. return ArcRotateCameraKeyboardMoveInput;
  12057. }());
  12058. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraKeyboardMoveInput"] = ArcRotateCameraKeyboardMoveInput;
  12059. /***/ }),
  12060. /***/ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts":
  12061. /*!**********************************************************!*\
  12062. !*** ./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts ***!
  12063. \**********************************************************/
  12064. /*! exports provided: ArcRotateCameraMouseWheelInput */
  12065. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12066. "use strict";
  12067. __webpack_require__.r(__webpack_exports__);
  12068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return ArcRotateCameraMouseWheelInput; });
  12069. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12070. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12071. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12072. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12073. /**
  12074. * Manage the mouse wheel inputs to control an arc rotate camera.
  12075. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12076. */
  12077. var ArcRotateCameraMouseWheelInput = /** @class */ (function () {
  12078. function ArcRotateCameraMouseWheelInput() {
  12079. /**
  12080. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  12081. */
  12082. this.wheelPrecision = 3.0;
  12083. /**
  12084. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  12085. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  12086. */
  12087. this.wheelDeltaPercentage = 0;
  12088. }
  12089. /**
  12090. * Attach the input controls to a specific dom element to get the input from.
  12091. * @param element Defines the element the controls should be listened from
  12092. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12093. */
  12094. ArcRotateCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  12095. var _this = this;
  12096. this._wheel = function (p, s) {
  12097. //sanity check - this should be a PointerWheel event.
  12098. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  12099. return;
  12100. }
  12101. var event = p.event;
  12102. var delta = 0;
  12103. var mouseWheelLegacyEvent = event;
  12104. if (mouseWheelLegacyEvent.wheelDelta) {
  12105. if (_this.wheelDeltaPercentage) {
  12106. var wheelDelta = (mouseWheelLegacyEvent.wheelDelta * 0.01 * _this.wheelDeltaPercentage) * _this.camera.radius;
  12107. if (mouseWheelLegacyEvent.wheelDelta > 0) {
  12108. delta = wheelDelta / (1.0 + _this.wheelDeltaPercentage);
  12109. }
  12110. else {
  12111. delta = wheelDelta * (1.0 + _this.wheelDeltaPercentage);
  12112. }
  12113. }
  12114. else {
  12115. delta = mouseWheelLegacyEvent.wheelDelta / (_this.wheelPrecision * 40);
  12116. }
  12117. }
  12118. else {
  12119. var deltaValue = event.deltaY || event.detail;
  12120. delta = -deltaValue / _this.wheelPrecision;
  12121. }
  12122. if (delta) {
  12123. _this.camera.inertialRadiusOffset += delta;
  12124. }
  12125. if (event.preventDefault) {
  12126. if (!noPreventDefault) {
  12127. event.preventDefault();
  12128. }
  12129. }
  12130. };
  12131. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  12132. };
  12133. /**
  12134. * Detach the current controls from the specified dom element.
  12135. * @param element Defines the element to stop listening the inputs from
  12136. */
  12137. ArcRotateCameraMouseWheelInput.prototype.detachControl = function (element) {
  12138. if (this._observer && element) {
  12139. this.camera.getScene().onPointerObservable.remove(this._observer);
  12140. this._observer = null;
  12141. this._wheel = null;
  12142. }
  12143. };
  12144. /**
  12145. * Gets the class name of the current intput.
  12146. * @returns the class name
  12147. */
  12148. ArcRotateCameraMouseWheelInput.prototype.getClassName = function () {
  12149. return "ArcRotateCameraMouseWheelInput";
  12150. };
  12151. /**
  12152. * Get the friendly name associated with the input class.
  12153. * @returns the input friendly name
  12154. */
  12155. ArcRotateCameraMouseWheelInput.prototype.getSimpleName = function () {
  12156. return "mousewheel";
  12157. };
  12158. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12159. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12160. ], ArcRotateCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  12161. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12162. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12163. ], ArcRotateCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  12164. return ArcRotateCameraMouseWheelInput;
  12165. }());
  12166. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraMouseWheelInput"] = ArcRotateCameraMouseWheelInput;
  12167. /***/ }),
  12168. /***/ "./Cameras/Inputs/arcRotateCameraPointersInput.ts":
  12169. /*!********************************************************!*\
  12170. !*** ./Cameras/Inputs/arcRotateCameraPointersInput.ts ***!
  12171. \********************************************************/
  12172. /*! exports provided: ArcRotateCameraPointersInput */
  12173. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12174. "use strict";
  12175. __webpack_require__.r(__webpack_exports__);
  12176. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return ArcRotateCameraPointersInput; });
  12177. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12178. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12179. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  12180. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12181. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12182. /**
  12183. * Manage the pointers inputs to control an arc rotate camera.
  12184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12185. */
  12186. var ArcRotateCameraPointersInput = /** @class */ (function () {
  12187. function ArcRotateCameraPointersInput() {
  12188. /**
  12189. * Defines the buttons associated with the input to handle camera move.
  12190. */
  12191. this.buttons = [0, 1, 2];
  12192. /**
  12193. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  12194. */
  12195. this.angularSensibilityX = 1000.0;
  12196. /**
  12197. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  12198. */
  12199. this.angularSensibilityY = 1000.0;
  12200. /**
  12201. * Defines the pointer pinch precision or how fast is the camera zooming.
  12202. */
  12203. this.pinchPrecision = 12.0;
  12204. /**
  12205. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  12206. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  12207. */
  12208. this.pinchDeltaPercentage = 0;
  12209. /**
  12210. * Defines the pointer panning sensibility or how fast is the camera moving.
  12211. */
  12212. this.panningSensibility = 1000.0;
  12213. /**
  12214. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  12215. */
  12216. this.multiTouchPanning = true;
  12217. /**
  12218. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  12219. */
  12220. this.multiTouchPanAndZoom = true;
  12221. /**
  12222. * Revers pinch action direction.
  12223. */
  12224. this.pinchInwards = true;
  12225. this._isPanClick = false;
  12226. }
  12227. /**
  12228. * Attach the input controls to a specific dom element to get the input from.
  12229. * @param element Defines the element the controls should be listened from
  12230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12231. */
  12232. ArcRotateCameraPointersInput.prototype.attachControl = function (element, noPreventDefault) {
  12233. var _this = this;
  12234. var engine = this.camera.getEngine();
  12235. var cacheSoloPointer; // cache pointer object for better perf on camera rotation
  12236. var pointA = null;
  12237. var pointB = null;
  12238. var previousPinchSquaredDistance = 0;
  12239. var initialDistance = 0;
  12240. var twoFingerActivityCount = 0;
  12241. var previousMultiTouchPanPosition = { x: 0, y: 0, isPaning: false, isPinching: false };
  12242. this._pointerInput = function (p, s) {
  12243. var evt = p.event;
  12244. var isTouch = p.event.pointerType === "touch";
  12245. if (engine.isInVRExclusivePointerMode) {
  12246. return;
  12247. }
  12248. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  12249. return;
  12250. }
  12251. var srcElement = (evt.srcElement || evt.target);
  12252. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN && srcElement) {
  12253. try {
  12254. srcElement.setPointerCapture(evt.pointerId);
  12255. }
  12256. catch (e) {
  12257. //Nothing to do with the error. Execution will continue.
  12258. }
  12259. // Manage panning with pan button click
  12260. _this._isPanClick = evt.button === _this.camera._panningMouseButton;
  12261. // manage pointers
  12262. cacheSoloPointer = { x: evt.clientX, y: evt.clientY, pointerId: evt.pointerId, type: evt.pointerType };
  12263. if (pointA === null) {
  12264. pointA = cacheSoloPointer;
  12265. }
  12266. else if (pointB === null) {
  12267. pointB = cacheSoloPointer;
  12268. }
  12269. if (!noPreventDefault) {
  12270. evt.preventDefault();
  12271. element.focus();
  12272. }
  12273. }
  12274. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOUBLETAP) {
  12275. if (_this.camera.useInputToRestoreState) {
  12276. _this.camera.restoreState();
  12277. }
  12278. }
  12279. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP && srcElement) {
  12280. try {
  12281. srcElement.releasePointerCapture(evt.pointerId);
  12282. }
  12283. catch (e) {
  12284. //Nothing to do with the error.
  12285. }
  12286. cacheSoloPointer = null;
  12287. previousPinchSquaredDistance = 0;
  12288. previousMultiTouchPanPosition.isPaning = false;
  12289. previousMultiTouchPanPosition.isPinching = false;
  12290. twoFingerActivityCount = 0;
  12291. initialDistance = 0;
  12292. if (!isTouch) {
  12293. pointB = null; // Mouse and pen are mono pointer
  12294. }
  12295. //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,
  12296. //but emptying completly pointers collection is required to fix a bug on iPhone :
  12297. //when changing orientation while pinching camera, one pointer stay pressed forever if we don't release all pointers
  12298. //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected
  12299. if (engine._badOS) {
  12300. pointA = pointB = null;
  12301. }
  12302. else {
  12303. //only remove the impacted pointer in case of multitouch allowing on most
  12304. //platforms switching from rotate to zoom and pan seamlessly.
  12305. if (pointB && pointA && pointA.pointerId == evt.pointerId) {
  12306. pointA = pointB;
  12307. pointB = null;
  12308. cacheSoloPointer = { x: pointA.x, y: pointA.y, pointerId: pointA.pointerId, type: evt.pointerType };
  12309. }
  12310. else if (pointA && pointB && pointB.pointerId == evt.pointerId) {
  12311. pointB = null;
  12312. cacheSoloPointer = { x: pointA.x, y: pointA.y, pointerId: pointA.pointerId, type: evt.pointerType };
  12313. }
  12314. else {
  12315. pointA = pointB = null;
  12316. }
  12317. }
  12318. if (!noPreventDefault) {
  12319. evt.preventDefault();
  12320. }
  12321. }
  12322. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  12323. if (!noPreventDefault) {
  12324. evt.preventDefault();
  12325. }
  12326. // One button down
  12327. if (pointA && pointB === null && cacheSoloPointer) {
  12328. if (_this.panningSensibility !== 0 &&
  12329. ((evt.ctrlKey && _this.camera._useCtrlForPanning) || _this._isPanClick)) {
  12330. _this.camera.inertialPanningX += -(evt.clientX - cacheSoloPointer.x) / _this.panningSensibility;
  12331. _this.camera.inertialPanningY += (evt.clientY - cacheSoloPointer.y) / _this.panningSensibility;
  12332. }
  12333. else {
  12334. var offsetX = evt.clientX - cacheSoloPointer.x;
  12335. var offsetY = evt.clientY - cacheSoloPointer.y;
  12336. _this.camera.inertialAlphaOffset -= offsetX / _this.angularSensibilityX;
  12337. _this.camera.inertialBetaOffset -= offsetY / _this.angularSensibilityY;
  12338. }
  12339. cacheSoloPointer.x = evt.clientX;
  12340. cacheSoloPointer.y = evt.clientY;
  12341. }
  12342. // Two buttons down: pinch/pan
  12343. else if (pointA && pointB) {
  12344. //if (noPreventDefault) { evt.preventDefault(); } //if pinch gesture, could be useful to force preventDefault to avoid html page scroll/zoom in some mobile browsers
  12345. var ed = (pointA.pointerId === evt.pointerId) ? pointA : pointB;
  12346. ed.x = evt.clientX;
  12347. ed.y = evt.clientY;
  12348. var direction = _this.pinchInwards ? 1 : -1;
  12349. var distX = pointA.x - pointB.x;
  12350. var distY = pointA.y - pointB.y;
  12351. var pinchSquaredDistance = (distX * distX) + (distY * distY);
  12352. var pinchDistance = Math.sqrt(pinchSquaredDistance);
  12353. if (previousPinchSquaredDistance === 0) {
  12354. initialDistance = pinchDistance;
  12355. previousPinchSquaredDistance = pinchSquaredDistance;
  12356. previousMultiTouchPanPosition.x = (pointA.x + pointB.x) / 2;
  12357. previousMultiTouchPanPosition.y = (pointA.y + pointB.y) / 2;
  12358. return;
  12359. }
  12360. if (_this.multiTouchPanAndZoom) {
  12361. if (_this.pinchDeltaPercentage) {
  12362. _this.camera.inertialRadiusOffset += ((pinchSquaredDistance - previousPinchSquaredDistance) * 0.001) * _this.camera.radius * _this.pinchDeltaPercentage;
  12363. }
  12364. else {
  12365. _this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
  12366. (_this.pinchPrecision *
  12367. ((_this.angularSensibilityX + _this.angularSensibilityY) / 2) *
  12368. direction);
  12369. }
  12370. if (_this.panningSensibility !== 0) {
  12371. var pointersCenterX = (pointA.x + pointB.x) / 2;
  12372. var pointersCenterY = (pointA.y + pointB.y) / 2;
  12373. var pointersCenterDistX = pointersCenterX - previousMultiTouchPanPosition.x;
  12374. var pointersCenterDistY = pointersCenterY - previousMultiTouchPanPosition.y;
  12375. previousMultiTouchPanPosition.x = pointersCenterX;
  12376. previousMultiTouchPanPosition.y = pointersCenterY;
  12377. _this.camera.inertialPanningX += -(pointersCenterDistX) / (_this.panningSensibility);
  12378. _this.camera.inertialPanningY += (pointersCenterDistY) / (_this.panningSensibility);
  12379. }
  12380. }
  12381. else {
  12382. twoFingerActivityCount++;
  12383. if (previousMultiTouchPanPosition.isPinching || (twoFingerActivityCount < 20 && Math.abs(pinchDistance - initialDistance) > _this.camera.pinchToPanMaxDistance)) {
  12384. if (_this.pinchDeltaPercentage) {
  12385. _this.camera.inertialRadiusOffset += ((pinchSquaredDistance - previousPinchSquaredDistance) * 0.001) * _this.camera.radius * _this.pinchDeltaPercentage;
  12386. }
  12387. else {
  12388. _this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
  12389. (_this.pinchPrecision *
  12390. ((_this.angularSensibilityX + _this.angularSensibilityY) / 2) *
  12391. direction);
  12392. }
  12393. previousMultiTouchPanPosition.isPaning = false;
  12394. previousMultiTouchPanPosition.isPinching = true;
  12395. }
  12396. else {
  12397. if (cacheSoloPointer && cacheSoloPointer.pointerId === ed.pointerId && _this.panningSensibility !== 0 && _this.multiTouchPanning) {
  12398. if (!previousMultiTouchPanPosition.isPaning) {
  12399. previousMultiTouchPanPosition.isPaning = true;
  12400. previousMultiTouchPanPosition.isPinching = false;
  12401. previousMultiTouchPanPosition.x = ed.x;
  12402. previousMultiTouchPanPosition.y = ed.y;
  12403. return;
  12404. }
  12405. _this.camera.inertialPanningX += -(ed.x - previousMultiTouchPanPosition.x) / (_this.panningSensibility);
  12406. _this.camera.inertialPanningY += (ed.y - previousMultiTouchPanPosition.y) / (_this.panningSensibility);
  12407. }
  12408. }
  12409. if (cacheSoloPointer && cacheSoloPointer.pointerId === evt.pointerId) {
  12410. previousMultiTouchPanPosition.x = ed.x;
  12411. previousMultiTouchPanPosition.y = ed.y;
  12412. }
  12413. }
  12414. previousPinchSquaredDistance = pinchSquaredDistance;
  12415. }
  12416. }
  12417. };
  12418. 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);
  12419. this._onContextMenu = function (evt) {
  12420. evt.preventDefault();
  12421. };
  12422. if (!this.camera._useCtrlForPanning) {
  12423. element.addEventListener("contextmenu", this._onContextMenu, false);
  12424. }
  12425. this._onLostFocus = function () {
  12426. //this._keys = [];
  12427. pointA = pointB = null;
  12428. previousPinchSquaredDistance = 0;
  12429. previousMultiTouchPanPosition.isPaning = false;
  12430. previousMultiTouchPanPosition.isPinching = false;
  12431. twoFingerActivityCount = 0;
  12432. cacheSoloPointer = null;
  12433. initialDistance = 0;
  12434. };
  12435. this._onMouseMove = function (evt) {
  12436. if (!engine.isPointerLock) {
  12437. return;
  12438. }
  12439. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  12440. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  12441. _this.camera.inertialAlphaOffset -= offsetX / _this.angularSensibilityX;
  12442. _this.camera.inertialBetaOffset -= offsetY / _this.angularSensibilityY;
  12443. if (!noPreventDefault) {
  12444. evt.preventDefault();
  12445. }
  12446. };
  12447. this._onGestureStart = function (e) {
  12448. if (window.MSGesture === undefined) {
  12449. return;
  12450. }
  12451. if (!_this._MSGestureHandler) {
  12452. _this._MSGestureHandler = new MSGesture();
  12453. _this._MSGestureHandler.target = element;
  12454. }
  12455. _this._MSGestureHandler.addPointer(e.pointerId);
  12456. };
  12457. this._onGesture = function (e) {
  12458. _this.camera.radius *= e.scale;
  12459. if (e.preventDefault) {
  12460. if (!noPreventDefault) {
  12461. e.stopPropagation();
  12462. e.preventDefault();
  12463. }
  12464. }
  12465. };
  12466. element.addEventListener("mousemove", this._onMouseMove, false);
  12467. element.addEventListener("MSPointerDown", this._onGestureStart, false);
  12468. element.addEventListener("MSGestureChange", this._onGesture, false);
  12469. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RegisterTopRootEvents([
  12470. { name: "blur", handler: this._onLostFocus }
  12471. ]);
  12472. };
  12473. /**
  12474. * Detach the current controls from the specified dom element.
  12475. * @param element Defines the element to stop listening the inputs from
  12476. */
  12477. ArcRotateCameraPointersInput.prototype.detachControl = function (element) {
  12478. if (this._onLostFocus) {
  12479. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].UnregisterTopRootEvents([
  12480. { name: "blur", handler: this._onLostFocus }
  12481. ]);
  12482. }
  12483. if (element && this._observer) {
  12484. this.camera.getScene().onPointerObservable.remove(this._observer);
  12485. this._observer = null;
  12486. if (this._onContextMenu) {
  12487. element.removeEventListener("contextmenu", this._onContextMenu);
  12488. }
  12489. if (this._onMouseMove) {
  12490. element.removeEventListener("mousemove", this._onMouseMove);
  12491. }
  12492. if (this._onGestureStart) {
  12493. element.removeEventListener("MSPointerDown", this._onGestureStart);
  12494. }
  12495. if (this._onGesture) {
  12496. element.removeEventListener("MSGestureChange", this._onGesture);
  12497. }
  12498. this._isPanClick = false;
  12499. this.pinchInwards = true;
  12500. this._onMouseMove = null;
  12501. this._onGestureStart = null;
  12502. this._onGesture = null;
  12503. this._MSGestureHandler = null;
  12504. this._onLostFocus = null;
  12505. this._onContextMenu = null;
  12506. }
  12507. };
  12508. /**
  12509. * Gets the class name of the current intput.
  12510. * @returns the class name
  12511. */
  12512. ArcRotateCameraPointersInput.prototype.getClassName = function () {
  12513. return "ArcRotateCameraPointersInput";
  12514. };
  12515. /**
  12516. * Get the friendly name associated with the input class.
  12517. * @returns the input friendly name
  12518. */
  12519. ArcRotateCameraPointersInput.prototype.getSimpleName = function () {
  12520. return "pointers";
  12521. };
  12522. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12523. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12524. ], ArcRotateCameraPointersInput.prototype, "buttons", void 0);
  12525. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12526. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12527. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityX", void 0);
  12528. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12529. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12530. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityY", void 0);
  12531. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12532. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12533. ], ArcRotateCameraPointersInput.prototype, "pinchPrecision", void 0);
  12534. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12535. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12536. ], ArcRotateCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  12537. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12538. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12539. ], ArcRotateCameraPointersInput.prototype, "panningSensibility", void 0);
  12540. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12541. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12542. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanning", void 0);
  12543. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12544. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12545. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
  12546. return ArcRotateCameraPointersInput;
  12547. }());
  12548. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["CameraInputTypes"]["ArcRotateCameraPointersInput"] = ArcRotateCameraPointersInput;
  12549. /***/ }),
  12550. /***/ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts":
  12551. /*!*******************************************************************!*\
  12552. !*** ./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts ***!
  12553. \*******************************************************************/
  12554. /*! exports provided: ArcRotateCameraVRDeviceOrientationInput */
  12555. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12556. "use strict";
  12557. __webpack_require__.r(__webpack_exports__);
  12558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return ArcRotateCameraVRDeviceOrientationInput; });
  12559. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12560. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  12561. /**
  12562. * Add orientation input support to the input manager.
  12563. * @returns the current input manager
  12564. */
  12565. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraInputsManager"].prototype.addVRDeviceOrientation = function () {
  12566. this.add(new ArcRotateCameraVRDeviceOrientationInput());
  12567. return this;
  12568. };
  12569. /**
  12570. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  12571. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12572. */
  12573. var ArcRotateCameraVRDeviceOrientationInput = /** @class */ (function () {
  12574. /**
  12575. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  12576. */
  12577. function ArcRotateCameraVRDeviceOrientationInput() {
  12578. /**
  12579. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  12580. */
  12581. this.alphaCorrection = 1;
  12582. /**
  12583. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  12584. */
  12585. this.gammaCorrection = 1;
  12586. this._alpha = 0;
  12587. this._gamma = 0;
  12588. this._dirty = false;
  12589. this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
  12590. }
  12591. /**
  12592. * Attach the input controls to a specific dom element to get the input from.
  12593. * @param element Defines the element the controls should be listened from
  12594. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12595. */
  12596. ArcRotateCameraVRDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  12597. this.camera.attachControl(element, noPreventDefault);
  12598. window.addEventListener("deviceorientation", this._deviceOrientationHandler);
  12599. };
  12600. /** @hidden */
  12601. ArcRotateCameraVRDeviceOrientationInput.prototype._onOrientationEvent = function (evt) {
  12602. if (evt.alpha !== null) {
  12603. this._alpha = (+evt.alpha | 0) * this.alphaCorrection;
  12604. }
  12605. if (evt.gamma !== null) {
  12606. this._gamma = (+evt.gamma | 0) * this.gammaCorrection;
  12607. }
  12608. this._dirty = true;
  12609. };
  12610. /**
  12611. * Update the current camera state depending on the inputs that have been used this frame.
  12612. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12613. */
  12614. ArcRotateCameraVRDeviceOrientationInput.prototype.checkInputs = function () {
  12615. if (this._dirty) {
  12616. this._dirty = false;
  12617. if (this._gamma < 0) {
  12618. this._gamma = 180 + this._gamma;
  12619. }
  12620. this.camera.alpha = (-this._alpha / 180.0 * Math.PI) % Math.PI * 2;
  12621. this.camera.beta = (this._gamma / 180.0 * Math.PI);
  12622. }
  12623. };
  12624. /**
  12625. * Detach the current controls from the specified dom element.
  12626. * @param element Defines the element to stop listening the inputs from
  12627. */
  12628. ArcRotateCameraVRDeviceOrientationInput.prototype.detachControl = function (element) {
  12629. window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
  12630. };
  12631. /**
  12632. * Gets the class name of the current intput.
  12633. * @returns the class name
  12634. */
  12635. ArcRotateCameraVRDeviceOrientationInput.prototype.getClassName = function () {
  12636. return "ArcRotateCameraVRDeviceOrientationInput";
  12637. };
  12638. /**
  12639. * Get the friendly name associated with the input class.
  12640. * @returns the input friendly name
  12641. */
  12642. ArcRotateCameraVRDeviceOrientationInput.prototype.getSimpleName = function () {
  12643. return "VRDeviceOrientation";
  12644. };
  12645. return ArcRotateCameraVRDeviceOrientationInput;
  12646. }());
  12647. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["ArcRotateCameraVRDeviceOrientationInput"] = ArcRotateCameraVRDeviceOrientationInput;
  12648. /***/ }),
  12649. /***/ "./Cameras/Inputs/flyCameraKeyboardInput.ts":
  12650. /*!**************************************************!*\
  12651. !*** ./Cameras/Inputs/flyCameraKeyboardInput.ts ***!
  12652. \**************************************************/
  12653. /*! exports provided: FlyCameraKeyboardInput */
  12654. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12655. "use strict";
  12656. __webpack_require__.r(__webpack_exports__);
  12657. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return FlyCameraKeyboardInput; });
  12658. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12659. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12660. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12661. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12662. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  12663. /**
  12664. * Listen to keyboard events to control the camera.
  12665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12666. */
  12667. var FlyCameraKeyboardInput = /** @class */ (function () {
  12668. function FlyCameraKeyboardInput() {
  12669. /**
  12670. * The list of keyboard keys used to control the forward move of the camera.
  12671. */
  12672. this.keysForward = [87];
  12673. /**
  12674. * The list of keyboard keys used to control the backward move of the camera.
  12675. */
  12676. this.keysBackward = [83];
  12677. /**
  12678. * The list of keyboard keys used to control the forward move of the camera.
  12679. */
  12680. this.keysUp = [69];
  12681. /**
  12682. * The list of keyboard keys used to control the backward move of the camera.
  12683. */
  12684. this.keysDown = [81];
  12685. /**
  12686. * The list of keyboard keys used to control the right strafe move of the camera.
  12687. */
  12688. this.keysRight = [68];
  12689. /**
  12690. * The list of keyboard keys used to control the left strafe move of the camera.
  12691. */
  12692. this.keysLeft = [65];
  12693. this._keys = new Array();
  12694. }
  12695. /**
  12696. * Attach the input controls to a specific dom element to get the input from.
  12697. * @param element Defines the element the controls should be listened from
  12698. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12699. */
  12700. FlyCameraKeyboardInput.prototype.attachControl = function (element, noPreventDefault) {
  12701. var _this = this;
  12702. if (this._onCanvasBlurObserver) {
  12703. return;
  12704. }
  12705. this._scene = this.camera.getScene();
  12706. this._engine = this._scene.getEngine();
  12707. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12708. _this._keys = [];
  12709. });
  12710. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  12711. var evt = info.event;
  12712. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  12713. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  12714. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  12715. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12716. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12717. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12718. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  12719. var index = _this._keys.indexOf(evt.keyCode);
  12720. if (index === -1) {
  12721. _this._keys.push(evt.keyCode);
  12722. }
  12723. if (!noPreventDefault) {
  12724. evt.preventDefault();
  12725. }
  12726. }
  12727. }
  12728. else {
  12729. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  12730. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  12731. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12732. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12733. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12734. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  12735. var index = _this._keys.indexOf(evt.keyCode);
  12736. if (index >= 0) {
  12737. _this._keys.splice(index, 1);
  12738. }
  12739. if (!noPreventDefault) {
  12740. evt.preventDefault();
  12741. }
  12742. }
  12743. }
  12744. });
  12745. };
  12746. /**
  12747. * Detach the current controls from the specified dom element.
  12748. * @param element Defines the element to stop listening the inputs from
  12749. */
  12750. FlyCameraKeyboardInput.prototype.detachControl = function (element) {
  12751. if (this._scene) {
  12752. if (this._onKeyboardObserver) {
  12753. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  12754. }
  12755. if (this._onCanvasBlurObserver) {
  12756. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  12757. }
  12758. this._onKeyboardObserver = null;
  12759. this._onCanvasBlurObserver = null;
  12760. }
  12761. this._keys = [];
  12762. };
  12763. /**
  12764. * Gets the class name of the current intput.
  12765. * @returns the class name
  12766. */
  12767. FlyCameraKeyboardInput.prototype.getClassName = function () {
  12768. return "FlyCameraKeyboardInput";
  12769. };
  12770. /** @hidden */
  12771. FlyCameraKeyboardInput.prototype._onLostFocus = function (e) {
  12772. this._keys = [];
  12773. };
  12774. /**
  12775. * Get the friendly name associated with the input class.
  12776. * @returns the input friendly name
  12777. */
  12778. FlyCameraKeyboardInput.prototype.getSimpleName = function () {
  12779. return "keyboard";
  12780. };
  12781. /**
  12782. * Update the current camera state depending on the inputs that have been used this frame.
  12783. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12784. */
  12785. FlyCameraKeyboardInput.prototype.checkInputs = function () {
  12786. if (this._onKeyboardObserver) {
  12787. var camera = this.camera;
  12788. // Keyboard
  12789. for (var index = 0; index < this._keys.length; index++) {
  12790. var keyCode = this._keys[index];
  12791. var speed = camera._computeLocalCameraSpeed();
  12792. if (this.keysForward.indexOf(keyCode) !== -1) {
  12793. camera._localDirection.copyFromFloats(0, 0, speed);
  12794. }
  12795. else if (this.keysBackward.indexOf(keyCode) !== -1) {
  12796. camera._localDirection.copyFromFloats(0, 0, -speed);
  12797. }
  12798. else if (this.keysUp.indexOf(keyCode) !== -1) {
  12799. camera._localDirection.copyFromFloats(0, speed, 0);
  12800. }
  12801. else if (this.keysDown.indexOf(keyCode) !== -1) {
  12802. camera._localDirection.copyFromFloats(0, -speed, 0);
  12803. }
  12804. else if (this.keysRight.indexOf(keyCode) !== -1) {
  12805. camera._localDirection.copyFromFloats(speed, 0, 0);
  12806. }
  12807. else if (this.keysLeft.indexOf(keyCode) !== -1) {
  12808. camera._localDirection.copyFromFloats(-speed, 0, 0);
  12809. }
  12810. if (camera.getScene().useRightHandedSystem) {
  12811. camera._localDirection.z *= -1;
  12812. }
  12813. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  12814. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  12815. camera.cameraDirection.addInPlace(camera._transformedDirection);
  12816. }
  12817. }
  12818. };
  12819. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12820. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12821. ], FlyCameraKeyboardInput.prototype, "keysForward", void 0);
  12822. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12823. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12824. ], FlyCameraKeyboardInput.prototype, "keysBackward", void 0);
  12825. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12826. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12827. ], FlyCameraKeyboardInput.prototype, "keysUp", void 0);
  12828. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12830. ], FlyCameraKeyboardInput.prototype, "keysDown", void 0);
  12831. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12832. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12833. ], FlyCameraKeyboardInput.prototype, "keysRight", void 0);
  12834. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12835. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12836. ], FlyCameraKeyboardInput.prototype, "keysLeft", void 0);
  12837. return FlyCameraKeyboardInput;
  12838. }());
  12839. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraKeyboardInput"] = FlyCameraKeyboardInput;
  12840. /***/ }),
  12841. /***/ "./Cameras/Inputs/flyCameraMouseInput.ts":
  12842. /*!***********************************************!*\
  12843. !*** ./Cameras/Inputs/flyCameraMouseInput.ts ***!
  12844. \***********************************************/
  12845. /*! exports provided: FlyCameraMouseInput */
  12846. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12847. "use strict";
  12848. __webpack_require__.r(__webpack_exports__);
  12849. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return FlyCameraMouseInput; });
  12850. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12851. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12852. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12853. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12854. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  12855. /**
  12856. * Listen to mouse events to control the camera.
  12857. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12858. */
  12859. var FlyCameraMouseInput = /** @class */ (function () {
  12860. /**
  12861. * Listen to mouse events to control the camera.
  12862. * @param touchEnabled Define if touch is enabled. (Default is true.)
  12863. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12864. */
  12865. function FlyCameraMouseInput(touchEnabled) {
  12866. if (touchEnabled === void 0) { touchEnabled = true; }
  12867. /**
  12868. * Defines the buttons associated with the input to handle camera rotation.
  12869. */
  12870. this.buttons = [0, 1, 2];
  12871. /**
  12872. * Assign buttons for Yaw control.
  12873. */
  12874. this.buttonsYaw = [-1, 0, 1];
  12875. /**
  12876. * Assign buttons for Pitch control.
  12877. */
  12878. this.buttonsPitch = [-1, 0, 1];
  12879. /**
  12880. * Assign buttons for Roll control.
  12881. */
  12882. this.buttonsRoll = [2];
  12883. /**
  12884. * Detect if any button is being pressed while mouse is moved.
  12885. * -1 = Mouse locked.
  12886. * 0 = Left button.
  12887. * 1 = Middle Button.
  12888. * 2 = Right Button.
  12889. */
  12890. this.activeButton = -1;
  12891. /**
  12892. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  12893. * Higher values reduce its sensitivity.
  12894. */
  12895. this.angularSensibility = 1000.0;
  12896. this.previousPosition = null;
  12897. }
  12898. /**
  12899. * Attach the mouse control to the HTML DOM element.
  12900. * @param element Defines the element that listens to the input events.
  12901. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  12902. */
  12903. FlyCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  12904. var _this = this;
  12905. this.element = element;
  12906. this.noPreventDefault = noPreventDefault;
  12907. this._observer = this.camera.getScene().onPointerObservable.add(function (p, s) {
  12908. _this._pointerInput(p, s);
  12909. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  12910. // Correct Roll by rate, if enabled.
  12911. this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add(function () {
  12912. if (_this.camera.rollCorrect) {
  12913. _this.camera.restoreRoll(_this.camera.rollCorrect);
  12914. }
  12915. });
  12916. // Helper function to keep 'this'.
  12917. this._mousemoveCallback = function (e) {
  12918. _this._onMouseMove(e);
  12919. };
  12920. element.addEventListener("mousemove", this._mousemoveCallback, false);
  12921. };
  12922. /**
  12923. * Detach the current controls from the specified dom element.
  12924. * @param element Defines the element to stop listening the inputs from
  12925. */
  12926. FlyCameraMouseInput.prototype.detachControl = function (element) {
  12927. if (this._observer && element) {
  12928. this.camera.getScene().onPointerObservable.remove(this._observer);
  12929. this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver);
  12930. if (this._mousemoveCallback) {
  12931. element.removeEventListener("mousemove", this._mousemoveCallback);
  12932. }
  12933. this._observer = null;
  12934. this._rollObserver = null;
  12935. this.previousPosition = null;
  12936. this.noPreventDefault = undefined;
  12937. }
  12938. };
  12939. /**
  12940. * Gets the class name of the current input.
  12941. * @returns the class name.
  12942. */
  12943. FlyCameraMouseInput.prototype.getClassName = function () {
  12944. return "FlyCameraMouseInput";
  12945. };
  12946. /**
  12947. * Get the friendly name associated with the input class.
  12948. * @returns the input's friendly name.
  12949. */
  12950. FlyCameraMouseInput.prototype.getSimpleName = function () {
  12951. return "mouse";
  12952. };
  12953. // Track mouse movement, when the pointer is not locked.
  12954. FlyCameraMouseInput.prototype._pointerInput = function (p, s) {
  12955. var e = p.event;
  12956. var camera = this.camera;
  12957. var engine = camera.getEngine();
  12958. if (engine.isInVRExclusivePointerMode) {
  12959. return;
  12960. }
  12961. if (!this.touchEnabled && e.pointerType === "touch") {
  12962. return;
  12963. }
  12964. // Mouse is moved but an unknown mouse button is pressed.
  12965. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && this.buttons.indexOf(e.button) === -1) {
  12966. return;
  12967. }
  12968. var srcElement = (e.srcElement || e.target);
  12969. // Mouse down.
  12970. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  12971. try {
  12972. srcElement.setPointerCapture(e.pointerId);
  12973. }
  12974. catch (e) {
  12975. // Nothing to do with the error. Execution continues.
  12976. }
  12977. this.previousPosition = {
  12978. x: e.clientX,
  12979. y: e.clientY
  12980. };
  12981. this.activeButton = e.button;
  12982. if (!this.noPreventDefault) {
  12983. e.preventDefault();
  12984. this.element.focus();
  12985. }
  12986. }
  12987. else
  12988. // Mouse up.
  12989. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  12990. try {
  12991. srcElement.releasePointerCapture(e.pointerId);
  12992. }
  12993. catch (e) {
  12994. // Nothing to do with the error. Execution continues.
  12995. }
  12996. this.activeButton = -1;
  12997. this.previousPosition = null;
  12998. if (!this.noPreventDefault) {
  12999. e.preventDefault();
  13000. }
  13001. }
  13002. else
  13003. // Mouse move.
  13004. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13005. if (!this.previousPosition || engine.isPointerLock) {
  13006. return;
  13007. }
  13008. var offsetX = e.clientX - this.previousPosition.x;
  13009. var offsetY = e.clientY - this.previousPosition.y;
  13010. this.rotateCamera(offsetX, offsetY);
  13011. this.previousPosition = {
  13012. x: e.clientX,
  13013. y: e.clientY
  13014. };
  13015. if (!this.noPreventDefault) {
  13016. e.preventDefault();
  13017. }
  13018. }
  13019. };
  13020. // Track mouse movement, when pointer is locked.
  13021. FlyCameraMouseInput.prototype._onMouseMove = function (e) {
  13022. var camera = this.camera;
  13023. var engine = camera.getEngine();
  13024. if (!engine.isPointerLock || engine.isInVRExclusivePointerMode) {
  13025. return;
  13026. }
  13027. var offsetX = e.movementX || e.mozMovementX || e.webkitMovementX || e.msMovementX || 0;
  13028. var offsetY = e.movementY || e.mozMovementY || e.webkitMovementY || e.msMovementY || 0;
  13029. this.rotateCamera(offsetX, offsetY);
  13030. this.previousPosition = null;
  13031. if (!this.noPreventDefault) {
  13032. e.preventDefault();
  13033. }
  13034. };
  13035. /**
  13036. * Rotate camera by mouse offset.
  13037. */
  13038. FlyCameraMouseInput.prototype.rotateCamera = function (offsetX, offsetY) {
  13039. var _this = this;
  13040. var camera = this.camera;
  13041. var scene = this.camera.getScene();
  13042. if (scene.useRightHandedSystem) {
  13043. offsetX *= -1;
  13044. }
  13045. if (camera.parent && camera.parent._getWorldMatrixDeterminant() < 0) {
  13046. offsetX *= -1;
  13047. }
  13048. var x = offsetX / this.angularSensibility;
  13049. var y = offsetY / this.angularSensibility;
  13050. // Initialize to current rotation.
  13051. var currentRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, camera.rotation.z);
  13052. var rotationChange;
  13053. // Pitch.
  13054. if (this.buttonsPitch.some(function (v) { return v === _this.activeButton; })) {
  13055. // Apply change in Radians to vector Angle.
  13056. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].X, y);
  13057. // Apply Pitch to quaternion.
  13058. currentRotation.multiplyInPlace(rotationChange);
  13059. }
  13060. // Yaw.
  13061. if (this.buttonsYaw.some(function (v) { return v === _this.activeButton; })) {
  13062. // Apply change in Radians to vector Angle.
  13063. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Y, x);
  13064. // Apply Yaw to quaternion.
  13065. currentRotation.multiplyInPlace(rotationChange);
  13066. // Add Roll, if banked turning is enabled, within Roll limit.
  13067. var limit = (camera.bankedTurnLimit) + camera._trackRoll; // Defaults to 90° plus manual roll.
  13068. if (camera.bankedTurn && -limit < camera.rotation.z && camera.rotation.z < limit) {
  13069. var bankingDelta = camera.bankedTurnMultiplier * -x;
  13070. // Apply change in Radians to vector Angle.
  13071. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, bankingDelta);
  13072. // Apply Yaw to quaternion.
  13073. currentRotation.multiplyInPlace(rotationChange);
  13074. }
  13075. }
  13076. // Roll.
  13077. if (this.buttonsRoll.some(function (v) { return v === _this.activeButton; })) {
  13078. // Apply change in Radians to vector Angle.
  13079. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, -x);
  13080. // Track Rolling.
  13081. camera._trackRoll -= x;
  13082. // Apply Pitch to quaternion.
  13083. currentRotation.multiplyInPlace(rotationChange);
  13084. }
  13085. // Apply rotationQuaternion to Euler camera.rotation.
  13086. currentRotation.toEulerAnglesToRef(camera.rotation);
  13087. };
  13088. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13089. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13090. ], FlyCameraMouseInput.prototype, "buttons", void 0);
  13091. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13092. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13093. ], FlyCameraMouseInput.prototype, "angularSensibility", void 0);
  13094. return FlyCameraMouseInput;
  13095. }());
  13096. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraMouseInput"] = FlyCameraMouseInput;
  13097. /***/ }),
  13098. /***/ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts":
  13099. /*!*********************************************************!*\
  13100. !*** ./Cameras/Inputs/followCameraKeyboardMoveInput.ts ***!
  13101. \*********************************************************/
  13102. /*! exports provided: FollowCameraKeyboardMoveInput */
  13103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13104. "use strict";
  13105. __webpack_require__.r(__webpack_exports__);
  13106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return FollowCameraKeyboardMoveInput; });
  13107. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13108. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13109. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13110. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13111. /**
  13112. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  13113. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13114. */
  13115. var FollowCameraKeyboardMoveInput = /** @class */ (function () {
  13116. function FollowCameraKeyboardMoveInput() {
  13117. /**
  13118. * Defines the list of key codes associated with the up action (increase heightOffset)
  13119. */
  13120. this.keysUp = [38];
  13121. /**
  13122. * Defines the list of key codes associated with the down action (decrease heightOffset)
  13123. */
  13124. this.keysDown = [40];
  13125. /**
  13126. * Defines the list of key codes associated with the left action (increase rotation)
  13127. */
  13128. this.keysLeft = [37];
  13129. /**
  13130. * Defines the list of key codes associated with the right action (decrease rotation)
  13131. */
  13132. this.keysRight = [39];
  13133. /**
  13134. * Defines the rate of change of heightOffset.
  13135. */
  13136. this.heightSensibility = 1;
  13137. /**
  13138. * Defines the rate of change of rotationOffset.
  13139. */
  13140. this.rotationSensibility = 1;
  13141. /**
  13142. * Defines the rate of change of radius.
  13143. */
  13144. this.radiusSensibility = 1;
  13145. /**
  13146. * Defines the minimum heightOffset value.
  13147. */
  13148. this.minHeightOffset = 0;
  13149. /**
  13150. * Defines the minimum radius value.
  13151. */
  13152. this.minRadius = 0;
  13153. this._keys = new Array();
  13154. }
  13155. /**
  13156. * Attach the input controls to a specific dom element to get the input from.
  13157. * @param element Defines the element the controls should be listened from
  13158. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13159. */
  13160. FollowCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  13161. var _this = this;
  13162. if (this._onCanvasBlurObserver) {
  13163. return;
  13164. }
  13165. this._scene = this.camera.getScene();
  13166. this._engine = this._scene.getEngine();
  13167. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13168. _this._keys = [];
  13169. });
  13170. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13171. var evt = info.event;
  13172. if (!evt.metaKey) {
  13173. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13174. // this._ctrlPressed = evt.ctrlKey;
  13175. _this._altPressed = evt.altKey;
  13176. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13177. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13178. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13179. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13180. var index = _this._keys.indexOf(evt.keyCode);
  13181. if (index === -1) {
  13182. _this._keys.push(evt.keyCode);
  13183. }
  13184. if (evt.preventDefault) {
  13185. if (!noPreventDefault) {
  13186. evt.preventDefault();
  13187. }
  13188. }
  13189. }
  13190. }
  13191. else {
  13192. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13193. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13194. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13195. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13196. var index = _this._keys.indexOf(evt.keyCode);
  13197. if (index >= 0) {
  13198. _this._keys.splice(index, 1);
  13199. }
  13200. if (evt.preventDefault) {
  13201. if (!noPreventDefault) {
  13202. evt.preventDefault();
  13203. }
  13204. }
  13205. }
  13206. }
  13207. }
  13208. });
  13209. };
  13210. /**
  13211. * Detach the current controls from the specified dom element.
  13212. * @param element Defines the element to stop listening the inputs from
  13213. */
  13214. FollowCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  13215. if (this._scene) {
  13216. if (this._onKeyboardObserver) {
  13217. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13218. }
  13219. if (this._onCanvasBlurObserver) {
  13220. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13221. }
  13222. this._onKeyboardObserver = null;
  13223. this._onCanvasBlurObserver = null;
  13224. }
  13225. this._keys = [];
  13226. };
  13227. /**
  13228. * Update the current camera state depending on the inputs that have been used this frame.
  13229. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13230. */
  13231. FollowCameraKeyboardMoveInput.prototype.checkInputs = function () {
  13232. if (this._onKeyboardObserver) {
  13233. for (var index = 0; index < this._keys.length; index++) {
  13234. var keyCode = this._keys[index];
  13235. if (this.keysLeft.indexOf(keyCode) !== -1) {
  13236. this.camera.rotationOffset += this.rotationSensibility;
  13237. this.camera.rotationOffset %= 360;
  13238. }
  13239. else if (this.keysUp.indexOf(keyCode) !== -1) {
  13240. if (this._altPressed) {
  13241. this.camera.radius += this.radiusSensibility;
  13242. }
  13243. else {
  13244. this.camera.heightOffset += this.heightSensibility;
  13245. }
  13246. }
  13247. else if (this.keysRight.indexOf(keyCode) !== -1) {
  13248. this.camera.rotationOffset -= this.rotationSensibility;
  13249. this.camera.rotationOffset %= 360;
  13250. }
  13251. else if (this.keysDown.indexOf(keyCode) !== -1) {
  13252. if (this._altPressed) {
  13253. this.camera.radius -= this.radiusSensibility;
  13254. this.camera.radius =
  13255. Math.max(this.minRadius, this.camera.radius);
  13256. }
  13257. else {
  13258. this.camera.heightOffset -= this.heightSensibility;
  13259. this.camera.heightOffset =
  13260. Math.max(this.minHeightOffset, this.camera.heightOffset);
  13261. }
  13262. }
  13263. }
  13264. }
  13265. };
  13266. /**
  13267. * Gets the class name of the current intput.
  13268. * @returns the class name
  13269. */
  13270. FollowCameraKeyboardMoveInput.prototype.getClassName = function () {
  13271. return "FollowCameraKeyboardMoveInput";
  13272. };
  13273. /**
  13274. * Get the friendly name associated with the input class.
  13275. * @returns the input friendly name
  13276. */
  13277. FollowCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  13278. return "keyboard";
  13279. };
  13280. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13281. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13282. ], FollowCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  13283. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13284. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13285. ], FollowCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  13286. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13288. ], FollowCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  13289. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13291. ], FollowCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  13292. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13293. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13294. ], FollowCameraKeyboardMoveInput.prototype, "heightSensibility", void 0);
  13295. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13296. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13297. ], FollowCameraKeyboardMoveInput.prototype, "rotationSensibility", void 0);
  13298. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13299. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13300. ], FollowCameraKeyboardMoveInput.prototype, "radiusSensibility", void 0);
  13301. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13302. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13303. ], FollowCameraKeyboardMoveInput.prototype, "minHeightOffset", void 0);
  13304. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13305. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13306. ], FollowCameraKeyboardMoveInput.prototype, "minRadius", void 0);
  13307. return FollowCameraKeyboardMoveInput;
  13308. }());
  13309. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FollowCameraKeyboardMoveInput"] = FollowCameraKeyboardMoveInput;
  13310. /***/ }),
  13311. /***/ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts":
  13312. /*!************************************************************!*\
  13313. !*** ./Cameras/Inputs/freeCameraDeviceOrientationInput.ts ***!
  13314. \************************************************************/
  13315. /*! exports provided: FreeCameraDeviceOrientationInput */
  13316. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13317. "use strict";
  13318. __webpack_require__.r(__webpack_exports__);
  13319. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return FreeCameraDeviceOrientationInput; });
  13320. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13321. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13322. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  13323. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  13324. /**
  13325. * Add orientation input support to the input manager.
  13326. * @returns the current input manager
  13327. */
  13328. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addDeviceOrientation = function () {
  13329. this.add(new FreeCameraDeviceOrientationInput());
  13330. return this;
  13331. };
  13332. /**
  13333. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  13334. * Screen rotation is taken into account.
  13335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13336. */
  13337. var FreeCameraDeviceOrientationInput = /** @class */ (function () {
  13338. /**
  13339. * Instantiates a new input
  13340. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13341. */
  13342. function FreeCameraDeviceOrientationInput() {
  13343. var _this = this;
  13344. this._screenOrientationAngle = 0;
  13345. this._screenQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  13346. this._alpha = 0;
  13347. this._beta = 0;
  13348. this._gamma = 0;
  13349. this._orientationChanged = function () {
  13350. _this._screenOrientationAngle = (window.orientation !== undefined ? +window.orientation : (window.screen.orientation && (window.screen.orientation)['angle'] ? (window.screen.orientation).angle : 0));
  13351. _this._screenOrientationAngle = -_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(_this._screenOrientationAngle / 2);
  13352. _this._screenQuaternion.copyFromFloats(0, Math.sin(_this._screenOrientationAngle), 0, Math.cos(_this._screenOrientationAngle));
  13353. };
  13354. this._deviceOrientation = function (evt) {
  13355. _this._alpha = evt.alpha !== null ? evt.alpha : 0;
  13356. _this._beta = evt.beta !== null ? evt.beta : 0;
  13357. _this._gamma = evt.gamma !== null ? evt.gamma : 0;
  13358. };
  13359. this._constantTranform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5));
  13360. this._orientationChanged();
  13361. }
  13362. Object.defineProperty(FreeCameraDeviceOrientationInput.prototype, "camera", {
  13363. /**
  13364. * Define the camera controlled by the input.
  13365. */
  13366. get: function () {
  13367. return this._camera;
  13368. },
  13369. set: function (camera) {
  13370. this._camera = camera;
  13371. if (this._camera != null && !this._camera.rotationQuaternion) {
  13372. this._camera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  13373. }
  13374. },
  13375. enumerable: true,
  13376. configurable: true
  13377. });
  13378. /**
  13379. * Attach the input controls to a specific dom element to get the input from.
  13380. * @param element Defines the element the controls should be listened from
  13381. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13382. */
  13383. FreeCameraDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  13384. window.addEventListener("orientationchange", this._orientationChanged);
  13385. window.addEventListener("deviceorientation", this._deviceOrientation);
  13386. //In certain cases, the attach control is called AFTER orientation was changed,
  13387. //So this is needed.
  13388. this._orientationChanged();
  13389. };
  13390. /**
  13391. * Detach the current controls from the specified dom element.
  13392. * @param element Defines the element to stop listening the inputs from
  13393. */
  13394. FreeCameraDeviceOrientationInput.prototype.detachControl = function (element) {
  13395. window.removeEventListener("orientationchange", this._orientationChanged);
  13396. window.removeEventListener("deviceorientation", this._deviceOrientation);
  13397. };
  13398. /**
  13399. * Update the current camera state depending on the inputs that have been used this frame.
  13400. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13401. */
  13402. FreeCameraDeviceOrientationInput.prototype.checkInputs = function () {
  13403. //if no device orientation provided, don't update the rotation.
  13404. //Only testing against alpha under the assumption thatnorientation will never be so exact when set.
  13405. if (!this._alpha) {
  13406. return;
  13407. }
  13408. _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);
  13409. this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);
  13410. this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform);
  13411. //Mirror on XY Plane
  13412. this._camera.rotationQuaternion.z *= -1;
  13413. this._camera.rotationQuaternion.w *= -1;
  13414. };
  13415. /**
  13416. * Gets the class name of the current intput.
  13417. * @returns the class name
  13418. */
  13419. FreeCameraDeviceOrientationInput.prototype.getClassName = function () {
  13420. return "FreeCameraDeviceOrientationInput";
  13421. };
  13422. /**
  13423. * Get the friendly name associated with the input class.
  13424. * @returns the input friendly name
  13425. */
  13426. FreeCameraDeviceOrientationInput.prototype.getSimpleName = function () {
  13427. return "deviceOrientation";
  13428. };
  13429. return FreeCameraDeviceOrientationInput;
  13430. }());
  13431. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["FreeCameraDeviceOrientationInput"] = FreeCameraDeviceOrientationInput;
  13432. /***/ }),
  13433. /***/ "./Cameras/Inputs/freeCameraGamepadInput.ts":
  13434. /*!**************************************************!*\
  13435. !*** ./Cameras/Inputs/freeCameraGamepadInput.ts ***!
  13436. \**************************************************/
  13437. /*! exports provided: FreeCameraGamepadInput */
  13438. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13439. "use strict";
  13440. __webpack_require__.r(__webpack_exports__);
  13441. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return FreeCameraGamepadInput; });
  13442. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13443. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13444. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13445. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13446. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  13447. /**
  13448. * Manage the gamepad inputs to control a free camera.
  13449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13450. */
  13451. var FreeCameraGamepadInput = /** @class */ (function () {
  13452. function FreeCameraGamepadInput() {
  13453. /**
  13454. * Defines the gamepad rotation sensiblity.
  13455. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  13456. */
  13457. this.gamepadAngularSensibility = 200;
  13458. /**
  13459. * Defines the gamepad move sensiblity.
  13460. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  13461. */
  13462. this.gamepadMoveSensibility = 40;
  13463. this._cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  13464. this._deltaTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  13465. this._vector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  13466. this._vector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  13467. }
  13468. /**
  13469. * Attach the input controls to a specific dom element to get the input from.
  13470. * @param element Defines the element the controls should be listened from
  13471. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13472. */
  13473. FreeCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  13474. var _this = this;
  13475. var manager = this.camera.getScene().gamepadManager;
  13476. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  13477. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].POSE_ENABLED) {
  13478. // prioritize XBOX gamepads.
  13479. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX) {
  13480. _this.gamepad = gamepad;
  13481. }
  13482. }
  13483. });
  13484. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  13485. if (_this.gamepad === gamepad) {
  13486. _this.gamepad = null;
  13487. }
  13488. });
  13489. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX);
  13490. };
  13491. /**
  13492. * Detach the current controls from the specified dom element.
  13493. * @param element Defines the element to stop listening the inputs from
  13494. */
  13495. FreeCameraGamepadInput.prototype.detachControl = function (element) {
  13496. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  13497. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  13498. this.gamepad = null;
  13499. };
  13500. /**
  13501. * Update the current camera state depending on the inputs that have been used this frame.
  13502. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13503. */
  13504. FreeCameraGamepadInput.prototype.checkInputs = function () {
  13505. if (this.gamepad && this.gamepad.leftStick) {
  13506. var camera = this.camera;
  13507. var LSValues = this.gamepad.leftStick;
  13508. var normalizedLX = LSValues.x / this.gamepadMoveSensibility;
  13509. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  13510. LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
  13511. LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
  13512. var RSValues = this.gamepad.rightStick;
  13513. if (RSValues) {
  13514. var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
  13515. var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
  13516. RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
  13517. RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
  13518. }
  13519. else {
  13520. RSValues = { x: 0, y: 0 };
  13521. }
  13522. if (!camera.rotationQuaternion) {
  13523. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, this._cameraTransform);
  13524. }
  13525. else {
  13526. camera.rotationQuaternion.toRotationMatrix(this._cameraTransform);
  13527. }
  13528. var speed = camera._computeLocalCameraSpeed() * 50.0;
  13529. this._vector3.copyFromFloats(LSValues.x * speed, 0, -LSValues.y * speed);
  13530. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform);
  13531. camera.cameraDirection.addInPlace(this._deltaTransform);
  13532. this._vector2.copyFromFloats(RSValues.y, RSValues.x);
  13533. camera.cameraRotation.addInPlace(this._vector2);
  13534. }
  13535. };
  13536. /**
  13537. * Gets the class name of the current intput.
  13538. * @returns the class name
  13539. */
  13540. FreeCameraGamepadInput.prototype.getClassName = function () {
  13541. return "FreeCameraGamepadInput";
  13542. };
  13543. /**
  13544. * Get the friendly name associated with the input class.
  13545. * @returns the input friendly name
  13546. */
  13547. FreeCameraGamepadInput.prototype.getSimpleName = function () {
  13548. return "gamepad";
  13549. };
  13550. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13551. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13552. ], FreeCameraGamepadInput.prototype, "gamepadAngularSensibility", void 0);
  13553. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13554. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13555. ], FreeCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  13556. return FreeCameraGamepadInput;
  13557. }());
  13558. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraGamepadInput"] = FreeCameraGamepadInput;
  13559. /***/ }),
  13560. /***/ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts":
  13561. /*!*******************************************************!*\
  13562. !*** ./Cameras/Inputs/freeCameraKeyboardMoveInput.ts ***!
  13563. \*******************************************************/
  13564. /*! exports provided: FreeCameraKeyboardMoveInput */
  13565. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13566. "use strict";
  13567. __webpack_require__.r(__webpack_exports__);
  13568. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return FreeCameraKeyboardMoveInput; });
  13569. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13570. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13571. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13572. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13573. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13574. /**
  13575. * Manage the keyboard inputs to control the movement of a free camera.
  13576. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13577. */
  13578. var FreeCameraKeyboardMoveInput = /** @class */ (function () {
  13579. function FreeCameraKeyboardMoveInput() {
  13580. /**
  13581. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  13582. */
  13583. this.keysUp = [38];
  13584. /**
  13585. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  13586. */
  13587. this.keysDown = [40];
  13588. /**
  13589. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  13590. */
  13591. this.keysLeft = [37];
  13592. /**
  13593. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  13594. */
  13595. this.keysRight = [39];
  13596. this._keys = new Array();
  13597. }
  13598. /**
  13599. * Attach the input controls to a specific dom element to get the input from.
  13600. * @param element Defines the element the controls should be listened from
  13601. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13602. */
  13603. FreeCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  13604. var _this = this;
  13605. if (this._onCanvasBlurObserver) {
  13606. return;
  13607. }
  13608. this._scene = this.camera.getScene();
  13609. this._engine = this._scene.getEngine();
  13610. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13611. _this._keys = [];
  13612. });
  13613. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13614. var evt = info.event;
  13615. if (!evt.metaKey) {
  13616. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13617. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13618. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13619. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13620. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13621. var index = _this._keys.indexOf(evt.keyCode);
  13622. if (index === -1) {
  13623. _this._keys.push(evt.keyCode);
  13624. }
  13625. if (!noPreventDefault) {
  13626. evt.preventDefault();
  13627. }
  13628. }
  13629. }
  13630. else {
  13631. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13632. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13633. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13634. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13635. var index = _this._keys.indexOf(evt.keyCode);
  13636. if (index >= 0) {
  13637. _this._keys.splice(index, 1);
  13638. }
  13639. if (!noPreventDefault) {
  13640. evt.preventDefault();
  13641. }
  13642. }
  13643. }
  13644. }
  13645. });
  13646. };
  13647. /**
  13648. * Detach the current controls from the specified dom element.
  13649. * @param element Defines the element to stop listening the inputs from
  13650. */
  13651. FreeCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  13652. if (this._scene) {
  13653. if (this._onKeyboardObserver) {
  13654. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13655. }
  13656. if (this._onCanvasBlurObserver) {
  13657. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13658. }
  13659. this._onKeyboardObserver = null;
  13660. this._onCanvasBlurObserver = null;
  13661. }
  13662. this._keys = [];
  13663. };
  13664. /**
  13665. * Update the current camera state depending on the inputs that have been used this frame.
  13666. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13667. */
  13668. FreeCameraKeyboardMoveInput.prototype.checkInputs = function () {
  13669. if (this._onKeyboardObserver) {
  13670. var camera = this.camera;
  13671. // Keyboard
  13672. for (var index = 0; index < this._keys.length; index++) {
  13673. var keyCode = this._keys[index];
  13674. var speed = camera._computeLocalCameraSpeed();
  13675. if (this.keysLeft.indexOf(keyCode) !== -1) {
  13676. camera._localDirection.copyFromFloats(-speed, 0, 0);
  13677. }
  13678. else if (this.keysUp.indexOf(keyCode) !== -1) {
  13679. camera._localDirection.copyFromFloats(0, 0, speed);
  13680. }
  13681. else if (this.keysRight.indexOf(keyCode) !== -1) {
  13682. camera._localDirection.copyFromFloats(speed, 0, 0);
  13683. }
  13684. else if (this.keysDown.indexOf(keyCode) !== -1) {
  13685. camera._localDirection.copyFromFloats(0, 0, -speed);
  13686. }
  13687. if (camera.getScene().useRightHandedSystem) {
  13688. camera._localDirection.z *= -1;
  13689. }
  13690. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  13691. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  13692. camera.cameraDirection.addInPlace(camera._transformedDirection);
  13693. }
  13694. }
  13695. };
  13696. /**
  13697. * Gets the class name of the current intput.
  13698. * @returns the class name
  13699. */
  13700. FreeCameraKeyboardMoveInput.prototype.getClassName = function () {
  13701. return "FreeCameraKeyboardMoveInput";
  13702. };
  13703. /** @hidden */
  13704. FreeCameraKeyboardMoveInput.prototype._onLostFocus = function () {
  13705. this._keys = [];
  13706. };
  13707. /**
  13708. * Get the friendly name associated with the input class.
  13709. * @returns the input friendly name
  13710. */
  13711. FreeCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  13712. return "keyboard";
  13713. };
  13714. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13715. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13716. ], FreeCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  13717. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13718. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13719. ], FreeCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  13720. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13721. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13722. ], FreeCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  13723. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13724. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13725. ], FreeCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  13726. return FreeCameraKeyboardMoveInput;
  13727. }());
  13728. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraKeyboardMoveInput"] = FreeCameraKeyboardMoveInput;
  13729. /***/ }),
  13730. /***/ "./Cameras/Inputs/freeCameraMouseInput.ts":
  13731. /*!************************************************!*\
  13732. !*** ./Cameras/Inputs/freeCameraMouseInput.ts ***!
  13733. \************************************************/
  13734. /*! exports provided: FreeCameraMouseInput */
  13735. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13736. "use strict";
  13737. __webpack_require__.r(__webpack_exports__);
  13738. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return FreeCameraMouseInput; });
  13739. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13740. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13741. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13742. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13743. /**
  13744. * Manage the mouse inputs to control the movement of a free camera.
  13745. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13746. */
  13747. var FreeCameraMouseInput = /** @class */ (function () {
  13748. /**
  13749. * Manage the mouse inputs to control the movement of a free camera.
  13750. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13751. * @param touchEnabled Defines if touch is enabled or not
  13752. */
  13753. function FreeCameraMouseInput(
  13754. /**
  13755. * Define if touch is enabled in the mouse input
  13756. */
  13757. touchEnabled) {
  13758. if (touchEnabled === void 0) { touchEnabled = true; }
  13759. this.touchEnabled = touchEnabled;
  13760. /**
  13761. * Defines the buttons associated with the input to handle camera move.
  13762. */
  13763. this.buttons = [0, 1, 2];
  13764. /**
  13765. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  13766. */
  13767. this.angularSensibility = 2000.0;
  13768. this.previousPosition = null;
  13769. }
  13770. /**
  13771. * Attach the input controls to a specific dom element to get the input from.
  13772. * @param element Defines the element the controls should be listened from
  13773. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13774. */
  13775. FreeCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  13776. var _this = this;
  13777. var engine = this.camera.getEngine();
  13778. if (!this._pointerInput) {
  13779. this._pointerInput = function (p) {
  13780. var evt = p.event;
  13781. if (engine.isInVRExclusivePointerMode) {
  13782. return;
  13783. }
  13784. if (!_this.touchEnabled && evt.pointerType === "touch") {
  13785. return;
  13786. }
  13787. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  13788. return;
  13789. }
  13790. var srcElement = (evt.srcElement || evt.target);
  13791. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  13792. try {
  13793. srcElement.setPointerCapture(evt.pointerId);
  13794. }
  13795. catch (e) {
  13796. //Nothing to do with the error. Execution will continue.
  13797. }
  13798. _this.previousPosition = {
  13799. x: evt.clientX,
  13800. y: evt.clientY
  13801. };
  13802. if (!noPreventDefault) {
  13803. evt.preventDefault();
  13804. element.focus();
  13805. }
  13806. }
  13807. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  13808. try {
  13809. srcElement.releasePointerCapture(evt.pointerId);
  13810. }
  13811. catch (e) {
  13812. //Nothing to do with the error.
  13813. }
  13814. _this.previousPosition = null;
  13815. if (!noPreventDefault) {
  13816. evt.preventDefault();
  13817. }
  13818. }
  13819. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13820. if (!_this.previousPosition || engine.isPointerLock) {
  13821. return;
  13822. }
  13823. var offsetX = evt.clientX - _this.previousPosition.x;
  13824. if (_this.camera.getScene().useRightHandedSystem) {
  13825. offsetX *= -1;
  13826. }
  13827. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  13828. offsetX *= -1;
  13829. }
  13830. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  13831. var offsetY = evt.clientY - _this.previousPosition.y;
  13832. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  13833. _this.previousPosition = {
  13834. x: evt.clientX,
  13835. y: evt.clientY
  13836. };
  13837. if (!noPreventDefault) {
  13838. evt.preventDefault();
  13839. }
  13840. }
  13841. };
  13842. }
  13843. this._onMouseMove = function (evt) {
  13844. if (!engine.isPointerLock) {
  13845. return;
  13846. }
  13847. if (engine.isInVRExclusivePointerMode) {
  13848. return;
  13849. }
  13850. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  13851. if (_this.camera.getScene().useRightHandedSystem) {
  13852. offsetX *= -1;
  13853. }
  13854. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  13855. offsetX *= -1;
  13856. }
  13857. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  13858. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  13859. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  13860. _this.previousPosition = null;
  13861. if (!noPreventDefault) {
  13862. evt.preventDefault();
  13863. }
  13864. };
  13865. 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);
  13866. element.addEventListener("mousemove", this._onMouseMove, false);
  13867. };
  13868. /**
  13869. * Detach the current controls from the specified dom element.
  13870. * @param element Defines the element to stop listening the inputs from
  13871. */
  13872. FreeCameraMouseInput.prototype.detachControl = function (element) {
  13873. if (this._observer && element) {
  13874. this.camera.getScene().onPointerObservable.remove(this._observer);
  13875. if (this._onMouseMove) {
  13876. element.removeEventListener("mousemove", this._onMouseMove);
  13877. }
  13878. this._observer = null;
  13879. this._onMouseMove = null;
  13880. this.previousPosition = null;
  13881. }
  13882. };
  13883. /**
  13884. * Gets the class name of the current intput.
  13885. * @returns the class name
  13886. */
  13887. FreeCameraMouseInput.prototype.getClassName = function () {
  13888. return "FreeCameraMouseInput";
  13889. };
  13890. /**
  13891. * Get the friendly name associated with the input class.
  13892. * @returns the input friendly name
  13893. */
  13894. FreeCameraMouseInput.prototype.getSimpleName = function () {
  13895. return "mouse";
  13896. };
  13897. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13898. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13899. ], FreeCameraMouseInput.prototype, "buttons", void 0);
  13900. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13901. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13902. ], FreeCameraMouseInput.prototype, "angularSensibility", void 0);
  13903. return FreeCameraMouseInput;
  13904. }());
  13905. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraMouseInput"] = FreeCameraMouseInput;
  13906. /***/ }),
  13907. /***/ "./Cameras/Inputs/freeCameraTouchInput.ts":
  13908. /*!************************************************!*\
  13909. !*** ./Cameras/Inputs/freeCameraTouchInput.ts ***!
  13910. \************************************************/
  13911. /*! exports provided: FreeCameraTouchInput */
  13912. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13913. "use strict";
  13914. __webpack_require__.r(__webpack_exports__);
  13915. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return FreeCameraTouchInput; });
  13916. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13917. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13918. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13919. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13920. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13921. /**
  13922. * Manage the touch inputs to control the movement of a free camera.
  13923. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13924. */
  13925. var FreeCameraTouchInput = /** @class */ (function () {
  13926. function FreeCameraTouchInput() {
  13927. /**
  13928. * Defines the touch sensibility for rotation.
  13929. * The higher the faster.
  13930. */
  13931. this.touchAngularSensibility = 200000.0;
  13932. /**
  13933. * Defines the touch sensibility for move.
  13934. * The higher the faster.
  13935. */
  13936. this.touchMoveSensibility = 250.0;
  13937. this._offsetX = null;
  13938. this._offsetY = null;
  13939. this._pointerPressed = new Array();
  13940. }
  13941. /**
  13942. * Attach the input controls to a specific dom element to get the input from.
  13943. * @param element Defines the element the controls should be listened from
  13944. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13945. */
  13946. FreeCameraTouchInput.prototype.attachControl = function (element, noPreventDefault) {
  13947. var _this = this;
  13948. var previousPosition = null;
  13949. if (this._pointerInput === undefined) {
  13950. this._onLostFocus = function () {
  13951. _this._offsetX = null;
  13952. _this._offsetY = null;
  13953. };
  13954. this._pointerInput = function (p) {
  13955. var evt = p.event;
  13956. if (evt.pointerType === "mouse") {
  13957. return;
  13958. }
  13959. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN) {
  13960. if (!noPreventDefault) {
  13961. evt.preventDefault();
  13962. }
  13963. _this._pointerPressed.push(evt.pointerId);
  13964. if (_this._pointerPressed.length !== 1) {
  13965. return;
  13966. }
  13967. previousPosition = {
  13968. x: evt.clientX,
  13969. y: evt.clientY
  13970. };
  13971. }
  13972. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP) {
  13973. if (!noPreventDefault) {
  13974. evt.preventDefault();
  13975. }
  13976. var index = _this._pointerPressed.indexOf(evt.pointerId);
  13977. if (index === -1) {
  13978. return;
  13979. }
  13980. _this._pointerPressed.splice(index, 1);
  13981. if (index != 0) {
  13982. return;
  13983. }
  13984. previousPosition = null;
  13985. _this._offsetX = null;
  13986. _this._offsetY = null;
  13987. }
  13988. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13989. if (!noPreventDefault) {
  13990. evt.preventDefault();
  13991. }
  13992. if (!previousPosition) {
  13993. return;
  13994. }
  13995. var index = _this._pointerPressed.indexOf(evt.pointerId);
  13996. if (index != 0) {
  13997. return;
  13998. }
  13999. _this._offsetX = evt.clientX - previousPosition.x;
  14000. _this._offsetY = -(evt.clientY - previousPosition.y);
  14001. }
  14002. };
  14003. }
  14004. 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);
  14005. if (this._onLostFocus) {
  14006. element.addEventListener("blur", this._onLostFocus);
  14007. }
  14008. };
  14009. /**
  14010. * Detach the current controls from the specified dom element.
  14011. * @param element Defines the element to stop listening the inputs from
  14012. */
  14013. FreeCameraTouchInput.prototype.detachControl = function (element) {
  14014. if (this._pointerInput && element) {
  14015. if (this._observer) {
  14016. this.camera.getScene().onPointerObservable.remove(this._observer);
  14017. this._observer = null;
  14018. }
  14019. if (this._onLostFocus) {
  14020. element.removeEventListener("blur", this._onLostFocus);
  14021. this._onLostFocus = null;
  14022. }
  14023. this._pointerPressed = [];
  14024. this._offsetX = null;
  14025. this._offsetY = null;
  14026. }
  14027. };
  14028. /**
  14029. * Update the current camera state depending on the inputs that have been used this frame.
  14030. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14031. */
  14032. FreeCameraTouchInput.prototype.checkInputs = function () {
  14033. if (this._offsetX && this._offsetY) {
  14034. var camera = this.camera;
  14035. camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
  14036. if (this._pointerPressed.length > 1) {
  14037. camera.cameraRotation.x += -this._offsetY / this.touchAngularSensibility;
  14038. }
  14039. else {
  14040. var speed = camera._computeLocalCameraSpeed();
  14041. var direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, speed * this._offsetY / this.touchMoveSensibility);
  14042. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
  14043. camera.cameraDirection.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(direction, camera._cameraRotationMatrix));
  14044. }
  14045. }
  14046. };
  14047. /**
  14048. * Gets the class name of the current intput.
  14049. * @returns the class name
  14050. */
  14051. FreeCameraTouchInput.prototype.getClassName = function () {
  14052. return "FreeCameraTouchInput";
  14053. };
  14054. /**
  14055. * Get the friendly name associated with the input class.
  14056. * @returns the input friendly name
  14057. */
  14058. FreeCameraTouchInput.prototype.getSimpleName = function () {
  14059. return "touch";
  14060. };
  14061. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14062. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14063. ], FreeCameraTouchInput.prototype, "touchAngularSensibility", void 0);
  14064. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14065. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14066. ], FreeCameraTouchInput.prototype, "touchMoveSensibility", void 0);
  14067. return FreeCameraTouchInput;
  14068. }());
  14069. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraTouchInput"] = FreeCameraTouchInput;
  14070. /***/ }),
  14071. /***/ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts":
  14072. /*!**********************************************************!*\
  14073. !*** ./Cameras/Inputs/freeCameraVirtualJoystickInput.ts ***!
  14074. \**********************************************************/
  14075. /*! exports provided: FreeCameraVirtualJoystickInput */
  14076. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14077. "use strict";
  14078. __webpack_require__.r(__webpack_exports__);
  14079. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return FreeCameraVirtualJoystickInput; });
  14080. /* harmony import */ var _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/virtualJoystick */ "./Misc/virtualJoystick.ts");
  14081. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14082. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14083. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  14084. /**
  14085. * Add virtual joystick input support to the input manager.
  14086. * @returns the current input manager
  14087. */
  14088. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addVirtualJoystick = function () {
  14089. this.add(new FreeCameraVirtualJoystickInput());
  14090. return this;
  14091. };
  14092. /**
  14093. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  14094. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14095. */
  14096. var FreeCameraVirtualJoystickInput = /** @class */ (function () {
  14097. function FreeCameraVirtualJoystickInput() {
  14098. }
  14099. /**
  14100. * Gets the left stick of the virtual joystick.
  14101. * @returns The virtual Joystick
  14102. */
  14103. FreeCameraVirtualJoystickInput.prototype.getLeftJoystick = function () {
  14104. return this._leftjoystick;
  14105. };
  14106. /**
  14107. * Gets the right stick of the virtual joystick.
  14108. * @returns The virtual Joystick
  14109. */
  14110. FreeCameraVirtualJoystickInput.prototype.getRightJoystick = function () {
  14111. return this._rightjoystick;
  14112. };
  14113. /**
  14114. * Update the current camera state depending on the inputs that have been used this frame.
  14115. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14116. */
  14117. FreeCameraVirtualJoystickInput.prototype.checkInputs = function () {
  14118. if (this._leftjoystick) {
  14119. var camera = this.camera;
  14120. var speed = camera._computeLocalCameraSpeed() * 50;
  14121. var cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
  14122. 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);
  14123. camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
  14124. camera.cameraRotation = camera.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
  14125. if (!this._leftjoystick.pressed) {
  14126. this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
  14127. }
  14128. if (!this._rightjoystick.pressed) {
  14129. this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9);
  14130. }
  14131. }
  14132. };
  14133. /**
  14134. * Attach the input controls to a specific dom element to get the input from.
  14135. * @param element Defines the element the controls should be listened from
  14136. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14137. */
  14138. FreeCameraVirtualJoystickInput.prototype.attachControl = function (element, noPreventDefault) {
  14139. this._leftjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](true);
  14140. this._leftjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Z);
  14141. this._leftjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  14142. this._leftjoystick.setJoystickSensibility(0.15);
  14143. this._rightjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](false);
  14144. this._rightjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  14145. this._rightjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Y);
  14146. this._rightjoystick.reverseUpDown = true;
  14147. this._rightjoystick.setJoystickSensibility(0.05);
  14148. this._rightjoystick.setJoystickColor("yellow");
  14149. };
  14150. /**
  14151. * Detach the current controls from the specified dom element.
  14152. * @param element Defines the element to stop listening the inputs from
  14153. */
  14154. FreeCameraVirtualJoystickInput.prototype.detachControl = function (element) {
  14155. this._leftjoystick.releaseCanvas();
  14156. this._rightjoystick.releaseCanvas();
  14157. };
  14158. /**
  14159. * Gets the class name of the current intput.
  14160. * @returns the class name
  14161. */
  14162. FreeCameraVirtualJoystickInput.prototype.getClassName = function () {
  14163. return "FreeCameraVirtualJoystickInput";
  14164. };
  14165. /**
  14166. * Get the friendly name associated with the input class.
  14167. * @returns the input friendly name
  14168. */
  14169. FreeCameraVirtualJoystickInput.prototype.getSimpleName = function () {
  14170. return "virtualJoystick";
  14171. };
  14172. return FreeCameraVirtualJoystickInput;
  14173. }());
  14174. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FreeCameraVirtualJoystickInput"] = FreeCameraVirtualJoystickInput;
  14175. /***/ }),
  14176. /***/ "./Cameras/Inputs/index.ts":
  14177. /*!*********************************!*\
  14178. !*** ./Cameras/Inputs/index.ts ***!
  14179. \*********************************/
  14180. /*! exports provided: ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput */
  14181. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14182. "use strict";
  14183. __webpack_require__.r(__webpack_exports__);
  14184. /* harmony import */ var _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  14185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  14186. /* harmony import */ var _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  14187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraKeyboardMoveInput"]; });
  14188. /* harmony import */ var _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  14189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraMouseWheelInput"]; });
  14190. /* harmony import */ var _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  14191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraPointersInput"]; });
  14192. /* harmony import */ var _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  14193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__["ArcRotateCameraVRDeviceOrientationInput"]; });
  14194. /* harmony import */ var _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  14195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__["FlyCameraKeyboardInput"]; });
  14196. /* harmony import */ var _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  14197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__["FlyCameraMouseInput"]; });
  14198. /* harmony import */ var _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  14199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  14200. /* harmony import */ var _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  14201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_8__["FreeCameraGamepadInput"]; });
  14202. /* harmony import */ var _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  14203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_9__["FreeCameraKeyboardMoveInput"]; });
  14204. /* harmony import */ var _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  14205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_10__["FreeCameraMouseInput"]; });
  14206. /* harmony import */ var _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  14207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_11__["FreeCameraTouchInput"]; });
  14208. /* harmony import */ var _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  14209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_12__["FreeCameraVirtualJoystickInput"]; });
  14210. /***/ }),
  14211. /***/ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts":
  14212. /*!*********************************************************!*\
  14213. !*** ./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts ***!
  14214. \*********************************************************/
  14215. /*! no exports provided */
  14216. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14217. "use strict";
  14218. __webpack_require__.r(__webpack_exports__);
  14219. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14220. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  14221. /* harmony import */ var _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  14222. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicAnaglyphRigMode = function (camera) {
  14223. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  14224. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__["AnaglyphPostProcess"](camera.name + "_anaglyph", 1.0, camera._rigCameras);
  14225. };
  14226. /***/ }),
  14227. /***/ "./Cameras/RigModes/stereoscopicRigMode.ts":
  14228. /*!*************************************************!*\
  14229. !*** ./Cameras/RigModes/stereoscopicRigMode.ts ***!
  14230. \*************************************************/
  14231. /*! no exports provided */
  14232. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14233. "use strict";
  14234. __webpack_require__.r(__webpack_exports__);
  14235. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14236. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  14237. /* harmony import */ var _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  14238. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicRigMode = function (camera) {
  14239. 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;
  14240. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  14241. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__["StereoscopicInterlacePostProcess"](camera.name + "_stereoInterlace", camera._rigCameras, isStereoscopicHoriz);
  14242. };
  14243. /***/ }),
  14244. /***/ "./Cameras/RigModes/vrRigMode.ts":
  14245. /*!***************************************!*\
  14246. !*** ./Cameras/RigModes/vrRigMode.ts ***!
  14247. \***************************************/
  14248. /*! no exports provided */
  14249. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14250. "use strict";
  14251. __webpack_require__.r(__webpack_exports__);
  14252. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14253. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14254. /* harmony import */ var _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  14255. /* harmony import */ var _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  14256. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setVRRigMode = function (camera, rigParams) {
  14257. var metrics = rigParams.vrCameraMetrics || _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault();
  14258. camera._rigCameras[0]._cameraRigParams.vrMetrics = metrics;
  14259. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  14260. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14261. camera._rigCameras[0]._cameraRigParams.vrHMatrix = metrics.leftHMatrix;
  14262. camera._rigCameras[0]._cameraRigParams.vrPreViewMatrix = metrics.leftPreViewMatrix;
  14263. camera._rigCameras[0].getProjectionMatrix = camera._rigCameras[0]._getVRProjectionMatrix;
  14264. camera._rigCameras[1]._cameraRigParams.vrMetrics = metrics;
  14265. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  14266. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14267. camera._rigCameras[1]._cameraRigParams.vrHMatrix = metrics.rightHMatrix;
  14268. camera._rigCameras[1]._cameraRigParams.vrPreViewMatrix = metrics.rightPreViewMatrix;
  14269. camera._rigCameras[1].getProjectionMatrix = camera._rigCameras[1]._getVRProjectionMatrix;
  14270. if (metrics.compensateDistortion) {
  14271. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Left", camera._rigCameras[0], false, metrics);
  14272. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Right", camera._rigCameras[1], true, metrics);
  14273. }
  14274. };
  14275. /***/ }),
  14276. /***/ "./Cameras/RigModes/webVRRigMode.ts":
  14277. /*!******************************************!*\
  14278. !*** ./Cameras/RigModes/webVRRigMode.ts ***!
  14279. \******************************************/
  14280. /*! no exports provided */
  14281. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14282. "use strict";
  14283. __webpack_require__.r(__webpack_exports__);
  14284. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14285. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14286. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setWebVRRigMode = function (camera, rigParams) {
  14287. if (rigParams.vrDisplay) {
  14288. var leftEye = rigParams.vrDisplay.getEyeParameters('left');
  14289. var rightEye = rigParams.vrDisplay.getEyeParameters('right');
  14290. //Left eye
  14291. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  14292. camera._rigCameras[0].setCameraRigParameter("left", true);
  14293. //leaving this for future reference
  14294. camera._rigCameras[0].setCameraRigParameter("specs", rigParams.specs);
  14295. camera._rigCameras[0].setCameraRigParameter("eyeParameters", leftEye);
  14296. camera._rigCameras[0].setCameraRigParameter("frameData", rigParams.frameData);
  14297. camera._rigCameras[0].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  14298. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14299. camera._rigCameras[0].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  14300. camera._rigCameras[0].parent = camera;
  14301. camera._rigCameras[0]._getViewMatrix = camera._getWebVRViewMatrix;
  14302. //Right eye
  14303. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  14304. camera._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
  14305. camera._rigCameras[1].setCameraRigParameter("specs", rigParams.specs);
  14306. camera._rigCameras[1].setCameraRigParameter("frameData", rigParams.frameData);
  14307. camera._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  14308. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14309. camera._rigCameras[1].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  14310. camera._rigCameras[1].parent = camera;
  14311. camera._rigCameras[1]._getViewMatrix = camera._getWebVRViewMatrix;
  14312. if (_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].UseAlternateWebVRRendering) {
  14313. camera._rigCameras[1]._skipRendering = true;
  14314. camera._rigCameras[0]._alternateCamera = camera._rigCameras[1];
  14315. }
  14316. }
  14317. };
  14318. /***/ }),
  14319. /***/ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts":
  14320. /*!*********************************************************!*\
  14321. !*** ./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts ***!
  14322. \*********************************************************/
  14323. /*! exports provided: AnaglyphArcRotateCamera */
  14324. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14325. "use strict";
  14326. __webpack_require__.r(__webpack_exports__);
  14327. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return AnaglyphArcRotateCamera; });
  14328. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14329. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14330. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  14331. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14332. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14333. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14334. // Side effect import to define the stereoscopic mode.
  14335. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphArcRotateCamera", function (name, scene, options) {
  14336. return function () { return new AnaglyphArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14337. });
  14338. /**
  14339. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  14340. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14341. */
  14342. var AnaglyphArcRotateCamera = /** @class */ (function (_super) {
  14343. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphArcRotateCamera, _super);
  14344. /**
  14345. * Creates a new AnaglyphArcRotateCamera
  14346. * @param name defines camera name
  14347. * @param alpha defines alpha angle (in radians)
  14348. * @param beta defines beta angle (in radians)
  14349. * @param radius defines radius
  14350. * @param target defines camera target
  14351. * @param interaxialDistance defines distance between each color axis
  14352. * @param scene defines the hosting scene
  14353. */
  14354. function AnaglyphArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, scene) {
  14355. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  14356. _this.interaxialDistance = interaxialDistance;
  14357. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14358. return _this;
  14359. }
  14360. /**
  14361. * Gets camera class name
  14362. * @returns AnaglyphArcRotateCamera
  14363. */
  14364. AnaglyphArcRotateCamera.prototype.getClassName = function () {
  14365. return "AnaglyphArcRotateCamera";
  14366. };
  14367. return AnaglyphArcRotateCamera;
  14368. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  14369. /***/ }),
  14370. /***/ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts":
  14371. /*!****************************************************!*\
  14372. !*** ./Cameras/Stereoscopic/anaglyphFreeCamera.ts ***!
  14373. \****************************************************/
  14374. /*! exports provided: AnaglyphFreeCamera */
  14375. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14376. "use strict";
  14377. __webpack_require__.r(__webpack_exports__);
  14378. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return AnaglyphFreeCamera; });
  14379. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14380. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14381. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  14382. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14383. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14384. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14385. // Side effect import to define the stereoscopic mode.
  14386. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphFreeCamera", function (name, scene, options) {
  14387. return function () { return new AnaglyphFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14388. });
  14389. /**
  14390. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  14391. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14392. */
  14393. var AnaglyphFreeCamera = /** @class */ (function (_super) {
  14394. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphFreeCamera, _super);
  14395. /**
  14396. * Creates a new AnaglyphFreeCamera
  14397. * @param name defines camera name
  14398. * @param position defines initial position
  14399. * @param interaxialDistance defines distance between each color axis
  14400. * @param scene defines the hosting scene
  14401. */
  14402. function AnaglyphFreeCamera(name, position, interaxialDistance, scene) {
  14403. var _this = _super.call(this, name, position, scene) || this;
  14404. _this.interaxialDistance = interaxialDistance;
  14405. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14406. return _this;
  14407. }
  14408. /**
  14409. * Gets camera class name
  14410. * @returns AnaglyphFreeCamera
  14411. */
  14412. AnaglyphFreeCamera.prototype.getClassName = function () {
  14413. return "AnaglyphFreeCamera";
  14414. };
  14415. return AnaglyphFreeCamera;
  14416. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  14417. /***/ }),
  14418. /***/ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts":
  14419. /*!*******************************************************!*\
  14420. !*** ./Cameras/Stereoscopic/anaglyphGamepadCamera.ts ***!
  14421. \*******************************************************/
  14422. /*! exports provided: AnaglyphGamepadCamera */
  14423. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14424. "use strict";
  14425. __webpack_require__.r(__webpack_exports__);
  14426. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return AnaglyphGamepadCamera; });
  14427. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14428. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14429. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  14430. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14431. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14432. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14433. // Side effect import to define the stereoscopic mode.
  14434. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphGamepadCamera", function (name, scene, options) {
  14435. return function () { return new AnaglyphGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14436. });
  14437. /**
  14438. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  14439. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14440. */
  14441. var AnaglyphGamepadCamera = /** @class */ (function (_super) {
  14442. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphGamepadCamera, _super);
  14443. /**
  14444. * Creates a new AnaglyphGamepadCamera
  14445. * @param name defines camera name
  14446. * @param position defines initial position
  14447. * @param interaxialDistance defines distance between each color axis
  14448. * @param scene defines the hosting scene
  14449. */
  14450. function AnaglyphGamepadCamera(name, position, interaxialDistance, scene) {
  14451. var _this = _super.call(this, name, position, scene) || this;
  14452. _this.interaxialDistance = interaxialDistance;
  14453. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14454. return _this;
  14455. }
  14456. /**
  14457. * Gets camera class name
  14458. * @returns AnaglyphGamepadCamera
  14459. */
  14460. AnaglyphGamepadCamera.prototype.getClassName = function () {
  14461. return "AnaglyphGamepadCamera";
  14462. };
  14463. return AnaglyphGamepadCamera;
  14464. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  14465. /***/ }),
  14466. /***/ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts":
  14467. /*!*********************************************************!*\
  14468. !*** ./Cameras/Stereoscopic/anaglyphUniversalCamera.ts ***!
  14469. \*********************************************************/
  14470. /*! exports provided: AnaglyphUniversalCamera */
  14471. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14472. "use strict";
  14473. __webpack_require__.r(__webpack_exports__);
  14474. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return AnaglyphUniversalCamera; });
  14475. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14476. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14477. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  14478. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14479. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14480. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14481. // Side effect import to define the stereoscopic mode.
  14482. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphUniversalCamera", function (name, scene, options) {
  14483. return function () { return new AnaglyphUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14484. });
  14485. /**
  14486. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  14487. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14488. */
  14489. var AnaglyphUniversalCamera = /** @class */ (function (_super) {
  14490. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphUniversalCamera, _super);
  14491. /**
  14492. * Creates a new AnaglyphUniversalCamera
  14493. * @param name defines camera name
  14494. * @param position defines initial position
  14495. * @param interaxialDistance defines distance between each color axis
  14496. * @param scene defines the hosting scene
  14497. */
  14498. function AnaglyphUniversalCamera(name, position, interaxialDistance, scene) {
  14499. var _this = _super.call(this, name, position, scene) || this;
  14500. _this.interaxialDistance = interaxialDistance;
  14501. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14502. return _this;
  14503. }
  14504. /**
  14505. * Gets camera class name
  14506. * @returns AnaglyphUniversalCamera
  14507. */
  14508. AnaglyphUniversalCamera.prototype.getClassName = function () {
  14509. return "AnaglyphUniversalCamera";
  14510. };
  14511. return AnaglyphUniversalCamera;
  14512. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  14513. /***/ }),
  14514. /***/ "./Cameras/Stereoscopic/index.ts":
  14515. /*!***************************************!*\
  14516. !*** ./Cameras/Stereoscopic/index.ts ***!
  14517. \***************************************/
  14518. /*! exports provided: AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera */
  14519. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14520. "use strict";
  14521. __webpack_require__.r(__webpack_exports__);
  14522. /* harmony import */ var _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphArcRotateCamera */ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts");
  14523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  14524. /* harmony import */ var _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./anaglyphFreeCamera */ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts");
  14525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__["AnaglyphFreeCamera"]; });
  14526. /* harmony import */ var _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./anaglyphGamepadCamera */ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts");
  14527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__["AnaglyphGamepadCamera"]; });
  14528. /* harmony import */ var _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./anaglyphUniversalCamera */ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts");
  14529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__["AnaglyphUniversalCamera"]; });
  14530. /* harmony import */ var _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stereoscopicArcRotateCamera */ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts");
  14531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__["StereoscopicArcRotateCamera"]; });
  14532. /* harmony import */ var _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stereoscopicFreeCamera */ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts");
  14533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__["StereoscopicFreeCamera"]; });
  14534. /* harmony import */ var _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./stereoscopicGamepadCamera */ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts");
  14535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__["StereoscopicGamepadCamera"]; });
  14536. /* harmony import */ var _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stereoscopicUniversalCamera */ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts");
  14537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  14538. /***/ }),
  14539. /***/ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts":
  14540. /*!*************************************************************!*\
  14541. !*** ./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts ***!
  14542. \*************************************************************/
  14543. /*! exports provided: StereoscopicArcRotateCamera */
  14544. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14545. "use strict";
  14546. __webpack_require__.r(__webpack_exports__);
  14547. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return StereoscopicArcRotateCamera; });
  14548. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14549. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14550. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  14551. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14552. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14553. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  14554. // Side effect import to define the stereoscopic mode.
  14555. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicArcRotateCamera", function (name, scene, options) {
  14556. return function () { return new StereoscopicArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  14557. });
  14558. /**
  14559. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  14560. * @see http://doc.babylonjs.com/features/cameras
  14561. */
  14562. var StereoscopicArcRotateCamera = /** @class */ (function (_super) {
  14563. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicArcRotateCamera, _super);
  14564. /**
  14565. * Creates a new StereoscopicArcRotateCamera
  14566. * @param name defines camera name
  14567. * @param alpha defines alpha angle (in radians)
  14568. * @param beta defines beta angle (in radians)
  14569. * @param radius defines radius
  14570. * @param target defines camera target
  14571. * @param interaxialDistance defines distance between each color axis
  14572. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  14573. * @param scene defines the hosting scene
  14574. */
  14575. function StereoscopicArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, isStereoscopicSideBySide, scene) {
  14576. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  14577. _this.interaxialDistance = interaxialDistance;
  14578. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  14579. _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 });
  14580. return _this;
  14581. }
  14582. /**
  14583. * Gets camera class name
  14584. * @returns StereoscopicArcRotateCamera
  14585. */
  14586. StereoscopicArcRotateCamera.prototype.getClassName = function () {
  14587. return "StereoscopicArcRotateCamera";
  14588. };
  14589. return StereoscopicArcRotateCamera;
  14590. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  14591. /***/ }),
  14592. /***/ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts":
  14593. /*!********************************************************!*\
  14594. !*** ./Cameras/Stereoscopic/stereoscopicFreeCamera.ts ***!
  14595. \********************************************************/
  14596. /*! exports provided: StereoscopicFreeCamera */
  14597. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14598. "use strict";
  14599. __webpack_require__.r(__webpack_exports__);
  14600. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return StereoscopicFreeCamera; });
  14601. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14602. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14603. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  14604. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14605. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14606. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  14607. // Side effect import to define the stereoscopic mode.
  14608. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  14609. return function () { return new StereoscopicFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  14610. });
  14611. /**
  14612. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  14613. * @see http://doc.babylonjs.com/features/cameras
  14614. */
  14615. var StereoscopicFreeCamera = /** @class */ (function (_super) {
  14616. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicFreeCamera, _super);
  14617. /**
  14618. * Creates a new StereoscopicFreeCamera
  14619. * @param name defines camera name
  14620. * @param position defines initial position
  14621. * @param interaxialDistance defines distance between each color axis
  14622. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  14623. * @param scene defines the hosting scene
  14624. */
  14625. function StereoscopicFreeCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  14626. var _this = _super.call(this, name, position, scene) || this;
  14627. _this.interaxialDistance = interaxialDistance;
  14628. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  14629. _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 });
  14630. return _this;
  14631. }
  14632. /**
  14633. * Gets camera class name
  14634. * @returns StereoscopicFreeCamera
  14635. */
  14636. StereoscopicFreeCamera.prototype.getClassName = function () {
  14637. return "StereoscopicFreeCamera";
  14638. };
  14639. return StereoscopicFreeCamera;
  14640. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  14641. /***/ }),
  14642. /***/ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts":
  14643. /*!***********************************************************!*\
  14644. !*** ./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts ***!
  14645. \***********************************************************/
  14646. /*! exports provided: StereoscopicGamepadCamera */
  14647. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14648. "use strict";
  14649. __webpack_require__.r(__webpack_exports__);
  14650. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return StereoscopicGamepadCamera; });
  14651. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14652. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14653. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  14654. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14655. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14656. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  14657. // Side effect import to define the stereoscopic mode.
  14658. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicGamepadCamera", function (name, scene, options) {
  14659. return function () { return new StereoscopicGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  14660. });
  14661. /**
  14662. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  14663. * @see http://doc.babylonjs.com/features/cameras
  14664. */
  14665. var StereoscopicGamepadCamera = /** @class */ (function (_super) {
  14666. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicGamepadCamera, _super);
  14667. /**
  14668. * Creates a new StereoscopicGamepadCamera
  14669. * @param name defines camera name
  14670. * @param position defines initial position
  14671. * @param interaxialDistance defines distance between each color axis
  14672. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  14673. * @param scene defines the hosting scene
  14674. */
  14675. function StereoscopicGamepadCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  14676. var _this = _super.call(this, name, position, scene) || this;
  14677. _this.interaxialDistance = interaxialDistance;
  14678. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  14679. _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 });
  14680. return _this;
  14681. }
  14682. /**
  14683. * Gets camera class name
  14684. * @returns StereoscopicGamepadCamera
  14685. */
  14686. StereoscopicGamepadCamera.prototype.getClassName = function () {
  14687. return "StereoscopicGamepadCamera";
  14688. };
  14689. return StereoscopicGamepadCamera;
  14690. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  14691. /***/ }),
  14692. /***/ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts":
  14693. /*!*************************************************************!*\
  14694. !*** ./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts ***!
  14695. \*************************************************************/
  14696. /*! exports provided: StereoscopicUniversalCamera */
  14697. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14698. "use strict";
  14699. __webpack_require__.r(__webpack_exports__);
  14700. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return StereoscopicUniversalCamera; });
  14701. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14702. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14703. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  14704. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14705. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14706. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  14707. // Side effect import to define the stereoscopic mode.
  14708. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  14709. return function () { return new StereoscopicUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  14710. });
  14711. /**
  14712. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  14713. * @see http://doc.babylonjs.com/features/cameras
  14714. */
  14715. var StereoscopicUniversalCamera = /** @class */ (function (_super) {
  14716. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicUniversalCamera, _super);
  14717. /**
  14718. * Creates a new StereoscopicUniversalCamera
  14719. * @param name defines camera name
  14720. * @param position defines initial position
  14721. * @param interaxialDistance defines distance between each color axis
  14722. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  14723. * @param scene defines the hosting scene
  14724. */
  14725. function StereoscopicUniversalCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  14726. var _this = _super.call(this, name, position, scene) || this;
  14727. _this.interaxialDistance = interaxialDistance;
  14728. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  14729. _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 });
  14730. return _this;
  14731. }
  14732. /**
  14733. * Gets camera class name
  14734. * @returns StereoscopicUniversalCamera
  14735. */
  14736. StereoscopicUniversalCamera.prototype.getClassName = function () {
  14737. return "StereoscopicUniversalCamera";
  14738. };
  14739. return StereoscopicUniversalCamera;
  14740. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  14741. /***/ }),
  14742. /***/ "./Cameras/VR/index.ts":
  14743. /*!*****************************!*\
  14744. !*** ./Cameras/VR/index.ts ***!
  14745. \*****************************/
  14746. /*! exports provided: VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera */
  14747. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14748. "use strict";
  14749. __webpack_require__.r(__webpack_exports__);
  14750. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  14751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  14752. /* harmony import */ var _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationArcRotateCamera */ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts");
  14753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationArcRotateCamera"]; });
  14754. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  14755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__["VRDeviceOrientationFreeCamera"]; });
  14756. /* harmony import */ var _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrDeviceOrientationGamepadCamera */ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts");
  14757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__["VRDeviceOrientationGamepadCamera"]; });
  14758. /* harmony import */ var _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  14759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["VRExperienceHelper"]; });
  14760. /* harmony import */ var _webVRCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  14761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _webVRCamera__WEBPACK_IMPORTED_MODULE_5__["WebVRFreeCamera"]; });
  14762. /***/ }),
  14763. /***/ "./Cameras/VR/vrCameraMetrics.ts":
  14764. /*!***************************************!*\
  14765. !*** ./Cameras/VR/vrCameraMetrics.ts ***!
  14766. \***************************************/
  14767. /*! exports provided: VRCameraMetrics */
  14768. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14769. "use strict";
  14770. __webpack_require__.r(__webpack_exports__);
  14771. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return VRCameraMetrics; });
  14772. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14773. /**
  14774. * This represents all the required metrics to create a VR camera.
  14775. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  14776. */
  14777. var VRCameraMetrics = /** @class */ (function () {
  14778. function VRCameraMetrics() {
  14779. /**
  14780. * Define if the current vr camera should compensate the distortion of the lense or not.
  14781. */
  14782. this.compensateDistortion = true;
  14783. }
  14784. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatio", {
  14785. /**
  14786. * Gets the rendering aspect ratio based on the provided resolutions.
  14787. */
  14788. get: function () {
  14789. return this.hResolution / (2 * this.vResolution);
  14790. },
  14791. enumerable: true,
  14792. configurable: true
  14793. });
  14794. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatioFov", {
  14795. /**
  14796. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  14797. */
  14798. get: function () {
  14799. return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
  14800. },
  14801. enumerable: true,
  14802. configurable: true
  14803. });
  14804. Object.defineProperty(VRCameraMetrics.prototype, "leftHMatrix", {
  14805. /**
  14806. * @hidden
  14807. */
  14808. get: function () {
  14809. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  14810. var h = (4 * meters) / this.hScreenSize;
  14811. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(h, 0, 0);
  14812. },
  14813. enumerable: true,
  14814. configurable: true
  14815. });
  14816. Object.defineProperty(VRCameraMetrics.prototype, "rightHMatrix", {
  14817. /**
  14818. * @hidden
  14819. */
  14820. get: function () {
  14821. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  14822. var h = (4 * meters) / this.hScreenSize;
  14823. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-h, 0, 0);
  14824. },
  14825. enumerable: true,
  14826. configurable: true
  14827. });
  14828. Object.defineProperty(VRCameraMetrics.prototype, "leftPreViewMatrix", {
  14829. /**
  14830. * @hidden
  14831. */
  14832. get: function () {
  14833. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(0.5 * this.interpupillaryDistance, 0, 0);
  14834. },
  14835. enumerable: true,
  14836. configurable: true
  14837. });
  14838. Object.defineProperty(VRCameraMetrics.prototype, "rightPreViewMatrix", {
  14839. /**
  14840. * @hidden
  14841. */
  14842. get: function () {
  14843. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-0.5 * this.interpupillaryDistance, 0, 0);
  14844. },
  14845. enumerable: true,
  14846. configurable: true
  14847. });
  14848. /**
  14849. * Get the default VRMetrics based on the most generic setup.
  14850. * @returns the default vr metrics
  14851. */
  14852. VRCameraMetrics.GetDefault = function () {
  14853. var result = new VRCameraMetrics();
  14854. result.hResolution = 1280;
  14855. result.vResolution = 800;
  14856. result.hScreenSize = 0.149759993;
  14857. result.vScreenSize = 0.0935999975;
  14858. result.vScreenCenter = 0.0467999987;
  14859. result.eyeToScreenDistance = 0.0410000011;
  14860. result.lensSeparationDistance = 0.0635000020;
  14861. result.interpupillaryDistance = 0.0640000030;
  14862. result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];
  14863. result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];
  14864. result.postProcessScaleFactor = 1.714605507808412;
  14865. result.lensCenterOffset = 0.151976421;
  14866. return result;
  14867. };
  14868. return VRCameraMetrics;
  14869. }());
  14870. /***/ }),
  14871. /***/ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts":
  14872. /*!**********************************************************!*\
  14873. !*** ./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts ***!
  14874. \**********************************************************/
  14875. /*! exports provided: VRDeviceOrientationArcRotateCamera */
  14876. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14877. "use strict";
  14878. __webpack_require__.r(__webpack_exports__);
  14879. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return VRDeviceOrientationArcRotateCamera; });
  14880. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14881. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14882. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  14883. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  14884. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14885. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14886. /* harmony import */ var _Inputs_arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Inputs/arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  14887. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  14888. // Side effect import to define the stereoscopic mode.
  14889. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  14890. return function () { return new VRDeviceOrientationArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  14891. });
  14892. /**
  14893. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  14894. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  14895. */
  14896. var VRDeviceOrientationArcRotateCamera = /** @class */ (function (_super) {
  14897. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationArcRotateCamera, _super);
  14898. /**
  14899. * Creates a new VRDeviceOrientationArcRotateCamera
  14900. * @param name defines camera name
  14901. * @param alpha defines the camera rotation along the logitudinal axis
  14902. * @param beta defines the camera rotation along the latitudinal axis
  14903. * @param radius defines the camera distance from its target
  14904. * @param target defines the camera target
  14905. * @param scene defines the scene the camera belongs to
  14906. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  14907. * @param vrCameraMetrics defines the vr metrics associated to the camera
  14908. */
  14909. function VRDeviceOrientationArcRotateCamera(name, alpha, beta, radius, target, scene, compensateDistortion, vrCameraMetrics) {
  14910. if (compensateDistortion === void 0) { compensateDistortion = true; }
  14911. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  14912. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  14913. vrCameraMetrics.compensateDistortion = compensateDistortion;
  14914. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  14915. _this.inputs.addVRDeviceOrientation();
  14916. return _this;
  14917. }
  14918. /**
  14919. * Gets camera class name
  14920. * @returns VRDeviceOrientationArcRotateCamera
  14921. */
  14922. VRDeviceOrientationArcRotateCamera.prototype.getClassName = function () {
  14923. return "VRDeviceOrientationArcRotateCamera";
  14924. };
  14925. return VRDeviceOrientationArcRotateCamera;
  14926. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  14927. /***/ }),
  14928. /***/ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts":
  14929. /*!*****************************************************!*\
  14930. !*** ./Cameras/VR/vrDeviceOrientationFreeCamera.ts ***!
  14931. \*****************************************************/
  14932. /*! exports provided: VRDeviceOrientationFreeCamera */
  14933. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14934. "use strict";
  14935. __webpack_require__.r(__webpack_exports__);
  14936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return VRDeviceOrientationFreeCamera; });
  14937. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14938. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14939. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  14940. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  14941. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14942. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14943. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  14944. // Side effect import to define the stereoscopic mode.
  14945. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  14946. return function () { return new VRDeviceOrientationFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  14947. });
  14948. /**
  14949. * Camera used to simulate VR rendering (based on FreeCamera)
  14950. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  14951. */
  14952. var VRDeviceOrientationFreeCamera = /** @class */ (function (_super) {
  14953. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationFreeCamera, _super);
  14954. /**
  14955. * Creates a new VRDeviceOrientationFreeCamera
  14956. * @param name defines camera name
  14957. * @param position defines the start position of the camera
  14958. * @param scene defines the scene the camera belongs to
  14959. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  14960. * @param vrCameraMetrics defines the vr metrics associated to the camera
  14961. */
  14962. function VRDeviceOrientationFreeCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  14963. if (compensateDistortion === void 0) { compensateDistortion = true; }
  14964. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  14965. var _this = _super.call(this, name, position, scene) || this;
  14966. vrCameraMetrics.compensateDistortion = compensateDistortion;
  14967. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  14968. return _this;
  14969. }
  14970. /**
  14971. * Gets camera class name
  14972. * @returns VRDeviceOrientationFreeCamera
  14973. */
  14974. VRDeviceOrientationFreeCamera.prototype.getClassName = function () {
  14975. return "VRDeviceOrientationFreeCamera";
  14976. };
  14977. return VRDeviceOrientationFreeCamera;
  14978. }(_Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__["DeviceOrientationCamera"]));
  14979. /***/ }),
  14980. /***/ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts":
  14981. /*!********************************************************!*\
  14982. !*** ./Cameras/VR/vrDeviceOrientationGamepadCamera.ts ***!
  14983. \********************************************************/
  14984. /*! exports provided: VRDeviceOrientationGamepadCamera */
  14985. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14986. "use strict";
  14987. __webpack_require__.r(__webpack_exports__);
  14988. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return VRDeviceOrientationGamepadCamera; });
  14989. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14990. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  14991. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  14992. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14993. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14994. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("VRDeviceOrientationGamepadCamera", function (name, scene) {
  14995. return function () { return new VRDeviceOrientationGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  14996. });
  14997. /**
  14998. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  14999. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15000. */
  15001. var VRDeviceOrientationGamepadCamera = /** @class */ (function (_super) {
  15002. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationGamepadCamera, _super);
  15003. /**
  15004. * Creates a new VRDeviceOrientationGamepadCamera
  15005. * @param name defines camera name
  15006. * @param position defines the start position of the camera
  15007. * @param scene defines the scene the camera belongs to
  15008. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15009. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15010. */
  15011. function VRDeviceOrientationGamepadCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15012. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15013. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__["VRCameraMetrics"].GetDefault(); }
  15014. var _this = _super.call(this, name, position, scene, compensateDistortion, vrCameraMetrics) || this;
  15015. _this.inputs.addGamepad();
  15016. return _this;
  15017. }
  15018. /**
  15019. * Gets camera class name
  15020. * @returns VRDeviceOrientationGamepadCamera
  15021. */
  15022. VRDeviceOrientationGamepadCamera.prototype.getClassName = function () {
  15023. return "VRDeviceOrientationGamepadCamera";
  15024. };
  15025. return VRDeviceOrientationGamepadCamera;
  15026. }(_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationFreeCamera"]));
  15027. /***/ }),
  15028. /***/ "./Cameras/VR/vrExperienceHelper.ts":
  15029. /*!******************************************!*\
  15030. !*** ./Cameras/VR/vrExperienceHelper.ts ***!
  15031. \******************************************/
  15032. /*! exports provided: VRExperienceHelper */
  15033. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15034. "use strict";
  15035. __webpack_require__.r(__webpack_exports__);
  15036. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return VRExperienceHelper; });
  15037. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15038. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  15039. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  15040. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15041. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  15042. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15043. /* harmony import */ var _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Cameras/VR/vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15044. /* harmony import */ var _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Cameras/VR/webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15045. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  15046. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15047. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  15048. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  15049. /* harmony import */ var _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Gamepads/Controllers/webVRController */ "./Gamepads/Controllers/webVRController.ts");
  15050. /* harmony import */ var _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Gamepads/xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  15051. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  15052. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  15053. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  15054. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  15055. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  15056. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  15057. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  15058. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  15059. var VRExperienceHelperGazer = /** @class */ (function () {
  15060. function VRExperienceHelperGazer(scene, gazeTrackerToClone) {
  15061. if (gazeTrackerToClone === void 0) { gazeTrackerToClone = null; }
  15062. this.scene = scene;
  15063. /** @hidden */
  15064. this._pointerDownOnMeshAsked = false;
  15065. /** @hidden */
  15066. this._isActionableMesh = false;
  15067. /** @hidden */
  15068. this._teleportationRequestInitiated = false;
  15069. /** @hidden */
  15070. this._teleportationBackRequestInitiated = false;
  15071. /** @hidden */
  15072. this._rotationRightAsked = false;
  15073. /** @hidden */
  15074. this._rotationLeftAsked = false;
  15075. /** @hidden */
  15076. this._dpadPressed = true;
  15077. /** @hidden */
  15078. this._activePointer = false;
  15079. this._id = VRExperienceHelperGazer._idCounter++;
  15080. // Gaze tracker
  15081. if (!gazeTrackerToClone) {
  15082. this._gazeTracker = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("gazeTracker", 0.0035, 0.0025, 20, scene, false);
  15083. this._gazeTracker.bakeCurrentTransformIntoVertices();
  15084. this._gazeTracker.isPickable = false;
  15085. this._gazeTracker.isVisible = false;
  15086. var targetMat = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("targetMat", scene);
  15087. targetMat.specularColor = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"].Black();
  15088. targetMat.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  15089. targetMat.backFaceCulling = false;
  15090. this._gazeTracker.material = targetMat;
  15091. }
  15092. else {
  15093. this._gazeTracker = gazeTrackerToClone.clone("gazeTracker");
  15094. }
  15095. }
  15096. /** @hidden */
  15097. VRExperienceHelperGazer.prototype._getForwardRay = function (length) {
  15098. 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));
  15099. };
  15100. /** @hidden */
  15101. VRExperienceHelperGazer.prototype._selectionPointerDown = function () {
  15102. this._pointerDownOnMeshAsked = true;
  15103. if (this._currentHit) {
  15104. this.scene.simulatePointerDown(this._currentHit, { pointerId: this._id });
  15105. }
  15106. };
  15107. /** @hidden */
  15108. VRExperienceHelperGazer.prototype._selectionPointerUp = function () {
  15109. if (this._currentHit) {
  15110. this.scene.simulatePointerUp(this._currentHit, { pointerId: this._id });
  15111. }
  15112. this._pointerDownOnMeshAsked = false;
  15113. };
  15114. /** @hidden */
  15115. VRExperienceHelperGazer.prototype._activatePointer = function () {
  15116. this._activePointer = true;
  15117. };
  15118. /** @hidden */
  15119. VRExperienceHelperGazer.prototype._deactivatePointer = function () {
  15120. this._activePointer = false;
  15121. };
  15122. /** @hidden */
  15123. VRExperienceHelperGazer.prototype._updatePointerDistance = function (distance) {
  15124. if (distance === void 0) { distance = 100; }
  15125. };
  15126. VRExperienceHelperGazer.prototype.dispose = function () {
  15127. this._interactionsEnabled = false;
  15128. this._teleportationEnabled = false;
  15129. if (this._gazeTracker) {
  15130. this._gazeTracker.dispose();
  15131. }
  15132. };
  15133. VRExperienceHelperGazer._idCounter = 0;
  15134. return VRExperienceHelperGazer;
  15135. }());
  15136. var VRExperienceHelperControllerGazer = /** @class */ (function (_super) {
  15137. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperControllerGazer, _super);
  15138. function VRExperienceHelperControllerGazer(webVRController, scene, gazeTrackerToClone) {
  15139. var _this = _super.call(this, scene, gazeTrackerToClone) || this;
  15140. _this.webVRController = webVRController;
  15141. // Laser pointer
  15142. _this._laserPointer = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateCylinder("laserPointer", 1, 0.004, 0.0002, 20, 1, scene, false);
  15143. var laserPointerMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("laserPointerMat", scene);
  15144. laserPointerMaterial.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  15145. laserPointerMaterial.alpha = 0.6;
  15146. _this._laserPointer.material = laserPointerMaterial;
  15147. _this._laserPointer.rotation.x = Math.PI / 2;
  15148. _this._laserPointer.position.z = -0.5;
  15149. _this._laserPointer.isVisible = false;
  15150. _this._laserPointer.isPickable = false;
  15151. if (!webVRController.mesh) {
  15152. // Create an empty mesh that is used prior to loading the high quality model
  15153. var preloadMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"]("preloadControllerMesh", scene);
  15154. var preloadPointerPose = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"](_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE, scene);
  15155. preloadPointerPose.rotation.x = -0.7;
  15156. preloadMesh.addChild(preloadPointerPose);
  15157. webVRController.attachToMesh(preloadMesh);
  15158. }
  15159. _this._setLaserPointerParent(webVRController.mesh);
  15160. _this._meshAttachedObserver = webVRController._meshAttachedObservable.add(function (mesh) {
  15161. _this._setLaserPointerParent(mesh);
  15162. });
  15163. return _this;
  15164. }
  15165. VRExperienceHelperControllerGazer.prototype._getForwardRay = function (length) {
  15166. return this.webVRController.getForwardRay(length);
  15167. };
  15168. /** @hidden */
  15169. VRExperienceHelperControllerGazer.prototype._activatePointer = function () {
  15170. _super.prototype._activatePointer.call(this);
  15171. this._laserPointer.isVisible = true;
  15172. };
  15173. /** @hidden */
  15174. VRExperienceHelperControllerGazer.prototype._deactivatePointer = function () {
  15175. _super.prototype._deactivatePointer.call(this);
  15176. this._laserPointer.isVisible = false;
  15177. };
  15178. /** @hidden */
  15179. VRExperienceHelperControllerGazer.prototype._setLaserPointerColor = function (color) {
  15180. this._laserPointer.material.emissiveColor = color;
  15181. };
  15182. /** @hidden */
  15183. VRExperienceHelperControllerGazer.prototype._setLaserPointerParent = function (mesh) {
  15184. var makeNotPick = function (root) {
  15185. root.isPickable = false;
  15186. root.getChildMeshes().forEach(function (c) {
  15187. makeNotPick(c);
  15188. });
  15189. };
  15190. makeNotPick(mesh);
  15191. var meshChildren = mesh.getChildren(undefined, false);
  15192. var laserParent = mesh;
  15193. this.webVRController._pointingPoseNode = null;
  15194. for (var i = 0; i < meshChildren.length; i++) {
  15195. if (meshChildren[i].name && meshChildren[i].name.indexOf(_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE) >= 0) {
  15196. laserParent = meshChildren[i];
  15197. this.webVRController._pointingPoseNode = laserParent;
  15198. break;
  15199. }
  15200. }
  15201. this._laserPointer.parent = laserParent;
  15202. };
  15203. VRExperienceHelperControllerGazer.prototype._updatePointerDistance = function (distance) {
  15204. if (distance === void 0) { distance = 100; }
  15205. this._laserPointer.scaling.y = distance;
  15206. this._laserPointer.position.z = -distance / 2;
  15207. };
  15208. VRExperienceHelperControllerGazer.prototype.dispose = function () {
  15209. _super.prototype.dispose.call(this);
  15210. this._laserPointer.dispose();
  15211. if (this._meshAttachedObserver) {
  15212. this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver);
  15213. }
  15214. };
  15215. return VRExperienceHelperControllerGazer;
  15216. }(VRExperienceHelperGazer));
  15217. var VRExperienceHelperCameraGazer = /** @class */ (function (_super) {
  15218. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperCameraGazer, _super);
  15219. function VRExperienceHelperCameraGazer(getCamera, scene) {
  15220. var _this = _super.call(this, scene) || this;
  15221. _this.getCamera = getCamera;
  15222. return _this;
  15223. }
  15224. VRExperienceHelperCameraGazer.prototype._getForwardRay = function (length) {
  15225. var camera = this.getCamera();
  15226. if (camera) {
  15227. return camera.getForwardRay(length);
  15228. }
  15229. else {
  15230. 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());
  15231. }
  15232. };
  15233. return VRExperienceHelperCameraGazer;
  15234. }(VRExperienceHelperGazer));
  15235. /**
  15236. * Helps to quickly add VR support to an existing scene.
  15237. * See http://doc.babylonjs.com/how_to/webvr_helper
  15238. */
  15239. var VRExperienceHelper = /** @class */ (function () {
  15240. /**
  15241. * Instantiates a VRExperienceHelper.
  15242. * Helps to quickly add VR support to an existing scene.
  15243. * @param scene The scene the VRExperienceHelper belongs to.
  15244. * @param webVROptions Options to modify the vr experience helper's behavior.
  15245. */
  15246. function VRExperienceHelper(scene,
  15247. /** Options to modify the vr experience helper's behavior. */
  15248. webVROptions) {
  15249. if (webVROptions === void 0) { webVROptions = {}; }
  15250. var _this = this;
  15251. this.webVROptions = webVROptions;
  15252. // Can the system support WebVR, even if a headset isn't plugged in?
  15253. this._webVRsupported = false;
  15254. // If WebVR is supported, is a headset plugged in and are we ready to present?
  15255. this._webVRready = false;
  15256. // Are we waiting for the requestPresent callback to complete?
  15257. this._webVRrequesting = false;
  15258. // Are we presenting to the headset right now? (this is the vrDevice state)
  15259. this._webVRpresenting = false;
  15260. // Are we presenting in the fullscreen fallback?
  15261. this._fullscreenVRpresenting = false;
  15262. /**
  15263. * Observable raised when entering VR.
  15264. */
  15265. this.onEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15266. /**
  15267. * Observable raised when exiting VR.
  15268. */
  15269. this.onExitingVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15270. /**
  15271. * Observable raised when controller mesh is loaded.
  15272. */
  15273. this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15274. this._useCustomVRButton = false;
  15275. this._teleportationRequested = false;
  15276. this._teleportActive = false;
  15277. this._floorMeshesCollection = [];
  15278. this._rotationAllowed = true;
  15279. this._teleportBackwardsVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, -1, -1);
  15280. this._isDefaultTeleportationTarget = true;
  15281. this._teleportationFillColor = "#444444";
  15282. this._teleportationBorderColor = "#FFFFFF";
  15283. this._rotationAngle = 0;
  15284. this._haloCenter = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, 0, 0);
  15285. this._padSensibilityUp = 0.65;
  15286. this._padSensibilityDown = 0.35;
  15287. this._leftController = null;
  15288. this._rightController = null;
  15289. /**
  15290. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  15291. */
  15292. this.onNewMeshSelected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15293. /**
  15294. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  15295. */
  15296. this.onNewMeshPicked = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15297. /**
  15298. * Observable raised before camera teleportation
  15299. */
  15300. this.onBeforeCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15301. /**
  15302. * Observable raised after camera teleportation
  15303. */
  15304. this.onAfterCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15305. /**
  15306. * Observable raised when current selected mesh gets unselected
  15307. */
  15308. this.onSelectedMeshUnselected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15309. /**
  15310. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  15311. */
  15312. this.teleportationEnabled = true;
  15313. this._teleportationInitialized = false;
  15314. this._interactionsEnabled = false;
  15315. this._interactionsRequested = false;
  15316. this._displayGaze = true;
  15317. this._displayLaserPointer = true;
  15318. /**
  15319. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  15320. */
  15321. this.updateGazeTrackerScale = true;
  15322. /**
  15323. * If the gaze trackers color should be updated when selecting meshes
  15324. */
  15325. this.updateGazeTrackerColor = true;
  15326. this._onResize = function () {
  15327. _this.moveButtonToBottomRight();
  15328. if (_this._fullscreenVRpresenting && _this._webVRready) {
  15329. _this.exitVR();
  15330. }
  15331. };
  15332. this._onFullscreenChange = function () {
  15333. if (document.fullscreen !== undefined) {
  15334. _this._fullscreenVRpresenting = document.fullscreen;
  15335. }
  15336. else if (document.mozFullScreen !== undefined) {
  15337. _this._fullscreenVRpresenting = document.mozFullScreen;
  15338. }
  15339. else if (document.webkitIsFullScreen !== undefined) {
  15340. _this._fullscreenVRpresenting = document.webkitIsFullScreen;
  15341. }
  15342. else if (document.msIsFullScreen !== undefined) {
  15343. _this._fullscreenVRpresenting = document.msIsFullScreen;
  15344. }
  15345. else if (document.msFullscreenElement !== undefined) {
  15346. _this._fullscreenVRpresenting = document.msFullscreenElement;
  15347. }
  15348. if (!_this._fullscreenVRpresenting && _this._canvas) {
  15349. _this.exitVR();
  15350. if (!_this._useCustomVRButton) {
  15351. _this._btnVR.style.top = _this._canvas.offsetTop + _this._canvas.offsetHeight - 70 + "px";
  15352. _this._btnVR.style.left = _this._canvas.offsetLeft + _this._canvas.offsetWidth - 100 + "px";
  15353. }
  15354. }
  15355. };
  15356. this._cachedAngularSensibility = { angularSensibilityX: null, angularSensibilityY: null, angularSensibility: null };
  15357. this.beforeRender = function () {
  15358. if (_this._leftController && _this._leftController._activePointer) {
  15359. _this._castRayAndSelectObject(_this._leftController);
  15360. }
  15361. if (_this._rightController && _this._rightController._activePointer) {
  15362. _this._castRayAndSelectObject(_this._rightController);
  15363. }
  15364. if (_this._noControllerIsActive) {
  15365. _this._castRayAndSelectObject(_this._cameraGazer);
  15366. }
  15367. else {
  15368. _this._cameraGazer._gazeTracker.isVisible = false;
  15369. }
  15370. };
  15371. this._onNewGamepadConnected = function (gamepad) {
  15372. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].POSE_ENABLED) {
  15373. if (gamepad.leftStick) {
  15374. gamepad.onleftstickchanged(function (stickValues) {
  15375. if (_this._teleportationInitialized && _this.teleportationEnabled) {
  15376. // Listening to classic/xbox gamepad only if no VR controller is active
  15377. if ((!_this._leftController && !_this._rightController) ||
  15378. ((_this._leftController && !_this._leftController._activePointer) &&
  15379. (_this._rightController && !_this._rightController._activePointer))) {
  15380. _this._checkTeleportWithRay(stickValues, _this._cameraGazer);
  15381. _this._checkTeleportBackwards(stickValues, _this._cameraGazer);
  15382. }
  15383. }
  15384. });
  15385. }
  15386. if (gamepad.rightStick) {
  15387. gamepad.onrightstickchanged(function (stickValues) {
  15388. if (_this._teleportationInitialized) {
  15389. _this._checkRotate(stickValues, _this._cameraGazer);
  15390. }
  15391. });
  15392. }
  15393. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].XBOX) {
  15394. gamepad.onbuttondown(function (buttonPressed) {
  15395. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  15396. _this._cameraGazer._selectionPointerDown();
  15397. }
  15398. });
  15399. gamepad.onbuttonup(function (buttonPressed) {
  15400. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  15401. _this._cameraGazer._selectionPointerUp();
  15402. }
  15403. });
  15404. }
  15405. }
  15406. else {
  15407. var webVRController = gamepad;
  15408. var controller = new VRExperienceHelperControllerGazer(webVRController, _this._scene, _this._cameraGazer._gazeTracker);
  15409. if (webVRController.hand === "right" || (_this._leftController && _this._leftController.webVRController != webVRController)) {
  15410. _this._rightController = controller;
  15411. }
  15412. else {
  15413. _this._leftController = controller;
  15414. }
  15415. _this._tryEnableInteractionOnController(controller);
  15416. }
  15417. };
  15418. // 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
  15419. this._tryEnableInteractionOnController = function (controller) {
  15420. if (_this._interactionsRequested && !controller._interactionsEnabled) {
  15421. _this._enableInteractionOnController(controller);
  15422. }
  15423. if (_this._teleportationRequested && !controller._teleportationEnabled) {
  15424. _this._enableTeleportationOnController(controller);
  15425. }
  15426. };
  15427. this._onNewGamepadDisconnected = function (gamepad) {
  15428. if (gamepad instanceof _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__["WebVRController"]) {
  15429. if (gamepad.hand === "left" && _this._leftController != null) {
  15430. _this._leftController.dispose();
  15431. _this._leftController = null;
  15432. }
  15433. if (gamepad.hand === "right" && _this._rightController != null) {
  15434. _this._rightController.dispose();
  15435. _this._rightController = null;
  15436. }
  15437. }
  15438. };
  15439. this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero();
  15440. this._workingQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].Identity();
  15441. this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].Identity();
  15442. this._scene = scene;
  15443. this._canvas = scene.getEngine().getRenderingCanvas();
  15444. // Parse options
  15445. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera === undefined) {
  15446. webVROptions.createFallbackVRDeviceOrientationFreeCamera = true;
  15447. }
  15448. if (webVROptions.createDeviceOrientationCamera === undefined) {
  15449. webVROptions.createDeviceOrientationCamera = true;
  15450. }
  15451. if (webVROptions.laserToggle === undefined) {
  15452. webVROptions.laserToggle = true;
  15453. }
  15454. if (webVROptions.defaultHeight === undefined) {
  15455. webVROptions.defaultHeight = 1.7;
  15456. }
  15457. if (webVROptions.useCustomVRButton) {
  15458. this._useCustomVRButton = true;
  15459. if (webVROptions.customVRButton) {
  15460. this._btnVR = webVROptions.customVRButton;
  15461. }
  15462. }
  15463. if (webVROptions.rayLength) {
  15464. this._rayLength = webVROptions.rayLength;
  15465. }
  15466. this._defaultHeight = webVROptions.defaultHeight;
  15467. if (webVROptions.positionScale) {
  15468. this._rayLength *= webVROptions.positionScale;
  15469. this._defaultHeight *= webVROptions.positionScale;
  15470. }
  15471. this._hasEnteredVR = false;
  15472. // Set position
  15473. if (this._scene.activeCamera) {
  15474. this._position = this._scene.activeCamera.position.clone();
  15475. }
  15476. else {
  15477. this._position = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, this._defaultHeight, 0);
  15478. }
  15479. // Set non-vr camera
  15480. if (webVROptions.createDeviceOrientationCamera || !this._scene.activeCamera) {
  15481. this._deviceOrientationCamera = new _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__["DeviceOrientationCamera"]("deviceOrientationVRHelper", this._position.clone(), scene);
  15482. // Copy data from existing camera
  15483. if (this._scene.activeCamera) {
  15484. this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  15485. this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
  15486. // Set rotation from previous camera
  15487. if (this._scene.activeCamera instanceof _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"] && this._scene.activeCamera.rotation) {
  15488. var targetCamera = this._scene.activeCamera;
  15489. if (targetCamera.rotationQuaternion) {
  15490. this._deviceOrientationCamera.rotationQuaternion.copyFrom(targetCamera.rotationQuaternion);
  15491. }
  15492. else {
  15493. this._deviceOrientationCamera.rotationQuaternion.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
  15494. }
  15495. this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
  15496. }
  15497. }
  15498. this._scene.activeCamera = this._deviceOrientationCamera;
  15499. if (this._canvas) {
  15500. this._scene.activeCamera.attachControl(this._canvas);
  15501. }
  15502. }
  15503. else {
  15504. this._existingCamera = this._scene.activeCamera;
  15505. }
  15506. // Create VR cameras
  15507. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  15508. this._vrDeviceOrientationCamera = new _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__["VRDeviceOrientationFreeCamera"]("VRDeviceOrientationVRHelper", this._position, this._scene);
  15509. this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  15510. }
  15511. this._webVRCamera = new _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]("WebVRHelper", this._position, this._scene, webVROptions);
  15512. this._webVRCamera.useStandingMatrix();
  15513. this._cameraGazer = new VRExperienceHelperCameraGazer(function () { return _this.currentVRCamera; }, scene);
  15514. // Create default button
  15515. if (!this._useCustomVRButton) {
  15516. this._btnVR = document.createElement("BUTTON");
  15517. this._btnVR.className = "babylonVRicon";
  15518. this._btnVR.id = "babylonVRiconbtn";
  15519. this._btnVR.title = "Click to switch to VR";
  15520. 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) }";
  15521. css += ".babylonVRicon.vrdisplaypresenting { display: none; }";
  15522. // TODO: Add user feedback so that they know what state the VRDisplay is in (disconnected, connected, entering-VR)
  15523. // css += ".babylonVRicon.vrdisplaysupported { }";
  15524. // css += ".babylonVRicon.vrdisplayready { }";
  15525. // css += ".babylonVRicon.vrdisplayrequesting { }";
  15526. var style = document.createElement('style');
  15527. style.appendChild(document.createTextNode(css));
  15528. document.getElementsByTagName('head')[0].appendChild(style);
  15529. this.moveButtonToBottomRight();
  15530. }
  15531. // VR button click event
  15532. if (this._btnVR) {
  15533. this._btnVR.addEventListener("click", function () {
  15534. if (!_this.isInVRMode) {
  15535. _this.enterVR();
  15536. }
  15537. else {
  15538. _this.exitVR();
  15539. }
  15540. });
  15541. }
  15542. // Window events
  15543. window.addEventListener("resize", this._onResize);
  15544. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  15545. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  15546. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  15547. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  15548. document.onmsfullscreenchange = this._onFullscreenChange;
  15549. // Display vr button when headset is connected
  15550. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  15551. this.displayVRButton();
  15552. }
  15553. else {
  15554. this._scene.getEngine().onVRDisplayChangedObservable.add(function (e) {
  15555. if (e.vrDisplay) {
  15556. _this.displayVRButton();
  15557. }
  15558. });
  15559. }
  15560. // Exiting VR mode using 'ESC' key on desktop
  15561. this._onKeyDown = function (event) {
  15562. if (event.keyCode === 27 && _this.isInVRMode) {
  15563. _this.exitVR();
  15564. }
  15565. };
  15566. document.addEventListener("keydown", this._onKeyDown);
  15567. // Exiting VR mode double tapping the touch screen
  15568. this._scene.onPrePointerObservable.add(function () {
  15569. if (_this.isInVRMode) {
  15570. _this.exitVR();
  15571. if (_this._fullscreenVRpresenting) {
  15572. _this._scene.getEngine().switchFullscreen(true);
  15573. }
  15574. }
  15575. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__["PointerEventTypes"].POINTERDOUBLETAP, false);
  15576. // Listen for WebVR display changes
  15577. this._onVRDisplayChanged = function (eventArgs) { return _this.onVRDisplayChanged(eventArgs); };
  15578. this._onVrDisplayPresentChange = function () { return _this.onVrDisplayPresentChange(); };
  15579. this._onVRRequestPresentStart = function () {
  15580. _this._webVRrequesting = true;
  15581. _this.updateButtonVisibility();
  15582. };
  15583. this._onVRRequestPresentComplete = function () {
  15584. _this._webVRrequesting = false;
  15585. _this.updateButtonVisibility();
  15586. };
  15587. scene.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged);
  15588. scene.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart);
  15589. scene.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete);
  15590. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  15591. scene.onDisposeObservable.add(function () {
  15592. _this.dispose();
  15593. });
  15594. // Gamepad connection events
  15595. this._webVRCamera.onControllerMeshLoadedObservable.add(function (webVRController) { return _this._onDefaultMeshLoaded(webVRController); });
  15596. this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected);
  15597. this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected);
  15598. this.updateButtonVisibility();
  15599. //create easing functions
  15600. this._circleEase = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["CircleEase"]();
  15601. this._circleEase.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  15602. if (this.webVROptions.floorMeshes) {
  15603. this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes });
  15604. }
  15605. }
  15606. Object.defineProperty(VRExperienceHelper.prototype, "onEnteringVR", {
  15607. /** Return this.onEnteringVRObservable
  15608. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  15609. */
  15610. get: function () {
  15611. return this.onEnteringVRObservable;
  15612. },
  15613. enumerable: true,
  15614. configurable: true
  15615. });
  15616. Object.defineProperty(VRExperienceHelper.prototype, "onExitingVR", {
  15617. /** Return this.onExitingVRObservable
  15618. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  15619. */
  15620. get: function () {
  15621. return this.onExitingVRObservable;
  15622. },
  15623. enumerable: true,
  15624. configurable: true
  15625. });
  15626. Object.defineProperty(VRExperienceHelper.prototype, "onControllerMeshLoaded", {
  15627. /** Return this.onControllerMeshLoadedObservable
  15628. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  15629. */
  15630. get: function () {
  15631. return this.onControllerMeshLoadedObservable;
  15632. },
  15633. enumerable: true,
  15634. configurable: true
  15635. });
  15636. Object.defineProperty(VRExperienceHelper.prototype, "teleportationTarget", {
  15637. /**
  15638. * The mesh used to display where the user is going to teleport.
  15639. */
  15640. get: function () {
  15641. return this._teleportationTarget;
  15642. },
  15643. /**
  15644. * Sets the mesh to be used to display where the user is going to teleport.
  15645. */
  15646. set: function (value) {
  15647. if (value) {
  15648. value.name = "teleportationTarget";
  15649. this._isDefaultTeleportationTarget = false;
  15650. this._teleportationTarget = value;
  15651. }
  15652. },
  15653. enumerable: true,
  15654. configurable: true
  15655. });
  15656. Object.defineProperty(VRExperienceHelper.prototype, "gazeTrackerMesh", {
  15657. /**
  15658. * 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
  15659. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  15660. * See http://doc.babylonjs.com/resources/baking_transformations
  15661. */
  15662. get: function () {
  15663. return this._cameraGazer._gazeTracker;
  15664. },
  15665. set: function (value) {
  15666. if (value) {
  15667. // Dispose of existing meshes
  15668. if (this._cameraGazer._gazeTracker) {
  15669. this._cameraGazer._gazeTracker.dispose();
  15670. }
  15671. if (this._leftController && this._leftController._gazeTracker) {
  15672. this._leftController._gazeTracker.dispose();
  15673. }
  15674. if (this._rightController && this._rightController._gazeTracker) {
  15675. this._rightController._gazeTracker.dispose();
  15676. }
  15677. // Set and create gaze trackers on head and controllers
  15678. this._cameraGazer._gazeTracker = value;
  15679. this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices();
  15680. this._cameraGazer._gazeTracker.isPickable = false;
  15681. this._cameraGazer._gazeTracker.isVisible = false;
  15682. this._cameraGazer._gazeTracker.name = "gazeTracker";
  15683. if (this._leftController) {
  15684. this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  15685. }
  15686. if (this._rightController) {
  15687. this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  15688. }
  15689. }
  15690. },
  15691. enumerable: true,
  15692. configurable: true
  15693. });
  15694. Object.defineProperty(VRExperienceHelper.prototype, "leftControllerGazeTrackerMesh", {
  15695. /**
  15696. * The gaze tracking mesh corresponding to the left controller
  15697. */
  15698. get: function () {
  15699. if (this._leftController) {
  15700. return this._leftController._gazeTracker;
  15701. }
  15702. return null;
  15703. },
  15704. enumerable: true,
  15705. configurable: true
  15706. });
  15707. Object.defineProperty(VRExperienceHelper.prototype, "rightControllerGazeTrackerMesh", {
  15708. /**
  15709. * The gaze tracking mesh corresponding to the right controller
  15710. */
  15711. get: function () {
  15712. if (this._rightController) {
  15713. return this._rightController._gazeTracker;
  15714. }
  15715. return null;
  15716. },
  15717. enumerable: true,
  15718. configurable: true
  15719. });
  15720. Object.defineProperty(VRExperienceHelper.prototype, "displayGaze", {
  15721. /**
  15722. * If the ray of the gaze should be displayed.
  15723. */
  15724. get: function () {
  15725. return this._displayGaze;
  15726. },
  15727. /**
  15728. * Sets if the ray of the gaze should be displayed.
  15729. */
  15730. set: function (value) {
  15731. this._displayGaze = value;
  15732. if (!value) {
  15733. this._cameraGazer._gazeTracker.isVisible = false;
  15734. if (this._leftController) {
  15735. this._leftController._gazeTracker.isVisible = false;
  15736. }
  15737. if (this._rightController) {
  15738. this._rightController._gazeTracker.isVisible = false;
  15739. }
  15740. }
  15741. },
  15742. enumerable: true,
  15743. configurable: true
  15744. });
  15745. Object.defineProperty(VRExperienceHelper.prototype, "displayLaserPointer", {
  15746. /**
  15747. * If the ray of the LaserPointer should be displayed.
  15748. */
  15749. get: function () {
  15750. return this._displayLaserPointer;
  15751. },
  15752. /**
  15753. * Sets if the ray of the LaserPointer should be displayed.
  15754. */
  15755. set: function (value) {
  15756. this._displayLaserPointer = value;
  15757. if (!value) {
  15758. if (this._rightController) {
  15759. this._rightController._deactivatePointer();
  15760. this._rightController._gazeTracker.isVisible = false;
  15761. }
  15762. if (this._leftController) {
  15763. this._leftController._deactivatePointer();
  15764. this._leftController._gazeTracker.isVisible = false;
  15765. }
  15766. }
  15767. else {
  15768. if (this._rightController) {
  15769. this._rightController._activatePointer();
  15770. }
  15771. if (this._leftController) {
  15772. this._leftController._activatePointer();
  15773. }
  15774. }
  15775. },
  15776. enumerable: true,
  15777. configurable: true
  15778. });
  15779. Object.defineProperty(VRExperienceHelper.prototype, "deviceOrientationCamera", {
  15780. /**
  15781. * The deviceOrientationCamera used as the camera when not in VR.
  15782. */
  15783. get: function () {
  15784. return this._deviceOrientationCamera;
  15785. },
  15786. enumerable: true,
  15787. configurable: true
  15788. });
  15789. Object.defineProperty(VRExperienceHelper.prototype, "currentVRCamera", {
  15790. /**
  15791. * Based on the current WebVR support, returns the current VR camera used.
  15792. */
  15793. get: function () {
  15794. if (this._webVRready) {
  15795. return this._webVRCamera;
  15796. }
  15797. else {
  15798. return this._scene.activeCamera;
  15799. }
  15800. },
  15801. enumerable: true,
  15802. configurable: true
  15803. });
  15804. Object.defineProperty(VRExperienceHelper.prototype, "webVRCamera", {
  15805. /**
  15806. * The webVRCamera which is used when in VR.
  15807. */
  15808. get: function () {
  15809. return this._webVRCamera;
  15810. },
  15811. enumerable: true,
  15812. configurable: true
  15813. });
  15814. Object.defineProperty(VRExperienceHelper.prototype, "vrDeviceOrientationCamera", {
  15815. /**
  15816. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  15817. */
  15818. get: function () {
  15819. return this._vrDeviceOrientationCamera;
  15820. },
  15821. enumerable: true,
  15822. configurable: true
  15823. });
  15824. Object.defineProperty(VRExperienceHelper.prototype, "_teleportationRequestInitiated", {
  15825. get: function () {
  15826. var result = this._cameraGazer._teleportationRequestInitiated
  15827. || (this._leftController !== null && this._leftController._teleportationRequestInitiated)
  15828. || (this._rightController !== null && this._rightController._teleportationRequestInitiated);
  15829. return result;
  15830. },
  15831. enumerable: true,
  15832. configurable: true
  15833. });
  15834. // Raised when one of the controller has loaded successfully its associated default mesh
  15835. VRExperienceHelper.prototype._onDefaultMeshLoaded = function (webVRController) {
  15836. if (this._leftController && this._leftController.webVRController == webVRController) {
  15837. if (webVRController.mesh) {
  15838. this._leftController._setLaserPointerParent(webVRController.mesh);
  15839. }
  15840. }
  15841. if (this._rightController && this._rightController.webVRController == webVRController) {
  15842. if (webVRController.mesh) {
  15843. this._rightController._setLaserPointerParent(webVRController.mesh);
  15844. }
  15845. }
  15846. try {
  15847. this.onControllerMeshLoadedObservable.notifyObservers(webVRController);
  15848. }
  15849. catch (err) {
  15850. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onControllerMeshLoaded: " + err);
  15851. }
  15852. };
  15853. Object.defineProperty(VRExperienceHelper.prototype, "isInVRMode", {
  15854. /**
  15855. * Gets a value indicating if we are currently in VR mode.
  15856. */
  15857. get: function () {
  15858. return this._webVRpresenting || this._fullscreenVRpresenting;
  15859. },
  15860. enumerable: true,
  15861. configurable: true
  15862. });
  15863. VRExperienceHelper.prototype.onVrDisplayPresentChange = function () {
  15864. var vrDisplay = this._scene.getEngine().getVRDevice();
  15865. if (vrDisplay) {
  15866. var wasPresenting = this._webVRpresenting;
  15867. this._webVRpresenting = vrDisplay.isPresenting;
  15868. if (wasPresenting && !this._webVRpresenting) {
  15869. this.exitVR();
  15870. }
  15871. }
  15872. else {
  15873. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?');
  15874. }
  15875. this.updateButtonVisibility();
  15876. };
  15877. VRExperienceHelper.prototype.onVRDisplayChanged = function (eventArgs) {
  15878. this._webVRsupported = eventArgs.vrSupported;
  15879. this._webVRready = !!eventArgs.vrDisplay;
  15880. this._webVRpresenting = eventArgs.vrDisplay && eventArgs.vrDisplay.isPresenting;
  15881. this.updateButtonVisibility();
  15882. };
  15883. VRExperienceHelper.prototype.moveButtonToBottomRight = function () {
  15884. if (this._canvas && !this._useCustomVRButton) {
  15885. this._btnVR.style.top = this._canvas.offsetTop + this._canvas.offsetHeight - 70 + "px";
  15886. this._btnVR.style.left = this._canvas.offsetLeft + this._canvas.offsetWidth - 100 + "px";
  15887. }
  15888. };
  15889. VRExperienceHelper.prototype.displayVRButton = function () {
  15890. if (!this._useCustomVRButton && !this._btnVRDisplayed) {
  15891. document.body.appendChild(this._btnVR);
  15892. this._btnVRDisplayed = true;
  15893. }
  15894. };
  15895. VRExperienceHelper.prototype.updateButtonVisibility = function () {
  15896. if (!this._btnVR || this._useCustomVRButton) {
  15897. return;
  15898. }
  15899. this._btnVR.className = "babylonVRicon";
  15900. if (this.isInVRMode) {
  15901. this._btnVR.className += " vrdisplaypresenting";
  15902. }
  15903. else {
  15904. if (this._webVRready) {
  15905. this._btnVR.className += " vrdisplayready";
  15906. }
  15907. if (this._webVRsupported) {
  15908. this._btnVR.className += " vrdisplaysupported";
  15909. }
  15910. if (this._webVRrequesting) {
  15911. this._btnVR.className += " vrdisplayrequesting";
  15912. }
  15913. }
  15914. };
  15915. /**
  15916. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  15917. * Otherwise, will use the fullscreen API.
  15918. */
  15919. VRExperienceHelper.prototype.enterVR = function () {
  15920. if (this.onEnteringVRObservable) {
  15921. try {
  15922. this.onEnteringVRObservable.notifyObservers(this);
  15923. }
  15924. catch (err) {
  15925. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onEnteringVR: " + err);
  15926. }
  15927. }
  15928. if (this._scene.activeCamera) {
  15929. this._position = this._scene.activeCamera.position.clone();
  15930. if (this.vrDeviceOrientationCamera) {
  15931. this.vrDeviceOrientationCamera.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles();
  15932. this.vrDeviceOrientationCamera.angularSensibility = 2000;
  15933. }
  15934. if (this.webVRCamera) {
  15935. var currentYRotation = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y;
  15936. var desiredYRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y;
  15937. var delta = desiredYRotation - currentYRotation;
  15938. var currentGlobalRotation = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
  15939. this.webVRCamera.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromEulerAngles(0, currentGlobalRotation + delta, 0);
  15940. }
  15941. // make sure that we return to the last active camera
  15942. this._existingCamera = this._scene.activeCamera;
  15943. // Remove and cache angular sensability to avoid camera rotation when in VR
  15944. if (this._existingCamera.angularSensibilityX) {
  15945. this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX;
  15946. this._existingCamera.angularSensibilityX = Number.MAX_VALUE;
  15947. }
  15948. if (this._existingCamera.angularSensibilityY) {
  15949. this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY;
  15950. this._existingCamera.angularSensibilityY = Number.MAX_VALUE;
  15951. }
  15952. if (this._existingCamera.angularSensibility) {
  15953. this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility;
  15954. this._existingCamera.angularSensibility = Number.MAX_VALUE;
  15955. }
  15956. }
  15957. if (this._webVRrequesting) {
  15958. return;
  15959. }
  15960. // If WebVR is supported and a headset is connected
  15961. if (this._webVRready) {
  15962. if (!this._webVRpresenting) {
  15963. this._webVRCamera.position = this._position;
  15964. this._scene.activeCamera = this._webVRCamera;
  15965. }
  15966. }
  15967. else if (this._vrDeviceOrientationCamera) {
  15968. this._vrDeviceOrientationCamera.position = this._position;
  15969. if (this._scene.activeCamera) {
  15970. this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  15971. }
  15972. this._scene.activeCamera = this._vrDeviceOrientationCamera;
  15973. this._scene.getEngine().switchFullscreen(true);
  15974. this.updateButtonVisibility();
  15975. }
  15976. if (this._scene.activeCamera && this._canvas) {
  15977. this._scene.activeCamera.attachControl(this._canvas);
  15978. }
  15979. if (this._interactionsEnabled) {
  15980. this._scene.registerBeforeRender(this.beforeRender);
  15981. }
  15982. if (this._displayLaserPointer) {
  15983. [this._leftController, this._rightController].forEach(function (controller) {
  15984. if (controller) {
  15985. controller._activatePointer();
  15986. }
  15987. });
  15988. }
  15989. this._hasEnteredVR = true;
  15990. };
  15991. /**
  15992. * Attempt to exit VR, or fullscreen.
  15993. */
  15994. VRExperienceHelper.prototype.exitVR = function () {
  15995. if (this._hasEnteredVR) {
  15996. if (this.onExitingVRObservable) {
  15997. try {
  15998. this.onExitingVRObservable.notifyObservers(this);
  15999. }
  16000. catch (err) {
  16001. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onExitingVR: " + err);
  16002. }
  16003. }
  16004. if (this._webVRpresenting) {
  16005. this._scene.getEngine().disableVR();
  16006. }
  16007. if (this._scene.activeCamera) {
  16008. this._position = this._scene.activeCamera.position.clone();
  16009. }
  16010. if (this.vrDeviceOrientationCamera) {
  16011. this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16012. }
  16013. if (this._deviceOrientationCamera) {
  16014. this._deviceOrientationCamera.position = this._position;
  16015. this._scene.activeCamera = this._deviceOrientationCamera;
  16016. if (this._canvas) {
  16017. this._scene.activeCamera.attachControl(this._canvas);
  16018. }
  16019. // Restore angular sensibility
  16020. if (this._cachedAngularSensibility.angularSensibilityX) {
  16021. this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  16022. this._cachedAngularSensibility.angularSensibilityX = null;
  16023. }
  16024. if (this._cachedAngularSensibility.angularSensibilityY) {
  16025. this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  16026. this._cachedAngularSensibility.angularSensibilityY = null;
  16027. }
  16028. if (this._cachedAngularSensibility.angularSensibility) {
  16029. this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  16030. this._cachedAngularSensibility.angularSensibility = null;
  16031. }
  16032. }
  16033. else if (this._existingCamera) {
  16034. this._existingCamera.position = this._position;
  16035. this._scene.activeCamera = this._existingCamera;
  16036. // Restore angular sensibility
  16037. if (this._cachedAngularSensibility.angularSensibilityX) {
  16038. this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  16039. this._cachedAngularSensibility.angularSensibilityX = null;
  16040. }
  16041. if (this._cachedAngularSensibility.angularSensibilityY) {
  16042. this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  16043. this._cachedAngularSensibility.angularSensibilityY = null;
  16044. }
  16045. if (this._cachedAngularSensibility.angularSensibility) {
  16046. this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  16047. this._cachedAngularSensibility.angularSensibility = null;
  16048. }
  16049. }
  16050. this.updateButtonVisibility();
  16051. if (this._interactionsEnabled) {
  16052. this._scene.unregisterBeforeRender(this.beforeRender);
  16053. this._cameraGazer._gazeTracker.isVisible = false;
  16054. if (this._leftController) {
  16055. this._leftController._gazeTracker.isVisible = false;
  16056. }
  16057. if (this._rightController) {
  16058. this._rightController._gazeTracker.isVisible = false;
  16059. }
  16060. }
  16061. // resize to update width and height when exiting vr exits fullscreen
  16062. this._scene.getEngine().resize();
  16063. [this._leftController, this._rightController].forEach(function (controller) {
  16064. if (controller) {
  16065. controller._deactivatePointer();
  16066. }
  16067. });
  16068. this._hasEnteredVR = false;
  16069. }
  16070. };
  16071. Object.defineProperty(VRExperienceHelper.prototype, "position", {
  16072. /**
  16073. * The position of the vr experience helper.
  16074. */
  16075. get: function () {
  16076. return this._position;
  16077. },
  16078. /**
  16079. * Sets the position of the vr experience helper.
  16080. */
  16081. set: function (value) {
  16082. this._position = value;
  16083. if (this._scene.activeCamera) {
  16084. this._scene.activeCamera.position = value;
  16085. }
  16086. },
  16087. enumerable: true,
  16088. configurable: true
  16089. });
  16090. /**
  16091. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  16092. */
  16093. VRExperienceHelper.prototype.enableInteractions = function () {
  16094. var _this = this;
  16095. if (!this._interactionsEnabled) {
  16096. this._interactionsRequested = true;
  16097. if (this._leftController) {
  16098. this._enableInteractionOnController(this._leftController);
  16099. }
  16100. if (this._rightController) {
  16101. this._enableInteractionOnController(this._rightController);
  16102. }
  16103. this.raySelectionPredicate = function (mesh) {
  16104. return mesh.isVisible && (mesh.isPickable || mesh.name === _this._floorMeshName);
  16105. };
  16106. this.meshSelectionPredicate = function () {
  16107. return true;
  16108. };
  16109. this._raySelectionPredicate = function (mesh) {
  16110. if (_this._isTeleportationFloor(mesh) || (mesh.name.indexOf("gazeTracker") === -1
  16111. && mesh.name.indexOf("teleportationTarget") === -1
  16112. && mesh.name.indexOf("torusTeleportation") === -1)) {
  16113. return _this.raySelectionPredicate(mesh);
  16114. }
  16115. return false;
  16116. };
  16117. this._interactionsEnabled = true;
  16118. }
  16119. };
  16120. Object.defineProperty(VRExperienceHelper.prototype, "_noControllerIsActive", {
  16121. get: function () {
  16122. return !(this._leftController && this._leftController._activePointer) && !(this._rightController && this._rightController._activePointer);
  16123. },
  16124. enumerable: true,
  16125. configurable: true
  16126. });
  16127. VRExperienceHelper.prototype._isTeleportationFloor = function (mesh) {
  16128. for (var i = 0; i < this._floorMeshesCollection.length; i++) {
  16129. if (this._floorMeshesCollection[i].id === mesh.id) {
  16130. return true;
  16131. }
  16132. }
  16133. if (this._floorMeshName && mesh.name === this._floorMeshName) {
  16134. return true;
  16135. }
  16136. return false;
  16137. };
  16138. /**
  16139. * Adds a floor mesh to be used for teleportation.
  16140. * @param floorMesh the mesh to be used for teleportation.
  16141. */
  16142. VRExperienceHelper.prototype.addFloorMesh = function (floorMesh) {
  16143. if (!this._floorMeshesCollection) {
  16144. return;
  16145. }
  16146. if (this._floorMeshesCollection.indexOf(floorMesh) > -1) {
  16147. return;
  16148. }
  16149. this._floorMeshesCollection.push(floorMesh);
  16150. };
  16151. /**
  16152. * Removes a floor mesh from being used for teleportation.
  16153. * @param floorMesh the mesh to be removed.
  16154. */
  16155. VRExperienceHelper.prototype.removeFloorMesh = function (floorMesh) {
  16156. if (!this._floorMeshesCollection) {
  16157. return;
  16158. }
  16159. var meshIndex = this._floorMeshesCollection.indexOf(floorMesh);
  16160. if (meshIndex !== -1) {
  16161. this._floorMeshesCollection.splice(meshIndex, 1);
  16162. }
  16163. };
  16164. /**
  16165. * Enables interactions and teleportation using the VR controllers and gaze.
  16166. * @param vrTeleportationOptions options to modify teleportation behavior.
  16167. */
  16168. VRExperienceHelper.prototype.enableTeleportation = function (vrTeleportationOptions) {
  16169. if (vrTeleportationOptions === void 0) { vrTeleportationOptions = {}; }
  16170. if (!this._teleportationInitialized) {
  16171. this._teleportationRequested = true;
  16172. this.enableInteractions();
  16173. if (vrTeleportationOptions.floorMeshName) {
  16174. this._floorMeshName = vrTeleportationOptions.floorMeshName;
  16175. }
  16176. if (vrTeleportationOptions.floorMeshes) {
  16177. this._floorMeshesCollection = vrTeleportationOptions.floorMeshes;
  16178. }
  16179. if (this._leftController != null) {
  16180. this._enableTeleportationOnController(this._leftController);
  16181. }
  16182. if (this._rightController != null) {
  16183. this._enableTeleportationOnController(this._rightController);
  16184. }
  16185. // Creates an image processing post process for the vignette not relying
  16186. // on the main scene configuration for image processing to reduce setup and spaces
  16187. // (gamma/linear) conflicts.
  16188. var imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__["ImageProcessingConfiguration"]();
  16189. imageProcessingConfiguration.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color4"](0, 0, 0, 0);
  16190. imageProcessingConfiguration.vignetteEnabled = true;
  16191. this._postProcessMove = new _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__["ImageProcessingPostProcess"]("postProcessMove", 1.0, this._webVRCamera, undefined, undefined, undefined, undefined, imageProcessingConfiguration);
  16192. this._webVRCamera.detachPostProcess(this._postProcessMove);
  16193. this._teleportationInitialized = true;
  16194. if (this._isDefaultTeleportationTarget) {
  16195. this._createTeleportationCircles();
  16196. this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor);
  16197. }
  16198. }
  16199. };
  16200. VRExperienceHelper.prototype._enableInteractionOnController = function (controller) {
  16201. var _this = this;
  16202. var controllerMesh = controller.webVRController.mesh;
  16203. if (controllerMesh) {
  16204. controller._interactionsEnabled = true;
  16205. if (this.isInVRMode && this._displayLaserPointer) {
  16206. controller._activatePointer();
  16207. }
  16208. if (this.webVROptions.laserToggle) {
  16209. controller.webVRController.onMainButtonStateChangedObservable.add(function (stateObject) {
  16210. // Enabling / disabling laserPointer
  16211. if (_this._displayLaserPointer && stateObject.value === 1) {
  16212. if (controller._activePointer) {
  16213. controller._deactivatePointer();
  16214. }
  16215. else {
  16216. controller._activatePointer();
  16217. }
  16218. if (_this.displayGaze) {
  16219. controller._gazeTracker.isVisible = controller._activePointer;
  16220. }
  16221. }
  16222. });
  16223. }
  16224. controller.webVRController.onTriggerStateChangedObservable.add(function (stateObject) {
  16225. var gazer = controller;
  16226. if (_this._noControllerIsActive) {
  16227. gazer = _this._cameraGazer;
  16228. }
  16229. if (!gazer._pointerDownOnMeshAsked) {
  16230. if (stateObject.value > _this._padSensibilityUp) {
  16231. gazer._selectionPointerDown();
  16232. }
  16233. }
  16234. else if (stateObject.value < _this._padSensibilityDown) {
  16235. gazer._selectionPointerUp();
  16236. }
  16237. });
  16238. }
  16239. };
  16240. VRExperienceHelper.prototype._checkTeleportWithRay = function (stateObject, gazer) {
  16241. // Dont teleport if another gaze already requested teleportation
  16242. if (this._teleportationRequestInitiated && !gazer._teleportationRequestInitiated) {
  16243. return;
  16244. }
  16245. if (!gazer._teleportationRequestInitiated) {
  16246. if (stateObject.y < -this._padSensibilityUp && gazer._dpadPressed) {
  16247. gazer._activatePointer();
  16248. gazer._teleportationRequestInitiated = true;
  16249. }
  16250. }
  16251. else {
  16252. // Listening to the proper controller values changes to confirm teleportation
  16253. if (Math.sqrt(stateObject.y * stateObject.y + stateObject.x * stateObject.x) < this._padSensibilityDown) {
  16254. if (this._teleportActive) {
  16255. this.teleportCamera(this._haloCenter);
  16256. }
  16257. gazer._teleportationRequestInitiated = false;
  16258. }
  16259. }
  16260. };
  16261. VRExperienceHelper.prototype._checkRotate = function (stateObject, gazer) {
  16262. // Only rotate when user is not currently selecting a teleportation location
  16263. if (gazer._teleportationRequestInitiated) {
  16264. return;
  16265. }
  16266. if (!gazer._rotationLeftAsked) {
  16267. if (stateObject.x < -this._padSensibilityUp && gazer._dpadPressed) {
  16268. gazer._rotationLeftAsked = true;
  16269. if (this._rotationAllowed) {
  16270. this._rotateCamera(false);
  16271. }
  16272. }
  16273. }
  16274. else {
  16275. if (stateObject.x > -this._padSensibilityDown) {
  16276. gazer._rotationLeftAsked = false;
  16277. }
  16278. }
  16279. if (!gazer._rotationRightAsked) {
  16280. if (stateObject.x > this._padSensibilityUp && gazer._dpadPressed) {
  16281. gazer._rotationRightAsked = true;
  16282. if (this._rotationAllowed) {
  16283. this._rotateCamera(true);
  16284. }
  16285. }
  16286. }
  16287. else {
  16288. if (stateObject.x < this._padSensibilityDown) {
  16289. gazer._rotationRightAsked = false;
  16290. }
  16291. }
  16292. };
  16293. VRExperienceHelper.prototype._checkTeleportBackwards = function (stateObject, gazer) {
  16294. // Only teleport backwards when user is not currently selecting a teleportation location
  16295. if (gazer._teleportationRequestInitiated) {
  16296. return;
  16297. }
  16298. // Teleport backwards
  16299. if (stateObject.y > this._padSensibilityUp && gazer._dpadPressed) {
  16300. if (!gazer._teleportationBackRequestInitiated) {
  16301. if (!this.currentVRCamera) {
  16302. return;
  16303. }
  16304. // Get rotation and position of the current camera
  16305. var rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix());
  16306. var position = this.currentVRCamera.position;
  16307. // If the camera has device position, use that instead
  16308. if (this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion) {
  16309. rotation = this.currentVRCamera.deviceRotationQuaternion;
  16310. position = this.currentVRCamera.devicePosition;
  16311. }
  16312. // Get matrix with only the y rotation of the device rotation
  16313. rotation.toEulerAnglesToRef(this._workingVector);
  16314. this._workingVector.z = 0;
  16315. this._workingVector.x = 0;
  16316. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion);
  16317. this._workingQuaternion.toRotationMatrix(this._workingMatrix);
  16318. // Rotate backwards ray by device rotation to cast at the ground behind the user
  16319. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
  16320. // Teleport if ray hit the ground and is not to far away eg. backwards off a cliff
  16321. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_15__["Ray"](position, this._workingVector);
  16322. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  16323. if (hit && hit.pickedPoint && hit.pickedMesh && this._isTeleportationFloor(hit.pickedMesh) && hit.distance < 5) {
  16324. this.teleportCamera(hit.pickedPoint);
  16325. }
  16326. gazer._teleportationBackRequestInitiated = true;
  16327. }
  16328. }
  16329. else {
  16330. gazer._teleportationBackRequestInitiated = false;
  16331. }
  16332. };
  16333. VRExperienceHelper.prototype._enableTeleportationOnController = function (controller) {
  16334. var _this = this;
  16335. var controllerMesh = controller.webVRController.mesh;
  16336. if (controllerMesh) {
  16337. if (!controller._interactionsEnabled) {
  16338. this._enableInteractionOnController(controller);
  16339. }
  16340. controller._interactionsEnabled = true;
  16341. controller._teleportationEnabled = true;
  16342. if (controller.webVRController.controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledControllerType"].VIVE) {
  16343. controller._dpadPressed = false;
  16344. controller.webVRController.onPadStateChangedObservable.add(function (stateObject) {
  16345. controller._dpadPressed = stateObject.pressed;
  16346. if (!controller._dpadPressed) {
  16347. controller._rotationLeftAsked = false;
  16348. controller._rotationRightAsked = false;
  16349. controller._teleportationBackRequestInitiated = false;
  16350. }
  16351. });
  16352. }
  16353. controller.webVRController.onPadValuesChangedObservable.add(function (stateObject) {
  16354. if (_this.teleportationEnabled) {
  16355. _this._checkTeleportBackwards(stateObject, controller);
  16356. _this._checkTeleportWithRay(stateObject, controller);
  16357. }
  16358. _this._checkRotate(stateObject, controller);
  16359. });
  16360. }
  16361. };
  16362. VRExperienceHelper.prototype._createTeleportationCircles = function () {
  16363. this._teleportationTarget = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateGround("teleportationTarget", 2, 2, 2, this._scene);
  16364. this._teleportationTarget.isPickable = false;
  16365. var length = 512;
  16366. var dynamicTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__["DynamicTexture"]("DynamicTexture", length, this._scene, true);
  16367. dynamicTexture.hasAlpha = true;
  16368. var context = dynamicTexture.getContext();
  16369. var centerX = length / 2;
  16370. var centerY = length / 2;
  16371. var radius = 200;
  16372. context.beginPath();
  16373. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  16374. context.fillStyle = this._teleportationFillColor;
  16375. context.fill();
  16376. context.lineWidth = 10;
  16377. context.strokeStyle = this._teleportationBorderColor;
  16378. context.stroke();
  16379. context.closePath();
  16380. dynamicTexture.update();
  16381. var teleportationCircleMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("TextPlaneMaterial", this._scene);
  16382. teleportationCircleMaterial.diffuseTexture = dynamicTexture;
  16383. this._teleportationTarget.material = teleportationCircleMaterial;
  16384. var torus = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("torusTeleportation", 0.75, 0.1, 25, this._scene, false);
  16385. torus.isPickable = false;
  16386. torus.parent = this._teleportationTarget;
  16387. 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);
  16388. var keys = [];
  16389. keys.push({
  16390. frame: 0,
  16391. value: 0
  16392. });
  16393. keys.push({
  16394. frame: 30,
  16395. value: 0.4
  16396. });
  16397. keys.push({
  16398. frame: 60,
  16399. value: 0
  16400. });
  16401. animationInnerCircle.setKeys(keys);
  16402. var easingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["SineEase"]();
  16403. easingFunction.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16404. animationInnerCircle.setEasingFunction(easingFunction);
  16405. torus.animations = [];
  16406. torus.animations.push(animationInnerCircle);
  16407. this._scene.beginAnimation(torus, 0, 60, true);
  16408. this._hideTeleportationTarget();
  16409. };
  16410. VRExperienceHelper.prototype._displayTeleportationTarget = function () {
  16411. this._teleportActive = true;
  16412. if (this._teleportationInitialized) {
  16413. this._teleportationTarget.isVisible = true;
  16414. if (this._isDefaultTeleportationTarget) {
  16415. this._teleportationTarget.getChildren()[0].isVisible = true;
  16416. }
  16417. }
  16418. };
  16419. VRExperienceHelper.prototype._hideTeleportationTarget = function () {
  16420. this._teleportActive = false;
  16421. if (this._teleportationInitialized) {
  16422. this._teleportationTarget.isVisible = false;
  16423. if (this._isDefaultTeleportationTarget) {
  16424. this._teleportationTarget.getChildren()[0].isVisible = false;
  16425. }
  16426. }
  16427. };
  16428. VRExperienceHelper.prototype._rotateCamera = function (right) {
  16429. var _this = this;
  16430. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  16431. return;
  16432. }
  16433. if (right) {
  16434. this._rotationAngle++;
  16435. }
  16436. else {
  16437. this._rotationAngle--;
  16438. }
  16439. this.currentVRCamera.animations = [];
  16440. var target = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].RotationY(Math.PI / 4 * this._rotationAngle));
  16441. 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);
  16442. var animationRotationKeys = [];
  16443. animationRotationKeys.push({
  16444. frame: 0,
  16445. value: this.currentVRCamera.rotationQuaternion
  16446. });
  16447. animationRotationKeys.push({
  16448. frame: 6,
  16449. value: target
  16450. });
  16451. animationRotation.setKeys(animationRotationKeys);
  16452. animationRotation.setEasingFunction(this._circleEase);
  16453. this.currentVRCamera.animations.push(animationRotation);
  16454. this._postProcessMove.animations = [];
  16455. 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);
  16456. var vignetteWeightKeys = [];
  16457. vignetteWeightKeys.push({
  16458. frame: 0,
  16459. value: 0
  16460. });
  16461. vignetteWeightKeys.push({
  16462. frame: 3,
  16463. value: 4
  16464. });
  16465. vignetteWeightKeys.push({
  16466. frame: 6,
  16467. value: 0
  16468. });
  16469. animationPP.setKeys(vignetteWeightKeys);
  16470. animationPP.setEasingFunction(this._circleEase);
  16471. this._postProcessMove.animations.push(animationPP);
  16472. 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);
  16473. var vignetteStretchKeys = [];
  16474. vignetteStretchKeys.push({
  16475. frame: 0,
  16476. value: 0
  16477. });
  16478. vignetteStretchKeys.push({
  16479. frame: 3,
  16480. value: 10
  16481. });
  16482. vignetteStretchKeys.push({
  16483. frame: 6,
  16484. value: 0
  16485. });
  16486. animationPP2.setKeys(vignetteStretchKeys);
  16487. animationPP2.setEasingFunction(this._circleEase);
  16488. this._postProcessMove.animations.push(animationPP2);
  16489. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  16490. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  16491. this._postProcessMove.samples = 4;
  16492. this._webVRCamera.attachPostProcess(this._postProcessMove);
  16493. this._scene.beginAnimation(this._postProcessMove, 0, 6, false, 1, function () {
  16494. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  16495. });
  16496. this._scene.beginAnimation(this.currentVRCamera, 0, 6, false, 1);
  16497. };
  16498. VRExperienceHelper.prototype._moveTeleportationSelectorTo = function (hit, gazer, ray) {
  16499. if (hit.pickedPoint) {
  16500. if (gazer._teleportationRequestInitiated) {
  16501. this._displayTeleportationTarget();
  16502. this._haloCenter.copyFrom(hit.pickedPoint);
  16503. this._teleportationTarget.position.copyFrom(hit.pickedPoint);
  16504. }
  16505. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(true, false), ray);
  16506. if (pickNormal) {
  16507. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  16508. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  16509. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, this._teleportationTarget.rotation);
  16510. }
  16511. this._teleportationTarget.position.y += 0.1;
  16512. }
  16513. };
  16514. /**
  16515. * Teleports the users feet to the desired location
  16516. * @param location The location where the user's feet should be placed
  16517. */
  16518. VRExperienceHelper.prototype.teleportCamera = function (location) {
  16519. var _this = this;
  16520. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  16521. return;
  16522. }
  16523. // Teleport the hmd to where the user is looking by moving the anchor to where they are looking minus the
  16524. // offset of the headset from the anchor.
  16525. if (this.webVRCamera.leftCamera) {
  16526. this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition);
  16527. this._workingVector.subtractInPlace(this.webVRCamera.position);
  16528. location.subtractToRef(this._workingVector, this._workingVector);
  16529. }
  16530. else {
  16531. this._workingVector.copyFrom(location);
  16532. }
  16533. // Add height to account for user's height offset
  16534. if (this.isInVRMode) {
  16535. this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor;
  16536. }
  16537. else {
  16538. this._workingVector.y += this._defaultHeight;
  16539. }
  16540. this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
  16541. // Create animation from the camera's position to the new location
  16542. this.currentVRCamera.animations = [];
  16543. 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);
  16544. var animationCameraTeleportationKeys = [{
  16545. frame: 0,
  16546. value: this.currentVRCamera.position
  16547. },
  16548. {
  16549. frame: 11,
  16550. value: this._workingVector
  16551. }
  16552. ];
  16553. animationCameraTeleportation.setKeys(animationCameraTeleportationKeys);
  16554. animationCameraTeleportation.setEasingFunction(this._circleEase);
  16555. this.currentVRCamera.animations.push(animationCameraTeleportation);
  16556. this._postProcessMove.animations = [];
  16557. 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);
  16558. var vignetteWeightKeys = [];
  16559. vignetteWeightKeys.push({
  16560. frame: 0,
  16561. value: 0
  16562. });
  16563. vignetteWeightKeys.push({
  16564. frame: 5,
  16565. value: 8
  16566. });
  16567. vignetteWeightKeys.push({
  16568. frame: 11,
  16569. value: 0
  16570. });
  16571. animationPP.setKeys(vignetteWeightKeys);
  16572. this._postProcessMove.animations.push(animationPP);
  16573. 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);
  16574. var vignetteStretchKeys = [];
  16575. vignetteStretchKeys.push({
  16576. frame: 0,
  16577. value: 0
  16578. });
  16579. vignetteStretchKeys.push({
  16580. frame: 5,
  16581. value: 10
  16582. });
  16583. vignetteStretchKeys.push({
  16584. frame: 11,
  16585. value: 0
  16586. });
  16587. animationPP2.setKeys(vignetteStretchKeys);
  16588. this._postProcessMove.animations.push(animationPP2);
  16589. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  16590. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  16591. this._webVRCamera.attachPostProcess(this._postProcessMove);
  16592. this._scene.beginAnimation(this._postProcessMove, 0, 11, false, 1, function () {
  16593. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  16594. });
  16595. this._scene.beginAnimation(this.currentVRCamera, 0, 11, false, 1, function () {
  16596. _this.onAfterCameraTeleport.notifyObservers(_this._workingVector);
  16597. });
  16598. this._hideTeleportationTarget();
  16599. };
  16600. VRExperienceHelper.prototype._convertNormalToDirectionOfRay = function (normal, ray) {
  16601. if (normal) {
  16602. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Dot(normal, ray.direction));
  16603. if (angle < Math.PI / 2) {
  16604. normal.scaleInPlace(-1);
  16605. }
  16606. }
  16607. return normal;
  16608. };
  16609. VRExperienceHelper.prototype._castRayAndSelectObject = function (gazer) {
  16610. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  16611. return;
  16612. }
  16613. var ray = gazer._getForwardRay(this._rayLength);
  16614. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  16615. if (hit) {
  16616. // Populate the contrllers mesh that can be used for drag/drop
  16617. if (gazer._laserPointer) {
  16618. hit.originMesh = gazer._laserPointer.parent;
  16619. }
  16620. this._scene.simulatePointerMove(hit, { pointerId: gazer._id });
  16621. }
  16622. gazer._currentHit = hit;
  16623. // Moving the gazeTracker on the mesh face targetted
  16624. if (hit && hit.pickedPoint) {
  16625. if (this._displayGaze) {
  16626. var multiplier = 1;
  16627. gazer._gazeTracker.isVisible = true;
  16628. if (gazer._isActionableMesh) {
  16629. multiplier = 3;
  16630. }
  16631. if (this.updateGazeTrackerScale) {
  16632. gazer._gazeTracker.scaling.x = hit.distance * multiplier;
  16633. gazer._gazeTracker.scaling.y = hit.distance * multiplier;
  16634. gazer._gazeTracker.scaling.z = hit.distance * multiplier;
  16635. }
  16636. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(), ray);
  16637. // To avoid z-fighting
  16638. var deltaFighting = 0.002;
  16639. if (pickNormal) {
  16640. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  16641. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  16642. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, gazer._gazeTracker.rotation);
  16643. }
  16644. gazer._gazeTracker.position.copyFrom(hit.pickedPoint);
  16645. if (gazer._gazeTracker.position.x < 0) {
  16646. gazer._gazeTracker.position.x += deltaFighting;
  16647. }
  16648. else {
  16649. gazer._gazeTracker.position.x -= deltaFighting;
  16650. }
  16651. if (gazer._gazeTracker.position.y < 0) {
  16652. gazer._gazeTracker.position.y += deltaFighting;
  16653. }
  16654. else {
  16655. gazer._gazeTracker.position.y -= deltaFighting;
  16656. }
  16657. if (gazer._gazeTracker.position.z < 0) {
  16658. gazer._gazeTracker.position.z += deltaFighting;
  16659. }
  16660. else {
  16661. gazer._gazeTracker.position.z -= deltaFighting;
  16662. }
  16663. }
  16664. // Changing the size of the laser pointer based on the distance from the targetted point
  16665. gazer._updatePointerDistance(hit.distance);
  16666. }
  16667. else {
  16668. gazer._updatePointerDistance();
  16669. gazer._gazeTracker.isVisible = false;
  16670. }
  16671. if (hit && hit.pickedMesh) {
  16672. // The object selected is the floor, we're in a teleportation scenario
  16673. if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
  16674. // Moving the teleportation area to this targetted point
  16675. //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
  16676. if (gazer._currentMeshSelected && !this._isTeleportationFloor(gazer._currentMeshSelected)) {
  16677. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  16678. }
  16679. gazer._currentMeshSelected = null;
  16680. if (gazer._teleportationRequestInitiated) {
  16681. this._moveTeleportationSelectorTo(hit, gazer, ray);
  16682. }
  16683. return;
  16684. }
  16685. // If not, we're in a selection scenario
  16686. //this._teleportationAllowed = false;
  16687. if (hit.pickedMesh !== gazer._currentMeshSelected) {
  16688. if (this.meshSelectionPredicate(hit.pickedMesh)) {
  16689. this.onNewMeshPicked.notifyObservers(hit);
  16690. gazer._currentMeshSelected = hit.pickedMesh;
  16691. if (hit.pickedMesh.isPickable && hit.pickedMesh.actionManager) {
  16692. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0, 0, 1));
  16693. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.2, 0.2, 1));
  16694. gazer._isActionableMesh = true;
  16695. }
  16696. else {
  16697. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  16698. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  16699. gazer._isActionableMesh = false;
  16700. }
  16701. try {
  16702. this.onNewMeshSelected.notifyObservers(hit.pickedMesh);
  16703. }
  16704. catch (err) {
  16705. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onNewMeshSelected: " + err);
  16706. }
  16707. }
  16708. else {
  16709. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  16710. gazer._currentMeshSelected = null;
  16711. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  16712. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  16713. }
  16714. }
  16715. }
  16716. else {
  16717. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  16718. gazer._currentMeshSelected = null;
  16719. //this._teleportationAllowed = false;
  16720. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  16721. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  16722. }
  16723. };
  16724. VRExperienceHelper.prototype._notifySelectedMeshUnselected = function (mesh) {
  16725. if (mesh) {
  16726. this.onSelectedMeshUnselected.notifyObservers(mesh);
  16727. }
  16728. };
  16729. /**
  16730. * Sets the color of the laser ray from the vr controllers.
  16731. * @param color new color for the ray.
  16732. */
  16733. VRExperienceHelper.prototype.changeLaserColor = function (color) {
  16734. if (this._leftController) {
  16735. this._leftController._setLaserPointerColor(color);
  16736. }
  16737. if (this._rightController) {
  16738. this._rightController._setLaserPointerColor(color);
  16739. }
  16740. };
  16741. /**
  16742. * Sets the color of the ray from the vr headsets gaze.
  16743. * @param color new color for the ray.
  16744. */
  16745. VRExperienceHelper.prototype.changeGazeColor = function (color) {
  16746. if (!this.updateGazeTrackerColor) {
  16747. return;
  16748. }
  16749. if (!this._cameraGazer._gazeTracker.material) {
  16750. return;
  16751. }
  16752. this._cameraGazer._gazeTracker.material.emissiveColor = color;
  16753. if (this._leftController) {
  16754. this._leftController._gazeTracker.material.emissiveColor = color;
  16755. }
  16756. if (this._rightController) {
  16757. this._rightController._gazeTracker.material.emissiveColor = color;
  16758. }
  16759. };
  16760. /**
  16761. * Exits VR and disposes of the vr experience helper
  16762. */
  16763. VRExperienceHelper.prototype.dispose = function () {
  16764. if (this.isInVRMode) {
  16765. this.exitVR();
  16766. }
  16767. if (this._postProcessMove) {
  16768. this._postProcessMove.dispose();
  16769. }
  16770. if (this._webVRCamera) {
  16771. this._webVRCamera.dispose();
  16772. }
  16773. if (this._vrDeviceOrientationCamera) {
  16774. this._vrDeviceOrientationCamera.dispose();
  16775. }
  16776. if (!this._useCustomVRButton && this._btnVR.parentNode) {
  16777. document.body.removeChild(this._btnVR);
  16778. }
  16779. if (this._deviceOrientationCamera && (this._scene.activeCamera != this._deviceOrientationCamera)) {
  16780. this._deviceOrientationCamera.dispose();
  16781. }
  16782. if (this._cameraGazer) {
  16783. this._cameraGazer.dispose();
  16784. }
  16785. if (this._leftController) {
  16786. this._leftController.dispose();
  16787. }
  16788. if (this._rightController) {
  16789. this._rightController.dispose();
  16790. }
  16791. if (this._teleportationTarget) {
  16792. this._teleportationTarget.dispose();
  16793. }
  16794. this._floorMeshesCollection = [];
  16795. document.removeEventListener("keydown", this._onKeyDown);
  16796. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  16797. window.removeEventListener("resize", this._onResize);
  16798. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  16799. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  16800. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  16801. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  16802. document.onmsfullscreenchange = null;
  16803. this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged);
  16804. this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart);
  16805. this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete);
  16806. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  16807. this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected);
  16808. this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected);
  16809. this._scene.unregisterBeforeRender(this.beforeRender);
  16810. };
  16811. /**
  16812. * Gets the name of the VRExperienceHelper class
  16813. * @returns "VRExperienceHelper"
  16814. */
  16815. VRExperienceHelper.prototype.getClassName = function () {
  16816. return "VRExperienceHelper";
  16817. };
  16818. return VRExperienceHelper;
  16819. }());
  16820. /***/ }),
  16821. /***/ "./Cameras/VR/webVRCamera.ts":
  16822. /*!***********************************!*\
  16823. !*** ./Cameras/VR/webVRCamera.ts ***!
  16824. \***********************************/
  16825. /*! exports provided: WebVRFreeCamera */
  16826. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16827. "use strict";
  16828. __webpack_require__.r(__webpack_exports__);
  16829. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return WebVRFreeCamera; });
  16830. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  16831. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  16832. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  16833. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  16834. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  16835. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  16836. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  16837. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../node */ "./node.ts");
  16838. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  16839. /* harmony import */ var _RigModes_webVRRigMode__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../RigModes/webVRRigMode */ "./Cameras/RigModes/webVRRigMode.ts");
  16840. // Side effect import to define the stereoscopic mode.
  16841. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRFreeCamera", function (name, scene) {
  16842. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  16843. });
  16844. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRGamepadCamera", function (name, scene) {
  16845. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  16846. });
  16847. /**
  16848. * This represents a WebVR camera.
  16849. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  16850. * @example http://doc.babylonjs.com/how_to/webvr_camera
  16851. */
  16852. var WebVRFreeCamera = /** @class */ (function (_super) {
  16853. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRFreeCamera, _super);
  16854. /**
  16855. * Instantiates a WebVRFreeCamera.
  16856. * @param name The name of the WebVRFreeCamera
  16857. * @param position The starting anchor position for the camera
  16858. * @param scene The scene the camera belongs to
  16859. * @param webVROptions a set of customizable options for the webVRCamera
  16860. */
  16861. function WebVRFreeCamera(name, position, scene, webVROptions) {
  16862. if (webVROptions === void 0) { webVROptions = {}; }
  16863. var _this = _super.call(this, name, position, scene) || this;
  16864. _this.webVROptions = webVROptions;
  16865. /**
  16866. * @hidden
  16867. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  16868. */
  16869. _this._vrDevice = null;
  16870. /**
  16871. * The rawPose of the vrDevice.
  16872. */
  16873. _this.rawPose = null;
  16874. _this._specsVersion = "1.1";
  16875. _this._attached = false;
  16876. _this._descendants = [];
  16877. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  16878. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  16879. /** @hidden */
  16880. _this._deviceRoomRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  16881. _this._standingMatrix = null;
  16882. /**
  16883. * Represents device position in babylon space.
  16884. */
  16885. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  16886. /**
  16887. * Represents device rotation in babylon space.
  16888. */
  16889. _this.deviceRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  16890. /**
  16891. * The scale of the device to be used when translating from device space to babylon space.
  16892. */
  16893. _this.deviceScaleFactor = 1;
  16894. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  16895. _this._worldToDevice = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  16896. /**
  16897. * References to the webVR controllers for the vrDevice.
  16898. */
  16899. _this.controllers = [];
  16900. /**
  16901. * Emits an event when a controller is attached.
  16902. */
  16903. _this.onControllersAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  16904. /**
  16905. * Emits an event when a controller's mesh has been loaded;
  16906. */
  16907. _this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  16908. /**
  16909. * Emits an event when the HMD's pose has been updated.
  16910. */
  16911. _this.onPoseUpdatedFromDeviceObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  16912. _this._poseSet = false;
  16913. /**
  16914. * If the rig cameras be used as parent instead of this camera.
  16915. */
  16916. _this.rigParenting = true;
  16917. _this._defaultHeight = undefined;
  16918. _this._htmlElementAttached = null;
  16919. _this._detachIfAttached = function () {
  16920. var vrDisplay = _this.getEngine().getVRDevice();
  16921. if (vrDisplay && !vrDisplay.isPresenting && _this._htmlElementAttached) {
  16922. _this.detachControl(_this._htmlElementAttached);
  16923. }
  16924. };
  16925. _this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  16926. _this._oneVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  16927. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  16928. _this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  16929. _this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  16930. if (webVROptions.defaultHeight) {
  16931. _this._defaultHeight = webVROptions.defaultHeight;
  16932. _this.position.y = _this._defaultHeight;
  16933. }
  16934. _this.minZ = 0.1;
  16935. //legacy support - the compensation boolean was removed.
  16936. if (arguments.length === 5) {
  16937. _this.webVROptions = arguments[4];
  16938. }
  16939. // default webVR options
  16940. if (_this.webVROptions.trackPosition == undefined) {
  16941. _this.webVROptions.trackPosition = true;
  16942. }
  16943. if (_this.webVROptions.controllerMeshes == undefined) {
  16944. _this.webVROptions.controllerMeshes = true;
  16945. }
  16946. if (_this.webVROptions.defaultLightingOnControllers == undefined) {
  16947. _this.webVROptions.defaultLightingOnControllers = true;
  16948. }
  16949. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  16950. if (_this.webVROptions && _this.webVROptions.positionScale) {
  16951. _this.deviceScaleFactor = _this.webVROptions.positionScale;
  16952. }
  16953. //enable VR
  16954. var engine = _this.getEngine();
  16955. _this._onVREnabled = function (success) { if (success) {
  16956. _this.initControllers();
  16957. } };
  16958. engine.onVRRequestPresentComplete.add(_this._onVREnabled);
  16959. engine.initWebVR().add(function (event) {
  16960. if (!event.vrDisplay || _this._vrDevice === event.vrDisplay) {
  16961. return;
  16962. }
  16963. _this._vrDevice = event.vrDisplay;
  16964. //reset the rig parameters.
  16965. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].RIG_MODE_WEBVR, { parentCamera: _this, vrDisplay: _this._vrDevice, frameData: _this._frameData, specs: _this._specsVersion });
  16966. if (_this._attached) {
  16967. _this.getEngine().enableVR();
  16968. }
  16969. });
  16970. if (typeof (VRFrameData) !== "undefined") {
  16971. _this._frameData = new VRFrameData();
  16972. }
  16973. /**
  16974. * The idea behind the following lines:
  16975. * objects that have the camera as parent should actually have the rig cameras as a parent.
  16976. * BUT, each of those cameras has a different view matrix, which means that if we set the parent to the first rig camera,
  16977. * the second will not show it correctly.
  16978. *
  16979. * To solve this - each object that has the camera as parent will be added to a protected array.
  16980. * When the rig camera renders, it will take this array and set all of those to be its children.
  16981. * This way, the right camera will be used as a parent, and the mesh will be rendered correctly.
  16982. * Amazing!
  16983. */
  16984. scene.onBeforeCameraRenderObservable.add(function (camera) {
  16985. if (camera.parent === _this && _this.rigParenting) {
  16986. _this._descendants = _this.getDescendants(true, function (n) {
  16987. // don't take the cameras or the controllers!
  16988. var isController = _this.controllers.some(function (controller) { return controller._mesh === n; });
  16989. var isRigCamera = _this._rigCameras.indexOf(n) !== -1;
  16990. return !isController && !isRigCamera;
  16991. });
  16992. _this._descendants.forEach(function (node) {
  16993. node.parent = camera;
  16994. });
  16995. }
  16996. });
  16997. scene.onAfterCameraRenderObservable.add(function (camera) {
  16998. if (camera.parent === _this && _this.rigParenting) {
  16999. _this._descendants.forEach(function (node) {
  17000. node.parent = _this;
  17001. });
  17002. }
  17003. });
  17004. return _this;
  17005. }
  17006. /**
  17007. * Gets the device distance from the ground in meters.
  17008. * @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.
  17009. */
  17010. WebVRFreeCamera.prototype.deviceDistanceToRoomGround = function () {
  17011. if (this._standingMatrix) {
  17012. // Add standing matrix offset to get real offset from ground in room
  17013. this._standingMatrix.getTranslationToRef(this._workingVector);
  17014. return this._deviceRoomPosition.y + this._workingVector.y;
  17015. }
  17016. //If VRDisplay does not inform stage parameters and no default height is set we fallback to zero.
  17017. return this._defaultHeight || 0;
  17018. };
  17019. /**
  17020. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17021. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  17022. */
  17023. WebVRFreeCamera.prototype.useStandingMatrix = function (callback) {
  17024. var _this = this;
  17025. if (callback === void 0) { callback = function (bool) { }; }
  17026. // Use standing matrix if available
  17027. this.getEngine().initWebVRAsync().then(function (result) {
  17028. if (!result.vrDisplay || !result.vrDisplay.stageParameters || !result.vrDisplay.stageParameters.sittingToStandingTransform || !_this.webVROptions.trackPosition) {
  17029. callback(false);
  17030. }
  17031. else {
  17032. _this._standingMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  17033. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromFloat32ArrayToRefScaled(result.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, _this._standingMatrix);
  17034. if (!_this.getScene().useRightHandedSystem) {
  17035. if (_this._standingMatrix) {
  17036. _this._standingMatrix.toggleModelMatrixHandInPlace();
  17037. }
  17038. }
  17039. callback(true);
  17040. }
  17041. });
  17042. };
  17043. /**
  17044. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17045. * @returns A promise with a boolean set to if the standing matrix is supported.
  17046. */
  17047. WebVRFreeCamera.prototype.useStandingMatrixAsync = function () {
  17048. var _this = this;
  17049. return new Promise(function (res) {
  17050. _this.useStandingMatrix(function (supported) {
  17051. res(supported);
  17052. });
  17053. });
  17054. };
  17055. /**
  17056. * Disposes the camera
  17057. */
  17058. WebVRFreeCamera.prototype.dispose = function () {
  17059. this._detachIfAttached();
  17060. this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled);
  17061. if (this._updateCacheWhenTrackingDisabledObserver) {
  17062. this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver);
  17063. }
  17064. _super.prototype.dispose.call(this);
  17065. };
  17066. /**
  17067. * Gets a vrController by name.
  17068. * @param name The name of the controller to retreive
  17069. * @returns the controller matching the name specified or null if not found
  17070. */
  17071. WebVRFreeCamera.prototype.getControllerByName = function (name) {
  17072. for (var _i = 0, _a = this.controllers; _i < _a.length; _i++) {
  17073. var gp = _a[_i];
  17074. if (gp.hand === name) {
  17075. return gp;
  17076. }
  17077. }
  17078. return null;
  17079. };
  17080. Object.defineProperty(WebVRFreeCamera.prototype, "leftController", {
  17081. /**
  17082. * The controller corrisponding to the users left hand.
  17083. */
  17084. get: function () {
  17085. if (!this._leftController) {
  17086. this._leftController = this.getControllerByName("left");
  17087. }
  17088. return this._leftController;
  17089. },
  17090. enumerable: true,
  17091. configurable: true
  17092. });
  17093. Object.defineProperty(WebVRFreeCamera.prototype, "rightController", {
  17094. /**
  17095. * The controller corrisponding to the users right hand.
  17096. */
  17097. get: function () {
  17098. if (!this._rightController) {
  17099. this._rightController = this.getControllerByName("right");
  17100. }
  17101. return this._rightController;
  17102. },
  17103. enumerable: true,
  17104. configurable: true
  17105. });
  17106. /**
  17107. * Casts a ray forward from the vrCamera's gaze.
  17108. * @param length Length of the ray (default: 100)
  17109. * @returns the ray corrisponding to the gaze
  17110. */
  17111. WebVRFreeCamera.prototype.getForwardRay = function (length) {
  17112. if (length === void 0) { length = 100; }
  17113. if (this.leftCamera) {
  17114. // Use left eye to avoid computation to compute center on every call
  17115. return _super.prototype.getForwardRay.call(this, length, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition); // Need the actual rendered camera
  17116. }
  17117. else {
  17118. return _super.prototype.getForwardRay.call(this, length);
  17119. }
  17120. };
  17121. /**
  17122. * @hidden
  17123. * Updates the camera based on device's frame data
  17124. */
  17125. WebVRFreeCamera.prototype._checkInputs = function () {
  17126. if (this._vrDevice && this._vrDevice.isPresenting) {
  17127. this._vrDevice.getFrameData(this._frameData);
  17128. this.updateFromDevice(this._frameData.pose);
  17129. }
  17130. _super.prototype._checkInputs.call(this);
  17131. };
  17132. /**
  17133. * Updates the poseControlled values based on the input device pose.
  17134. * @param poseData Pose coming from the device
  17135. */
  17136. WebVRFreeCamera.prototype.updateFromDevice = function (poseData) {
  17137. if (poseData && poseData.orientation) {
  17138. this.rawPose = poseData;
  17139. this._deviceRoomRotationQuaternion.copyFromFloats(poseData.orientation[0], poseData.orientation[1], -poseData.orientation[2], -poseData.orientation[3]);
  17140. if (this.getScene().useRightHandedSystem) {
  17141. this._deviceRoomRotationQuaternion.z *= -1;
  17142. this._deviceRoomRotationQuaternion.w *= -1;
  17143. }
  17144. if (this.webVROptions.trackPosition && this.rawPose.position) {
  17145. this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]);
  17146. if (this.getScene().useRightHandedSystem) {
  17147. this._deviceRoomPosition.z *= -1;
  17148. }
  17149. }
  17150. this._poseSet = true;
  17151. }
  17152. };
  17153. /**
  17154. * WebVR's attach control will start broadcasting frames to the device.
  17155. * Note that in certain browsers (chrome for example) this function must be called
  17156. * within a user-interaction callback. Example:
  17157. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  17158. *
  17159. * @param element html element to attach the vrDevice to
  17160. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  17161. */
  17162. WebVRFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  17163. _super.prototype.attachControl.call(this, element, noPreventDefault);
  17164. this._attached = true;
  17165. this._htmlElementAttached = element;
  17166. noPreventDefault = _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  17167. if (this._vrDevice) {
  17168. this.getEngine().enableVR();
  17169. }
  17170. window.addEventListener('vrdisplaypresentchange', this._detachIfAttached);
  17171. };
  17172. /**
  17173. * Detaches the camera from the html element and disables VR
  17174. *
  17175. * @param element html element to detach from
  17176. */
  17177. WebVRFreeCamera.prototype.detachControl = function (element) {
  17178. this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  17179. this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  17180. _super.prototype.detachControl.call(this, element);
  17181. this._attached = false;
  17182. this.getEngine().disableVR();
  17183. window.removeEventListener('vrdisplaypresentchange', this._detachIfAttached);
  17184. };
  17185. /**
  17186. * @returns the name of this class
  17187. */
  17188. WebVRFreeCamera.prototype.getClassName = function () {
  17189. return "WebVRFreeCamera";
  17190. };
  17191. /**
  17192. * Calls resetPose on the vrDisplay
  17193. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  17194. */
  17195. WebVRFreeCamera.prototype.resetToCurrentRotation = function () {
  17196. //uses the vrDisplay's "resetPose()".
  17197. //pitch and roll won't be affected.
  17198. this._vrDevice.resetPose();
  17199. };
  17200. /**
  17201. * @hidden
  17202. * Updates the rig cameras (left and right eye)
  17203. */
  17204. WebVRFreeCamera.prototype._updateRigCameras = function () {
  17205. var camLeft = this._rigCameras[0];
  17206. var camRight = this._rigCameras[1];
  17207. camLeft.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  17208. camRight.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  17209. camLeft.position.copyFrom(this._deviceRoomPosition);
  17210. camRight.position.copyFrom(this._deviceRoomPosition);
  17211. };
  17212. // Remove translation from 6dof headset if trackposition is set to false
  17213. WebVRFreeCamera.prototype._correctPositionIfNotTrackPosition = function (matrix, isViewMatrix) {
  17214. if (isViewMatrix === void 0) { isViewMatrix = false; }
  17215. if (this.rawPose && this.rawPose.position && !this.webVROptions.trackPosition) {
  17216. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix);
  17217. if (!isViewMatrix) {
  17218. this._tmpMatrix.invert();
  17219. }
  17220. this._tmpMatrix.multiplyToRef(matrix, matrix);
  17221. }
  17222. };
  17223. /**
  17224. * @hidden
  17225. * Updates the cached values of the camera
  17226. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  17227. */
  17228. WebVRFreeCamera.prototype._updateCache = function (ignoreParentClass) {
  17229. var _this = this;
  17230. if (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) {
  17231. // Update to ensure devicePosition is up to date with most recent _deviceRoomPosition
  17232. if (!this.updateCacheCalled) {
  17233. // make sure it is only called once per loop. this.update() might cause an infinite loop.
  17234. this.updateCacheCalled = true;
  17235. this.update();
  17236. }
  17237. // Set working vector to the device position in room space rotated by the new rotation
  17238. this.rotationQuaternion.toRotationMatrix(this._workingMatrix);
  17239. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector);
  17240. // Subtract this vector from the current device position in world to get the translation for the device world matrix
  17241. this.devicePosition.subtractToRef(this._workingVector, this._workingVector);
  17242. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld);
  17243. // Add translation from anchor position
  17244. this._deviceToWorld.getTranslationToRef(this._workingVector);
  17245. this._workingVector.addInPlace(this.position);
  17246. this._workingVector.subtractInPlace(this._cache.position);
  17247. this._deviceToWorld.setTranslation(this._workingVector);
  17248. // Set an inverted matrix to be used when updating the camera
  17249. this._deviceToWorld.invertToRef(this._worldToDevice);
  17250. // Update the gamepad to ensure the mesh is updated on the same frame as camera
  17251. this.controllers.forEach(function (controller) {
  17252. controller._deviceToWorld.copyFrom(_this._deviceToWorld);
  17253. _this._correctPositionIfNotTrackPosition(controller._deviceToWorld);
  17254. controller.update();
  17255. });
  17256. }
  17257. if (!ignoreParentClass) {
  17258. _super.prototype._updateCache.call(this);
  17259. }
  17260. this.updateCacheCalled = false;
  17261. };
  17262. /**
  17263. * @hidden
  17264. * Get current device position in babylon world
  17265. */
  17266. WebVRFreeCamera.prototype._computeDevicePosition = function () {
  17267. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition);
  17268. };
  17269. /**
  17270. * Updates the current device position and rotation in the babylon world
  17271. */
  17272. WebVRFreeCamera.prototype.update = function () {
  17273. this._computeDevicePosition();
  17274. // Get current device rotation in babylon world
  17275. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix);
  17276. this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix);
  17277. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  17278. if (this._poseSet) {
  17279. this.onPoseUpdatedFromDeviceObservable.notifyObservers(null);
  17280. }
  17281. _super.prototype.update.call(this);
  17282. };
  17283. /**
  17284. * @hidden
  17285. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  17286. * @returns an identity matrix
  17287. */
  17288. WebVRFreeCamera.prototype._getViewMatrix = function () {
  17289. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17290. };
  17291. /**
  17292. * This function is called by the two RIG cameras.
  17293. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  17294. * @hidden
  17295. */
  17296. WebVRFreeCamera.prototype._getWebVRViewMatrix = function () {
  17297. // Update the parent camera prior to using a child camera to avoid desynchronization
  17298. var parentCamera = this._cameraRigParams["parentCamera"];
  17299. parentCamera._updateCache();
  17300. //WebVR 1.1
  17301. var viewArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftViewMatrix : this._cameraRigParams["frameData"].rightViewMatrix;
  17302. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(viewArray, 0, this._webvrViewMatrix);
  17303. if (!this.getScene().useRightHandedSystem) {
  17304. this._webvrViewMatrix.toggleModelMatrixHandInPlace();
  17305. }
  17306. // update the camera rotation matrix
  17307. this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix);
  17308. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  17309. // Computing target and final matrix
  17310. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  17311. // should the view matrix be updated with scale and position offset?
  17312. if (parentCamera.deviceScaleFactor !== 1) {
  17313. this._webvrViewMatrix.invert();
  17314. // scale the position, if set
  17315. if (parentCamera.deviceScaleFactor) {
  17316. this._webvrViewMatrix.multiplyAtIndex(12, parentCamera.deviceScaleFactor);
  17317. this._webvrViewMatrix.multiplyAtIndex(13, parentCamera.deviceScaleFactor);
  17318. this._webvrViewMatrix.multiplyAtIndex(14, parentCamera.deviceScaleFactor);
  17319. }
  17320. this._webvrViewMatrix.invert();
  17321. }
  17322. // Remove translation from 6dof headset if trackposition is set to false
  17323. parentCamera._correctPositionIfNotTrackPosition(this._webvrViewMatrix, true);
  17324. parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
  17325. // Compute global position
  17326. this._workingMatrix = this._workingMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17327. this._webvrViewMatrix.invertToRef(this._workingMatrix);
  17328. this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
  17329. this._workingMatrix.getTranslationToRef(this._globalPosition);
  17330. this._markSyncedWithParent();
  17331. return this._webvrViewMatrix;
  17332. };
  17333. /** @hidden */
  17334. WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
  17335. var parentCamera = this.parent;
  17336. parentCamera._vrDevice.depthNear = parentCamera.minZ;
  17337. parentCamera._vrDevice.depthFar = parentCamera.maxZ;
  17338. var projectionArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftProjectionMatrix : this._cameraRigParams["frameData"].rightProjectionMatrix;
  17339. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(projectionArray, 0, this._projectionMatrix);
  17340. //babylon compatible matrix
  17341. if (!this.getScene().useRightHandedSystem) {
  17342. this._projectionMatrix.toggleProjectionMatrixHandInPlace();
  17343. }
  17344. return this._projectionMatrix;
  17345. };
  17346. /**
  17347. * Initializes the controllers and their meshes
  17348. */
  17349. WebVRFreeCamera.prototype.initControllers = function () {
  17350. var _this = this;
  17351. this.controllers = [];
  17352. var manager = this.getScene().gamepadManager;
  17353. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  17354. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  17355. var webVrController = gamepad;
  17356. if (webVrController.defaultModel) {
  17357. webVrController.defaultModel.setEnabled(false);
  17358. }
  17359. if (webVrController.hand === "right") {
  17360. _this._rightController = null;
  17361. }
  17362. if (webVrController.hand === "left") {
  17363. _this._leftController = null;
  17364. }
  17365. var controllerIndex = _this.controllers.indexOf(webVrController);
  17366. if (controllerIndex !== -1) {
  17367. _this.controllers.splice(controllerIndex, 1);
  17368. }
  17369. }
  17370. });
  17371. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  17372. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  17373. var webVrController_1 = gamepad;
  17374. if (!_this.webVROptions.trackPosition) {
  17375. webVrController_1._disableTrackPosition(new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](webVrController_1.hand == "left" ? -0.15 : 0.15, -0.5, 0.25));
  17376. // Cache must be updated before rendering controllers to avoid them being one frame behind
  17377. if (!_this._updateCacheWhenTrackingDisabledObserver) {
  17378. _this._updateCacheWhenTrackingDisabledObserver = _this._scene.onBeforeRenderObservable.add(function () {
  17379. _this._updateCache();
  17380. });
  17381. }
  17382. }
  17383. webVrController_1.deviceScaleFactor = _this.deviceScaleFactor;
  17384. webVrController_1._deviceToWorld.copyFrom(_this._deviceToWorld);
  17385. _this._correctPositionIfNotTrackPosition(webVrController_1._deviceToWorld);
  17386. if (_this.webVROptions.controllerMeshes) {
  17387. if (webVrController_1.defaultModel) {
  17388. webVrController_1.defaultModel.setEnabled(true);
  17389. }
  17390. else {
  17391. // Load the meshes
  17392. webVrController_1.initControllerMesh(_this.getScene(), function (loadedMesh) {
  17393. loadedMesh.scaling.scaleInPlace(_this.deviceScaleFactor);
  17394. _this.onControllerMeshLoadedObservable.notifyObservers(webVrController_1);
  17395. if (_this.webVROptions.defaultLightingOnControllers) {
  17396. if (!_this._lightOnControllers) {
  17397. _this._lightOnControllers = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__["HemisphericLight"]("vrControllersLight", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0), _this.getScene());
  17398. }
  17399. var activateLightOnSubMeshes_1 = function (mesh, light) {
  17400. var children = mesh.getChildren();
  17401. if (children && children.length !== 0) {
  17402. children.forEach(function (mesh) {
  17403. light.includedOnlyMeshes.push(mesh);
  17404. activateLightOnSubMeshes_1(mesh, light);
  17405. });
  17406. }
  17407. };
  17408. _this._lightOnControllers.includedOnlyMeshes.push(loadedMesh);
  17409. activateLightOnSubMeshes_1(loadedMesh, _this._lightOnControllers);
  17410. }
  17411. });
  17412. }
  17413. }
  17414. webVrController_1.attachToPoseControlledCamera(_this);
  17415. // since this is async - sanity check. Is the controller already stored?
  17416. if (_this.controllers.indexOf(webVrController_1) === -1) {
  17417. //add to the controllers array
  17418. _this.controllers.push(webVrController_1);
  17419. // Forced to add some control code for Vive as it doesn't always fill properly the "hand" property
  17420. // Sometimes, both controllers are set correctly (left and right), sometimes none, sometimes only one of them...
  17421. // So we're overriding setting left & right manually to be sure
  17422. var firstViveWandDetected = false;
  17423. for (var i = 0; i < _this.controllers.length; i++) {
  17424. if (_this.controllers[i].controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__["PoseEnabledControllerType"].VIVE) {
  17425. if (!firstViveWandDetected) {
  17426. firstViveWandDetected = true;
  17427. _this.controllers[i].hand = "left";
  17428. }
  17429. else {
  17430. _this.controllers[i].hand = "right";
  17431. }
  17432. }
  17433. }
  17434. //did we find enough controllers? Great! let the developer know.
  17435. if (_this.controllers.length >= 2) {
  17436. _this.onControllersAttachedObservable.notifyObservers(_this.controllers);
  17437. }
  17438. }
  17439. }
  17440. });
  17441. };
  17442. return WebVRFreeCamera;
  17443. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  17444. /***/ }),
  17445. /***/ "./Cameras/XR/index.ts":
  17446. /*!*****************************!*\
  17447. !*** ./Cameras/XR/index.ts ***!
  17448. \*****************************/
  17449. /*! exports provided: WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  17450. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17451. "use strict";
  17452. __webpack_require__.r(__webpack_exports__);
  17453. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  17454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _webXRCamera__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  17455. /* harmony import */ var _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  17456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIButton"]; });
  17457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIOptions"]; });
  17458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUI"]; });
  17459. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  17460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"]; });
  17461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRExperienceHelper"]; });
  17462. /* harmony import */ var _webXRInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRInput */ "./Cameras/XR/webXRInput.ts");
  17463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRController"]; });
  17464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRInput"]; });
  17465. /* harmony import */ var _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  17466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__["WebXRManagedOutputCanvas"]; });
  17467. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  17468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__["WebXRSessionManager"]; });
  17469. /***/ }),
  17470. /***/ "./Cameras/XR/webXRCamera.ts":
  17471. /*!***********************************!*\
  17472. !*** ./Cameras/XR/webXRCamera.ts ***!
  17473. \***********************************/
  17474. /*! exports provided: WebXRCamera */
  17475. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17476. "use strict";
  17477. __webpack_require__.r(__webpack_exports__);
  17478. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return WebXRCamera; });
  17479. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  17480. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17481. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  17482. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  17483. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  17484. /**
  17485. * WebXR Camera which holds the views for the xrSession
  17486. * @see https://doc.babylonjs.com/how_to/webxr
  17487. */
  17488. var WebXRCamera = /** @class */ (function (_super) {
  17489. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebXRCamera, _super);
  17490. /**
  17491. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  17492. * @param name the name of the camera
  17493. * @param scene the scene to add the camera to
  17494. */
  17495. function WebXRCamera(name, scene) {
  17496. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), scene) || this;
  17497. // Initial camera configuration
  17498. _this.minZ = 0;
  17499. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  17500. _this.cameraRigMode = _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_CUSTOM;
  17501. _this.updateUpVectorFromRotation = true;
  17502. _this._updateNumberOfRigCameras(1);
  17503. return _this;
  17504. }
  17505. WebXRCamera.prototype._updateNumberOfRigCameras = function (viewCount) {
  17506. if (viewCount === void 0) { viewCount = 1; }
  17507. while (this.rigCameras.length < viewCount) {
  17508. var newCamera = new _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]("view: " + this.rigCameras.length, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), this.getScene());
  17509. newCamera.minZ = 0;
  17510. newCamera.parent = this;
  17511. newCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  17512. newCamera.updateUpVectorFromRotation = true;
  17513. this.rigCameras.push(newCamera);
  17514. }
  17515. while (this.rigCameras.length > viewCount) {
  17516. var removedCamera = this.rigCameras.pop();
  17517. if (removedCamera) {
  17518. removedCamera.dispose();
  17519. }
  17520. }
  17521. };
  17522. /** @hidden */
  17523. WebXRCamera.prototype._updateForDualEyeDebugging = function (pupilDistance) {
  17524. if (pupilDistance === void 0) { pupilDistance = 0.01; }
  17525. // Create initial camera rigs
  17526. this._updateNumberOfRigCameras(2);
  17527. this.rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  17528. this.rigCameras[0].position.x = -pupilDistance / 2;
  17529. this.rigCameras[0].outputRenderTarget = null;
  17530. this.rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  17531. this.rigCameras[1].position.x = pupilDistance / 2;
  17532. this.rigCameras[1].outputRenderTarget = null;
  17533. };
  17534. /**
  17535. * Updates the cameras position from the current pose information of the XR session
  17536. * @param xrSessionManager the session containing pose information
  17537. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  17538. */
  17539. WebXRCamera.prototype.updateFromXRSessionManager = function (xrSessionManager) {
  17540. var _this = this;
  17541. // Ensure all frame data is available
  17542. if (!xrSessionManager._currentXRFrame || !xrSessionManager._currentXRFrame.getDevicePose) {
  17543. return false;
  17544. }
  17545. var pose = xrSessionManager._currentXRFrame.getDevicePose(xrSessionManager._frameOfReference);
  17546. if (!pose || !pose.poseModelMatrix) {
  17547. return false;
  17548. }
  17549. // Update the parent cameras matrix
  17550. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.poseModelMatrix, 0, 1, WebXRCamera._TmpMatrix);
  17551. if (!this._scene.useRightHandedSystem) {
  17552. WebXRCamera._TmpMatrix.toggleModelMatrixHandInPlace();
  17553. }
  17554. WebXRCamera._TmpMatrix.getTranslationToRef(this.position);
  17555. WebXRCamera._TmpMatrix.getRotationMatrixToRef(WebXRCamera._TmpMatrix);
  17556. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(WebXRCamera._TmpMatrix, this.rotationQuaternion);
  17557. this.computeWorldMatrix();
  17558. // Update camera rigs
  17559. this._updateNumberOfRigCameras(xrSessionManager._currentXRFrame.views.length);
  17560. xrSessionManager._currentXRFrame.views.forEach(function (view, i) {
  17561. // Update view/projection matrix
  17562. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.getViewMatrix(view), 0, 1, _this.rigCameras[i]._computedViewMatrix);
  17563. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, _this.rigCameras[i]._projectionMatrix);
  17564. if (!_this._scene.useRightHandedSystem) {
  17565. _this.rigCameras[i]._computedViewMatrix.toggleModelMatrixHandInPlace();
  17566. _this.rigCameras[i]._projectionMatrix.toggleProjectionMatrixHandInPlace();
  17567. }
  17568. // Update viewport
  17569. var viewport = xrSessionManager._xrSession.baseLayer.getViewport(view);
  17570. var width = xrSessionManager._xrSession.baseLayer.framebufferWidth;
  17571. var height = xrSessionManager._xrSession.baseLayer.framebufferHeight;
  17572. _this.rigCameras[i].viewport.width = viewport.width / width;
  17573. _this.rigCameras[i].viewport.height = viewport.height / height;
  17574. _this.rigCameras[i].viewport.x = viewport.x / width;
  17575. _this.rigCameras[i].viewport.y = viewport.y / height;
  17576. // Set cameras to render to the session's render target
  17577. _this.rigCameras[i].outputRenderTarget = xrSessionManager._sessionRenderTargetTexture;
  17578. });
  17579. return true;
  17580. };
  17581. WebXRCamera._TmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  17582. return WebXRCamera;
  17583. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"]));
  17584. /***/ }),
  17585. /***/ "./Cameras/XR/webXREnterExitUI.ts":
  17586. /*!****************************************!*\
  17587. !*** ./Cameras/XR/webXREnterExitUI.ts ***!
  17588. \****************************************/
  17589. /*! exports provided: WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI */
  17590. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17591. "use strict";
  17592. __webpack_require__.r(__webpack_exports__);
  17593. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return WebXREnterExitUIButton; });
  17594. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return WebXREnterExitUIOptions; });
  17595. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return WebXREnterExitUI; });
  17596. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  17597. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  17598. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  17599. /**
  17600. * Button which can be used to enter a different mode of XR
  17601. */
  17602. var WebXREnterExitUIButton = /** @class */ (function () {
  17603. /**
  17604. * Creates a WebXREnterExitUIButton
  17605. * @param element button element
  17606. * @param initializationOptions XR initialization options for the button
  17607. */
  17608. function WebXREnterExitUIButton(
  17609. /** button element */
  17610. element,
  17611. /** XR initialization options for the button */
  17612. initializationOptions) {
  17613. this.element = element;
  17614. this.initializationOptions = initializationOptions;
  17615. }
  17616. /**
  17617. * Overwritable function which can be used to update the button's visuals when the state changes
  17618. * @param activeButton the current active button in the UI
  17619. */
  17620. WebXREnterExitUIButton.prototype.update = function (activeButton) {
  17621. };
  17622. return WebXREnterExitUIButton;
  17623. }());
  17624. /**
  17625. * Options to create the webXR UI
  17626. */
  17627. var WebXREnterExitUIOptions = /** @class */ (function () {
  17628. function WebXREnterExitUIOptions() {
  17629. }
  17630. return WebXREnterExitUIOptions;
  17631. }());
  17632. /**
  17633. * UI to allow the user to enter/exit XR mode
  17634. */
  17635. var WebXREnterExitUI = /** @class */ (function () {
  17636. function WebXREnterExitUI(scene, options) {
  17637. var _this = this;
  17638. this.scene = scene;
  17639. this._buttons = [];
  17640. this._activeButton = null;
  17641. /**
  17642. * Fired every time the active button is changed.
  17643. *
  17644. * When xr is entered via a button that launches xr that button will be the callback parameter
  17645. *
  17646. * When exiting xr the callback parameter will be null)
  17647. */
  17648. this.activeButtonChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17649. this._overlay = document.createElement("div");
  17650. this._overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";
  17651. if (options.customButtons) {
  17652. this._buttons = options.customButtons;
  17653. }
  17654. else {
  17655. var hmdBtn = document.createElement("button");
  17656. 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;";
  17657. hmdBtn.innerText = "HMD";
  17658. this._buttons.push(new WebXREnterExitUIButton(hmdBtn, { immersive: true, outputContext: options.outputCanvasContext }));
  17659. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  17660. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  17661. this.element.innerText = activeButton === this ? "EXIT" : "HMD";
  17662. };
  17663. var windowBtn = document.createElement("button");
  17664. windowBtn.style.cssText = hmdBtn.style.cssText;
  17665. windowBtn.innerText = "Window";
  17666. this._buttons.push(new WebXREnterExitUIButton(windowBtn, { immersive: false, environmentIntegration: true, outputContext: options.outputCanvasContext }));
  17667. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  17668. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  17669. this.element.innerText = activeButton === this ? "EXIT" : "Window";
  17670. };
  17671. this._updateButtons(null);
  17672. }
  17673. var renderCanvas = scene.getEngine().getRenderingCanvas();
  17674. if (renderCanvas && renderCanvas.parentNode) {
  17675. renderCanvas.parentNode.appendChild(this._overlay);
  17676. scene.onDisposeObservable.addOnce(function () {
  17677. _this.dispose();
  17678. });
  17679. }
  17680. }
  17681. /**
  17682. * Creates UI to allow the user to enter/exit XR mode
  17683. * @param scene the scene to add the ui to
  17684. * @param helper the xr experience helper to enter/exit xr with
  17685. * @param options options to configure the UI
  17686. * @returns the created ui
  17687. */
  17688. WebXREnterExitUI.CreateAsync = function (scene, helper, options) {
  17689. var _this = this;
  17690. var ui = new WebXREnterExitUI(scene, options);
  17691. var supportedPromises = ui._buttons.map(function (btn) {
  17692. return helper.supportsSessionAsync(btn.initializationOptions);
  17693. });
  17694. helper.onStateChangedObservable.add(function (state) {
  17695. if (state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR) {
  17696. ui._updateButtons(null);
  17697. }
  17698. });
  17699. return Promise.all(supportedPromises).then(function (results) {
  17700. results.forEach(function (supported, i) {
  17701. if (supported) {
  17702. ui._overlay.appendChild(ui._buttons[i].element);
  17703. ui._buttons[i].element.onclick = function () { return tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"](_this, void 0, void 0, function () {
  17704. return tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"](this, function (_a) {
  17705. switch (_a.label) {
  17706. case 0:
  17707. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].IN_XR)) return [3 /*break*/, 2];
  17708. ui._updateButtons(null);
  17709. return [4 /*yield*/, helper.exitXRAsync()];
  17710. case 1:
  17711. _a.sent();
  17712. return [2 /*return*/];
  17713. case 2:
  17714. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR)) return [3 /*break*/, 4];
  17715. ui._updateButtons(ui._buttons[i]);
  17716. return [4 /*yield*/, helper.enterXRAsync(ui._buttons[i].initializationOptions, "eye-level")];
  17717. case 3:
  17718. _a.sent();
  17719. _a.label = 4;
  17720. case 4: return [2 /*return*/];
  17721. }
  17722. });
  17723. }); };
  17724. }
  17725. });
  17726. return ui;
  17727. });
  17728. };
  17729. WebXREnterExitUI.prototype._updateButtons = function (activeButton) {
  17730. var _this = this;
  17731. this._activeButton = activeButton;
  17732. this._buttons.forEach(function (b) {
  17733. b.update(_this._activeButton);
  17734. });
  17735. this.activeButtonChangedObservable.notifyObservers(this._activeButton);
  17736. };
  17737. /**
  17738. * Disposes of the object
  17739. */
  17740. WebXREnterExitUI.prototype.dispose = function () {
  17741. var renderCanvas = this.scene.getEngine().getRenderingCanvas();
  17742. if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this._overlay)) {
  17743. renderCanvas.parentNode.removeChild(this._overlay);
  17744. }
  17745. this.activeButtonChangedObservable.clear();
  17746. };
  17747. return WebXREnterExitUI;
  17748. }());
  17749. /***/ }),
  17750. /***/ "./Cameras/XR/webXRExperienceHelper.ts":
  17751. /*!*********************************************!*\
  17752. !*** ./Cameras/XR/webXRExperienceHelper.ts ***!
  17753. \*********************************************/
  17754. /*! exports provided: WebXRState, WebXRExperienceHelper */
  17755. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17756. "use strict";
  17757. __webpack_require__.r(__webpack_exports__);
  17758. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return WebXRState; });
  17759. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return WebXRExperienceHelper; });
  17760. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  17761. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17762. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  17763. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  17764. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  17765. /**
  17766. * States of the webXR experience
  17767. */
  17768. var WebXRState;
  17769. (function (WebXRState) {
  17770. /**
  17771. * Transitioning to being in XR mode
  17772. */
  17773. WebXRState[WebXRState["ENTERING_XR"] = 0] = "ENTERING_XR";
  17774. /**
  17775. * Transitioning to non XR mode
  17776. */
  17777. WebXRState[WebXRState["EXITING_XR"] = 1] = "EXITING_XR";
  17778. /**
  17779. * In XR mode and presenting
  17780. */
  17781. WebXRState[WebXRState["IN_XR"] = 2] = "IN_XR";
  17782. /**
  17783. * Not entered XR mode
  17784. */
  17785. WebXRState[WebXRState["NOT_IN_XR"] = 3] = "NOT_IN_XR";
  17786. })(WebXRState || (WebXRState = {}));
  17787. /**
  17788. * Helper class used to enable XR
  17789. * @see https://doc.babylonjs.com/how_to/webxr
  17790. */
  17791. var WebXRExperienceHelper = /** @class */ (function () {
  17792. /**
  17793. * Creates a WebXRExperienceHelper
  17794. * @param scene The scene the helper should be created in
  17795. */
  17796. function WebXRExperienceHelper(scene) {
  17797. this.scene = scene;
  17798. /**
  17799. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  17800. */
  17801. this.state = WebXRState.NOT_IN_XR;
  17802. /**
  17803. * Fires when the state of the experience helper has changed
  17804. */
  17805. this.onStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  17806. this._nonVRCamera = null;
  17807. this._originalSceneAutoClear = true;
  17808. this._supported = false;
  17809. this.camera = new _webXRCamera__WEBPACK_IMPORTED_MODULE_4__["WebXRCamera"]("", scene);
  17810. this._sessionManager = new _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__["WebXRSessionManager"](scene);
  17811. this.container = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", scene);
  17812. this.camera.parent = this.container;
  17813. }
  17814. WebXRExperienceHelper.prototype._setState = function (val) {
  17815. this.state = val;
  17816. this.onStateChangedObservable.notifyObservers(this.state);
  17817. };
  17818. /**
  17819. * Creates the experience helper
  17820. * @param scene the scene to attach the experience helper to
  17821. * @returns a promise for the experience helper
  17822. */
  17823. WebXRExperienceHelper.CreateAsync = function (scene) {
  17824. var helper = new WebXRExperienceHelper(scene);
  17825. return helper._sessionManager.initializeAsync().then(function () {
  17826. helper._supported = true;
  17827. return helper;
  17828. }).catch(function () {
  17829. return helper;
  17830. });
  17831. };
  17832. /**
  17833. * Exits XR mode and returns the scene to its original state
  17834. * @returns promise that resolves after xr mode has exited
  17835. */
  17836. WebXRExperienceHelper.prototype.exitXRAsync = function () {
  17837. this._setState(WebXRState.EXITING_XR);
  17838. return this._sessionManager.exitXRAsync();
  17839. };
  17840. /**
  17841. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  17842. * @param sessionCreationOptions options for the XR session
  17843. * @param frameOfReference frame of reference of the XR session
  17844. * @returns promise that resolves after xr mode has entered
  17845. */
  17846. WebXRExperienceHelper.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReference) {
  17847. var _this = this;
  17848. if (!this._supported) {
  17849. throw "XR session not supported by this browser";
  17850. }
  17851. this._setState(WebXRState.ENTERING_XR);
  17852. return this._sessionManager.enterXRAsync(sessionCreationOptions, frameOfReference).then(function () {
  17853. // Cache pre xr scene settings
  17854. _this._originalSceneAutoClear = _this.scene.autoClear;
  17855. _this._nonVRCamera = _this.scene.activeCamera;
  17856. // Overwrite current scene settings
  17857. _this.scene.autoClear = false;
  17858. _this.scene.activeCamera = _this.camera;
  17859. _this._sessionManager.onXRFrameObservable.add(function () {
  17860. _this.camera.updateFromXRSessionManager(_this._sessionManager);
  17861. });
  17862. _this._sessionManager.onXRSessionEnded.addOnce(function () {
  17863. // Reset camera rigs output render target to ensure sessions render target is not drawn after it ends
  17864. _this.camera.rigCameras.forEach(function (c) {
  17865. c.outputRenderTarget = null;
  17866. });
  17867. // Restore scene settings
  17868. _this.scene.autoClear = _this._originalSceneAutoClear;
  17869. _this.scene.activeCamera = _this._nonVRCamera;
  17870. _this._sessionManager.onXRFrameObservable.clear();
  17871. _this._setState(WebXRState.NOT_IN_XR);
  17872. });
  17873. _this._setState(WebXRState.IN_XR);
  17874. });
  17875. };
  17876. /**
  17877. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  17878. * @param ray ray to cast into the environment
  17879. * @returns Promise which resolves with a collision point in the environment if it exists
  17880. */
  17881. WebXRExperienceHelper.prototype.environmentPointHitTestAsync = function (ray) {
  17882. return this._sessionManager.environmentPointHitTestAsync(ray);
  17883. };
  17884. /**
  17885. * Updates the global position of the camera by moving the camera's container
  17886. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  17887. * @param position The desired global position of the camera
  17888. */
  17889. WebXRExperienceHelper.prototype.setPositionOfCameraUsingContainer = function (position) {
  17890. this.camera.globalPosition.subtractToRef(position, WebXRExperienceHelper._TmpVector);
  17891. this.container.position.subtractInPlace(WebXRExperienceHelper._TmpVector);
  17892. };
  17893. /**
  17894. * Rotates the xr camera by rotating the camera's container around the camera's position
  17895. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  17896. * @param rotation the desired quaternion rotation to apply to the camera
  17897. */
  17898. WebXRExperienceHelper.prototype.rotateCameraByQuaternionUsingContainer = function (rotation) {
  17899. if (!this.container.rotationQuaternion) {
  17900. this.container.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromEulerVector(this.container.rotation);
  17901. }
  17902. this.container.rotationQuaternion.multiplyInPlace(rotation);
  17903. this.container.position.rotateByQuaternionAroundPointToRef(rotation, this.camera.globalPosition, this.container.position);
  17904. };
  17905. /**
  17906. * Checks if the creation options are supported by the xr session
  17907. * @param options creation options
  17908. * @returns true if supported
  17909. */
  17910. WebXRExperienceHelper.prototype.supportsSessionAsync = function (options) {
  17911. if (!this._supported) {
  17912. return Promise.resolve(false);
  17913. }
  17914. return this._sessionManager.supportsSessionAsync(options);
  17915. };
  17916. /**
  17917. * Disposes of the experience helper
  17918. */
  17919. WebXRExperienceHelper.prototype.dispose = function () {
  17920. this.camera.dispose();
  17921. this.container.dispose();
  17922. this.onStateChangedObservable.clear();
  17923. this._sessionManager.dispose();
  17924. };
  17925. WebXRExperienceHelper._TmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]();
  17926. return WebXRExperienceHelper;
  17927. }());
  17928. /***/ }),
  17929. /***/ "./Cameras/XR/webXRInput.ts":
  17930. /*!**********************************!*\
  17931. !*** ./Cameras/XR/webXRInput.ts ***!
  17932. \**********************************/
  17933. /*! exports provided: WebXRController, WebXRInput */
  17934. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17935. "use strict";
  17936. __webpack_require__.r(__webpack_exports__);
  17937. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return WebXRController; });
  17938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return WebXRInput; });
  17939. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17940. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  17941. /**
  17942. * Represents an XR input
  17943. */
  17944. var WebXRController = /** @class */ (function () {
  17945. /**
  17946. * Creates the controller
  17947. * @see https://doc.babylonjs.com/how_to/webxr
  17948. * @param scene the scene which the controller should be associated to
  17949. */
  17950. function WebXRController(scene) {
  17951. this.pointer = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerPointer", scene);
  17952. }
  17953. /**
  17954. * Disposes of the object
  17955. */
  17956. WebXRController.prototype.dispose = function () {
  17957. if (this.grip) {
  17958. this.grip.dispose();
  17959. }
  17960. this.pointer.dispose();
  17961. };
  17962. return WebXRController;
  17963. }());
  17964. /**
  17965. * XR input used to track XR inputs such as controllers/rays
  17966. */
  17967. var WebXRInput = /** @class */ (function () {
  17968. /**
  17969. * Initializes the WebXRInput
  17970. * @param helper experience helper which the input should be created for
  17971. */
  17972. function WebXRInput(helper) {
  17973. var _this = this;
  17974. this.helper = helper;
  17975. /**
  17976. * XR controllers being tracked
  17977. */
  17978. this.controllers = [];
  17979. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  17980. this._frameObserver = helper._sessionManager.onXRFrameObservable.add(function () {
  17981. if (!helper._sessionManager._currentXRFrame || !helper._sessionManager._currentXRFrame.getDevicePose) {
  17982. return;
  17983. }
  17984. var xrFrame = helper._sessionManager._currentXRFrame;
  17985. var inputSources = helper._sessionManager._xrSession.getInputSources();
  17986. inputSources.forEach(function (input, i) {
  17987. var inputPose = xrFrame.getInputPose(input, helper._sessionManager._frameOfReference);
  17988. if (inputPose) {
  17989. if (_this.controllers.length <= i) {
  17990. _this.controllers.push(new WebXRController(helper.container.getScene()));
  17991. }
  17992. var controller = _this.controllers[i];
  17993. // Manage the grip if it exists
  17994. if (inputPose.gripMatrix) {
  17995. if (!controller.grip) {
  17996. controller.grip = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerGrip", helper.container.getScene());
  17997. }
  17998. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.gripMatrix, 0, 1, _this._tmpMatrix);
  17999. if (!controller.grip.getScene().useRightHandedSystem) {
  18000. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  18001. }
  18002. if (!controller.grip.rotationQuaternion) {
  18003. controller.grip.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  18004. }
  18005. _this._tmpMatrix.decompose(controller.grip.scaling, controller.grip.rotationQuaternion, controller.grip.position);
  18006. }
  18007. // Manager pointer of controller
  18008. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.targetRay.transformMatrix, 0, 1, _this._tmpMatrix);
  18009. if (!controller.pointer.getScene().useRightHandedSystem) {
  18010. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  18011. }
  18012. if (!controller.pointer.rotationQuaternion) {
  18013. controller.pointer.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  18014. }
  18015. _this._tmpMatrix.decompose(controller.pointer.scaling, controller.pointer.rotationQuaternion, controller.pointer.position);
  18016. }
  18017. });
  18018. });
  18019. }
  18020. /**
  18021. * Disposes of the object
  18022. */
  18023. WebXRInput.prototype.dispose = function () {
  18024. this.controllers.forEach(function (c) {
  18025. c.dispose();
  18026. });
  18027. this.helper._sessionManager.onXRFrameObservable.remove(this._frameObserver);
  18028. };
  18029. return WebXRInput;
  18030. }());
  18031. /***/ }),
  18032. /***/ "./Cameras/XR/webXRManagedOutputCanvas.ts":
  18033. /*!************************************************!*\
  18034. !*** ./Cameras/XR/webXRManagedOutputCanvas.ts ***!
  18035. \************************************************/
  18036. /*! exports provided: WebXRManagedOutputCanvas */
  18037. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18038. "use strict";
  18039. __webpack_require__.r(__webpack_exports__);
  18040. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return WebXRManagedOutputCanvas; });
  18041. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18042. /**
  18043. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  18044. */
  18045. var WebXRManagedOutputCanvas = /** @class */ (function () {
  18046. /**
  18047. * Initializes the canvas to be added/removed upon entering/exiting xr
  18048. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  18049. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  18050. */
  18051. function WebXRManagedOutputCanvas(helper, canvas) {
  18052. var _this = this;
  18053. this._canvas = null;
  18054. /**
  18055. * xrpresent context of the canvas which can be used to display/mirror xr content
  18056. */
  18057. this.canvasContext = null;
  18058. if (!canvas) {
  18059. canvas = document.createElement('canvas');
  18060. canvas.style.cssText = "position:absolute; bottom:0px;right:0px;z-index:10;width:100%;height:100%;background-color: #000000;";
  18061. }
  18062. this._setManagedOutputCanvas(canvas);
  18063. helper.onStateChangedObservable.add(function (stateInfo) {
  18064. if (stateInfo == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].ENTERING_XR) {
  18065. // 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
  18066. _this._addCanvas();
  18067. }
  18068. else if (helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].NOT_IN_XR) {
  18069. _this._removeCanvas();
  18070. }
  18071. });
  18072. }
  18073. /**
  18074. * Disposes of the object
  18075. */
  18076. WebXRManagedOutputCanvas.prototype.dispose = function () {
  18077. this._removeCanvas();
  18078. this._setManagedOutputCanvas(null);
  18079. };
  18080. WebXRManagedOutputCanvas.prototype._setManagedOutputCanvas = function (canvas) {
  18081. this._removeCanvas();
  18082. if (!canvas) {
  18083. this._canvas = null;
  18084. this.canvasContext = null;
  18085. }
  18086. else {
  18087. this._canvas = canvas;
  18088. this.canvasContext = this._canvas.getContext('xrpresent');
  18089. }
  18090. };
  18091. WebXRManagedOutputCanvas.prototype._addCanvas = function () {
  18092. if (this._canvas) {
  18093. document.body.appendChild(this._canvas);
  18094. }
  18095. };
  18096. WebXRManagedOutputCanvas.prototype._removeCanvas = function () {
  18097. if (this._canvas && document.body.contains(this._canvas)) {
  18098. document.body.removeChild(this._canvas);
  18099. }
  18100. };
  18101. return WebXRManagedOutputCanvas;
  18102. }());
  18103. /***/ }),
  18104. /***/ "./Cameras/XR/webXRSessionManager.ts":
  18105. /*!*******************************************!*\
  18106. !*** ./Cameras/XR/webXRSessionManager.ts ***!
  18107. \*******************************************/
  18108. /*! exports provided: WebXRSessionManager */
  18109. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18110. "use strict";
  18111. __webpack_require__.r(__webpack_exports__);
  18112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return WebXRSessionManager; });
  18113. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  18114. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18115. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18116. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  18117. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  18118. /**
  18119. * Manages an XRSession
  18120. * @see https://doc.babylonjs.com/how_to/webxr
  18121. */
  18122. var WebXRSessionManager = /** @class */ (function () {
  18123. /**
  18124. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  18125. * @param scene The scene which the session should be created for
  18126. */
  18127. function WebXRSessionManager(scene) {
  18128. this.scene = scene;
  18129. /**
  18130. * Fires every time a new xrFrame arrives which can be used to update the camera
  18131. */
  18132. this.onXRFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18133. /**
  18134. * Fires when the xr session is ended either by the device or manually done
  18135. */
  18136. this.onXRSessionEnded = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18137. /** @hidden */
  18138. this._sessionRenderTargetTexture = null;
  18139. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  18140. }
  18141. /**
  18142. * Initializes the manager
  18143. * After initialization enterXR can be called to start an XR session
  18144. * @returns Promise which resolves after it is initialized
  18145. */
  18146. WebXRSessionManager.prototype.initializeAsync = function () {
  18147. var _this = this;
  18148. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("The WebXR APIs are still under development and are subject to change in the future.");
  18149. // Check if the browser supports webXR
  18150. this._xrNavigator = navigator;
  18151. if (!this._xrNavigator.xr) {
  18152. return Promise.reject("webXR not supported by this browser");
  18153. }
  18154. // Request the webXR device
  18155. return this._xrNavigator.xr.requestDevice().then(function (device) {
  18156. _this._xrDevice = device;
  18157. return _this.scene.getEngine()._gl.setCompatibleXRDevice(_this._xrDevice);
  18158. });
  18159. };
  18160. /**
  18161. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  18162. * @param sessionCreationOptions xr options to create the session with
  18163. * @param frameOfReferenceType option to configure how the xr pose is expressed
  18164. * @returns Promise which resolves after it enters XR
  18165. */
  18166. WebXRSessionManager.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReferenceType) {
  18167. var _this = this;
  18168. // initialize session
  18169. return this._xrDevice.requestSession(sessionCreationOptions).then(function (session) {
  18170. _this._xrSession = session;
  18171. // handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)
  18172. _this._xrSession.addEventListener("end", function () {
  18173. // Remove render target texture and notify frame obervers
  18174. _this._sessionRenderTargetTexture = null;
  18175. // Restore frame buffer to avoid clear on xr framebuffer after session end
  18176. _this.scene.getEngine().restoreDefaultFramebuffer();
  18177. // Need to restart render loop as after the session is ended the last request for new frame will never call callback
  18178. _this.scene.getEngine().customAnimationFrameRequester = null;
  18179. _this.onXRSessionEnded.notifyObservers(null);
  18180. _this.scene.getEngine()._renderLoop();
  18181. }, { once: true });
  18182. _this._xrSession.baseLayer = new XRWebGLLayer(_this._xrSession, _this.scene.getEngine()._gl);
  18183. return _this._xrSession.requestFrameOfReference(frameOfReferenceType);
  18184. }).then(function (frameOfRef) {
  18185. _this._frameOfReference = frameOfRef;
  18186. // Tell the engine's render loop to be driven by the xr session's refresh rate and provide xr pose information
  18187. _this.scene.getEngine().customAnimationFrameRequester = {
  18188. requestAnimationFrame: _this._xrSession.requestAnimationFrame.bind(_this._xrSession),
  18189. renderFunction: function (timestamp, xrFrame) {
  18190. // Store the XR frame in the manager to be consumed by the XR camera to update pose
  18191. _this._currentXRFrame = xrFrame;
  18192. _this.onXRFrameObservable.notifyObservers(null);
  18193. _this.scene.getEngine()._renderLoop();
  18194. }
  18195. };
  18196. // Create render target texture from xr's webgl render target
  18197. _this._sessionRenderTargetTexture = WebXRSessionManager._CreateRenderTargetTextureFromSession(_this._xrSession, _this.scene);
  18198. // Stop window's animation frame and trigger sessions animation frame
  18199. window.cancelAnimationFrame(_this.scene.getEngine()._frameHandler);
  18200. _this.scene.getEngine()._renderLoop();
  18201. });
  18202. };
  18203. /**
  18204. * Stops the xrSession and restores the renderloop
  18205. * @returns Promise which resolves after it exits XR
  18206. */
  18207. WebXRSessionManager.prototype.exitXRAsync = function () {
  18208. return this._xrSession.end();
  18209. };
  18210. /**
  18211. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18212. * @param ray ray to cast into the environment
  18213. * @returns Promise which resolves with a collision point in the environment if it exists
  18214. */
  18215. WebXRSessionManager.prototype.environmentPointHitTestAsync = function (ray) {
  18216. var _this = this;
  18217. return new Promise(function (res) {
  18218. // Compute left handed inputs to request hit test
  18219. var origin = new Float32Array([ray.origin.x, ray.origin.y, ray.origin.z]);
  18220. var direction = new Float32Array([ray.direction.x, ray.direction.y, ray.direction.z]);
  18221. if (!_this.scene.useRightHandedSystem) {
  18222. origin[2] *= -1;
  18223. direction[2] *= -1;
  18224. }
  18225. // Fire hittest
  18226. _this._xrSession.requestHitTest(origin, direction, _this._frameOfReference)
  18227. .then(function (hits) {
  18228. if (hits.length > 0) {
  18229. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromFloat32ArrayToRefScaled(hits[0].hitMatrix, 0, 1.0, _this._tmpMatrix);
  18230. var hitPoint = _this._tmpMatrix.getTranslation();
  18231. if (!_this.scene.useRightHandedSystem) {
  18232. hitPoint.z *= -1;
  18233. }
  18234. res(hitPoint);
  18235. }
  18236. else {
  18237. res(null);
  18238. }
  18239. }).catch(function () {
  18240. res(null);
  18241. });
  18242. });
  18243. };
  18244. /**
  18245. * Checks if a session would be supported for the creation options specified
  18246. * @param options creation options to check if they are supported
  18247. * @returns true if supported
  18248. */
  18249. WebXRSessionManager.prototype.supportsSessionAsync = function (options) {
  18250. return this._xrDevice.supportsSession(options).then(function () {
  18251. return true;
  18252. }).catch(function () {
  18253. return false;
  18254. });
  18255. };
  18256. /**
  18257. * @hidden
  18258. * Converts the render layer of xrSession to a render target
  18259. * @param session session to create render target for
  18260. * @param scene scene the new render target should be created for
  18261. */
  18262. WebXRSessionManager._CreateRenderTargetTextureFromSession = function (session, scene) {
  18263. // Create internal texture
  18264. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](scene.getEngine(), _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  18265. internalTexture.width = session.baseLayer.framebufferWidth;
  18266. internalTexture.height = session.baseLayer.framebufferHeight;
  18267. internalTexture._framebuffer = session.baseLayer.framebuffer;
  18268. // Create render target texture from the internal texture
  18269. 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);
  18270. renderTargetTexture._texture = internalTexture;
  18271. return renderTargetTexture;
  18272. };
  18273. /**
  18274. * Disposes of the session manager
  18275. */
  18276. WebXRSessionManager.prototype.dispose = function () {
  18277. this.onXRFrameObservable.clear();
  18278. this.onXRSessionEnded.clear();
  18279. };
  18280. return WebXRSessionManager;
  18281. }());
  18282. /***/ }),
  18283. /***/ "./Cameras/arcRotateCamera.ts":
  18284. /*!************************************!*\
  18285. !*** ./Cameras/arcRotateCamera.ts ***!
  18286. \************************************/
  18287. /*! exports provided: ArcRotateCamera */
  18288. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18289. "use strict";
  18290. __webpack_require__.r(__webpack_exports__);
  18291. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return ArcRotateCamera; });
  18292. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18293. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  18294. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  18295. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  18296. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  18297. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  18298. /* harmony import */ var _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Cameras/autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  18299. /* harmony import */ var _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Cameras/bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  18300. /* harmony import */ var _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Behaviors/Cameras/framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  18301. /* harmony import */ var _Collisions_collider__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Collisions/collider */ "./Collisions/collider.ts");
  18302. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  18303. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  18304. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  18305. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("ArcRotateCamera", function (name, scene) {
  18306. return function () { return new ArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  18307. });
  18308. /**
  18309. * This represents an orbital type of camera.
  18310. *
  18311. * 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.
  18312. * 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.
  18313. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  18314. */
  18315. var ArcRotateCamera = /** @class */ (function (_super) {
  18316. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCamera, _super);
  18317. /**
  18318. * Instantiates a new ArcRotateCamera in a given scene
  18319. * @param name Defines the name of the camera
  18320. * @param alpha Defines the camera rotation along the logitudinal axis
  18321. * @param beta Defines the camera rotation along the latitudinal axis
  18322. * @param radius Defines the camera distance from its target
  18323. * @param target Defines the camera target
  18324. * @param scene Defines the scene the camera belongs to
  18325. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18326. */
  18327. function ArcRotateCamera(name, alpha, beta, radius, target, scene, setActiveOnSceneIfNoneActive) {
  18328. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  18329. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene, setActiveOnSceneIfNoneActive) || this;
  18330. /**
  18331. * Current inertia value on the longitudinal axis.
  18332. * The bigger this number the longer it will take for the camera to stop.
  18333. */
  18334. _this.inertialAlphaOffset = 0;
  18335. /**
  18336. * Current inertia value on the latitudinal axis.
  18337. * The bigger this number the longer it will take for the camera to stop.
  18338. */
  18339. _this.inertialBetaOffset = 0;
  18340. /**
  18341. * Current inertia value on the radius axis.
  18342. * The bigger this number the longer it will take for the camera to stop.
  18343. */
  18344. _this.inertialRadiusOffset = 0;
  18345. /**
  18346. * Minimum allowed angle on the longitudinal axis.
  18347. * This can help limiting how the Camera is able to move in the scene.
  18348. */
  18349. _this.lowerAlphaLimit = null;
  18350. /**
  18351. * Maximum allowed angle on the longitudinal axis.
  18352. * This can help limiting how the Camera is able to move in the scene.
  18353. */
  18354. _this.upperAlphaLimit = null;
  18355. /**
  18356. * Minimum allowed angle on the latitudinal axis.
  18357. * This can help limiting how the Camera is able to move in the scene.
  18358. */
  18359. _this.lowerBetaLimit = 0.01;
  18360. /**
  18361. * Maximum allowed angle on the latitudinal axis.
  18362. * This can help limiting how the Camera is able to move in the scene.
  18363. */
  18364. _this.upperBetaLimit = Math.PI - 0.01;
  18365. /**
  18366. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  18367. * This can help limiting how the Camera is able to move in the scene.
  18368. */
  18369. _this.lowerRadiusLimit = null;
  18370. /**
  18371. * Maximum allowed distance of the camera to the target (The camera can not get further).
  18372. * This can help limiting how the Camera is able to move in the scene.
  18373. */
  18374. _this.upperRadiusLimit = null;
  18375. /**
  18376. * Defines the current inertia value used during panning of the camera along the X axis.
  18377. */
  18378. _this.inertialPanningX = 0;
  18379. /**
  18380. * Defines the current inertia value used during panning of the camera along the Y axis.
  18381. */
  18382. _this.inertialPanningY = 0;
  18383. /**
  18384. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  18385. * Basically if your fingers moves away from more than this distance you will be considered
  18386. * in pinch mode.
  18387. */
  18388. _this.pinchToPanMaxDistance = 20;
  18389. /**
  18390. * Defines the maximum distance the camera can pan.
  18391. * This could help keeping the cammera always in your scene.
  18392. */
  18393. _this.panningDistanceLimit = null;
  18394. /**
  18395. * Defines the target of the camera before paning.
  18396. */
  18397. _this.panningOriginTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18398. /**
  18399. * Defines the value of the inertia used during panning.
  18400. * 0 would mean stop inertia and one would mean no decelleration at all.
  18401. */
  18402. _this.panningInertia = 0.9;
  18403. //-- end properties for backward compatibility for inputs
  18404. /**
  18405. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  18406. */
  18407. _this.zoomOnFactor = 1;
  18408. /**
  18409. * Defines a screen offset for the camera position.
  18410. */
  18411. _this.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  18412. /**
  18413. * Allows the camera to be completely reversed.
  18414. * If false the camera can not arrive upside down.
  18415. */
  18416. _this.allowUpsideDown = true;
  18417. /**
  18418. * Define if double tap/click is used to restore the previously saved state of the camera.
  18419. */
  18420. _this.useInputToRestoreState = true;
  18421. /** @hidden */
  18422. _this._viewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  18423. /**
  18424. * Defines the allowed panning axis.
  18425. */
  18426. _this.panningAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 0);
  18427. /**
  18428. * Observable triggered when the mesh target has been changed on the camera.
  18429. */
  18430. _this.onMeshTargetChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  18431. /**
  18432. * Defines whether the camera should check collision with the objects oh the scene.
  18433. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  18434. */
  18435. _this.checkCollisions = false;
  18436. /**
  18437. * Defines the collision radius of the camera.
  18438. * This simulates a sphere around the camera.
  18439. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18440. */
  18441. _this.collisionRadius = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 0.5, 0.5);
  18442. _this._previousPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18443. _this._collisionVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18444. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18445. _this._computationVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18446. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  18447. if (collidedMesh === void 0) { collidedMesh = null; }
  18448. if (!collidedMesh) {
  18449. _this._previousPosition.copyFrom(_this.position);
  18450. }
  18451. else {
  18452. _this.setPosition(newPosition);
  18453. if (_this.onCollide) {
  18454. _this.onCollide(collidedMesh);
  18455. }
  18456. }
  18457. // Recompute because of constraints
  18458. var cosa = Math.cos(_this.alpha);
  18459. var sina = Math.sin(_this.alpha);
  18460. var cosb = Math.cos(_this.beta);
  18461. var sinb = Math.sin(_this.beta);
  18462. if (sinb === 0) {
  18463. sinb = 0.0001;
  18464. }
  18465. var target = _this._getTargetPosition();
  18466. _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
  18467. target.addToRef(_this._computationVector, _this._newPosition);
  18468. _this.position.copyFrom(_this._newPosition);
  18469. var up = _this.upVector;
  18470. if (_this.allowUpsideDown && _this.beta < 0) {
  18471. up = up.clone();
  18472. up = up.negate();
  18473. }
  18474. _this._computeViewMatrix(_this.position, target, up);
  18475. _this._viewMatrix.addAtIndex(12, _this.targetScreenOffset.x);
  18476. _this._viewMatrix.addAtIndex(13, _this.targetScreenOffset.y);
  18477. _this._collisionTriggered = false;
  18478. };
  18479. _this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18480. if (target) {
  18481. _this.setTarget(target);
  18482. }
  18483. _this.alpha = alpha;
  18484. _this.beta = beta;
  18485. _this.radius = radius;
  18486. _this.getViewMatrix();
  18487. _this.inputs = new _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_12__["ArcRotateCameraInputsManager"](_this);
  18488. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  18489. return _this;
  18490. }
  18491. Object.defineProperty(ArcRotateCamera.prototype, "target", {
  18492. /**
  18493. * Defines the target point of the camera.
  18494. * The camera looks towards it form the radius distance.
  18495. */
  18496. get: function () {
  18497. return this._target;
  18498. },
  18499. set: function (value) {
  18500. this.setTarget(value);
  18501. },
  18502. enumerable: true,
  18503. configurable: true
  18504. });
  18505. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityX", {
  18506. //-- begin properties for backward compatibility for inputs
  18507. /**
  18508. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  18509. */
  18510. get: function () {
  18511. var pointers = this.inputs.attached["pointers"];
  18512. if (pointers) {
  18513. return pointers.angularSensibilityX;
  18514. }
  18515. return 0;
  18516. },
  18517. set: function (value) {
  18518. var pointers = this.inputs.attached["pointers"];
  18519. if (pointers) {
  18520. pointers.angularSensibilityX = value;
  18521. }
  18522. },
  18523. enumerable: true,
  18524. configurable: true
  18525. });
  18526. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityY", {
  18527. /**
  18528. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  18529. */
  18530. get: function () {
  18531. var pointers = this.inputs.attached["pointers"];
  18532. if (pointers) {
  18533. return pointers.angularSensibilityY;
  18534. }
  18535. return 0;
  18536. },
  18537. set: function (value) {
  18538. var pointers = this.inputs.attached["pointers"];
  18539. if (pointers) {
  18540. pointers.angularSensibilityY = value;
  18541. }
  18542. },
  18543. enumerable: true,
  18544. configurable: true
  18545. });
  18546. Object.defineProperty(ArcRotateCamera.prototype, "pinchPrecision", {
  18547. /**
  18548. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  18549. */
  18550. get: function () {
  18551. var pointers = this.inputs.attached["pointers"];
  18552. if (pointers) {
  18553. return pointers.pinchPrecision;
  18554. }
  18555. return 0;
  18556. },
  18557. set: function (value) {
  18558. var pointers = this.inputs.attached["pointers"];
  18559. if (pointers) {
  18560. pointers.pinchPrecision = value;
  18561. }
  18562. },
  18563. enumerable: true,
  18564. configurable: true
  18565. });
  18566. Object.defineProperty(ArcRotateCamera.prototype, "pinchDeltaPercentage", {
  18567. /**
  18568. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  18569. * It will be used instead of pinchDeltaPrecision if different from 0.
  18570. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  18571. */
  18572. get: function () {
  18573. var pointers = this.inputs.attached["pointers"];
  18574. if (pointers) {
  18575. return pointers.pinchDeltaPercentage;
  18576. }
  18577. return 0;
  18578. },
  18579. set: function (value) {
  18580. var pointers = this.inputs.attached["pointers"];
  18581. if (pointers) {
  18582. pointers.pinchDeltaPercentage = value;
  18583. }
  18584. },
  18585. enumerable: true,
  18586. configurable: true
  18587. });
  18588. Object.defineProperty(ArcRotateCamera.prototype, "panningSensibility", {
  18589. /**
  18590. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  18591. */
  18592. get: function () {
  18593. var pointers = this.inputs.attached["pointers"];
  18594. if (pointers) {
  18595. return pointers.panningSensibility;
  18596. }
  18597. return 0;
  18598. },
  18599. set: function (value) {
  18600. var pointers = this.inputs.attached["pointers"];
  18601. if (pointers) {
  18602. pointers.panningSensibility = value;
  18603. }
  18604. },
  18605. enumerable: true,
  18606. configurable: true
  18607. });
  18608. Object.defineProperty(ArcRotateCamera.prototype, "keysUp", {
  18609. /**
  18610. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  18611. */
  18612. get: function () {
  18613. var keyboard = this.inputs.attached["keyboard"];
  18614. if (keyboard) {
  18615. return keyboard.keysUp;
  18616. }
  18617. return [];
  18618. },
  18619. set: function (value) {
  18620. var keyboard = this.inputs.attached["keyboard"];
  18621. if (keyboard) {
  18622. keyboard.keysUp = value;
  18623. }
  18624. },
  18625. enumerable: true,
  18626. configurable: true
  18627. });
  18628. Object.defineProperty(ArcRotateCamera.prototype, "keysDown", {
  18629. /**
  18630. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  18631. */
  18632. get: function () {
  18633. var keyboard = this.inputs.attached["keyboard"];
  18634. if (keyboard) {
  18635. return keyboard.keysDown;
  18636. }
  18637. return [];
  18638. },
  18639. set: function (value) {
  18640. var keyboard = this.inputs.attached["keyboard"];
  18641. if (keyboard) {
  18642. keyboard.keysDown = value;
  18643. }
  18644. },
  18645. enumerable: true,
  18646. configurable: true
  18647. });
  18648. Object.defineProperty(ArcRotateCamera.prototype, "keysLeft", {
  18649. /**
  18650. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  18651. */
  18652. get: function () {
  18653. var keyboard = this.inputs.attached["keyboard"];
  18654. if (keyboard) {
  18655. return keyboard.keysLeft;
  18656. }
  18657. return [];
  18658. },
  18659. set: function (value) {
  18660. var keyboard = this.inputs.attached["keyboard"];
  18661. if (keyboard) {
  18662. keyboard.keysLeft = value;
  18663. }
  18664. },
  18665. enumerable: true,
  18666. configurable: true
  18667. });
  18668. Object.defineProperty(ArcRotateCamera.prototype, "keysRight", {
  18669. /**
  18670. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  18671. */
  18672. get: function () {
  18673. var keyboard = this.inputs.attached["keyboard"];
  18674. if (keyboard) {
  18675. return keyboard.keysRight;
  18676. }
  18677. return [];
  18678. },
  18679. set: function (value) {
  18680. var keyboard = this.inputs.attached["keyboard"];
  18681. if (keyboard) {
  18682. keyboard.keysRight = value;
  18683. }
  18684. },
  18685. enumerable: true,
  18686. configurable: true
  18687. });
  18688. Object.defineProperty(ArcRotateCamera.prototype, "wheelPrecision", {
  18689. /**
  18690. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  18691. */
  18692. get: function () {
  18693. var mousewheel = this.inputs.attached["mousewheel"];
  18694. if (mousewheel) {
  18695. return mousewheel.wheelPrecision;
  18696. }
  18697. return 0;
  18698. },
  18699. set: function (value) {
  18700. var mousewheel = this.inputs.attached["mousewheel"];
  18701. if (mousewheel) {
  18702. mousewheel.wheelPrecision = value;
  18703. }
  18704. },
  18705. enumerable: true,
  18706. configurable: true
  18707. });
  18708. Object.defineProperty(ArcRotateCamera.prototype, "wheelDeltaPercentage", {
  18709. /**
  18710. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  18711. * It will be used instead of pinchDeltaPrecision if different from 0.
  18712. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  18713. */
  18714. get: function () {
  18715. var mousewheel = this.inputs.attached["mousewheel"];
  18716. if (mousewheel) {
  18717. return mousewheel.wheelDeltaPercentage;
  18718. }
  18719. return 0;
  18720. },
  18721. set: function (value) {
  18722. var mousewheel = this.inputs.attached["mousewheel"];
  18723. if (mousewheel) {
  18724. mousewheel.wheelDeltaPercentage = value;
  18725. }
  18726. },
  18727. enumerable: true,
  18728. configurable: true
  18729. });
  18730. Object.defineProperty(ArcRotateCamera.prototype, "bouncingBehavior", {
  18731. /**
  18732. * Gets the bouncing behavior of the camera if it has been enabled.
  18733. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  18734. */
  18735. get: function () {
  18736. return this._bouncingBehavior;
  18737. },
  18738. enumerable: true,
  18739. configurable: true
  18740. });
  18741. Object.defineProperty(ArcRotateCamera.prototype, "useBouncingBehavior", {
  18742. /**
  18743. * Defines if the bouncing behavior of the camera is enabled on the camera.
  18744. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  18745. */
  18746. get: function () {
  18747. return this._bouncingBehavior != null;
  18748. },
  18749. set: function (value) {
  18750. if (value === this.useBouncingBehavior) {
  18751. return;
  18752. }
  18753. if (value) {
  18754. this._bouncingBehavior = new _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__["BouncingBehavior"]();
  18755. this.addBehavior(this._bouncingBehavior);
  18756. }
  18757. else if (this._bouncingBehavior) {
  18758. this.removeBehavior(this._bouncingBehavior);
  18759. this._bouncingBehavior = null;
  18760. }
  18761. },
  18762. enumerable: true,
  18763. configurable: true
  18764. });
  18765. Object.defineProperty(ArcRotateCamera.prototype, "framingBehavior", {
  18766. /**
  18767. * Gets the framing behavior of the camera if it has been enabled.
  18768. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  18769. */
  18770. get: function () {
  18771. return this._framingBehavior;
  18772. },
  18773. enumerable: true,
  18774. configurable: true
  18775. });
  18776. Object.defineProperty(ArcRotateCamera.prototype, "useFramingBehavior", {
  18777. /**
  18778. * Defines if the framing behavior of the camera is enabled on the camera.
  18779. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  18780. */
  18781. get: function () {
  18782. return this._framingBehavior != null;
  18783. },
  18784. set: function (value) {
  18785. if (value === this.useFramingBehavior) {
  18786. return;
  18787. }
  18788. if (value) {
  18789. this._framingBehavior = new _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__["FramingBehavior"]();
  18790. this.addBehavior(this._framingBehavior);
  18791. }
  18792. else if (this._framingBehavior) {
  18793. this.removeBehavior(this._framingBehavior);
  18794. this._framingBehavior = null;
  18795. }
  18796. },
  18797. enumerable: true,
  18798. configurable: true
  18799. });
  18800. Object.defineProperty(ArcRotateCamera.prototype, "autoRotationBehavior", {
  18801. /**
  18802. * Gets the auto rotation behavior of the camera if it has been enabled.
  18803. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  18804. */
  18805. get: function () {
  18806. return this._autoRotationBehavior;
  18807. },
  18808. enumerable: true,
  18809. configurable: true
  18810. });
  18811. Object.defineProperty(ArcRotateCamera.prototype, "useAutoRotationBehavior", {
  18812. /**
  18813. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  18814. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  18815. */
  18816. get: function () {
  18817. return this._autoRotationBehavior != null;
  18818. },
  18819. set: function (value) {
  18820. if (value === this.useAutoRotationBehavior) {
  18821. return;
  18822. }
  18823. if (value) {
  18824. this._autoRotationBehavior = new _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__["AutoRotationBehavior"]();
  18825. this.addBehavior(this._autoRotationBehavior);
  18826. }
  18827. else if (this._autoRotationBehavior) {
  18828. this.removeBehavior(this._autoRotationBehavior);
  18829. this._autoRotationBehavior = null;
  18830. }
  18831. },
  18832. enumerable: true,
  18833. configurable: true
  18834. });
  18835. // Cache
  18836. /** @hidden */
  18837. ArcRotateCamera.prototype._initCache = function () {
  18838. _super.prototype._initCache.call(this);
  18839. this._cache._target = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  18840. this._cache.alpha = undefined;
  18841. this._cache.beta = undefined;
  18842. this._cache.radius = undefined;
  18843. this._cache.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  18844. };
  18845. /** @hidden */
  18846. ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
  18847. if (!ignoreParentClass) {
  18848. _super.prototype._updateCache.call(this);
  18849. }
  18850. this._cache._target.copyFrom(this._getTargetPosition());
  18851. this._cache.alpha = this.alpha;
  18852. this._cache.beta = this.beta;
  18853. this._cache.radius = this.radius;
  18854. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
  18855. };
  18856. ArcRotateCamera.prototype._getTargetPosition = function () {
  18857. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  18858. var pos = this._targetHost.absolutePosition;
  18859. if (this._targetBoundingCenter) {
  18860. pos.addToRef(this._targetBoundingCenter, this._target);
  18861. }
  18862. else {
  18863. this._target.copyFrom(pos);
  18864. }
  18865. }
  18866. var lockedTargetPosition = this._getLockedTargetPosition();
  18867. if (lockedTargetPosition) {
  18868. return lockedTargetPosition;
  18869. }
  18870. return this._target;
  18871. };
  18872. /**
  18873. * Stores the current state of the camera (alpha, beta, radius and target)
  18874. * @returns the camera itself
  18875. */
  18876. ArcRotateCamera.prototype.storeState = function () {
  18877. this._storedAlpha = this.alpha;
  18878. this._storedBeta = this.beta;
  18879. this._storedRadius = this.radius;
  18880. this._storedTarget = this._getTargetPosition().clone();
  18881. return _super.prototype.storeState.call(this);
  18882. };
  18883. /**
  18884. * @hidden
  18885. * Restored camera state. You must call storeState() first
  18886. */
  18887. ArcRotateCamera.prototype._restoreStateValues = function () {
  18888. if (!_super.prototype._restoreStateValues.call(this)) {
  18889. return false;
  18890. }
  18891. this.alpha = this._storedAlpha;
  18892. this.beta = this._storedBeta;
  18893. this.radius = this._storedRadius;
  18894. this.setTarget(this._storedTarget.clone());
  18895. this.inertialAlphaOffset = 0;
  18896. this.inertialBetaOffset = 0;
  18897. this.inertialRadiusOffset = 0;
  18898. this.inertialPanningX = 0;
  18899. this.inertialPanningY = 0;
  18900. return true;
  18901. };
  18902. // Synchronized
  18903. /** @hidden */
  18904. ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
  18905. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  18906. return false;
  18907. }
  18908. return this._cache._target.equals(this._getTargetPosition())
  18909. && this._cache.alpha === this.alpha
  18910. && this._cache.beta === this.beta
  18911. && this._cache.radius === this.radius
  18912. && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
  18913. };
  18914. /**
  18915. * Attached controls to the current camera.
  18916. * @param element Defines the element the controls should be listened from
  18917. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18918. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  18919. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  18920. */
  18921. ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault, useCtrlForPanning, panningMouseButton) {
  18922. var _this = this;
  18923. if (useCtrlForPanning === void 0) { useCtrlForPanning = true; }
  18924. if (panningMouseButton === void 0) { panningMouseButton = 2; }
  18925. this._useCtrlForPanning = useCtrlForPanning;
  18926. this._panningMouseButton = panningMouseButton;
  18927. this.inputs.attachElement(element, noPreventDefault);
  18928. this._reset = function () {
  18929. _this.inertialAlphaOffset = 0;
  18930. _this.inertialBetaOffset = 0;
  18931. _this.inertialRadiusOffset = 0;
  18932. _this.inertialPanningX = 0;
  18933. _this.inertialPanningY = 0;
  18934. };
  18935. };
  18936. /**
  18937. * Detach the current controls from the camera.
  18938. * The camera will stop reacting to inputs.
  18939. * @param element Defines the element to stop listening the inputs from
  18940. */
  18941. ArcRotateCamera.prototype.detachControl = function (element) {
  18942. this.inputs.detachElement(element);
  18943. if (this._reset) {
  18944. this._reset();
  18945. }
  18946. };
  18947. /** @hidden */
  18948. ArcRotateCamera.prototype._checkInputs = function () {
  18949. //if (async) collision inspection was triggered, don't update the camera's position - until the collision callback was called.
  18950. if (this._collisionTriggered) {
  18951. return;
  18952. }
  18953. this.inputs.checkInputs();
  18954. // Inertia
  18955. if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
  18956. var inertialAlphaOffset = this.inertialAlphaOffset;
  18957. if (this.beta <= 0) {
  18958. inertialAlphaOffset *= -1;
  18959. }
  18960. if (this.getScene().useRightHandedSystem) {
  18961. inertialAlphaOffset *= -1;
  18962. }
  18963. if (this.parent && this.parent._getWorldMatrixDeterminant() < 0) {
  18964. inertialAlphaOffset *= -1;
  18965. }
  18966. this.alpha += inertialAlphaOffset;
  18967. this.beta += this.inertialBetaOffset;
  18968. this.radius -= this.inertialRadiusOffset;
  18969. this.inertialAlphaOffset *= this.inertia;
  18970. this.inertialBetaOffset *= this.inertia;
  18971. this.inertialRadiusOffset *= this.inertia;
  18972. if (Math.abs(this.inertialAlphaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  18973. this.inertialAlphaOffset = 0;
  18974. }
  18975. if (Math.abs(this.inertialBetaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  18976. this.inertialBetaOffset = 0;
  18977. }
  18978. if (Math.abs(this.inertialRadiusOffset) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  18979. this.inertialRadiusOffset = 0;
  18980. }
  18981. }
  18982. // Panning inertia
  18983. if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
  18984. if (!this._localDirection) {
  18985. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18986. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18987. }
  18988. this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
  18989. this._localDirection.multiplyInPlace(this.panningAxis);
  18990. this._viewMatrix.invertToRef(this._cameraTransformMatrix);
  18991. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
  18992. //Eliminate y if map panning is enabled (panningAxis == 1,0,1)
  18993. if (!this.panningAxis.y) {
  18994. this._transformedDirection.y = 0;
  18995. }
  18996. if (!this._targetHost) {
  18997. if (this.panningDistanceLimit) {
  18998. this._transformedDirection.addInPlace(this._target);
  18999. var distanceSquared = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].DistanceSquared(this._transformedDirection, this.panningOriginTarget);
  19000. if (distanceSquared <= (this.panningDistanceLimit * this.panningDistanceLimit)) {
  19001. this._target.copyFrom(this._transformedDirection);
  19002. }
  19003. }
  19004. else {
  19005. this._target.addInPlace(this._transformedDirection);
  19006. }
  19007. }
  19008. this.inertialPanningX *= this.panningInertia;
  19009. this.inertialPanningY *= this.panningInertia;
  19010. if (Math.abs(this.inertialPanningX) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19011. this.inertialPanningX = 0;
  19012. }
  19013. if (Math.abs(this.inertialPanningY) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19014. this.inertialPanningY = 0;
  19015. }
  19016. }
  19017. // Limits
  19018. this._checkLimits();
  19019. _super.prototype._checkInputs.call(this);
  19020. };
  19021. ArcRotateCamera.prototype._checkLimits = function () {
  19022. if (this.lowerBetaLimit === null || this.lowerBetaLimit === undefined) {
  19023. if (this.allowUpsideDown && this.beta > Math.PI) {
  19024. this.beta = this.beta - (2 * Math.PI);
  19025. }
  19026. }
  19027. else {
  19028. if (this.beta < this.lowerBetaLimit) {
  19029. this.beta = this.lowerBetaLimit;
  19030. }
  19031. }
  19032. if (this.upperBetaLimit === null || this.upperBetaLimit === undefined) {
  19033. if (this.allowUpsideDown && this.beta < -Math.PI) {
  19034. this.beta = this.beta + (2 * Math.PI);
  19035. }
  19036. }
  19037. else {
  19038. if (this.beta > this.upperBetaLimit) {
  19039. this.beta = this.upperBetaLimit;
  19040. }
  19041. }
  19042. if (this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit) {
  19043. this.alpha = this.lowerAlphaLimit;
  19044. }
  19045. if (this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit) {
  19046. this.alpha = this.upperAlphaLimit;
  19047. }
  19048. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  19049. this.radius = this.lowerRadiusLimit;
  19050. this.inertialRadiusOffset = 0;
  19051. }
  19052. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  19053. this.radius = this.upperRadiusLimit;
  19054. this.inertialRadiusOffset = 0;
  19055. }
  19056. };
  19057. /**
  19058. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  19059. */
  19060. ArcRotateCamera.prototype.rebuildAnglesAndRadius = function () {
  19061. this.position.subtractToRef(this._getTargetPosition(), this._computationVector);
  19062. this.radius = this._computationVector.length();
  19063. if (this.radius === 0) {
  19064. this.radius = 0.0001; // Just to avoid division by zero
  19065. }
  19066. // Alpha
  19067. this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
  19068. if (this._computationVector.z < 0) {
  19069. this.alpha = 2 * Math.PI - this.alpha;
  19070. }
  19071. // Beta
  19072. this.beta = Math.acos(this._computationVector.y / this.radius);
  19073. this._checkLimits();
  19074. };
  19075. /**
  19076. * Use a position to define the current camera related information like aplha, beta and radius
  19077. * @param position Defines the position to set the camera at
  19078. */
  19079. ArcRotateCamera.prototype.setPosition = function (position) {
  19080. if (this.position.equals(position)) {
  19081. return;
  19082. }
  19083. this.position.copyFrom(position);
  19084. this.rebuildAnglesAndRadius();
  19085. };
  19086. /**
  19087. * Defines the target the camera should look at.
  19088. * This will automatically adapt alpha beta and radius to fit within the new target.
  19089. * @param target Defines the new target as a Vector or a mesh
  19090. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  19091. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  19092. */
  19093. ArcRotateCamera.prototype.setTarget = function (target, toBoundingCenter, allowSamePosition) {
  19094. if (toBoundingCenter === void 0) { toBoundingCenter = false; }
  19095. if (allowSamePosition === void 0) { allowSamePosition = false; }
  19096. if (target.getBoundingInfo) {
  19097. if (toBoundingCenter) {
  19098. this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
  19099. }
  19100. else {
  19101. this._targetBoundingCenter = null;
  19102. }
  19103. this._targetHost = target;
  19104. this._target = this._getTargetPosition();
  19105. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  19106. }
  19107. else {
  19108. var newTarget = target;
  19109. var currentTarget = this._getTargetPosition();
  19110. if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
  19111. return;
  19112. }
  19113. this._targetHost = null;
  19114. this._target = newTarget;
  19115. this._targetBoundingCenter = null;
  19116. this.onMeshTargetChangedObservable.notifyObservers(null);
  19117. }
  19118. this.rebuildAnglesAndRadius();
  19119. };
  19120. /** @hidden */
  19121. ArcRotateCamera.prototype._getViewMatrix = function () {
  19122. // Compute
  19123. var cosa = Math.cos(this.alpha);
  19124. var sina = Math.sin(this.alpha);
  19125. var cosb = Math.cos(this.beta);
  19126. var sinb = Math.sin(this.beta);
  19127. if (sinb === 0) {
  19128. sinb = 0.0001;
  19129. }
  19130. var target = this._getTargetPosition();
  19131. this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
  19132. // Rotate according to up vector
  19133. if (this.upVector.x !== 0 || this.upVector.y !== 1.0 || this.upVector.z !== 0) {
  19134. if (!this._tempAxisVector) {
  19135. this._tempAxisVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  19136. this._tempAxisRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19137. }
  19138. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), this.upVector, this._tempAxisVector);
  19139. this._tempAxisVector.normalize();
  19140. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this.upVector));
  19141. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(this._tempAxisVector, angle, this._tempAxisRotationMatrix);
  19142. this._tempAxisVector.copyFrom(this._computationVector);
  19143. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._tempAxisVector, this._tempAxisRotationMatrix, this._computationVector);
  19144. }
  19145. target.addToRef(this._computationVector, this._newPosition);
  19146. if (this.getScene().collisionsEnabled && this.checkCollisions) {
  19147. if (!this._collider) {
  19148. this._collider = new _Collisions_collider__WEBPACK_IMPORTED_MODULE_9__["Collider"]();
  19149. }
  19150. this._collider._radius = this.collisionRadius;
  19151. this._newPosition.subtractToRef(this.position, this._collisionVelocity);
  19152. this._collisionTriggered = true;
  19153. this.getScene().collisionCoordinator.getNewPosition(this.position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  19154. }
  19155. else {
  19156. this.position.copyFrom(this._newPosition);
  19157. var up = this.upVector;
  19158. if (this.allowUpsideDown && sinb < 0) {
  19159. up = up.clone();
  19160. up = up.negate();
  19161. }
  19162. this._computeViewMatrix(this.position, target, up);
  19163. this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x);
  19164. this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y);
  19165. }
  19166. this._currentTarget = target;
  19167. return this._viewMatrix;
  19168. };
  19169. /**
  19170. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  19171. * @param meshes Defines the mesh to zoom on
  19172. * @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)
  19173. */
  19174. ArcRotateCamera.prototype.zoomOn = function (meshes, doNotUpdateMaxZ) {
  19175. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  19176. meshes = meshes || this.getScene().meshes;
  19177. var minMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  19178. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(minMaxVector.min, minMaxVector.max);
  19179. this.radius = distance * this.zoomOnFactor;
  19180. this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance }, doNotUpdateMaxZ);
  19181. };
  19182. /**
  19183. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  19184. * The target will be changed but the radius
  19185. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  19186. * @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)
  19187. */
  19188. ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance, doNotUpdateMaxZ) {
  19189. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  19190. var meshesOrMinMaxVector;
  19191. var distance;
  19192. if (meshesOrMinMaxVectorAndDistance.min === undefined) { // meshes
  19193. var meshes = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
  19194. meshesOrMinMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  19195. distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
  19196. }
  19197. else { //minMaxVector and distance
  19198. var minMaxVectorAndDistance = meshesOrMinMaxVectorAndDistance;
  19199. meshesOrMinMaxVector = minMaxVectorAndDistance;
  19200. distance = minMaxVectorAndDistance.distance;
  19201. }
  19202. this._target = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].Center(meshesOrMinMaxVector);
  19203. if (!doNotUpdateMaxZ) {
  19204. this.maxZ = distance * 2;
  19205. }
  19206. };
  19207. /**
  19208. * @override
  19209. * Override Camera.createRigCamera
  19210. */
  19211. ArcRotateCamera.prototype.createRigCamera = function (name, cameraIndex) {
  19212. var alphaShift = 0;
  19213. switch (this.cameraRigMode) {
  19214. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  19215. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  19216. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  19217. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_VR:
  19218. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? 1 : -1);
  19219. break;
  19220. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  19221. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? -1 : 1);
  19222. break;
  19223. }
  19224. var rigCam = new ArcRotateCamera(name, this.alpha + alphaShift, this.beta, this.radius, this._target, this.getScene());
  19225. rigCam._cameraRigParams = {};
  19226. return rigCam;
  19227. };
  19228. /**
  19229. * @hidden
  19230. * @override
  19231. * Override Camera._updateRigCameras
  19232. */
  19233. ArcRotateCamera.prototype._updateRigCameras = function () {
  19234. var camLeft = this._rigCameras[0];
  19235. var camRight = this._rigCameras[1];
  19236. camLeft.beta = camRight.beta = this.beta;
  19237. switch (this.cameraRigMode) {
  19238. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  19239. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  19240. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  19241. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_VR:
  19242. camLeft.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  19243. camRight.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  19244. break;
  19245. case _camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  19246. camLeft.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  19247. camRight.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  19248. break;
  19249. }
  19250. _super.prototype._updateRigCameras.call(this);
  19251. };
  19252. /**
  19253. * Destroy the camera and release the current resources hold by it.
  19254. */
  19255. ArcRotateCamera.prototype.dispose = function () {
  19256. this.inputs.clear();
  19257. _super.prototype.dispose.call(this);
  19258. };
  19259. /**
  19260. * Gets the current object class name.
  19261. * @return the class name
  19262. */
  19263. ArcRotateCamera.prototype.getClassName = function () {
  19264. return "ArcRotateCamera";
  19265. };
  19266. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19267. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19268. ], ArcRotateCamera.prototype, "alpha", void 0);
  19269. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19270. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19271. ], ArcRotateCamera.prototype, "beta", void 0);
  19272. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19273. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19274. ], ArcRotateCamera.prototype, "radius", void 0);
  19275. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19276. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("target")
  19277. ], ArcRotateCamera.prototype, "_target", void 0);
  19278. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19279. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19280. ], ArcRotateCamera.prototype, "inertialAlphaOffset", void 0);
  19281. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19282. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19283. ], ArcRotateCamera.prototype, "inertialBetaOffset", void 0);
  19284. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19285. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19286. ], ArcRotateCamera.prototype, "inertialRadiusOffset", void 0);
  19287. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19288. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19289. ], ArcRotateCamera.prototype, "lowerAlphaLimit", void 0);
  19290. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19291. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19292. ], ArcRotateCamera.prototype, "upperAlphaLimit", void 0);
  19293. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19294. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19295. ], ArcRotateCamera.prototype, "lowerBetaLimit", void 0);
  19296. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19297. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19298. ], ArcRotateCamera.prototype, "upperBetaLimit", void 0);
  19299. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19300. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19301. ], ArcRotateCamera.prototype, "lowerRadiusLimit", void 0);
  19302. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19303. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19304. ], ArcRotateCamera.prototype, "upperRadiusLimit", void 0);
  19305. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19306. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19307. ], ArcRotateCamera.prototype, "inertialPanningX", void 0);
  19308. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19309. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19310. ], ArcRotateCamera.prototype, "inertialPanningY", void 0);
  19311. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19312. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19313. ], ArcRotateCamera.prototype, "pinchToPanMaxDistance", void 0);
  19314. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19315. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19316. ], ArcRotateCamera.prototype, "panningDistanceLimit", void 0);
  19317. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19318. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  19319. ], ArcRotateCamera.prototype, "panningOriginTarget", void 0);
  19320. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19321. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19322. ], ArcRotateCamera.prototype, "panningInertia", void 0);
  19323. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19324. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19325. ], ArcRotateCamera.prototype, "zoomOnFactor", void 0);
  19326. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19327. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19328. ], ArcRotateCamera.prototype, "targetScreenOffset", void 0);
  19329. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19330. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19331. ], ArcRotateCamera.prototype, "allowUpsideDown", void 0);
  19332. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19333. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19334. ], ArcRotateCamera.prototype, "useInputToRestoreState", void 0);
  19335. return ArcRotateCamera;
  19336. }(_targetCamera__WEBPACK_IMPORTED_MODULE_11__["TargetCamera"]));
  19337. /***/ }),
  19338. /***/ "./Cameras/arcRotateCameraInputsManager.ts":
  19339. /*!*************************************************!*\
  19340. !*** ./Cameras/arcRotateCameraInputsManager.ts ***!
  19341. \*************************************************/
  19342. /*! exports provided: ArcRotateCameraInputsManager */
  19343. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19344. "use strict";
  19345. __webpack_require__.r(__webpack_exports__);
  19346. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return ArcRotateCameraInputsManager; });
  19347. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19348. /* harmony import */ var _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  19349. /* harmony import */ var _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  19350. /* harmony import */ var _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  19351. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  19352. /**
  19353. * Default Inputs manager for the ArcRotateCamera.
  19354. * It groups all the default supported inputs for ease of use.
  19355. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19356. */
  19357. var ArcRotateCameraInputsManager = /** @class */ (function (_super) {
  19358. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraInputsManager, _super);
  19359. /**
  19360. * Instantiates a new ArcRotateCameraInputsManager.
  19361. * @param camera Defines the camera the inputs belong to
  19362. */
  19363. function ArcRotateCameraInputsManager(camera) {
  19364. return _super.call(this, camera) || this;
  19365. }
  19366. /**
  19367. * Add mouse wheel input support to the input manager.
  19368. * @returns the current input manager
  19369. */
  19370. ArcRotateCameraInputsManager.prototype.addMouseWheel = function () {
  19371. this.add(new _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraMouseWheelInput"]());
  19372. return this;
  19373. };
  19374. /**
  19375. * Add pointers input support to the input manager.
  19376. * @returns the current input manager
  19377. */
  19378. ArcRotateCameraInputsManager.prototype.addPointers = function () {
  19379. this.add(new _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraPointersInput"]());
  19380. return this;
  19381. };
  19382. /**
  19383. * Add keyboard input support to the input manager.
  19384. * @returns the current input manager
  19385. */
  19386. ArcRotateCameraInputsManager.prototype.addKeyboard = function () {
  19387. this.add(new _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraKeyboardMoveInput"]());
  19388. return this;
  19389. };
  19390. return ArcRotateCameraInputsManager;
  19391. }(_Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__["CameraInputsManager"]));
  19392. /***/ }),
  19393. /***/ "./Cameras/camera.ts":
  19394. /*!***************************!*\
  19395. !*** ./Cameras/camera.ts ***!
  19396. \***************************/
  19397. /*! exports provided: Camera */
  19398. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19399. "use strict";
  19400. __webpack_require__.r(__webpack_exports__);
  19401. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return Camera; });
  19402. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19403. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  19404. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  19405. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  19406. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  19407. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  19408. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  19409. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  19410. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  19411. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  19412. /**
  19413. * This is the base class of all the camera used in the application.
  19414. * @see http://doc.babylonjs.com/features/cameras
  19415. */
  19416. var Camera = /** @class */ (function (_super) {
  19417. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Camera, _super);
  19418. /**
  19419. * Instantiates a new camera object.
  19420. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  19421. * @see http://doc.babylonjs.com/features/cameras
  19422. * @param name Defines the name of the camera in the scene
  19423. * @param position Defines the position of the camera
  19424. * @param scene Defines the scene the camera belongs too
  19425. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  19426. */
  19427. function Camera(name, position, scene, setActiveOnSceneIfNoneActive) {
  19428. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  19429. var _this = _super.call(this, name, scene) || this;
  19430. /**
  19431. * The vector the camera should consider as up.
  19432. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  19433. */
  19434. _this.upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Up();
  19435. /**
  19436. * Define the current limit on the left side for an orthographic camera
  19437. * In scene unit
  19438. */
  19439. _this.orthoLeft = null;
  19440. /**
  19441. * Define the current limit on the right side for an orthographic camera
  19442. * In scene unit
  19443. */
  19444. _this.orthoRight = null;
  19445. /**
  19446. * Define the current limit on the bottom side for an orthographic camera
  19447. * In scene unit
  19448. */
  19449. _this.orthoBottom = null;
  19450. /**
  19451. * Define the current limit on the top side for an orthographic camera
  19452. * In scene unit
  19453. */
  19454. _this.orthoTop = null;
  19455. /**
  19456. * Field Of View is set in Radians. (default is 0.8)
  19457. */
  19458. _this.fov = 0.8;
  19459. /**
  19460. * Define the minimum distance the camera can see from.
  19461. * This is important to note that the depth buffer are not infinite and the closer it starts
  19462. * the more your scene might encounter depth fighting issue.
  19463. */
  19464. _this.minZ = 1;
  19465. /**
  19466. * Define the maximum distance the camera can see to.
  19467. * This is important to note that the depth buffer are not infinite and the further it end
  19468. * the more your scene might encounter depth fighting issue.
  19469. */
  19470. _this.maxZ = 10000.0;
  19471. /**
  19472. * Define the default inertia of the camera.
  19473. * This helps giving a smooth feeling to the camera movement.
  19474. */
  19475. _this.inertia = 0.9;
  19476. /**
  19477. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  19478. */
  19479. _this.mode = Camera.PERSPECTIVE_CAMERA;
  19480. /**
  19481. * Define wether the camera is intermediate.
  19482. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  19483. */
  19484. _this.isIntermediate = false;
  19485. /**
  19486. * Define the viewport of the camera.
  19487. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  19488. */
  19489. _this.viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0, 0, 1.0, 1.0);
  19490. /**
  19491. * Restricts the camera to viewing objects with the same layerMask.
  19492. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  19493. */
  19494. _this.layerMask = 0x0FFFFFFF;
  19495. /**
  19496. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  19497. */
  19498. _this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
  19499. /**
  19500. * Rig mode of the camera.
  19501. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  19502. * This is normally controlled byt the camera themselves as internal use.
  19503. */
  19504. _this.cameraRigMode = Camera.RIG_MODE_NONE;
  19505. /**
  19506. * 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
  19507. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  19508. * else in the scene.
  19509. */
  19510. _this.customRenderTargets = new Array();
  19511. /**
  19512. * When set, the camera will render to this render target instead of the default canvas
  19513. */
  19514. _this.outputRenderTarget = null;
  19515. /**
  19516. * Observable triggered when the camera view matrix has changed.
  19517. */
  19518. _this.onViewMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  19519. /**
  19520. * Observable triggered when the camera Projection matrix has changed.
  19521. */
  19522. _this.onProjectionMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  19523. /**
  19524. * Observable triggered when the inputs have been processed.
  19525. */
  19526. _this.onAfterCheckInputsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  19527. /**
  19528. * Observable triggered when reset has been called and applied to the camera.
  19529. */
  19530. _this.onRestoreStateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  19531. /** @hidden */
  19532. _this._rigCameras = new Array();
  19533. _this._webvrViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  19534. /** @hidden */
  19535. _this._skipRendering = false;
  19536. /** @hidden */
  19537. _this._projectionMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  19538. /** @hidden */
  19539. _this._postProcesses = new Array();
  19540. /** @hidden */
  19541. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](256);
  19542. _this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  19543. /** hidden */
  19544. _this._computedViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  19545. _this._doNotComputeProjectionMatrix = false;
  19546. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Zero();
  19547. _this._refreshFrustumPlanes = true;
  19548. /** @hidden */
  19549. _this._isCamera = true;
  19550. _this.getScene().addCamera(_this);
  19551. if (setActiveOnSceneIfNoneActive && !_this.getScene().activeCamera) {
  19552. _this.getScene().activeCamera = _this;
  19553. }
  19554. _this.position = position;
  19555. return _this;
  19556. }
  19557. /**
  19558. * Store current camera state (fov, position, etc..)
  19559. * @returns the camera
  19560. */
  19561. Camera.prototype.storeState = function () {
  19562. this._stateStored = true;
  19563. this._storedFov = this.fov;
  19564. return this;
  19565. };
  19566. /**
  19567. * Restores the camera state values if it has been stored. You must call storeState() first
  19568. */
  19569. Camera.prototype._restoreStateValues = function () {
  19570. if (!this._stateStored) {
  19571. return false;
  19572. }
  19573. this.fov = this._storedFov;
  19574. return true;
  19575. };
  19576. /**
  19577. * Restored camera state. You must call storeState() first.
  19578. * @returns true if restored and false otherwise
  19579. */
  19580. Camera.prototype.restoreState = function () {
  19581. if (this._restoreStateValues()) {
  19582. this.onRestoreStateObservable.notifyObservers(this);
  19583. return true;
  19584. }
  19585. return false;
  19586. };
  19587. /**
  19588. * Gets the class name of the camera.
  19589. * @returns the class name
  19590. */
  19591. Camera.prototype.getClassName = function () {
  19592. return "Camera";
  19593. };
  19594. /**
  19595. * Gets a string representation of the camera useful for debug purpose.
  19596. * @param fullDetails Defines that a more verboe level of logging is required
  19597. * @returns the string representation
  19598. */
  19599. Camera.prototype.toString = function (fullDetails) {
  19600. var ret = "Name: " + this.name;
  19601. ret += ", type: " + this.getClassName();
  19602. if (this.animations) {
  19603. for (var i = 0; i < this.animations.length; i++) {
  19604. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  19605. }
  19606. }
  19607. if (fullDetails) {
  19608. }
  19609. return ret;
  19610. };
  19611. Object.defineProperty(Camera.prototype, "globalPosition", {
  19612. /**
  19613. * Gets the current world space position of the camera.
  19614. */
  19615. get: function () {
  19616. return this._globalPosition;
  19617. },
  19618. enumerable: true,
  19619. configurable: true
  19620. });
  19621. /**
  19622. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  19623. * @returns the active meshe list
  19624. */
  19625. Camera.prototype.getActiveMeshes = function () {
  19626. return this._activeMeshes;
  19627. };
  19628. /**
  19629. * Check wether a mesh is part of the current active mesh list of the camera
  19630. * @param mesh Defines the mesh to check
  19631. * @returns true if active, false otherwise
  19632. */
  19633. Camera.prototype.isActiveMesh = function (mesh) {
  19634. return (this._activeMeshes.indexOf(mesh) !== -1);
  19635. };
  19636. /**
  19637. * Is this camera ready to be used/rendered
  19638. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  19639. * @return true if the camera is ready
  19640. */
  19641. Camera.prototype.isReady = function (completeCheck) {
  19642. if (completeCheck === void 0) { completeCheck = false; }
  19643. if (completeCheck) {
  19644. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  19645. var pp = _a[_i];
  19646. if (pp && !pp.isReady()) {
  19647. return false;
  19648. }
  19649. }
  19650. }
  19651. return _super.prototype.isReady.call(this, completeCheck);
  19652. };
  19653. /** @hidden */
  19654. Camera.prototype._initCache = function () {
  19655. _super.prototype._initCache.call(this);
  19656. this._cache.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  19657. this._cache.upVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  19658. this._cache.mode = undefined;
  19659. this._cache.minZ = undefined;
  19660. this._cache.maxZ = undefined;
  19661. this._cache.fov = undefined;
  19662. this._cache.fovMode = undefined;
  19663. this._cache.aspectRatio = undefined;
  19664. this._cache.orthoLeft = undefined;
  19665. this._cache.orthoRight = undefined;
  19666. this._cache.orthoBottom = undefined;
  19667. this._cache.orthoTop = undefined;
  19668. this._cache.renderWidth = undefined;
  19669. this._cache.renderHeight = undefined;
  19670. };
  19671. /** @hidden */
  19672. Camera.prototype._updateCache = function (ignoreParentClass) {
  19673. if (!ignoreParentClass) {
  19674. _super.prototype._updateCache.call(this);
  19675. }
  19676. this._cache.position.copyFrom(this.position);
  19677. this._cache.upVector.copyFrom(this.upVector);
  19678. };
  19679. /** @hidden */
  19680. Camera.prototype._isSynchronized = function () {
  19681. return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
  19682. };
  19683. /** @hidden */
  19684. Camera.prototype._isSynchronizedViewMatrix = function () {
  19685. if (!_super.prototype._isSynchronized.call(this)) {
  19686. return false;
  19687. }
  19688. return this._cache.position.equals(this.position)
  19689. && this._cache.upVector.equals(this.upVector)
  19690. && this.isSynchronizedWithParent();
  19691. };
  19692. /** @hidden */
  19693. Camera.prototype._isSynchronizedProjectionMatrix = function () {
  19694. var check = this._cache.mode === this.mode
  19695. && this._cache.minZ === this.minZ
  19696. && this._cache.maxZ === this.maxZ;
  19697. if (!check) {
  19698. return false;
  19699. }
  19700. var engine = this.getEngine();
  19701. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  19702. check = this._cache.fov === this.fov
  19703. && this._cache.fovMode === this.fovMode
  19704. && this._cache.aspectRatio === engine.getAspectRatio(this);
  19705. }
  19706. else {
  19707. check = this._cache.orthoLeft === this.orthoLeft
  19708. && this._cache.orthoRight === this.orthoRight
  19709. && this._cache.orthoBottom === this.orthoBottom
  19710. && this._cache.orthoTop === this.orthoTop
  19711. && this._cache.renderWidth === engine.getRenderWidth()
  19712. && this._cache.renderHeight === engine.getRenderHeight();
  19713. }
  19714. return check;
  19715. };
  19716. /**
  19717. * Attach the input controls to a specific dom element to get the input from.
  19718. * @param element Defines the element the controls should be listened from
  19719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19720. */
  19721. Camera.prototype.attachControl = function (element, noPreventDefault) {
  19722. };
  19723. /**
  19724. * Detach the current controls from the specified dom element.
  19725. * @param element Defines the element to stop listening the inputs from
  19726. */
  19727. Camera.prototype.detachControl = function (element) {
  19728. };
  19729. /**
  19730. * Update the camera state according to the different inputs gathered during the frame.
  19731. */
  19732. Camera.prototype.update = function () {
  19733. this._checkInputs();
  19734. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  19735. this._updateRigCameras();
  19736. }
  19737. };
  19738. /** @hidden */
  19739. Camera.prototype._checkInputs = function () {
  19740. this.onAfterCheckInputsObservable.notifyObservers(this);
  19741. };
  19742. Object.defineProperty(Camera.prototype, "rigCameras", {
  19743. /** @hidden */
  19744. get: function () {
  19745. return this._rigCameras;
  19746. },
  19747. enumerable: true,
  19748. configurable: true
  19749. });
  19750. Object.defineProperty(Camera.prototype, "rigPostProcess", {
  19751. /**
  19752. * Gets the post process used by the rig cameras
  19753. */
  19754. get: function () {
  19755. return this._rigPostProcess;
  19756. },
  19757. enumerable: true,
  19758. configurable: true
  19759. });
  19760. /**
  19761. * Internal, gets the first post proces.
  19762. * @returns the first post process to be run on this camera.
  19763. */
  19764. Camera.prototype._getFirstPostProcess = function () {
  19765. for (var ppIndex = 0; ppIndex < this._postProcesses.length; ppIndex++) {
  19766. if (this._postProcesses[ppIndex] !== null) {
  19767. return this._postProcesses[ppIndex];
  19768. }
  19769. }
  19770. return null;
  19771. };
  19772. Camera.prototype._cascadePostProcessesToRigCams = function () {
  19773. // invalidate framebuffer
  19774. var firstPostProcess = this._getFirstPostProcess();
  19775. if (firstPostProcess) {
  19776. firstPostProcess.markTextureDirty();
  19777. }
  19778. // glue the rigPostProcess to the end of the user postprocesses & assign to each sub-camera
  19779. for (var i = 0, len = this._rigCameras.length; i < len; i++) {
  19780. var cam = this._rigCameras[i];
  19781. var rigPostProcess = cam._rigPostProcess;
  19782. // for VR rig, there does not have to be a post process
  19783. if (rigPostProcess) {
  19784. var isPass = rigPostProcess.getEffectName() === "pass";
  19785. if (isPass) {
  19786. // any rig which has a PassPostProcess for rig[0], cannot be isIntermediate when there are also user postProcesses
  19787. cam.isIntermediate = this._postProcesses.length === 0;
  19788. }
  19789. cam._postProcesses = this._postProcesses.slice(0).concat(rigPostProcess);
  19790. rigPostProcess.markTextureDirty();
  19791. }
  19792. else {
  19793. cam._postProcesses = this._postProcesses.slice(0);
  19794. }
  19795. }
  19796. };
  19797. /**
  19798. * Attach a post process to the camera.
  19799. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  19800. * @param postProcess The post process to attach to the camera
  19801. * @param insertAt The position of the post process in case several of them are in use in the scene
  19802. * @returns the position the post process has been inserted at
  19803. */
  19804. Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
  19805. if (insertAt === void 0) { insertAt = null; }
  19806. if (!postProcess.isReusable() && this._postProcesses.indexOf(postProcess) > -1) {
  19807. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Error("You're trying to reuse a post process not defined as reusable.");
  19808. return 0;
  19809. }
  19810. if (insertAt == null || insertAt < 0) {
  19811. this._postProcesses.push(postProcess);
  19812. }
  19813. else if (this._postProcesses[insertAt] === null) {
  19814. this._postProcesses[insertAt] = postProcess;
  19815. }
  19816. else {
  19817. this._postProcesses.splice(insertAt, 0, postProcess);
  19818. }
  19819. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  19820. return this._postProcesses.indexOf(postProcess);
  19821. };
  19822. /**
  19823. * Detach a post process to the camera.
  19824. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  19825. * @param postProcess The post process to detach from the camera
  19826. */
  19827. Camera.prototype.detachPostProcess = function (postProcess) {
  19828. var idx = this._postProcesses.indexOf(postProcess);
  19829. if (idx !== -1) {
  19830. this._postProcesses[idx] = null;
  19831. }
  19832. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  19833. };
  19834. /**
  19835. * Gets the current world matrix of the camera
  19836. */
  19837. Camera.prototype.getWorldMatrix = function () {
  19838. if (this._isSynchronizedViewMatrix()) {
  19839. return this._worldMatrix;
  19840. }
  19841. // Getting the the view matrix will also compute the world matrix.
  19842. this.getViewMatrix();
  19843. return this._worldMatrix;
  19844. };
  19845. /** @hidden */
  19846. Camera.prototype._getViewMatrix = function () {
  19847. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  19848. };
  19849. /**
  19850. * Gets the current view matrix of the camera.
  19851. * @param force forces the camera to recompute the matrix without looking at the cached state
  19852. * @returns the view matrix
  19853. */
  19854. Camera.prototype.getViewMatrix = function (force) {
  19855. if (!force && this._isSynchronizedViewMatrix()) {
  19856. return this._computedViewMatrix;
  19857. }
  19858. this.updateCache();
  19859. this._computedViewMatrix = this._getViewMatrix();
  19860. this._currentRenderId = this.getScene().getRenderId();
  19861. this._childRenderId = this._currentRenderId;
  19862. this._refreshFrustumPlanes = true;
  19863. if (this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix) {
  19864. this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix);
  19865. }
  19866. this.onViewMatrixChangedObservable.notifyObservers(this);
  19867. this._computedViewMatrix.invertToRef(this._worldMatrix);
  19868. return this._computedViewMatrix;
  19869. };
  19870. /**
  19871. * Freeze the projection matrix.
  19872. * It will prevent the cache check of the camera projection compute and can speed up perf
  19873. * if no parameter of the camera are meant to change
  19874. * @param projection Defines manually a projection if necessary
  19875. */
  19876. Camera.prototype.freezeProjectionMatrix = function (projection) {
  19877. this._doNotComputeProjectionMatrix = true;
  19878. if (projection !== undefined) {
  19879. this._projectionMatrix = projection;
  19880. }
  19881. };
  19882. /**
  19883. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  19884. */
  19885. Camera.prototype.unfreezeProjectionMatrix = function () {
  19886. this._doNotComputeProjectionMatrix = false;
  19887. };
  19888. /**
  19889. * Gets the current projection matrix of the camera.
  19890. * @param force forces the camera to recompute the matrix without looking at the cached state
  19891. * @returns the projection matrix
  19892. */
  19893. Camera.prototype.getProjectionMatrix = function (force) {
  19894. if (this._doNotComputeProjectionMatrix || (!force && this._isSynchronizedProjectionMatrix())) {
  19895. return this._projectionMatrix;
  19896. }
  19897. // Cache
  19898. this._cache.mode = this.mode;
  19899. this._cache.minZ = this.minZ;
  19900. this._cache.maxZ = this.maxZ;
  19901. // Matrix
  19902. this._refreshFrustumPlanes = true;
  19903. var engine = this.getEngine();
  19904. var scene = this.getScene();
  19905. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  19906. this._cache.fov = this.fov;
  19907. this._cache.fovMode = this.fovMode;
  19908. this._cache.aspectRatio = engine.getAspectRatio(this);
  19909. if (this.minZ <= 0) {
  19910. this.minZ = 0.1;
  19911. }
  19912. if (scene.useRightHandedSystem) {
  19913. _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);
  19914. }
  19915. else {
  19916. _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);
  19917. }
  19918. }
  19919. else {
  19920. var halfWidth = engine.getRenderWidth() / 2.0;
  19921. var halfHeight = engine.getRenderHeight() / 2.0;
  19922. if (scene.useRightHandedSystem) {
  19923. _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);
  19924. }
  19925. else {
  19926. _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);
  19927. }
  19928. this._cache.orthoLeft = this.orthoLeft;
  19929. this._cache.orthoRight = this.orthoRight;
  19930. this._cache.orthoBottom = this.orthoBottom;
  19931. this._cache.orthoTop = this.orthoTop;
  19932. this._cache.renderWidth = engine.getRenderWidth();
  19933. this._cache.renderHeight = engine.getRenderHeight();
  19934. }
  19935. this.onProjectionMatrixChangedObservable.notifyObservers(this);
  19936. return this._projectionMatrix;
  19937. };
  19938. /**
  19939. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  19940. * @returns a Matrix
  19941. */
  19942. Camera.prototype.getTransformationMatrix = function () {
  19943. this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  19944. return this._transformMatrix;
  19945. };
  19946. Camera.prototype._updateFrustumPlanes = function () {
  19947. if (!this._refreshFrustumPlanes) {
  19948. return;
  19949. }
  19950. this.getTransformationMatrix();
  19951. if (!this._frustumPlanes) {
  19952. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanes(this._transformMatrix);
  19953. }
  19954. else {
  19955. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  19956. }
  19957. this._refreshFrustumPlanes = false;
  19958. };
  19959. /**
  19960. * Checks if a cullable object (mesh...) is in the camera frustum
  19961. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  19962. * @param target The object to check
  19963. * @returns true if the object is in frustum otherwise false
  19964. */
  19965. Camera.prototype.isInFrustum = function (target) {
  19966. this._updateFrustumPlanes();
  19967. return target.isInFrustum(this._frustumPlanes);
  19968. };
  19969. /**
  19970. * Checks if a cullable object (mesh...) is in the camera frustum
  19971. * Unlike isInFrustum this cheks the full bounding box
  19972. * @param target The object to check
  19973. * @returns true if the object is in frustum otherwise false
  19974. */
  19975. Camera.prototype.isCompletelyInFrustum = function (target) {
  19976. this._updateFrustumPlanes();
  19977. return target.isCompletelyInFrustum(this._frustumPlanes);
  19978. };
  19979. /**
  19980. * Gets a ray in the forward direction from the camera.
  19981. * @param length Defines the length of the ray to create
  19982. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  19983. * @param origin Defines the start point of the ray which defaults to the camera position
  19984. * @returns the forward ray
  19985. */
  19986. Camera.prototype.getForwardRay = function (length, transform, origin) {
  19987. if (length === void 0) { length = 100; }
  19988. if (!transform) {
  19989. transform = this.getWorldMatrix();
  19990. }
  19991. if (!origin) {
  19992. origin = this.position;
  19993. }
  19994. var forward = this._scene.useRightHandedSystem ? new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 0, -1) : new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 0, 1);
  19995. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(forward, transform);
  19996. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(forwardWorld);
  19997. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_7__["Ray"](origin, direction, length);
  19998. };
  19999. /**
  20000. * Releases resources associated with this node.
  20001. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20002. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20003. */
  20004. Camera.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  20005. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  20006. // Observables
  20007. this.onViewMatrixChangedObservable.clear();
  20008. this.onProjectionMatrixChangedObservable.clear();
  20009. this.onAfterCheckInputsObservable.clear();
  20010. this.onRestoreStateObservable.clear();
  20011. // Inputs
  20012. if (this.inputs) {
  20013. this.inputs.clear();
  20014. }
  20015. // Animations
  20016. this.getScene().stopAnimation(this);
  20017. // Remove from scene
  20018. this.getScene().removeCamera(this);
  20019. while (this._rigCameras.length > 0) {
  20020. var camera = this._rigCameras.pop();
  20021. if (camera) {
  20022. camera.dispose();
  20023. }
  20024. }
  20025. // Postprocesses
  20026. if (this._rigPostProcess) {
  20027. this._rigPostProcess.dispose(this);
  20028. this._rigPostProcess = null;
  20029. this._postProcesses = [];
  20030. }
  20031. else if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20032. this._rigPostProcess = null;
  20033. this._postProcesses = [];
  20034. }
  20035. else {
  20036. var i = this._postProcesses.length;
  20037. while (--i >= 0) {
  20038. var postProcess = this._postProcesses[i];
  20039. if (postProcess) {
  20040. postProcess.dispose(this);
  20041. }
  20042. }
  20043. }
  20044. // Render targets
  20045. var i = this.customRenderTargets.length;
  20046. while (--i >= 0) {
  20047. this.customRenderTargets[i].dispose();
  20048. }
  20049. this.customRenderTargets = [];
  20050. // Active Meshes
  20051. this._activeMeshes.dispose();
  20052. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  20053. };
  20054. Object.defineProperty(Camera.prototype, "leftCamera", {
  20055. /**
  20056. * Gets the left camera of a rig setup in case of Rigged Camera
  20057. */
  20058. get: function () {
  20059. if (this._rigCameras.length < 1) {
  20060. return null;
  20061. }
  20062. return this._rigCameras[0];
  20063. },
  20064. enumerable: true,
  20065. configurable: true
  20066. });
  20067. Object.defineProperty(Camera.prototype, "rightCamera", {
  20068. /**
  20069. * Gets the right camera of a rig setup in case of Rigged Camera
  20070. */
  20071. get: function () {
  20072. if (this._rigCameras.length < 2) {
  20073. return null;
  20074. }
  20075. return this._rigCameras[1];
  20076. },
  20077. enumerable: true,
  20078. configurable: true
  20079. });
  20080. /**
  20081. * Gets the left camera target of a rig setup in case of Rigged Camera
  20082. * @returns the target position
  20083. */
  20084. Camera.prototype.getLeftTarget = function () {
  20085. if (this._rigCameras.length < 1) {
  20086. return null;
  20087. }
  20088. return this._rigCameras[0].getTarget();
  20089. };
  20090. /**
  20091. * Gets the right camera target of a rig setup in case of Rigged Camera
  20092. * @returns the target position
  20093. */
  20094. Camera.prototype.getRightTarget = function () {
  20095. if (this._rigCameras.length < 2) {
  20096. return null;
  20097. }
  20098. return this._rigCameras[1].getTarget();
  20099. };
  20100. /**
  20101. * @hidden
  20102. */
  20103. Camera.prototype.setCameraRigMode = function (mode, rigParams) {
  20104. if (this.cameraRigMode === mode) {
  20105. return;
  20106. }
  20107. while (this._rigCameras.length > 0) {
  20108. var camera = this._rigCameras.pop();
  20109. if (camera) {
  20110. camera.dispose();
  20111. }
  20112. }
  20113. this.cameraRigMode = mode;
  20114. this._cameraRigParams = {};
  20115. //we have to implement stereo camera calcultating left and right viewpoints from interaxialDistance and target,
  20116. //not from a given angle as it is now, but until that complete code rewriting provisional stereoHalfAngle value is introduced
  20117. this._cameraRigParams.interaxialDistance = rigParams.interaxialDistance || 0.0637;
  20118. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(this._cameraRigParams.interaxialDistance / 0.0637);
  20119. // create the rig cameras, unless none
  20120. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20121. var leftCamera = this.createRigCamera(this.name + "_L", 0);
  20122. var rightCamera = this.createRigCamera(this.name + "_R", 1);
  20123. if (leftCamera && rightCamera) {
  20124. this._rigCameras.push(leftCamera);
  20125. this._rigCameras.push(rightCamera);
  20126. }
  20127. }
  20128. switch (this.cameraRigMode) {
  20129. case Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20130. Camera._setStereoscopicAnaglyphRigMode(this);
  20131. break;
  20132. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20133. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20134. case Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20135. Camera._setStereoscopicRigMode(this);
  20136. break;
  20137. case Camera.RIG_MODE_VR:
  20138. Camera._setVRRigMode(this, rigParams);
  20139. break;
  20140. case Camera.RIG_MODE_WEBVR:
  20141. Camera._setWebVRRigMode(this, rigParams);
  20142. break;
  20143. }
  20144. this._cascadePostProcessesToRigCams();
  20145. this.update();
  20146. };
  20147. /** @hidden */
  20148. Camera._setStereoscopicRigMode = function (camera) {
  20149. throw "Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode";
  20150. };
  20151. /** @hidden */
  20152. Camera._setStereoscopicAnaglyphRigMode = function (camera) {
  20153. throw "Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode";
  20154. };
  20155. /** @hidden */
  20156. Camera._setVRRigMode = function (camera, rigParams) {
  20157. throw "Import Cameras/RigModes/vrRigMode before using VR rig mode";
  20158. };
  20159. /** @hidden */
  20160. Camera._setWebVRRigMode = function (camera, rigParams) {
  20161. throw "Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode";
  20162. };
  20163. /** @hidden */
  20164. Camera.prototype._getVRProjectionMatrix = function () {
  20165. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix);
  20166. this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix);
  20167. return this._projectionMatrix;
  20168. };
  20169. Camera.prototype._updateCameraRotationMatrix = function () {
  20170. //Here for WebVR
  20171. };
  20172. Camera.prototype._updateWebVRCameraRotationMatrix = function () {
  20173. //Here for WebVR
  20174. };
  20175. /**
  20176. * This function MUST be overwritten by the different WebVR cameras available.
  20177. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  20178. * @hidden
  20179. */
  20180. Camera.prototype._getWebVRProjectionMatrix = function () {
  20181. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20182. };
  20183. /**
  20184. * This function MUST be overwritten by the different WebVR cameras available.
  20185. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  20186. * @hidden
  20187. */
  20188. Camera.prototype._getWebVRViewMatrix = function () {
  20189. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20190. };
  20191. /** @hidden */
  20192. Camera.prototype.setCameraRigParameter = function (name, value) {
  20193. if (!this._cameraRigParams) {
  20194. this._cameraRigParams = {};
  20195. }
  20196. this._cameraRigParams[name] = value;
  20197. //provisionnally:
  20198. if (name === "interaxialDistance") {
  20199. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(value / 0.0637);
  20200. }
  20201. };
  20202. /**
  20203. * needs to be overridden by children so sub has required properties to be copied
  20204. * @hidden
  20205. */
  20206. Camera.prototype.createRigCamera = function (name, cameraIndex) {
  20207. return null;
  20208. };
  20209. /**
  20210. * May need to be overridden by children
  20211. * @hidden
  20212. */
  20213. Camera.prototype._updateRigCameras = function () {
  20214. for (var i = 0; i < this._rigCameras.length; i++) {
  20215. this._rigCameras[i].minZ = this.minZ;
  20216. this._rigCameras[i].maxZ = this.maxZ;
  20217. this._rigCameras[i].fov = this.fov;
  20218. this._rigCameras[i].upVector.copyFrom(this.upVector);
  20219. }
  20220. // only update viewport when ANAGLYPH
  20221. if (this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH) {
  20222. this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport;
  20223. }
  20224. };
  20225. /** @hidden */
  20226. Camera.prototype._setupInputs = function () {
  20227. };
  20228. /**
  20229. * Serialiaze the camera setup to a json represention
  20230. * @returns the JSON representation
  20231. */
  20232. Camera.prototype.serialize = function () {
  20233. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  20234. // Type
  20235. serializationObject.type = this.getClassName();
  20236. // Parent
  20237. if (this.parent) {
  20238. serializationObject.parentId = this.parent.id;
  20239. }
  20240. if (this.inputs) {
  20241. this.inputs.serialize(serializationObject);
  20242. }
  20243. // Animations
  20244. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  20245. serializationObject.ranges = this.serializeAnimationRanges();
  20246. return serializationObject;
  20247. };
  20248. /**
  20249. * Clones the current camera.
  20250. * @param name The cloned camera name
  20251. * @returns the cloned camera
  20252. */
  20253. Camera.prototype.clone = function (name) {
  20254. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(Camera.GetConstructorFromName(this.getClassName(), name, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
  20255. };
  20256. /**
  20257. * Gets the direction of the camera relative to a given local axis.
  20258. * @param localAxis Defines the reference axis to provide a relative direction.
  20259. * @return the direction
  20260. */
  20261. Camera.prototype.getDirection = function (localAxis) {
  20262. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20263. this.getDirectionToRef(localAxis, result);
  20264. return result;
  20265. };
  20266. /**
  20267. * Gets the direction of the camera relative to a given local axis into a passed vector.
  20268. * @param localAxis Defines the reference axis to provide a relative direction.
  20269. * @param result Defines the vector to store the result in
  20270. */
  20271. Camera.prototype.getDirectionToRef = function (localAxis, result) {
  20272. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  20273. };
  20274. /**
  20275. * Gets a camera constructor for a given camera type
  20276. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  20277. * @param name The name of the camera the result will be able to instantiate
  20278. * @param scene The scene the result will construct the camera in
  20279. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  20280. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  20281. * @returns a factory method to construc the camera
  20282. */
  20283. Camera.GetConstructorFromName = function (type, name, scene, interaxial_distance, isStereoscopicSideBySide) {
  20284. if (interaxial_distance === void 0) { interaxial_distance = 0; }
  20285. if (isStereoscopicSideBySide === void 0) { isStereoscopicSideBySide = true; }
  20286. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_6__["Node"].Construct(type, name, scene, {
  20287. interaxial_distance: interaxial_distance,
  20288. isStereoscopicSideBySide: isStereoscopicSideBySide
  20289. });
  20290. if (constructorFunc) {
  20291. return constructorFunc;
  20292. }
  20293. // Default to universal camera
  20294. return function () { return Camera._createDefaultParsedCamera(name, scene); };
  20295. };
  20296. /**
  20297. * Compute the world matrix of the camera.
  20298. * @returns the camera workd matrix
  20299. */
  20300. Camera.prototype.computeWorldMatrix = function () {
  20301. return this.getWorldMatrix();
  20302. };
  20303. /**
  20304. * Parse a JSON and creates the camera from the parsed information
  20305. * @param parsedCamera The JSON to parse
  20306. * @param scene The scene to instantiate the camera in
  20307. * @returns the newly constructed camera
  20308. */
  20309. Camera.Parse = function (parsedCamera, scene) {
  20310. var type = parsedCamera.type;
  20311. var construct = Camera.GetConstructorFromName(type, parsedCamera.name, scene, parsedCamera.interaxial_distance, parsedCamera.isStereoscopicSideBySide);
  20312. var camera = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(construct, parsedCamera, scene);
  20313. // Parent
  20314. if (parsedCamera.parentId) {
  20315. camera._waitingParentId = parsedCamera.parentId;
  20316. }
  20317. //If camera has an input manager, let it parse inputs settings
  20318. if (camera.inputs) {
  20319. camera.inputs.parse(parsedCamera);
  20320. camera._setupInputs();
  20321. }
  20322. if (camera.setPosition) { // need to force position
  20323. camera.position.copyFromFloats(0, 0, 0);
  20324. camera.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.position));
  20325. }
  20326. // Target
  20327. if (parsedCamera.target) {
  20328. if (camera.setTarget) {
  20329. camera.setTarget(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.target));
  20330. }
  20331. }
  20332. // Apply 3d rig, when found
  20333. if (parsedCamera.cameraRigMode) {
  20334. var rigParams = (parsedCamera.interaxial_distance) ? { interaxialDistance: parsedCamera.interaxial_distance } : {};
  20335. camera.setCameraRigMode(parsedCamera.cameraRigMode, rigParams);
  20336. }
  20337. // Animations
  20338. if (parsedCamera.animations) {
  20339. for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
  20340. var parsedAnimation = parsedCamera.animations[animationIndex];
  20341. camera.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_9__["Animation"].Parse(parsedAnimation));
  20342. }
  20343. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(camera, parsedCamera, scene);
  20344. }
  20345. if (parsedCamera.autoAnimate) {
  20346. scene.beginAnimation(camera, parsedCamera.autoAnimateFrom, parsedCamera.autoAnimateTo, parsedCamera.autoAnimateLoop, parsedCamera.autoAnimateSpeed || 1.0);
  20347. }
  20348. return camera;
  20349. };
  20350. /** @hidden */
  20351. Camera._createDefaultParsedCamera = function (name, scene) {
  20352. throw "UniversalCamera needs to be imported before deserialization can create a default camera.";
  20353. };
  20354. /**
  20355. * This is the default projection mode used by the cameras.
  20356. * It helps recreating a feeling of perspective and better appreciate depth.
  20357. * This is the best way to simulate real life cameras.
  20358. */
  20359. Camera.PERSPECTIVE_CAMERA = 0;
  20360. /**
  20361. * This helps creating camera with an orthographic mode.
  20362. * 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.
  20363. */
  20364. Camera.ORTHOGRAPHIC_CAMERA = 1;
  20365. /**
  20366. * This is the default FOV mode for perspective cameras.
  20367. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  20368. */
  20369. Camera.FOVMODE_VERTICAL_FIXED = 0;
  20370. /**
  20371. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  20372. */
  20373. Camera.FOVMODE_HORIZONTAL_FIXED = 1;
  20374. /**
  20375. * This specifies ther is no need for a camera rig.
  20376. * Basically only one eye is rendered corresponding to the camera.
  20377. */
  20378. Camera.RIG_MODE_NONE = 0;
  20379. /**
  20380. * Simulates a camera Rig with one blue eye and one red eye.
  20381. * This can be use with 3d blue and red glasses.
  20382. */
  20383. Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10;
  20384. /**
  20385. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  20386. */
  20387. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11;
  20388. /**
  20389. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  20390. */
  20391. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12;
  20392. /**
  20393. * Defines that both eyes of the camera will be rendered over under each other.
  20394. */
  20395. Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13;
  20396. /**
  20397. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  20398. */
  20399. Camera.RIG_MODE_VR = 20;
  20400. /**
  20401. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  20402. */
  20403. Camera.RIG_MODE_WEBVR = 21;
  20404. /**
  20405. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  20406. */
  20407. Camera.RIG_MODE_CUSTOM = 22;
  20408. /**
  20409. * Defines if by default attaching controls should prevent the default javascript event to continue.
  20410. */
  20411. Camera.ForceAttachControlToAlwaysPreventDefault = false;
  20412. /**
  20413. * @hidden
  20414. * Might be removed once multiview will be a thing
  20415. */
  20416. Camera.UseAlternateWebVRRendering = false;
  20417. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20418. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20419. ], Camera.prototype, "position", void 0);
  20420. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20421. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20422. ], Camera.prototype, "upVector", void 0);
  20423. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20424. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20425. ], Camera.prototype, "orthoLeft", void 0);
  20426. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20427. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20428. ], Camera.prototype, "orthoRight", void 0);
  20429. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20430. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20431. ], Camera.prototype, "orthoBottom", void 0);
  20432. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20433. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20434. ], Camera.prototype, "orthoTop", void 0);
  20435. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20436. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20437. ], Camera.prototype, "fov", void 0);
  20438. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20439. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20440. ], Camera.prototype, "minZ", void 0);
  20441. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20442. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20443. ], Camera.prototype, "maxZ", void 0);
  20444. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20445. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20446. ], Camera.prototype, "inertia", void 0);
  20447. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20448. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20449. ], Camera.prototype, "mode", void 0);
  20450. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20451. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20452. ], Camera.prototype, "layerMask", void 0);
  20453. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20454. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20455. ], Camera.prototype, "fovMode", void 0);
  20456. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20457. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20458. ], Camera.prototype, "cameraRigMode", void 0);
  20459. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20460. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20461. ], Camera.prototype, "interaxialDistance", void 0);
  20462. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20463. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20464. ], Camera.prototype, "isStereoscopicSideBySide", void 0);
  20465. return Camera;
  20466. }(_node__WEBPACK_IMPORTED_MODULE_6__["Node"]));
  20467. /***/ }),
  20468. /***/ "./Cameras/cameraInputsManager.ts":
  20469. /*!****************************************!*\
  20470. !*** ./Cameras/cameraInputsManager.ts ***!
  20471. \****************************************/
  20472. /*! exports provided: CameraInputTypes, CameraInputsManager */
  20473. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20474. "use strict";
  20475. __webpack_require__.r(__webpack_exports__);
  20476. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return CameraInputTypes; });
  20477. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return CameraInputsManager; });
  20478. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  20479. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  20480. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  20481. /**
  20482. * @ignore
  20483. * This is a list of all the different input types that are available in the application.
  20484. * Fo instance: ArcRotateCameraGamepadInput...
  20485. */
  20486. var CameraInputTypes = {};
  20487. /**
  20488. * This represents the input manager used within a camera.
  20489. * It helps dealing with all the different kind of input attached to a camera.
  20490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  20491. */
  20492. var CameraInputsManager = /** @class */ (function () {
  20493. /**
  20494. * Instantiate a new Camera Input Manager.
  20495. * @param camera Defines the camera the input manager blongs to
  20496. */
  20497. function CameraInputsManager(camera) {
  20498. this.attached = {};
  20499. this.camera = camera;
  20500. this.checkInputs = function () { };
  20501. }
  20502. /**
  20503. * Add an input method to a camera
  20504. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  20505. * @param input camera input method
  20506. */
  20507. CameraInputsManager.prototype.add = function (input) {
  20508. var type = input.getSimpleName();
  20509. if (this.attached[type]) {
  20510. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("camera input of type " + type + " already exists on camera");
  20511. return;
  20512. }
  20513. this.attached[type] = input;
  20514. input.camera = this.camera;
  20515. //for checkInputs, we are dynamically creating a function
  20516. //the goal is to avoid the performance penalty of looping for inputs in the render loop
  20517. if (input.checkInputs) {
  20518. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  20519. }
  20520. if (this.attachedElement) {
  20521. input.attachControl(this.attachedElement);
  20522. }
  20523. };
  20524. /**
  20525. * Remove a specific input method from a camera
  20526. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  20527. * @param inputToRemove camera input method
  20528. */
  20529. CameraInputsManager.prototype.remove = function (inputToRemove) {
  20530. for (var cam in this.attached) {
  20531. var input = this.attached[cam];
  20532. if (input === inputToRemove) {
  20533. input.detachControl(this.attachedElement);
  20534. input.camera = null;
  20535. delete this.attached[cam];
  20536. this.rebuildInputCheck();
  20537. }
  20538. }
  20539. };
  20540. /**
  20541. * Remove a specific input type from a camera
  20542. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  20543. * @param inputType the type of the input to remove
  20544. */
  20545. CameraInputsManager.prototype.removeByType = function (inputType) {
  20546. for (var cam in this.attached) {
  20547. var input = this.attached[cam];
  20548. if (input.getClassName() === inputType) {
  20549. input.detachControl(this.attachedElement);
  20550. input.camera = null;
  20551. delete this.attached[cam];
  20552. this.rebuildInputCheck();
  20553. }
  20554. }
  20555. };
  20556. CameraInputsManager.prototype._addCheckInputs = function (fn) {
  20557. var current = this.checkInputs;
  20558. return function () {
  20559. current();
  20560. fn();
  20561. };
  20562. };
  20563. /**
  20564. * Attach the input controls to the currently attached dom element to listen the events from.
  20565. * @param input Defines the input to attach
  20566. */
  20567. CameraInputsManager.prototype.attachInput = function (input) {
  20568. if (this.attachedElement) {
  20569. input.attachControl(this.attachedElement, this.noPreventDefault);
  20570. }
  20571. };
  20572. /**
  20573. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  20574. * @param element Defines the dom element to collect the events from
  20575. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20576. */
  20577. CameraInputsManager.prototype.attachElement = function (element, noPreventDefault) {
  20578. if (noPreventDefault === void 0) { noPreventDefault = false; }
  20579. if (this.attachedElement) {
  20580. return;
  20581. }
  20582. noPreventDefault = _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  20583. this.attachedElement = element;
  20584. this.noPreventDefault = noPreventDefault;
  20585. for (var cam in this.attached) {
  20586. this.attached[cam].attachControl(element, noPreventDefault);
  20587. }
  20588. };
  20589. /**
  20590. * Detach the current manager inputs controls from a specific dom element.
  20591. * @param element Defines the dom element to collect the events from
  20592. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  20593. */
  20594. CameraInputsManager.prototype.detachElement = function (element, disconnect) {
  20595. if (disconnect === void 0) { disconnect = false; }
  20596. if (this.attachedElement !== element) {
  20597. return;
  20598. }
  20599. for (var cam in this.attached) {
  20600. this.attached[cam].detachControl(element);
  20601. if (disconnect) {
  20602. this.attached[cam].camera = null;
  20603. }
  20604. }
  20605. this.attachedElement = null;
  20606. };
  20607. /**
  20608. * Rebuild the dynamic inputCheck function from the current list of
  20609. * defined inputs in the manager.
  20610. */
  20611. CameraInputsManager.prototype.rebuildInputCheck = function () {
  20612. this.checkInputs = function () { };
  20613. for (var cam in this.attached) {
  20614. var input = this.attached[cam];
  20615. if (input.checkInputs) {
  20616. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  20617. }
  20618. }
  20619. };
  20620. /**
  20621. * Remove all attached input methods from a camera
  20622. */
  20623. CameraInputsManager.prototype.clear = function () {
  20624. if (this.attachedElement) {
  20625. this.detachElement(this.attachedElement, true);
  20626. }
  20627. this.attached = {};
  20628. this.attachedElement = null;
  20629. this.checkInputs = function () { };
  20630. };
  20631. /**
  20632. * Serialize the current input manager attached to a camera.
  20633. * This ensures than once parsed,
  20634. * the input associated to the camera will be identical to the current ones
  20635. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  20636. */
  20637. CameraInputsManager.prototype.serialize = function (serializedCamera) {
  20638. var inputs = {};
  20639. for (var cam in this.attached) {
  20640. var input = this.attached[cam];
  20641. var res = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(input);
  20642. inputs[input.getClassName()] = res;
  20643. }
  20644. serializedCamera.inputsmgr = inputs;
  20645. };
  20646. /**
  20647. * Parses an input manager serialized JSON to restore the previous list of inputs
  20648. * and states associated to a camera.
  20649. * @param parsedCamera Defines the JSON to parse
  20650. */
  20651. CameraInputsManager.prototype.parse = function (parsedCamera) {
  20652. var parsedInputs = parsedCamera.inputsmgr;
  20653. if (parsedInputs) {
  20654. this.clear();
  20655. for (var n in parsedInputs) {
  20656. var construct = CameraInputTypes[n];
  20657. if (construct) {
  20658. var parsedinput = parsedInputs[n];
  20659. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedinput, null);
  20660. this.add(input);
  20661. }
  20662. }
  20663. }
  20664. else {
  20665. //2016-03-08 this part is for managing backward compatibility
  20666. for (var n in this.attached) {
  20667. var construct = CameraInputTypes[this.attached[n].getClassName()];
  20668. if (construct) {
  20669. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedCamera, null);
  20670. this.remove(this.attached[n]);
  20671. this.add(input);
  20672. }
  20673. }
  20674. }
  20675. };
  20676. return CameraInputsManager;
  20677. }());
  20678. /***/ }),
  20679. /***/ "./Cameras/deviceOrientationCamera.ts":
  20680. /*!********************************************!*\
  20681. !*** ./Cameras/deviceOrientationCamera.ts ***!
  20682. \********************************************/
  20683. /*! exports provided: DeviceOrientationCamera */
  20684. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20685. "use strict";
  20686. __webpack_require__.r(__webpack_exports__);
  20687. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return DeviceOrientationCamera; });
  20688. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20689. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  20690. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  20691. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  20692. /* harmony import */ var _Inputs_freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  20693. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("DeviceOrientationCamera", function (name, scene) {
  20694. return function () { return new DeviceOrientationCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  20695. });
  20696. // We're mainly based on the logic defined into the FreeCamera code
  20697. /**
  20698. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  20699. * being tilted forward or back and left or right.
  20700. */
  20701. var DeviceOrientationCamera = /** @class */ (function (_super) {
  20702. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DeviceOrientationCamera, _super);
  20703. /**
  20704. * Creates a new device orientation camera
  20705. * @param name The name of the camera
  20706. * @param position The start position camera
  20707. * @param scene The scene the camera belongs to
  20708. */
  20709. function DeviceOrientationCamera(name, position, scene) {
  20710. var _this = _super.call(this, name, position, scene) || this;
  20711. _this._quaternionCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  20712. _this.inputs.addDeviceOrientation();
  20713. return _this;
  20714. }
  20715. /**
  20716. * Gets the current instance class name ("DeviceOrientationCamera").
  20717. * This helps avoiding instanceof at run time.
  20718. * @returns the class name
  20719. */
  20720. DeviceOrientationCamera.prototype.getClassName = function () {
  20721. return "DeviceOrientationCamera";
  20722. };
  20723. /**
  20724. * @hidden
  20725. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  20726. */
  20727. DeviceOrientationCamera.prototype._checkInputs = function () {
  20728. _super.prototype._checkInputs.call(this);
  20729. this._quaternionCache.copyFrom(this.rotationQuaternion);
  20730. if (this._initialQuaternion) {
  20731. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  20732. }
  20733. };
  20734. /**
  20735. * Reset the camera to its default orientation on the specified axis only.
  20736. * @param axis The axis to reset
  20737. */
  20738. DeviceOrientationCamera.prototype.resetToCurrentRotation = function (axis) {
  20739. var _this = this;
  20740. if (axis === void 0) { axis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y; }
  20741. //can only work if this camera has a rotation quaternion already.
  20742. if (!this.rotationQuaternion) {
  20743. return;
  20744. }
  20745. if (!this._initialQuaternion) {
  20746. this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  20747. }
  20748. this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion);
  20749. ['x', 'y', 'z'].forEach(function (axisName) {
  20750. if (!axis[axisName]) {
  20751. _this._initialQuaternion[axisName] = 0;
  20752. }
  20753. else {
  20754. _this._initialQuaternion[axisName] *= -1;
  20755. }
  20756. });
  20757. this._initialQuaternion.normalize();
  20758. //force rotation update
  20759. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  20760. };
  20761. return DeviceOrientationCamera;
  20762. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  20763. /***/ }),
  20764. /***/ "./Cameras/flyCamera.ts":
  20765. /*!******************************!*\
  20766. !*** ./Cameras/flyCamera.ts ***!
  20767. \******************************/
  20768. /*! exports provided: FlyCamera */
  20769. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20770. "use strict";
  20771. __webpack_require__.r(__webpack_exports__);
  20772. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return FlyCamera; });
  20773. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20774. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  20775. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  20776. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  20777. /* harmony import */ var _Collisions_collider__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Collisions/collider */ "./Collisions/collider.ts");
  20778. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  20779. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  20780. /**
  20781. * This is a flying camera, designed for 3D movement and rotation in all directions,
  20782. * such as in a 3D Space Shooter or a Flight Simulator.
  20783. */
  20784. var FlyCamera = /** @class */ (function (_super) {
  20785. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCamera, _super);
  20786. /**
  20787. * Instantiates a FlyCamera.
  20788. * This is a flying camera, designed for 3D movement and rotation in all directions,
  20789. * such as in a 3D Space Shooter or a Flight Simulator.
  20790. * @param name Define the name of the camera in the scene.
  20791. * @param position Define the starting position of the camera in the scene.
  20792. * @param scene Define the scene the camera belongs to.
  20793. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  20794. */
  20795. function FlyCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  20796. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  20797. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  20798. /**
  20799. * Define the collision ellipsoid of the camera.
  20800. * This is helpful for simulating a camera body, like a player's body.
  20801. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  20802. */
  20803. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  20804. /**
  20805. * Define an offset for the position of the ellipsoid around the camera.
  20806. * This can be helpful if the camera is attached away from the player's body center,
  20807. * such as at its head.
  20808. */
  20809. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  20810. /**
  20811. * Enable or disable collisions of the camera with the rest of the scene objects.
  20812. */
  20813. _this.checkCollisions = false;
  20814. /**
  20815. * Enable or disable gravity on the camera.
  20816. */
  20817. _this.applyGravity = false;
  20818. /**
  20819. * Define the current direction the camera is moving to.
  20820. */
  20821. _this.cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  20822. /**
  20823. * Track Roll to maintain the wanted Rolling when looking around.
  20824. */
  20825. _this._trackRoll = 0;
  20826. /**
  20827. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  20828. */
  20829. _this.rollCorrect = 100;
  20830. /**
  20831. * Mimic a banked turn, Rolling the camera when Yawing.
  20832. * It's recommended to use rollCorrect = 10 for faster banking correction.
  20833. */
  20834. _this.bankedTurn = false;
  20835. /**
  20836. * Limit in radians for how much Roll banking will add. (Default: 90°)
  20837. */
  20838. _this.bankedTurnLimit = Math.PI / 2;
  20839. /**
  20840. * Value of 0 disables the banked Roll.
  20841. * Value of 1 is equal to the Yaw angle in radians.
  20842. */
  20843. _this.bankedTurnMultiplier = 1;
  20844. _this._needMoveForGravity = false;
  20845. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  20846. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  20847. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  20848. // Collisions.
  20849. _this._collisionMask = -1;
  20850. /** @hidden */
  20851. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  20852. if (collidedMesh === void 0) { collidedMesh = null; }
  20853. var updatePosition = function (newPos) {
  20854. _this._newPosition.copyFrom(newPos);
  20855. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  20856. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  20857. _this.position.addInPlace(_this._diffPosition);
  20858. if (_this.onCollide && collidedMesh) {
  20859. _this.onCollide(collidedMesh);
  20860. }
  20861. }
  20862. };
  20863. updatePosition(newPosition);
  20864. };
  20865. _this.inputs = new _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FlyCameraInputsManager"](_this);
  20866. _this.inputs.addKeyboard().addMouse();
  20867. return _this;
  20868. }
  20869. Object.defineProperty(FlyCamera.prototype, "angularSensibility", {
  20870. /**
  20871. * Gets the input sensibility for mouse input.
  20872. * Higher values reduce sensitivity.
  20873. */
  20874. get: function () {
  20875. var mouse = this.inputs.attached["mouse"];
  20876. if (mouse) {
  20877. return mouse.angularSensibility;
  20878. }
  20879. return 0;
  20880. },
  20881. /**
  20882. * Sets the input sensibility for a mouse input.
  20883. * Higher values reduce sensitivity.
  20884. */
  20885. set: function (value) {
  20886. var mouse = this.inputs.attached["mouse"];
  20887. if (mouse) {
  20888. mouse.angularSensibility = value;
  20889. }
  20890. },
  20891. enumerable: true,
  20892. configurable: true
  20893. });
  20894. Object.defineProperty(FlyCamera.prototype, "keysForward", {
  20895. /**
  20896. * Get the keys for camera movement forward.
  20897. */
  20898. get: function () {
  20899. var keyboard = this.inputs.attached["keyboard"];
  20900. if (keyboard) {
  20901. return keyboard.keysForward;
  20902. }
  20903. return [];
  20904. },
  20905. /**
  20906. * Set the keys for camera movement forward.
  20907. */
  20908. set: function (value) {
  20909. var keyboard = this.inputs.attached["keyboard"];
  20910. if (keyboard) {
  20911. keyboard.keysForward = value;
  20912. }
  20913. },
  20914. enumerable: true,
  20915. configurable: true
  20916. });
  20917. Object.defineProperty(FlyCamera.prototype, "keysBackward", {
  20918. /**
  20919. * Get the keys for camera movement backward.
  20920. */
  20921. get: function () {
  20922. var keyboard = this.inputs.attached["keyboard"];
  20923. if (keyboard) {
  20924. return keyboard.keysBackward;
  20925. }
  20926. return [];
  20927. },
  20928. set: function (value) {
  20929. var keyboard = this.inputs.attached["keyboard"];
  20930. if (keyboard) {
  20931. keyboard.keysBackward = value;
  20932. }
  20933. },
  20934. enumerable: true,
  20935. configurable: true
  20936. });
  20937. Object.defineProperty(FlyCamera.prototype, "keysUp", {
  20938. /**
  20939. * Get the keys for camera movement up.
  20940. */
  20941. get: function () {
  20942. var keyboard = this.inputs.attached["keyboard"];
  20943. if (keyboard) {
  20944. return keyboard.keysUp;
  20945. }
  20946. return [];
  20947. },
  20948. /**
  20949. * Set the keys for camera movement up.
  20950. */
  20951. set: function (value) {
  20952. var keyboard = this.inputs.attached["keyboard"];
  20953. if (keyboard) {
  20954. keyboard.keysUp = value;
  20955. }
  20956. },
  20957. enumerable: true,
  20958. configurable: true
  20959. });
  20960. Object.defineProperty(FlyCamera.prototype, "keysDown", {
  20961. /**
  20962. * Get the keys for camera movement down.
  20963. */
  20964. get: function () {
  20965. var keyboard = this.inputs.attached["keyboard"];
  20966. if (keyboard) {
  20967. return keyboard.keysDown;
  20968. }
  20969. return [];
  20970. },
  20971. /**
  20972. * Set the keys for camera movement down.
  20973. */
  20974. set: function (value) {
  20975. var keyboard = this.inputs.attached["keyboard"];
  20976. if (keyboard) {
  20977. keyboard.keysDown = value;
  20978. }
  20979. },
  20980. enumerable: true,
  20981. configurable: true
  20982. });
  20983. Object.defineProperty(FlyCamera.prototype, "keysLeft", {
  20984. /**
  20985. * Get the keys for camera movement left.
  20986. */
  20987. get: function () {
  20988. var keyboard = this.inputs.attached["keyboard"];
  20989. if (keyboard) {
  20990. return keyboard.keysLeft;
  20991. }
  20992. return [];
  20993. },
  20994. /**
  20995. * Set the keys for camera movement left.
  20996. */
  20997. set: function (value) {
  20998. var keyboard = this.inputs.attached["keyboard"];
  20999. if (keyboard) {
  21000. keyboard.keysLeft = value;
  21001. }
  21002. },
  21003. enumerable: true,
  21004. configurable: true
  21005. });
  21006. Object.defineProperty(FlyCamera.prototype, "keysRight", {
  21007. /**
  21008. * Set the keys for camera movement right.
  21009. */
  21010. get: function () {
  21011. var keyboard = this.inputs.attached["keyboard"];
  21012. if (keyboard) {
  21013. return keyboard.keysRight;
  21014. }
  21015. return [];
  21016. },
  21017. /**
  21018. * Set the keys for camera movement right.
  21019. */
  21020. set: function (value) {
  21021. var keyboard = this.inputs.attached["keyboard"];
  21022. if (keyboard) {
  21023. keyboard.keysRight = value;
  21024. }
  21025. },
  21026. enumerable: true,
  21027. configurable: true
  21028. });
  21029. /**
  21030. * Attach a control to the HTML DOM element.
  21031. * @param element Defines the element that listens to the input events.
  21032. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  21033. */
  21034. FlyCamera.prototype.attachControl = function (element, noPreventDefault) {
  21035. this.inputs.attachElement(element, noPreventDefault);
  21036. };
  21037. /**
  21038. * Detach a control from the HTML DOM element.
  21039. * The camera will stop reacting to that input.
  21040. * @param element Defines the element that listens to the input events.
  21041. */
  21042. FlyCamera.prototype.detachControl = function (element) {
  21043. this.inputs.detachElement(element);
  21044. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21045. };
  21046. Object.defineProperty(FlyCamera.prototype, "collisionMask", {
  21047. /**
  21048. * Get the mask that the camera ignores in collision events.
  21049. */
  21050. get: function () {
  21051. return this._collisionMask;
  21052. },
  21053. /**
  21054. * Set the mask that the camera ignores in collision events.
  21055. */
  21056. set: function (mask) {
  21057. this._collisionMask = !isNaN(mask) ? mask : -1;
  21058. },
  21059. enumerable: true,
  21060. configurable: true
  21061. });
  21062. /** @hidden */
  21063. FlyCamera.prototype._collideWithWorld = function (displacement) {
  21064. var globalPosition;
  21065. if (this.parent) {
  21066. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  21067. }
  21068. else {
  21069. globalPosition = this.position;
  21070. }
  21071. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  21072. this._oldPosition.addInPlace(this.ellipsoidOffset);
  21073. if (!this._collider) {
  21074. this._collider = new _Collisions_collider__WEBPACK_IMPORTED_MODULE_4__["Collider"]();
  21075. }
  21076. this._collider._radius = this.ellipsoid;
  21077. this._collider.collisionMask = this._collisionMask;
  21078. // No need for clone, as long as gravity is not on.
  21079. var actualDisplacement = displacement;
  21080. // Add gravity to direction to prevent dual-collision checking.
  21081. if (this.applyGravity) {
  21082. // This prevents mending with cameraDirection, a global variable of the fly camera class.
  21083. actualDisplacement = displacement.add(this.getScene().gravity);
  21084. }
  21085. this.getScene().collisionCoordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  21086. };
  21087. /** @hidden */
  21088. FlyCamera.prototype._checkInputs = function () {
  21089. if (!this._localDirection) {
  21090. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21091. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21092. }
  21093. this.inputs.checkInputs();
  21094. _super.prototype._checkInputs.call(this);
  21095. };
  21096. /** @hidden */
  21097. FlyCamera.prototype._decideIfNeedsToMove = function () {
  21098. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  21099. };
  21100. /** @hidden */
  21101. FlyCamera.prototype._updatePosition = function () {
  21102. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  21103. this._collideWithWorld(this.cameraDirection);
  21104. }
  21105. else {
  21106. _super.prototype._updatePosition.call(this);
  21107. }
  21108. };
  21109. /**
  21110. * Restore the Roll to its target value at the rate specified.
  21111. * @param rate - Higher means slower restoring.
  21112. * @hidden
  21113. */
  21114. FlyCamera.prototype.restoreRoll = function (rate) {
  21115. var limit = this._trackRoll; // Target Roll.
  21116. var z = this.rotation.z; // Current Roll.
  21117. var delta = limit - z; // Difference in Roll.
  21118. var minRad = 0.001; // Tenth of a radian is a barely noticable difference.
  21119. // If the difference is noticable, restore the Roll.
  21120. if (Math.abs(delta) >= minRad) {
  21121. // Change Z rotation towards the target Roll.
  21122. this.rotation.z += delta / rate;
  21123. // Match when near enough.
  21124. if (Math.abs(limit - this.rotation.z) <= minRad) {
  21125. this.rotation.z = limit;
  21126. }
  21127. }
  21128. };
  21129. /**
  21130. * Destroy the camera and release the current resources held by it.
  21131. */
  21132. FlyCamera.prototype.dispose = function () {
  21133. this.inputs.clear();
  21134. _super.prototype.dispose.call(this);
  21135. };
  21136. /**
  21137. * Get the current object class name.
  21138. * @returns the class name.
  21139. */
  21140. FlyCamera.prototype.getClassName = function () {
  21141. return "FlyCamera";
  21142. };
  21143. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21144. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21145. ], FlyCamera.prototype, "ellipsoid", void 0);
  21146. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21147. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21148. ], FlyCamera.prototype, "ellipsoidOffset", void 0);
  21149. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21150. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21151. ], FlyCamera.prototype, "checkCollisions", void 0);
  21152. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21153. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21154. ], FlyCamera.prototype, "applyGravity", void 0);
  21155. return FlyCamera;
  21156. }(_targetCamera__WEBPACK_IMPORTED_MODULE_5__["TargetCamera"]));
  21157. /***/ }),
  21158. /***/ "./Cameras/flyCameraInputsManager.ts":
  21159. /*!*******************************************!*\
  21160. !*** ./Cameras/flyCameraInputsManager.ts ***!
  21161. \*******************************************/
  21162. /*! exports provided: FlyCameraInputsManager */
  21163. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21164. "use strict";
  21165. __webpack_require__.r(__webpack_exports__);
  21166. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return FlyCameraInputsManager; });
  21167. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21168. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  21169. /* harmony import */ var _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  21170. /* harmony import */ var _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  21171. /**
  21172. * Default Inputs manager for the FlyCamera.
  21173. * It groups all the default supported inputs for ease of use.
  21174. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21175. */
  21176. var FlyCameraInputsManager = /** @class */ (function (_super) {
  21177. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCameraInputsManager, _super);
  21178. /**
  21179. * Instantiates a new FlyCameraInputsManager.
  21180. * @param camera Defines the camera the inputs belong to.
  21181. */
  21182. function FlyCameraInputsManager(camera) {
  21183. return _super.call(this, camera) || this;
  21184. }
  21185. /**
  21186. * Add keyboard input support to the input manager.
  21187. * @returns the new FlyCameraKeyboardMoveInput().
  21188. */
  21189. FlyCameraInputsManager.prototype.addKeyboard = function () {
  21190. this.add(new _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__["FlyCameraKeyboardInput"]());
  21191. return this;
  21192. };
  21193. /**
  21194. * Add mouse input support to the input manager.
  21195. * @param touchEnabled Enable touch screen support.
  21196. * @returns the new FlyCameraMouseInput().
  21197. */
  21198. FlyCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  21199. if (touchEnabled === void 0) { touchEnabled = true; }
  21200. this.add(new _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__["FlyCameraMouseInput"](touchEnabled));
  21201. return this;
  21202. };
  21203. return FlyCameraInputsManager;
  21204. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  21205. /***/ }),
  21206. /***/ "./Cameras/followCamera.ts":
  21207. /*!*********************************!*\
  21208. !*** ./Cameras/followCamera.ts ***!
  21209. \*********************************/
  21210. /*! exports provided: FollowCamera, ArcFollowCamera */
  21211. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21212. "use strict";
  21213. __webpack_require__.r(__webpack_exports__);
  21214. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return FollowCamera; });
  21215. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return ArcFollowCamera; });
  21216. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21217. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21218. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  21219. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21220. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21221. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  21222. /* harmony import */ var _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./followCameraInputsManager */ "./Cameras/followCameraInputsManager.ts");
  21223. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("FollowCamera", function (name, scene) {
  21224. return function () { return new FollowCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  21225. });
  21226. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("ArcFollowCamera", function (name, scene) {
  21227. return function () { return new ArcFollowCamera(name, 0, 0, 1.0, null, scene); };
  21228. });
  21229. /**
  21230. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  21231. * an arc rotate version arcFollowCamera are available.
  21232. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21233. */
  21234. var FollowCamera = /** @class */ (function (_super) {
  21235. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCamera, _super);
  21236. /**
  21237. * Instantiates the follow camera.
  21238. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21239. * @param name Define the name of the camera in the scene
  21240. * @param position Define the position of the camera
  21241. * @param scene Define the scene the camera belong to
  21242. * @param lockedTarget Define the target of the camera
  21243. */
  21244. function FollowCamera(name, position, scene, lockedTarget) {
  21245. if (lockedTarget === void 0) { lockedTarget = null; }
  21246. var _this = _super.call(this, name, position, scene) || this;
  21247. /**
  21248. * Distance the follow camera should follow an object at
  21249. */
  21250. _this.radius = 12;
  21251. /**
  21252. * Define a rotation offset between the camera and the object it follows
  21253. */
  21254. _this.rotationOffset = 0;
  21255. /**
  21256. * Define a height offset between the camera and the object it follows.
  21257. * It can help following an object from the top (like a car chaing a plane)
  21258. */
  21259. _this.heightOffset = 4;
  21260. /**
  21261. * Define how fast the camera can accelerate to follow it s target.
  21262. */
  21263. _this.cameraAcceleration = 0.05;
  21264. /**
  21265. * Define the speed limit of the camera following an object.
  21266. */
  21267. _this.maxCameraSpeed = 20;
  21268. _this.lockedTarget = lockedTarget;
  21269. _this.inputs = new _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FollowCameraInputsManager"](_this);
  21270. _this.inputs.addKeyboard();
  21271. return _this;
  21272. // Uncomment the following line when the relevant handlers have been implemented.
  21273. // this.inputs.addKeyboard().addMouseWheel().addPointers().addVRDeviceOrientation();
  21274. }
  21275. FollowCamera.prototype._follow = function (cameraTarget) {
  21276. if (!cameraTarget) {
  21277. return;
  21278. }
  21279. var yRotation;
  21280. if (cameraTarget.rotationQuaternion) {
  21281. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  21282. cameraTarget.rotationQuaternion.toRotationMatrix(rotMatrix);
  21283. yRotation = Math.atan2(rotMatrix.m[8], rotMatrix.m[10]);
  21284. }
  21285. else {
  21286. yRotation = cameraTarget.rotation.y;
  21287. }
  21288. var radians = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this.rotationOffset) + yRotation;
  21289. var targetPosition = cameraTarget.getAbsolutePosition();
  21290. var targetX = targetPosition.x + Math.sin(radians) * this.radius;
  21291. var targetZ = targetPosition.z + Math.cos(radians) * this.radius;
  21292. var dx = targetX - this.position.x;
  21293. var dy = (targetPosition.y + this.heightOffset) - this.position.y;
  21294. var dz = (targetZ) - this.position.z;
  21295. var vx = dx * this.cameraAcceleration * 2; //this is set to .05
  21296. var vy = dy * this.cameraAcceleration;
  21297. var vz = dz * this.cameraAcceleration * 2;
  21298. if (vx > this.maxCameraSpeed || vx < -this.maxCameraSpeed) {
  21299. vx = vx < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21300. }
  21301. if (vy > this.maxCameraSpeed || vy < -this.maxCameraSpeed) {
  21302. vy = vy < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21303. }
  21304. if (vz > this.maxCameraSpeed || vz < -this.maxCameraSpeed) {
  21305. vz = vz < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21306. }
  21307. this.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](this.position.x + vx, this.position.y + vy, this.position.z + vz);
  21308. this.setTarget(targetPosition);
  21309. };
  21310. /**
  21311. * Attached controls to the current camera.
  21312. * @param element Defines the element the controls should be listened from
  21313. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21314. */
  21315. FollowCamera.prototype.attachControl = function (element, noPreventDefault) {
  21316. this.inputs.attachElement(element, noPreventDefault);
  21317. this._reset = function () {
  21318. };
  21319. };
  21320. /**
  21321. * Detach the current controls from the camera.
  21322. * The camera will stop reacting to inputs.
  21323. * @param element Defines the element to stop listening the inputs from
  21324. */
  21325. FollowCamera.prototype.detachControl = function (element) {
  21326. this.inputs.detachElement(element);
  21327. if (this._reset) {
  21328. this._reset();
  21329. }
  21330. };
  21331. /** @hidden */
  21332. FollowCamera.prototype._checkInputs = function () {
  21333. this.inputs.checkInputs();
  21334. _super.prototype._checkInputs.call(this);
  21335. if (this.lockedTarget) {
  21336. this._follow(this.lockedTarget);
  21337. }
  21338. };
  21339. /**
  21340. * Gets the camera class name.
  21341. * @returns the class name
  21342. */
  21343. FollowCamera.prototype.getClassName = function () {
  21344. return "FollowCamera";
  21345. };
  21346. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21347. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21348. ], FollowCamera.prototype, "radius", void 0);
  21349. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21350. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21351. ], FollowCamera.prototype, "rotationOffset", void 0);
  21352. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21353. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21354. ], FollowCamera.prototype, "heightOffset", void 0);
  21355. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21356. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21357. ], FollowCamera.prototype, "cameraAcceleration", void 0);
  21358. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21359. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21360. ], FollowCamera.prototype, "maxCameraSpeed", void 0);
  21361. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21362. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  21363. ], FollowCamera.prototype, "lockedTarget", void 0);
  21364. return FollowCamera;
  21365. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  21366. /**
  21367. * Arc Rotate version of the follow camera.
  21368. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  21369. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21370. */
  21371. var ArcFollowCamera = /** @class */ (function (_super) {
  21372. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcFollowCamera, _super);
  21373. /**
  21374. * Instantiates a new ArcFollowCamera
  21375. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21376. * @param name Define the name of the camera
  21377. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  21378. * @param beta Define the rotation angle of the camera around the elevation axis
  21379. * @param radius Define the radius of the camera from its target point
  21380. * @param target Define the target of the camera
  21381. * @param scene Define the scene the camera belongs to
  21382. */
  21383. function ArcFollowCamera(name,
  21384. /** The longitudinal angle of the camera */
  21385. alpha,
  21386. /** The latitudinal angle of the camera */
  21387. beta,
  21388. /** The radius of the camera from its target */
  21389. radius,
  21390. /** Define the camera target (the messh it should follow) */
  21391. target, scene) {
  21392. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene) || this;
  21393. _this.alpha = alpha;
  21394. _this.beta = beta;
  21395. _this.radius = radius;
  21396. _this.target = target;
  21397. _this._cartesianCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  21398. _this._follow();
  21399. return _this;
  21400. }
  21401. ArcFollowCamera.prototype._follow = function () {
  21402. if (!this.target) {
  21403. return;
  21404. }
  21405. this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta);
  21406. this._cartesianCoordinates.y = this.radius * Math.sin(this.beta);
  21407. this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
  21408. var targetPosition = this.target.getAbsolutePosition();
  21409. this.position = targetPosition.add(this._cartesianCoordinates);
  21410. this.setTarget(targetPosition);
  21411. };
  21412. /** @hidden */
  21413. ArcFollowCamera.prototype._checkInputs = function () {
  21414. _super.prototype._checkInputs.call(this);
  21415. this._follow();
  21416. };
  21417. /**
  21418. * Returns the class name of the object.
  21419. * It is mostly used internally for serialization purposes.
  21420. */
  21421. ArcFollowCamera.prototype.getClassName = function () {
  21422. return "ArcFollowCamera";
  21423. };
  21424. return ArcFollowCamera;
  21425. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  21426. /***/ }),
  21427. /***/ "./Cameras/followCameraInputsManager.ts":
  21428. /*!**********************************************!*\
  21429. !*** ./Cameras/followCameraInputsManager.ts ***!
  21430. \**********************************************/
  21431. /*! exports provided: FollowCameraInputsManager */
  21432. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21433. "use strict";
  21434. __webpack_require__.r(__webpack_exports__);
  21435. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraInputsManager", function() { return FollowCameraInputsManager; });
  21436. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21437. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  21438. /* harmony import */ var _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Inputs/followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  21439. /**
  21440. * Default Inputs manager for the FollowCamera.
  21441. * It groups all the default supported inputs for ease of use.
  21442. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21443. */
  21444. var FollowCameraInputsManager = /** @class */ (function (_super) {
  21445. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraInputsManager, _super);
  21446. /**
  21447. * Instantiates a new FollowCameraInputsManager.
  21448. * @param camera Defines the camera the inputs belong to
  21449. */
  21450. function FollowCameraInputsManager(camera) {
  21451. return _super.call(this, camera) || this;
  21452. }
  21453. /**
  21454. * Add keyboard input support to the input manager.
  21455. * @returns the current input manager
  21456. */
  21457. FollowCameraInputsManager.prototype.addKeyboard = function () {
  21458. this.add(new _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FollowCameraKeyboardMoveInput"]());
  21459. return this;
  21460. };
  21461. /**
  21462. * Add mouse wheel input support to the input manager.
  21463. * @returns the current input manager
  21464. */
  21465. FollowCameraInputsManager.prototype.addMouseWheel = function () {
  21466. console.warn("MouseWheel support not yet implemented for FollowCamera.");
  21467. return this;
  21468. };
  21469. /**
  21470. * Add pointers input support to the input manager.
  21471. * @returns the current input manager
  21472. */
  21473. FollowCameraInputsManager.prototype.addPointers = function () {
  21474. console.warn("Pointer support not yet implemented for FollowCamera.");
  21475. return this;
  21476. };
  21477. /**
  21478. * Add orientation input support to the input manager.
  21479. * @returns the current input manager
  21480. */
  21481. FollowCameraInputsManager.prototype.addVRDeviceOrientation = function () {
  21482. console.warn("DeviceOrientation support not yet implemented for FollowCamera.");
  21483. return this;
  21484. };
  21485. return FollowCameraInputsManager;
  21486. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  21487. /***/ }),
  21488. /***/ "./Cameras/freeCamera.ts":
  21489. /*!*******************************!*\
  21490. !*** ./Cameras/freeCamera.ts ***!
  21491. \*******************************/
  21492. /*! exports provided: FreeCamera */
  21493. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21494. "use strict";
  21495. __webpack_require__.r(__webpack_exports__);
  21496. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return FreeCamera; });
  21497. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21498. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21499. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21500. /* harmony import */ var _Collisions_collider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/collider */ "./Collisions/collider.ts");
  21501. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  21502. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21503. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  21504. /**
  21505. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  21506. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  21507. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  21508. */
  21509. var FreeCamera = /** @class */ (function (_super) {
  21510. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCamera, _super);
  21511. /**
  21512. * Instantiates a Free Camera.
  21513. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  21514. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  21515. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  21516. * @param name Define the name of the camera in the scene
  21517. * @param position Define the start position of the camera in the scene
  21518. * @param scene Define the scene the camera belongs to
  21519. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  21520. */
  21521. function FreeCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  21522. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  21523. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  21524. /**
  21525. * Define the collision ellipsoid of the camera.
  21526. * This is helpful to simulate a camera body like the player body around the camera
  21527. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  21528. */
  21529. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.5, 1, 0.5);
  21530. /**
  21531. * Define an offset for the position of the ellipsoid around the camera.
  21532. * This can be helpful to determine the center of the body near the gravity center of the body
  21533. * instead of its head.
  21534. */
  21535. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21536. /**
  21537. * Enable or disable collisions of the camera with the rest of the scene objects.
  21538. */
  21539. _this.checkCollisions = false;
  21540. /**
  21541. * Enable or disable gravity on the camera.
  21542. */
  21543. _this.applyGravity = false;
  21544. _this._needMoveForGravity = false;
  21545. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21546. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21547. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21548. // Collisions
  21549. _this._collisionMask = -1;
  21550. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  21551. if (collidedMesh === void 0) { collidedMesh = null; }
  21552. var updatePosition = function (newPos) {
  21553. _this._newPosition.copyFrom(newPos);
  21554. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  21555. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].CollisionsEpsilon) {
  21556. _this.position.addInPlace(_this._diffPosition);
  21557. if (_this.onCollide && collidedMesh) {
  21558. _this.onCollide(collidedMesh);
  21559. }
  21560. }
  21561. };
  21562. updatePosition(newPosition);
  21563. };
  21564. _this.inputs = new _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FreeCameraInputsManager"](_this);
  21565. _this.inputs.addKeyboard().addMouse();
  21566. return _this;
  21567. }
  21568. Object.defineProperty(FreeCamera.prototype, "angularSensibility", {
  21569. /**
  21570. * Gets the input sensibility for a mouse input. (default is 2000.0)
  21571. * Higher values reduce sensitivity.
  21572. */
  21573. get: function () {
  21574. var mouse = this.inputs.attached["mouse"];
  21575. if (mouse) {
  21576. return mouse.angularSensibility;
  21577. }
  21578. return 0;
  21579. },
  21580. /**
  21581. * Sets the input sensibility for a mouse input. (default is 2000.0)
  21582. * Higher values reduce sensitivity.
  21583. */
  21584. set: function (value) {
  21585. var mouse = this.inputs.attached["mouse"];
  21586. if (mouse) {
  21587. mouse.angularSensibility = value;
  21588. }
  21589. },
  21590. enumerable: true,
  21591. configurable: true
  21592. });
  21593. Object.defineProperty(FreeCamera.prototype, "keysUp", {
  21594. /**
  21595. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  21596. */
  21597. get: function () {
  21598. var keyboard = this.inputs.attached["keyboard"];
  21599. if (keyboard) {
  21600. return keyboard.keysUp;
  21601. }
  21602. return [];
  21603. },
  21604. set: function (value) {
  21605. var keyboard = this.inputs.attached["keyboard"];
  21606. if (keyboard) {
  21607. keyboard.keysUp = value;
  21608. }
  21609. },
  21610. enumerable: true,
  21611. configurable: true
  21612. });
  21613. Object.defineProperty(FreeCamera.prototype, "keysDown", {
  21614. /**
  21615. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  21616. */
  21617. get: function () {
  21618. var keyboard = this.inputs.attached["keyboard"];
  21619. if (keyboard) {
  21620. return keyboard.keysDown;
  21621. }
  21622. return [];
  21623. },
  21624. set: function (value) {
  21625. var keyboard = this.inputs.attached["keyboard"];
  21626. if (keyboard) {
  21627. keyboard.keysDown = value;
  21628. }
  21629. },
  21630. enumerable: true,
  21631. configurable: true
  21632. });
  21633. Object.defineProperty(FreeCamera.prototype, "keysLeft", {
  21634. /**
  21635. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  21636. */
  21637. get: function () {
  21638. var keyboard = this.inputs.attached["keyboard"];
  21639. if (keyboard) {
  21640. return keyboard.keysLeft;
  21641. }
  21642. return [];
  21643. },
  21644. set: function (value) {
  21645. var keyboard = this.inputs.attached["keyboard"];
  21646. if (keyboard) {
  21647. keyboard.keysLeft = value;
  21648. }
  21649. },
  21650. enumerable: true,
  21651. configurable: true
  21652. });
  21653. Object.defineProperty(FreeCamera.prototype, "keysRight", {
  21654. /**
  21655. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  21656. */
  21657. get: function () {
  21658. var keyboard = this.inputs.attached["keyboard"];
  21659. if (keyboard) {
  21660. return keyboard.keysRight;
  21661. }
  21662. return [];
  21663. },
  21664. set: function (value) {
  21665. var keyboard = this.inputs.attached["keyboard"];
  21666. if (keyboard) {
  21667. keyboard.keysRight = value;
  21668. }
  21669. },
  21670. enumerable: true,
  21671. configurable: true
  21672. });
  21673. /**
  21674. * Attached controls to the current camera.
  21675. * @param element Defines the element the controls should be listened from
  21676. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21677. */
  21678. FreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  21679. this.inputs.attachElement(element, noPreventDefault);
  21680. };
  21681. /**
  21682. * Detach the current controls from the camera.
  21683. * The camera will stop reacting to inputs.
  21684. * @param element Defines the element to stop listening the inputs from
  21685. */
  21686. FreeCamera.prototype.detachControl = function (element) {
  21687. this.inputs.detachElement(element);
  21688. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21689. this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  21690. };
  21691. Object.defineProperty(FreeCamera.prototype, "collisionMask", {
  21692. /**
  21693. * Define a collision mask to limit the list of object the camera can collide with
  21694. */
  21695. get: function () {
  21696. return this._collisionMask;
  21697. },
  21698. set: function (mask) {
  21699. this._collisionMask = !isNaN(mask) ? mask : -1;
  21700. },
  21701. enumerable: true,
  21702. configurable: true
  21703. });
  21704. /** @hidden */
  21705. FreeCamera.prototype._collideWithWorld = function (displacement) {
  21706. var globalPosition;
  21707. if (this.parent) {
  21708. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  21709. }
  21710. else {
  21711. globalPosition = this.position;
  21712. }
  21713. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  21714. this._oldPosition.addInPlace(this.ellipsoidOffset);
  21715. if (!this._collider) {
  21716. this._collider = new _Collisions_collider__WEBPACK_IMPORTED_MODULE_3__["Collider"]();
  21717. }
  21718. this._collider._radius = this.ellipsoid;
  21719. this._collider.collisionMask = this._collisionMask;
  21720. //no need for clone, as long as gravity is not on.
  21721. var actualDisplacement = displacement;
  21722. //add gravity to the direction to prevent the dual-collision checking
  21723. if (this.applyGravity) {
  21724. //this prevents mending with cameraDirection, a global variable of the free camera class.
  21725. actualDisplacement = displacement.add(this.getScene().gravity);
  21726. }
  21727. this.getScene().collisionCoordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  21728. };
  21729. /** @hidden */
  21730. FreeCamera.prototype._checkInputs = function () {
  21731. if (!this._localDirection) {
  21732. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21733. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21734. }
  21735. this.inputs.checkInputs();
  21736. _super.prototype._checkInputs.call(this);
  21737. };
  21738. /** @hidden */
  21739. FreeCamera.prototype._decideIfNeedsToMove = function () {
  21740. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  21741. };
  21742. /** @hidden */
  21743. FreeCamera.prototype._updatePosition = function () {
  21744. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  21745. this._collideWithWorld(this.cameraDirection);
  21746. }
  21747. else {
  21748. _super.prototype._updatePosition.call(this);
  21749. }
  21750. };
  21751. /**
  21752. * Destroy the camera and release the current resources hold by it.
  21753. */
  21754. FreeCamera.prototype.dispose = function () {
  21755. this.inputs.clear();
  21756. _super.prototype.dispose.call(this);
  21757. };
  21758. /**
  21759. * Gets the current object class name.
  21760. * @return the class name
  21761. */
  21762. FreeCamera.prototype.getClassName = function () {
  21763. return "FreeCamera";
  21764. };
  21765. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21766. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21767. ], FreeCamera.prototype, "ellipsoid", void 0);
  21768. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21769. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21770. ], FreeCamera.prototype, "ellipsoidOffset", void 0);
  21771. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21772. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21773. ], FreeCamera.prototype, "checkCollisions", void 0);
  21774. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21775. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21776. ], FreeCamera.prototype, "applyGravity", void 0);
  21777. return FreeCamera;
  21778. }(_targetCamera__WEBPACK_IMPORTED_MODULE_5__["TargetCamera"]));
  21779. /***/ }),
  21780. /***/ "./Cameras/freeCameraInputsManager.ts":
  21781. /*!********************************************!*\
  21782. !*** ./Cameras/freeCameraInputsManager.ts ***!
  21783. \********************************************/
  21784. /*! exports provided: FreeCameraInputsManager */
  21785. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21786. "use strict";
  21787. __webpack_require__.r(__webpack_exports__);
  21788. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return FreeCameraInputsManager; });
  21789. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21790. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  21791. /* harmony import */ var _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  21792. /* harmony import */ var _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  21793. /* harmony import */ var _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  21794. /**
  21795. * Default Inputs manager for the FreeCamera.
  21796. * It groups all the default supported inputs for ease of use.
  21797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21798. */
  21799. var FreeCameraInputsManager = /** @class */ (function (_super) {
  21800. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCameraInputsManager, _super);
  21801. /**
  21802. * Instantiates a new FreeCameraInputsManager.
  21803. * @param camera Defines the camera the inputs belong to
  21804. */
  21805. function FreeCameraInputsManager(camera) {
  21806. return _super.call(this, camera) || this;
  21807. }
  21808. /**
  21809. * Add keyboard input support to the input manager.
  21810. * @returns the current input manager
  21811. */
  21812. FreeCameraInputsManager.prototype.addKeyboard = function () {
  21813. this.add(new _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FreeCameraKeyboardMoveInput"]());
  21814. return this;
  21815. };
  21816. /**
  21817. * Add mouse input support to the input manager.
  21818. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  21819. * @returns the current input manager
  21820. */
  21821. FreeCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  21822. if (touchEnabled === void 0) { touchEnabled = true; }
  21823. this.add(new _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__["FreeCameraMouseInput"](touchEnabled));
  21824. return this;
  21825. };
  21826. /**
  21827. * Add touch input support to the input manager.
  21828. * @returns the current input manager
  21829. */
  21830. FreeCameraInputsManager.prototype.addTouch = function () {
  21831. this.add(new _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraTouchInput"]());
  21832. return this;
  21833. };
  21834. return FreeCameraInputsManager;
  21835. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  21836. /***/ }),
  21837. /***/ "./Cameras/gamepadCamera.ts":
  21838. /*!**********************************!*\
  21839. !*** ./Cameras/gamepadCamera.ts ***!
  21840. \**********************************/
  21841. /*! exports provided: GamepadCamera */
  21842. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21843. "use strict";
  21844. __webpack_require__.r(__webpack_exports__);
  21845. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return GamepadCamera; });
  21846. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21847. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  21848. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21849. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  21850. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("GamepadCamera", function (name, scene) {
  21851. return function () { return new GamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  21852. });
  21853. /**
  21854. * This represents a FPS type of camera. This is only here for back compat purpose.
  21855. * Please use the UniversalCamera instead as both are identical.
  21856. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  21857. */
  21858. var GamepadCamera = /** @class */ (function (_super) {
  21859. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GamepadCamera, _super);
  21860. /**
  21861. * Instantiates a new Gamepad Camera
  21862. * This represents a FPS type of camera. This is only here for back compat purpose.
  21863. * Please use the UniversalCamera instead as both are identical.
  21864. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  21865. * @param name Define the name of the camera in the scene
  21866. * @param position Define the start position of the camera in the scene
  21867. * @param scene Define the scene the camera belongs to
  21868. */
  21869. function GamepadCamera(name, position, scene) {
  21870. return _super.call(this, name, position, scene) || this;
  21871. }
  21872. /**
  21873. * Gets the current object class name.
  21874. * @return the class name
  21875. */
  21876. GamepadCamera.prototype.getClassName = function () {
  21877. return "GamepadCamera";
  21878. };
  21879. return GamepadCamera;
  21880. }(_universalCamera__WEBPACK_IMPORTED_MODULE_1__["UniversalCamera"]));
  21881. /***/ }),
  21882. /***/ "./Cameras/index.ts":
  21883. /*!**************************!*\
  21884. !*** ./Cameras/index.ts ***!
  21885. \**************************/
  21886. /*! 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 */
  21887. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21888. "use strict";
  21889. __webpack_require__.r(__webpack_exports__);
  21890. /* harmony import */ var _Inputs_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Inputs/index */ "./Cameras/Inputs/index.ts");
  21891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  21892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  21893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  21894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  21895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  21896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  21897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  21898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  21899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  21900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  21901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  21902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  21903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  21904. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  21905. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]; });
  21906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]; });
  21907. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  21908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]; });
  21909. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]; });
  21911. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  21912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _freeCamera__WEBPACK_IMPORTED_MODULE_4__["FreeCamera"]; });
  21913. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  21914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"]; });
  21915. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  21916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _touchCamera__WEBPACK_IMPORTED_MODULE_6__["TouchCamera"]; });
  21917. /* harmony import */ var _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  21918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  21919. /* harmony import */ var _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  21920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__["ArcRotateCameraInputsManager"]; });
  21921. /* harmony import */ var _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  21922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__["DeviceOrientationCamera"]; });
  21923. /* harmony import */ var _flyCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./flyCamera */ "./Cameras/flyCamera.ts");
  21924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _flyCamera__WEBPACK_IMPORTED_MODULE_10__["FlyCamera"]; });
  21925. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  21926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["FlyCameraInputsManager"]; });
  21927. /* harmony import */ var _followCamera__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./followCamera */ "./Cameras/followCamera.ts");
  21928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["FollowCamera"]; });
  21929. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["ArcFollowCamera"]; });
  21930. /* harmony import */ var _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./gamepadCamera */ "./Cameras/gamepadCamera.ts");
  21931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__["GamepadCamera"]; });
  21932. /* harmony import */ var _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Stereoscopic/index */ "./Cameras/Stereoscopic/index.ts");
  21933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphArcRotateCamera"]; });
  21934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphFreeCamera"]; });
  21935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphGamepadCamera"]; });
  21936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphUniversalCamera"]; });
  21937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicArcRotateCamera"]; });
  21938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicFreeCamera"]; });
  21939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicGamepadCamera"]; });
  21940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicUniversalCamera"]; });
  21941. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  21942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _universalCamera__WEBPACK_IMPORTED_MODULE_15__["UniversalCamera"]; });
  21943. /* harmony import */ var _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./virtualJoysticksCamera */ "./Cameras/virtualJoysticksCamera.ts");
  21944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__["VirtualJoysticksCamera"]; });
  21945. /* harmony import */ var _VR_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./VR/index */ "./Cameras/VR/index.ts");
  21946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRCameraMetrics"]; });
  21947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationArcRotateCamera"]; });
  21948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationFreeCamera"]; });
  21949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationGamepadCamera"]; });
  21950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRExperienceHelper"]; });
  21951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["WebVRFreeCamera"]; });
  21952. /* harmony import */ var _XR_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./XR/index */ "./Cameras/XR/index.ts");
  21953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRCamera"]; });
  21954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIButton"]; });
  21955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIOptions"]; });
  21956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUI"]; });
  21957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRState"]; });
  21958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRExperienceHelper"]; });
  21959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRController"]; });
  21960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRInput"]; });
  21961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRManagedOutputCanvas"]; });
  21962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRSessionManager"]; });
  21963. /***/ }),
  21964. /***/ "./Cameras/targetCamera.ts":
  21965. /*!*********************************!*\
  21966. !*** ./Cameras/targetCamera.ts ***!
  21967. \*********************************/
  21968. /*! exports provided: TargetCamera */
  21969. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21970. "use strict";
  21971. __webpack_require__.r(__webpack_exports__);
  21972. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return TargetCamera; });
  21973. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21974. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21975. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  21976. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21977. /**
  21978. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  21979. * This is the base of the follow, arc rotate cameras and Free camera
  21980. * @see http://doc.babylonjs.com/features/cameras
  21981. */
  21982. var TargetCamera = /** @class */ (function (_super) {
  21983. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TargetCamera, _super);
  21984. /**
  21985. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  21986. * This is the base of the follow, arc rotate cameras and Free camera
  21987. * @see http://doc.babylonjs.com/features/cameras
  21988. * @param name Defines the name of the camera in the scene
  21989. * @param position Defines the start position of the camera in the scene
  21990. * @param scene Defines the scene the camera belongs to
  21991. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  21992. */
  21993. function TargetCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  21994. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  21995. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  21996. /**
  21997. * Define the current direction the camera is moving to
  21998. */
  21999. _this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  22000. /**
  22001. * Define the current rotation the camera is rotating to
  22002. */
  22003. _this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  22004. /**
  22005. * When set, the up vector of the camera will be updated by the rotation of the camera
  22006. */
  22007. _this.updateUpVectorFromRotation = false;
  22008. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22009. /**
  22010. * Define the current rotation of the camera
  22011. */
  22012. _this.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  22013. /**
  22014. * Define the current speed of the camera
  22015. */
  22016. _this.speed = 2.0;
  22017. /**
  22018. * Add cconstraint to the camera to prevent it to move freely in all directions and
  22019. * around all axis.
  22020. */
  22021. _this.noRotationConstraint = false;
  22022. /**
  22023. * Define the current target of the camera as an object or a position.
  22024. */
  22025. _this.lockedTarget = null;
  22026. /** @hidden */
  22027. _this._currentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22028. /** @hidden */
  22029. _this._initialFocalDistance = 1;
  22030. /** @hidden */
  22031. _this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22032. /** @hidden */
  22033. _this._camMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22034. /** @hidden */
  22035. _this._cameraTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22036. /** @hidden */
  22037. _this._cameraRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22038. /** @hidden */
  22039. _this._referencePoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  22040. /** @hidden */
  22041. _this._transformedReferencePoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22042. _this._globalCurrentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22043. _this._globalCurrentUpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22044. _this._defaultUp = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  22045. _this._cachedRotationZ = 0;
  22046. _this._cachedQuaternionRotationZ = 0;
  22047. return _this;
  22048. }
  22049. /**
  22050. * Gets the position in front of the camera at a given distance.
  22051. * @param distance The distance from the camera we want the position to be
  22052. * @returns the position
  22053. */
  22054. TargetCamera.prototype.getFrontPosition = function (distance) {
  22055. this.getWorldMatrix();
  22056. var direction = this.getTarget().subtract(this.position);
  22057. direction.normalize();
  22058. direction.scaleInPlace(distance);
  22059. return this.globalPosition.add(direction);
  22060. };
  22061. /** @hidden */
  22062. TargetCamera.prototype._getLockedTargetPosition = function () {
  22063. if (!this.lockedTarget) {
  22064. return null;
  22065. }
  22066. if (this.lockedTarget.absolutePosition) {
  22067. this.lockedTarget.computeWorldMatrix();
  22068. }
  22069. return this.lockedTarget.absolutePosition || this.lockedTarget;
  22070. };
  22071. /**
  22072. * Store current camera state of the camera (fov, position, rotation, etc..)
  22073. * @returns the camera
  22074. */
  22075. TargetCamera.prototype.storeState = function () {
  22076. this._storedPosition = this.position.clone();
  22077. this._storedRotation = this.rotation.clone();
  22078. if (this.rotationQuaternion) {
  22079. this._storedRotationQuaternion = this.rotationQuaternion.clone();
  22080. }
  22081. return _super.prototype.storeState.call(this);
  22082. };
  22083. /**
  22084. * Restored camera state. You must call storeState() first
  22085. * @returns whether it was successful or not
  22086. * @hidden
  22087. */
  22088. TargetCamera.prototype._restoreStateValues = function () {
  22089. if (!_super.prototype._restoreStateValues.call(this)) {
  22090. return false;
  22091. }
  22092. this.position = this._storedPosition.clone();
  22093. this.rotation = this._storedRotation.clone();
  22094. if (this.rotationQuaternion) {
  22095. this.rotationQuaternion = this._storedRotationQuaternion.clone();
  22096. }
  22097. this.cameraDirection.copyFromFloats(0, 0, 0);
  22098. this.cameraRotation.copyFromFloats(0, 0);
  22099. return true;
  22100. };
  22101. /** @hidden */
  22102. TargetCamera.prototype._initCache = function () {
  22103. _super.prototype._initCache.call(this);
  22104. this._cache.lockedTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22105. this._cache.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22106. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22107. };
  22108. /** @hidden */
  22109. TargetCamera.prototype._updateCache = function (ignoreParentClass) {
  22110. if (!ignoreParentClass) {
  22111. _super.prototype._updateCache.call(this);
  22112. }
  22113. var lockedTargetPosition = this._getLockedTargetPosition();
  22114. if (!lockedTargetPosition) {
  22115. this._cache.lockedTarget = null;
  22116. }
  22117. else {
  22118. if (!this._cache.lockedTarget) {
  22119. this._cache.lockedTarget = lockedTargetPosition.clone();
  22120. }
  22121. else {
  22122. this._cache.lockedTarget.copyFrom(lockedTargetPosition);
  22123. }
  22124. }
  22125. this._cache.rotation.copyFrom(this.rotation);
  22126. if (this.rotationQuaternion) {
  22127. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22128. }
  22129. };
  22130. // Synchronized
  22131. /** @hidden */
  22132. TargetCamera.prototype._isSynchronizedViewMatrix = function () {
  22133. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  22134. return false;
  22135. }
  22136. var lockedTargetPosition = this._getLockedTargetPosition();
  22137. return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(lockedTargetPosition) : !lockedTargetPosition)
  22138. && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation));
  22139. };
  22140. // Methods
  22141. /** @hidden */
  22142. TargetCamera.prototype._computeLocalCameraSpeed = function () {
  22143. var engine = this.getEngine();
  22144. return this.speed * Math.sqrt((engine.getDeltaTime() / (engine.getFps() * 100.0)));
  22145. };
  22146. // Target
  22147. /** @hidden */
  22148. TargetCamera.prototype.setTarget = function (target) {
  22149. this.upVector.normalize();
  22150. this._initialFocalDistance = target.subtract(this.position).length();
  22151. if (this.position.z === target.z) {
  22152. this.position.z += _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  22153. }
  22154. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this.position, target, this._defaultUp, this._camMatrix);
  22155. this._camMatrix.invert();
  22156. this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
  22157. var vDir = target.subtract(this.position);
  22158. if (vDir.x >= 0.0) {
  22159. this.rotation.y = (-Math.atan(vDir.z / vDir.x) + Math.PI / 2.0);
  22160. }
  22161. else {
  22162. this.rotation.y = (-Math.atan(vDir.z / vDir.x) - Math.PI / 2.0);
  22163. }
  22164. this.rotation.z = 0;
  22165. if (isNaN(this.rotation.x)) {
  22166. this.rotation.x = 0;
  22167. }
  22168. if (isNaN(this.rotation.y)) {
  22169. this.rotation.y = 0;
  22170. }
  22171. if (isNaN(this.rotation.z)) {
  22172. this.rotation.z = 0;
  22173. }
  22174. if (this.rotationQuaternion) {
  22175. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  22176. }
  22177. };
  22178. /**
  22179. * Return the current target position of the camera. This value is expressed in local space.
  22180. * @returns the target position
  22181. */
  22182. TargetCamera.prototype.getTarget = function () {
  22183. return this._currentTarget;
  22184. };
  22185. /** @hidden */
  22186. TargetCamera.prototype._decideIfNeedsToMove = function () {
  22187. return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22188. };
  22189. /** @hidden */
  22190. TargetCamera.prototype._updatePosition = function () {
  22191. if (this.parent) {
  22192. this.parent.getWorldMatrix().invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  22193. _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]);
  22194. this.position.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  22195. return;
  22196. }
  22197. this.position.addInPlace(this.cameraDirection);
  22198. };
  22199. /** @hidden */
  22200. TargetCamera.prototype._checkInputs = function () {
  22201. var needToMove = this._decideIfNeedsToMove();
  22202. var needToRotate = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
  22203. // Move
  22204. if (needToMove) {
  22205. this._updatePosition();
  22206. }
  22207. // Rotate
  22208. if (needToRotate) {
  22209. this.rotation.x += this.cameraRotation.x;
  22210. this.rotation.y += this.cameraRotation.y;
  22211. //rotate, if quaternion is set and rotation was used
  22212. if (this.rotationQuaternion) {
  22213. var len = this.rotation.lengthSquared();
  22214. if (len) {
  22215. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  22216. }
  22217. }
  22218. if (!this.noRotationConstraint) {
  22219. var limit = (Math.PI / 2) * 0.95;
  22220. if (this.rotation.x > limit) {
  22221. this.rotation.x = limit;
  22222. }
  22223. if (this.rotation.x < -limit) {
  22224. this.rotation.x = -limit;
  22225. }
  22226. }
  22227. }
  22228. // Inertia
  22229. if (needToMove) {
  22230. if (Math.abs(this.cameraDirection.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22231. this.cameraDirection.x = 0;
  22232. }
  22233. if (Math.abs(this.cameraDirection.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22234. this.cameraDirection.y = 0;
  22235. }
  22236. if (Math.abs(this.cameraDirection.z) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22237. this.cameraDirection.z = 0;
  22238. }
  22239. this.cameraDirection.scaleInPlace(this.inertia);
  22240. }
  22241. if (needToRotate) {
  22242. if (Math.abs(this.cameraRotation.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22243. this.cameraRotation.x = 0;
  22244. }
  22245. if (Math.abs(this.cameraRotation.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22246. this.cameraRotation.y = 0;
  22247. }
  22248. this.cameraRotation.scaleInPlace(this.inertia);
  22249. }
  22250. _super.prototype._checkInputs.call(this);
  22251. };
  22252. TargetCamera.prototype._updateCameraRotationMatrix = function () {
  22253. if (this.rotationQuaternion) {
  22254. this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
  22255. }
  22256. else {
  22257. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
  22258. }
  22259. };
  22260. /**
  22261. * 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)
  22262. * @returns the current camera
  22263. */
  22264. TargetCamera.prototype._rotateUpVectorWithCameraRotationMatrix = function () {
  22265. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector);
  22266. return this;
  22267. };
  22268. /** @hidden */
  22269. TargetCamera.prototype._getViewMatrix = function () {
  22270. if (this.lockedTarget) {
  22271. this.setTarget(this._getLockedTargetPosition());
  22272. }
  22273. // Compute
  22274. this._updateCameraRotationMatrix();
  22275. // Apply the changed rotation to the upVector
  22276. if (this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z) {
  22277. this._rotateUpVectorWithCameraRotationMatrix();
  22278. this._cachedQuaternionRotationZ = this.rotationQuaternion.z;
  22279. }
  22280. else if (this._cachedRotationZ != this.rotation.z) {
  22281. this._rotateUpVectorWithCameraRotationMatrix();
  22282. this._cachedRotationZ = this.rotation.z;
  22283. }
  22284. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  22285. // Computing target and final matrix
  22286. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  22287. if (this.updateUpVectorFromRotation) {
  22288. if (this.rotationQuaternion) {
  22289. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector);
  22290. }
  22291. else {
  22292. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, this._tmpQuaternion);
  22293. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector);
  22294. }
  22295. }
  22296. this._computeViewMatrix(this.position, this._currentTarget, this.upVector);
  22297. return this._viewMatrix;
  22298. };
  22299. TargetCamera.prototype._computeViewMatrix = function (position, target, up) {
  22300. if (this.parent) {
  22301. var parentWorldMatrix = this.parent.getWorldMatrix();
  22302. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(position, parentWorldMatrix, this._globalPosition);
  22303. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(target, parentWorldMatrix, this._globalCurrentTarget);
  22304. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(up, parentWorldMatrix, this._globalCurrentUpVector);
  22305. this._markSyncedWithParent();
  22306. }
  22307. else {
  22308. this._globalPosition.copyFrom(position);
  22309. this._globalCurrentTarget.copyFrom(target);
  22310. this._globalCurrentUpVector.copyFrom(up);
  22311. }
  22312. if (this.getScene().useRightHandedSystem) {
  22313. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtRHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  22314. }
  22315. else {
  22316. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  22317. }
  22318. };
  22319. /**
  22320. * @hidden
  22321. */
  22322. TargetCamera.prototype.createRigCamera = function (name, cameraIndex) {
  22323. if (this.cameraRigMode !== _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_NONE) {
  22324. var rigCamera = new TargetCamera(name, this.position.clone(), this.getScene());
  22325. if (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR || this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_WEBVR) {
  22326. if (!this.rotationQuaternion) {
  22327. this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22328. }
  22329. rigCamera._cameraRigParams = {};
  22330. rigCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22331. }
  22332. return rigCamera;
  22333. }
  22334. return null;
  22335. };
  22336. /**
  22337. * @hidden
  22338. */
  22339. TargetCamera.prototype._updateRigCameras = function () {
  22340. var camLeft = this._rigCameras[0];
  22341. var camRight = this._rigCameras[1];
  22342. this.computeWorldMatrix();
  22343. switch (this.cameraRigMode) {
  22344. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  22345. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  22346. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  22347. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  22348. //provisionnaly using _cameraRigParams.stereoHalfAngle instead of calculations based on _cameraRigParams.interaxialDistance:
  22349. var leftSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? 1 : -1;
  22350. var rightSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? -1 : 1;
  22351. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * leftSign, camLeft);
  22352. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * rightSign, camRight);
  22353. break;
  22354. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR:
  22355. if (camLeft.rotationQuaternion) {
  22356. camLeft.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22357. camRight.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22358. }
  22359. else {
  22360. camLeft.rotation.copyFrom(this.rotation);
  22361. camRight.rotation.copyFrom(this.rotation);
  22362. }
  22363. camLeft.position.copyFrom(this.position);
  22364. camRight.position.copyFrom(this.position);
  22365. break;
  22366. }
  22367. _super.prototype._updateRigCameras.call(this);
  22368. };
  22369. TargetCamera.prototype._getRigCamPositionAndTarget = function (halfSpace, rigCamera) {
  22370. var target = this.getTarget();
  22371. target.subtractToRef(this.position, TargetCamera._TargetFocalPoint);
  22372. TargetCamera._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
  22373. var newFocalTarget = TargetCamera._TargetFocalPoint.addInPlace(this.position);
  22374. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-newFocalTarget.x, -newFocalTarget.y, -newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  22375. TargetCamera._TargetTransformMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(halfSpace), TargetCamera._RigCamTransformMatrix);
  22376. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(newFocalTarget.x, newFocalTarget.y, newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  22377. TargetCamera._RigCamTransformMatrix.multiplyToRef(TargetCamera._TargetTransformMatrix, TargetCamera._RigCamTransformMatrix);
  22378. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, TargetCamera._RigCamTransformMatrix, rigCamera.position);
  22379. rigCamera.setTarget(newFocalTarget);
  22380. };
  22381. /**
  22382. * Gets the current object class name.
  22383. * @return the class name
  22384. */
  22385. TargetCamera.prototype.getClassName = function () {
  22386. return "TargetCamera";
  22387. };
  22388. TargetCamera._RigCamTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  22389. TargetCamera._TargetTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  22390. TargetCamera._TargetFocalPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  22391. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22392. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22393. ], TargetCamera.prototype, "rotation", void 0);
  22394. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22395. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22396. ], TargetCamera.prototype, "speed", void 0);
  22397. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22398. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  22399. ], TargetCamera.prototype, "lockedTarget", void 0);
  22400. return TargetCamera;
  22401. }(_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]));
  22402. /***/ }),
  22403. /***/ "./Cameras/touchCamera.ts":
  22404. /*!********************************!*\
  22405. !*** ./Cameras/touchCamera.ts ***!
  22406. \********************************/
  22407. /*! exports provided: TouchCamera */
  22408. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22409. "use strict";
  22410. __webpack_require__.r(__webpack_exports__);
  22411. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return TouchCamera; });
  22412. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22413. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  22414. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22415. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  22416. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("TouchCamera", function (name, scene) {
  22417. return function () { return new TouchCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  22418. });
  22419. /**
  22420. * This represents a FPS type of camera controlled by touch.
  22421. * This is like a universal camera minus the Gamepad controls.
  22422. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22423. */
  22424. var TouchCamera = /** @class */ (function (_super) {
  22425. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TouchCamera, _super);
  22426. /**
  22427. * Instantiates a new touch camera.
  22428. * This represents a FPS type of camera controlled by touch.
  22429. * This is like a universal camera minus the Gamepad controls.
  22430. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22431. * @param name Define the name of the camera in the scene
  22432. * @param position Define the start position of the camera in the scene
  22433. * @param scene Define the scene the camera belongs to
  22434. */
  22435. function TouchCamera(name, position, scene) {
  22436. var _this = _super.call(this, name, position, scene) || this;
  22437. _this.inputs.addTouch();
  22438. _this._setupInputs();
  22439. return _this;
  22440. }
  22441. Object.defineProperty(TouchCamera.prototype, "touchAngularSensibility", {
  22442. /**
  22443. * Defines the touch sensibility for rotation.
  22444. * The higher the faster.
  22445. */
  22446. get: function () {
  22447. var touch = this.inputs.attached["touch"];
  22448. if (touch) {
  22449. return touch.touchAngularSensibility;
  22450. }
  22451. return 0;
  22452. },
  22453. set: function (value) {
  22454. var touch = this.inputs.attached["touch"];
  22455. if (touch) {
  22456. touch.touchAngularSensibility = value;
  22457. }
  22458. },
  22459. enumerable: true,
  22460. configurable: true
  22461. });
  22462. Object.defineProperty(TouchCamera.prototype, "touchMoveSensibility", {
  22463. /**
  22464. * Defines the touch sensibility for move.
  22465. * The higher the faster.
  22466. */
  22467. get: function () {
  22468. var touch = this.inputs.attached["touch"];
  22469. if (touch) {
  22470. return touch.touchMoveSensibility;
  22471. }
  22472. return 0;
  22473. },
  22474. set: function (value) {
  22475. var touch = this.inputs.attached["touch"];
  22476. if (touch) {
  22477. touch.touchMoveSensibility = value;
  22478. }
  22479. },
  22480. enumerable: true,
  22481. configurable: true
  22482. });
  22483. /**
  22484. * Gets the current object class name.
  22485. * @return the class name
  22486. */
  22487. TouchCamera.prototype.getClassName = function () {
  22488. return "TouchCamera";
  22489. };
  22490. /** @hidden */
  22491. TouchCamera.prototype._setupInputs = function () {
  22492. var mouse = this.inputs.attached["mouse"];
  22493. if (mouse) {
  22494. mouse.touchEnabled = false;
  22495. }
  22496. };
  22497. return TouchCamera;
  22498. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  22499. /***/ }),
  22500. /***/ "./Cameras/universalCamera.ts":
  22501. /*!************************************!*\
  22502. !*** ./Cameras/universalCamera.ts ***!
  22503. \************************************/
  22504. /*! exports provided: UniversalCamera */
  22505. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22506. "use strict";
  22507. __webpack_require__.r(__webpack_exports__);
  22508. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return UniversalCamera; });
  22509. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22510. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  22511. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node */ "./node.ts");
  22512. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22513. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  22514. _node__WEBPACK_IMPORTED_MODULE_2__["Node"].AddNodeConstructor("FreeCamera", function (name, scene) {
  22515. // Forcing to use the Universal camera
  22516. return function () { return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  22517. });
  22518. /**
  22519. * 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,
  22520. * which still works and will still be found in many Playgrounds.
  22521. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22522. */
  22523. var UniversalCamera = /** @class */ (function (_super) {
  22524. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](UniversalCamera, _super);
  22525. /**
  22526. * 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,
  22527. * which still works and will still be found in many Playgrounds.
  22528. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22529. * @param name Define the name of the camera in the scene
  22530. * @param position Define the start position of the camera in the scene
  22531. * @param scene Define the scene the camera belongs to
  22532. */
  22533. function UniversalCamera(name, position, scene) {
  22534. var _this = _super.call(this, name, position, scene) || this;
  22535. _this.inputs.addGamepad();
  22536. return _this;
  22537. }
  22538. Object.defineProperty(UniversalCamera.prototype, "gamepadAngularSensibility", {
  22539. /**
  22540. * Defines the gamepad rotation sensiblity.
  22541. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  22542. */
  22543. get: function () {
  22544. var gamepad = this.inputs.attached["gamepad"];
  22545. if (gamepad) {
  22546. return gamepad.gamepadAngularSensibility;
  22547. }
  22548. return 0;
  22549. },
  22550. set: function (value) {
  22551. var gamepad = this.inputs.attached["gamepad"];
  22552. if (gamepad) {
  22553. gamepad.gamepadAngularSensibility = value;
  22554. }
  22555. },
  22556. enumerable: true,
  22557. configurable: true
  22558. });
  22559. Object.defineProperty(UniversalCamera.prototype, "gamepadMoveSensibility", {
  22560. /**
  22561. * Defines the gamepad move sensiblity.
  22562. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  22563. */
  22564. get: function () {
  22565. var gamepad = this.inputs.attached["gamepad"];
  22566. if (gamepad) {
  22567. return gamepad.gamepadMoveSensibility;
  22568. }
  22569. return 0;
  22570. },
  22571. set: function (value) {
  22572. var gamepad = this.inputs.attached["gamepad"];
  22573. if (gamepad) {
  22574. gamepad.gamepadMoveSensibility = value;
  22575. }
  22576. },
  22577. enumerable: true,
  22578. configurable: true
  22579. });
  22580. /**
  22581. * Gets the current object class name.
  22582. * @return the class name
  22583. */
  22584. UniversalCamera.prototype.getClassName = function () {
  22585. return "UniversalCamera";
  22586. };
  22587. return UniversalCamera;
  22588. }(_touchCamera__WEBPACK_IMPORTED_MODULE_1__["TouchCamera"]));
  22589. _camera__WEBPACK_IMPORTED_MODULE_4__["Camera"]._createDefaultParsedCamera = function (name, scene) {
  22590. return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene);
  22591. };
  22592. /***/ }),
  22593. /***/ "./Cameras/virtualJoysticksCamera.ts":
  22594. /*!*******************************************!*\
  22595. !*** ./Cameras/virtualJoysticksCamera.ts ***!
  22596. \*******************************************/
  22597. /*! exports provided: VirtualJoysticksCamera */
  22598. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22599. "use strict";
  22600. __webpack_require__.r(__webpack_exports__);
  22601. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return VirtualJoysticksCamera; });
  22602. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22603. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  22604. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22605. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  22606. /* harmony import */ var _Inputs_freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  22607. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("VirtualJoysticksCamera", function (name, scene) {
  22608. return function () { return new VirtualJoysticksCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  22609. });
  22610. /**
  22611. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22612. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  22613. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  22614. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  22615. */
  22616. var VirtualJoysticksCamera = /** @class */ (function (_super) {
  22617. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualJoysticksCamera, _super);
  22618. /**
  22619. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  22620. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  22621. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  22622. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  22623. * @param name Define the name of the camera in the scene
  22624. * @param position Define the start position of the camera in the scene
  22625. * @param scene Define the scene the camera belongs to
  22626. */
  22627. function VirtualJoysticksCamera(name, position, scene) {
  22628. var _this = _super.call(this, name, position, scene) || this;
  22629. _this.inputs.addVirtualJoystick();
  22630. return _this;
  22631. }
  22632. /**
  22633. * Gets the current object class name.
  22634. * @return the class name
  22635. */
  22636. VirtualJoysticksCamera.prototype.getClassName = function () {
  22637. return "VirtualJoysticksCamera";
  22638. };
  22639. return VirtualJoysticksCamera;
  22640. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  22641. /***/ }),
  22642. /***/ "./Collisions/collider.ts":
  22643. /*!********************************!*\
  22644. !*** ./Collisions/collider.ts ***!
  22645. \********************************/
  22646. /*! exports provided: Collider */
  22647. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22648. "use strict";
  22649. __webpack_require__.r(__webpack_exports__);
  22650. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return Collider; });
  22651. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22652. var intersectBoxAASphere = function (boxMin, boxMax, sphereCenter, sphereRadius) {
  22653. if (boxMin.x > sphereCenter.x + sphereRadius) {
  22654. return false;
  22655. }
  22656. if (sphereCenter.x - sphereRadius > boxMax.x) {
  22657. return false;
  22658. }
  22659. if (boxMin.y > sphereCenter.y + sphereRadius) {
  22660. return false;
  22661. }
  22662. if (sphereCenter.y - sphereRadius > boxMax.y) {
  22663. return false;
  22664. }
  22665. if (boxMin.z > sphereCenter.z + sphereRadius) {
  22666. return false;
  22667. }
  22668. if (sphereCenter.z - sphereRadius > boxMax.z) {
  22669. return false;
  22670. }
  22671. return true;
  22672. };
  22673. var getLowestRoot = (function () {
  22674. var result = { root: 0, found: false };
  22675. return function (a, b, c, maxR) {
  22676. result.root = 0;
  22677. result.found = false;
  22678. var determinant = b * b - 4.0 * a * c;
  22679. if (determinant < 0) {
  22680. return result;
  22681. }
  22682. var sqrtD = Math.sqrt(determinant);
  22683. var r1 = (-b - sqrtD) / (2.0 * a);
  22684. var r2 = (-b + sqrtD) / (2.0 * a);
  22685. if (r1 > r2) {
  22686. var temp = r2;
  22687. r2 = r1;
  22688. r1 = temp;
  22689. }
  22690. if (r1 > 0 && r1 < maxR) {
  22691. result.root = r1;
  22692. result.found = true;
  22693. return result;
  22694. }
  22695. if (r2 > 0 && r2 < maxR) {
  22696. result.root = r2;
  22697. result.found = true;
  22698. return result;
  22699. }
  22700. return result;
  22701. };
  22702. })();
  22703. /** @hidden */
  22704. var Collider = /** @class */ (function () {
  22705. function Collider() {
  22706. this._collisionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22707. this._planeIntersectionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22708. this._tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22709. this._tempVector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22710. this._tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22711. this._tempVector4 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22712. this._edge = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22713. this._baseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22714. this._destinationPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22715. this._slidePlaneNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22716. this._displacementVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22717. /** @hidden */
  22718. this._radius = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  22719. /** @hidden */
  22720. this._retry = 0;
  22721. /** @hidden */
  22722. this._basePointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22723. this._velocityWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22724. this._normalizedVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22725. this._collisionMask = -1;
  22726. }
  22727. Object.defineProperty(Collider.prototype, "collisionMask", {
  22728. get: function () {
  22729. return this._collisionMask;
  22730. },
  22731. set: function (mask) {
  22732. this._collisionMask = !isNaN(mask) ? mask : -1;
  22733. },
  22734. enumerable: true,
  22735. configurable: true
  22736. });
  22737. Object.defineProperty(Collider.prototype, "slidePlaneNormal", {
  22738. /**
  22739. * Gets the plane normal used to compute the sliding response (in local space)
  22740. */
  22741. get: function () {
  22742. return this._slidePlaneNormal;
  22743. },
  22744. enumerable: true,
  22745. configurable: true
  22746. });
  22747. // Methods
  22748. /** @hidden */
  22749. Collider.prototype._initialize = function (source, dir, e) {
  22750. this._velocity = dir;
  22751. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].NormalizeToRef(dir, this._normalizedVelocity);
  22752. this._basePoint = source;
  22753. source.multiplyToRef(this._radius, this._basePointWorld);
  22754. dir.multiplyToRef(this._radius, this._velocityWorld);
  22755. this._velocityWorldLength = this._velocityWorld.length();
  22756. this._epsilon = e;
  22757. this.collisionFound = false;
  22758. };
  22759. /** @hidden */
  22760. Collider.prototype._checkPointInTriangle = function (point, pa, pb, pc, n) {
  22761. pa.subtractToRef(point, this._tempVector);
  22762. pb.subtractToRef(point, this._tempVector2);
  22763. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
  22764. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  22765. if (d < 0) {
  22766. return false;
  22767. }
  22768. pc.subtractToRef(point, this._tempVector3);
  22769. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4);
  22770. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  22771. if (d < 0) {
  22772. return false;
  22773. }
  22774. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector3, this._tempVector, this._tempVector4);
  22775. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  22776. return d >= 0;
  22777. };
  22778. /** @hidden */
  22779. Collider.prototype._canDoCollision = function (sphereCenter, sphereRadius, vecMin, vecMax) {
  22780. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._basePointWorld, sphereCenter);
  22781. var max = Math.max(this._radius.x, this._radius.y, this._radius.z);
  22782. if (distance > this._velocityWorldLength + max + sphereRadius) {
  22783. return false;
  22784. }
  22785. if (!intersectBoxAASphere(vecMin, vecMax, this._basePointWorld, this._velocityWorldLength + max)) {
  22786. return false;
  22787. }
  22788. return true;
  22789. };
  22790. /** @hidden */
  22791. Collider.prototype._testTriangle = function (faceIndex, trianglePlaneArray, p1, p2, p3, hasMaterial) {
  22792. var t0;
  22793. var embeddedInPlane = false;
  22794. //defensive programming, actually not needed.
  22795. if (!trianglePlaneArray) {
  22796. trianglePlaneArray = [];
  22797. }
  22798. if (!trianglePlaneArray[faceIndex]) {
  22799. trianglePlaneArray[faceIndex] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"](0, 0, 0, 0);
  22800. trianglePlaneArray[faceIndex].copyFromPoints(p1, p2, p3);
  22801. }
  22802. var trianglePlane = trianglePlaneArray[faceIndex];
  22803. if ((!hasMaterial) && !trianglePlane.isFrontFacingTo(this._normalizedVelocity, 0)) {
  22804. return;
  22805. }
  22806. var signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this._basePoint);
  22807. var normalDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(trianglePlane.normal, this._velocity);
  22808. if (normalDotVelocity == 0) {
  22809. if (Math.abs(signedDistToTrianglePlane) >= 1.0) {
  22810. return;
  22811. }
  22812. embeddedInPlane = true;
  22813. t0 = 0;
  22814. }
  22815. else {
  22816. t0 = (-1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  22817. var t1 = (1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  22818. if (t0 > t1) {
  22819. var temp = t1;
  22820. t1 = t0;
  22821. t0 = temp;
  22822. }
  22823. if (t0 > 1.0 || t1 < 0.0) {
  22824. return;
  22825. }
  22826. if (t0 < 0) {
  22827. t0 = 0;
  22828. }
  22829. if (t0 > 1.0) {
  22830. t0 = 1.0;
  22831. }
  22832. }
  22833. this._collisionPoint.copyFromFloats(0, 0, 0);
  22834. var found = false;
  22835. var t = 1.0;
  22836. if (!embeddedInPlane) {
  22837. this._basePoint.subtractToRef(trianglePlane.normal, this._planeIntersectionPoint);
  22838. this._velocity.scaleToRef(t0, this._tempVector);
  22839. this._planeIntersectionPoint.addInPlace(this._tempVector);
  22840. if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, trianglePlane.normal)) {
  22841. found = true;
  22842. t = t0;
  22843. this._collisionPoint.copyFrom(this._planeIntersectionPoint);
  22844. }
  22845. }
  22846. if (!found) {
  22847. var velocitySquaredLength = this._velocity.lengthSquared();
  22848. var a = velocitySquaredLength;
  22849. this._basePoint.subtractToRef(p1, this._tempVector);
  22850. var b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  22851. var c = this._tempVector.lengthSquared() - 1.0;
  22852. var lowestRoot = getLowestRoot(a, b, c, t);
  22853. if (lowestRoot.found) {
  22854. t = lowestRoot.root;
  22855. found = true;
  22856. this._collisionPoint.copyFrom(p1);
  22857. }
  22858. this._basePoint.subtractToRef(p2, this._tempVector);
  22859. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  22860. c = this._tempVector.lengthSquared() - 1.0;
  22861. lowestRoot = getLowestRoot(a, b, c, t);
  22862. if (lowestRoot.found) {
  22863. t = lowestRoot.root;
  22864. found = true;
  22865. this._collisionPoint.copyFrom(p2);
  22866. }
  22867. this._basePoint.subtractToRef(p3, this._tempVector);
  22868. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  22869. c = this._tempVector.lengthSquared() - 1.0;
  22870. lowestRoot = getLowestRoot(a, b, c, t);
  22871. if (lowestRoot.found) {
  22872. t = lowestRoot.root;
  22873. found = true;
  22874. this._collisionPoint.copyFrom(p3);
  22875. }
  22876. p2.subtractToRef(p1, this._edge);
  22877. p1.subtractToRef(this._basePoint, this._baseToVertex);
  22878. var edgeSquaredLength = this._edge.lengthSquared();
  22879. var edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  22880. var edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  22881. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  22882. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  22883. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  22884. lowestRoot = getLowestRoot(a, b, c, t);
  22885. if (lowestRoot.found) {
  22886. var f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  22887. if (f >= 0.0 && f <= 1.0) {
  22888. t = lowestRoot.root;
  22889. found = true;
  22890. this._edge.scaleInPlace(f);
  22891. p1.addToRef(this._edge, this._collisionPoint);
  22892. }
  22893. }
  22894. p3.subtractToRef(p2, this._edge);
  22895. p2.subtractToRef(this._basePoint, this._baseToVertex);
  22896. edgeSquaredLength = this._edge.lengthSquared();
  22897. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  22898. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  22899. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  22900. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  22901. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  22902. lowestRoot = getLowestRoot(a, b, c, t);
  22903. if (lowestRoot.found) {
  22904. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  22905. if (f >= 0.0 && f <= 1.0) {
  22906. t = lowestRoot.root;
  22907. found = true;
  22908. this._edge.scaleInPlace(f);
  22909. p2.addToRef(this._edge, this._collisionPoint);
  22910. }
  22911. }
  22912. p1.subtractToRef(p3, this._edge);
  22913. p3.subtractToRef(this._basePoint, this._baseToVertex);
  22914. edgeSquaredLength = this._edge.lengthSquared();
  22915. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  22916. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  22917. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  22918. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  22919. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  22920. lowestRoot = getLowestRoot(a, b, c, t);
  22921. if (lowestRoot.found) {
  22922. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  22923. if (f >= 0.0 && f <= 1.0) {
  22924. t = lowestRoot.root;
  22925. found = true;
  22926. this._edge.scaleInPlace(f);
  22927. p3.addToRef(this._edge, this._collisionPoint);
  22928. }
  22929. }
  22930. }
  22931. if (found) {
  22932. var distToCollision = t * this._velocity.length();
  22933. if (!this.collisionFound || distToCollision < this._nearestDistance) {
  22934. if (!this.intersectionPoint) {
  22935. this.intersectionPoint = this._collisionPoint.clone();
  22936. }
  22937. else {
  22938. this.intersectionPoint.copyFrom(this._collisionPoint);
  22939. }
  22940. this._nearestDistance = distToCollision;
  22941. this.collisionFound = true;
  22942. }
  22943. }
  22944. };
  22945. /** @hidden */
  22946. Collider.prototype._collide = function (trianglePlaneArray, pts, indices, indexStart, indexEnd, decal, hasMaterial) {
  22947. for (var i = indexStart; i < indexEnd; i += 3) {
  22948. var p1 = pts[indices[i] - decal];
  22949. var p2 = pts[indices[i + 1] - decal];
  22950. var p3 = pts[indices[i + 2] - decal];
  22951. this._testTriangle(i, trianglePlaneArray, p3, p2, p1, hasMaterial);
  22952. }
  22953. };
  22954. /** @hidden */
  22955. Collider.prototype._getResponse = function (pos, vel) {
  22956. pos.addToRef(vel, this._destinationPoint);
  22957. vel.scaleInPlace((this._nearestDistance / vel.length()));
  22958. this._basePoint.addToRef(vel, pos);
  22959. pos.subtractToRef(this.intersectionPoint, this._slidePlaneNormal);
  22960. this._slidePlaneNormal.normalize();
  22961. this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector);
  22962. pos.addInPlace(this._displacementVector);
  22963. this.intersectionPoint.addInPlace(this._displacementVector);
  22964. this._slidePlaneNormal.scaleInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"].SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint));
  22965. this._destinationPoint.subtractInPlace(this._slidePlaneNormal);
  22966. this._destinationPoint.subtractToRef(this.intersectionPoint, vel);
  22967. };
  22968. return Collider;
  22969. }());
  22970. /***/ }),
  22971. /***/ "./Collisions/collisionCoordinator.ts":
  22972. /*!********************************************!*\
  22973. !*** ./Collisions/collisionCoordinator.ts ***!
  22974. \********************************************/
  22975. /*! exports provided: CollisionCoordinatorLegacy */
  22976. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22977. "use strict";
  22978. __webpack_require__.r(__webpack_exports__);
  22979. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CollisionCoordinatorLegacy", function() { return CollisionCoordinatorLegacy; });
  22980. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22981. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  22982. /** @hidden */
  22983. var CollisionCoordinatorLegacy = /** @class */ (function () {
  22984. function CollisionCoordinatorLegacy() {
  22985. this._scaledPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22986. this._scaledVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22987. this._finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  22988. }
  22989. CollisionCoordinatorLegacy.prototype.getNewPosition = function (position, displacement, collider, maximumRetry, excludedMesh, onNewPosition, collisionIndex) {
  22990. position.divideToRef(collider._radius, this._scaledPosition);
  22991. displacement.divideToRef(collider._radius, this._scaledVelocity);
  22992. collider.collidedMesh = null;
  22993. collider._retry = 0;
  22994. collider._initialVelocity = this._scaledVelocity;
  22995. collider._initialPosition = this._scaledPosition;
  22996. this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, this._finalPosition, excludedMesh);
  22997. this._finalPosition.multiplyInPlace(collider._radius);
  22998. //run the callback
  22999. onNewPosition(collisionIndex, this._finalPosition, collider.collidedMesh);
  23000. };
  23001. CollisionCoordinatorLegacy.prototype.init = function (scene) {
  23002. this._scene = scene;
  23003. };
  23004. CollisionCoordinatorLegacy.prototype.destroy = function () {
  23005. //Legacy need no destruction method.
  23006. };
  23007. //No update in legacy mode
  23008. CollisionCoordinatorLegacy.prototype.onMeshAdded = function (mesh) { };
  23009. CollisionCoordinatorLegacy.prototype.onMeshUpdated = function (mesh) { };
  23010. CollisionCoordinatorLegacy.prototype.onMeshRemoved = function (mesh) { };
  23011. CollisionCoordinatorLegacy.prototype.onGeometryAdded = function (geometry) { };
  23012. CollisionCoordinatorLegacy.prototype.onGeometryUpdated = function (geometry) { };
  23013. CollisionCoordinatorLegacy.prototype.onGeometryDeleted = function (geometry) { };
  23014. CollisionCoordinatorLegacy.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
  23015. if (excludedMesh === void 0) { excludedMesh = null; }
  23016. var closeDistance = _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].CollisionsEpsilon * 10.0;
  23017. if (collider._retry >= maximumRetry) {
  23018. finalPosition.copyFrom(position);
  23019. return;
  23020. }
  23021. // Check if this is a mesh else camera or -1
  23022. var collisionMask = (excludedMesh ? excludedMesh.collisionMask : collider.collisionMask);
  23023. collider._initialize(position, velocity, closeDistance);
  23024. // Check all meshes
  23025. for (var index = 0; index < this._scene.meshes.length; index++) {
  23026. var mesh = this._scene.meshes[index];
  23027. if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh && ((collisionMask & mesh.collisionGroup) !== 0)) {
  23028. mesh._checkCollision(collider);
  23029. }
  23030. }
  23031. if (!collider.collisionFound) {
  23032. position.addToRef(velocity, finalPosition);
  23033. return;
  23034. }
  23035. if (velocity.x !== 0 || velocity.y !== 0 || velocity.z !== 0) {
  23036. collider._getResponse(position, velocity);
  23037. }
  23038. if (velocity.length() <= closeDistance) {
  23039. finalPosition.copyFrom(position);
  23040. return;
  23041. }
  23042. collider._retry++;
  23043. this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
  23044. };
  23045. return CollisionCoordinatorLegacy;
  23046. }());
  23047. /***/ }),
  23048. /***/ "./Collisions/index.ts":
  23049. /*!*****************************!*\
  23050. !*** ./Collisions/index.ts ***!
  23051. \*****************************/
  23052. /*! exports provided: Collider, CollisionCoordinatorLegacy, PickingInfo, IntersectionInfo */
  23053. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23054. "use strict";
  23055. __webpack_require__.r(__webpack_exports__);
  23056. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  23057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _collider__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  23058. /* harmony import */ var _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./collisionCoordinator */ "./Collisions/collisionCoordinator.ts");
  23059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CollisionCoordinatorLegacy", function() { return _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__["CollisionCoordinatorLegacy"]; });
  23060. /* harmony import */ var _pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pickingInfo */ "./Collisions/pickingInfo.ts");
  23061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]; });
  23062. /* harmony import */ var _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./intersectionInfo */ "./Collisions/intersectionInfo.ts");
  23063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"]; });
  23064. /***/ }),
  23065. /***/ "./Collisions/intersectionInfo.ts":
  23066. /*!****************************************!*\
  23067. !*** ./Collisions/intersectionInfo.ts ***!
  23068. \****************************************/
  23069. /*! exports provided: IntersectionInfo */
  23070. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23071. "use strict";
  23072. __webpack_require__.r(__webpack_exports__);
  23073. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return IntersectionInfo; });
  23074. /**
  23075. * @hidden
  23076. */
  23077. var IntersectionInfo = /** @class */ (function () {
  23078. function IntersectionInfo(bu, bv, distance) {
  23079. this.bu = bu;
  23080. this.bv = bv;
  23081. this.distance = distance;
  23082. this.faceId = 0;
  23083. this.subMeshId = 0;
  23084. }
  23085. return IntersectionInfo;
  23086. }());
  23087. /***/ }),
  23088. /***/ "./Collisions/pickingInfo.ts":
  23089. /*!***********************************!*\
  23090. !*** ./Collisions/pickingInfo.ts ***!
  23091. \***********************************/
  23092. /*! exports provided: PickingInfo */
  23093. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23094. "use strict";
  23095. __webpack_require__.r(__webpack_exports__);
  23096. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return PickingInfo; });
  23097. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23098. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  23099. /**
  23100. * Information about the result of picking within a scene
  23101. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  23102. */
  23103. var PickingInfo = /** @class */ (function () {
  23104. function PickingInfo() {
  23105. /**
  23106. * If the pick collided with an object
  23107. */
  23108. this.hit = false;
  23109. /**
  23110. * Distance away where the pick collided
  23111. */
  23112. this.distance = 0;
  23113. /**
  23114. * The location of pick collision
  23115. */
  23116. this.pickedPoint = null;
  23117. /**
  23118. * The mesh corresponding the the pick collision
  23119. */
  23120. this.pickedMesh = null;
  23121. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  23122. this.bu = 0;
  23123. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  23124. this.bv = 0;
  23125. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23126. this.faceId = -1;
  23127. /** Id of the the submesh that was picked */
  23128. this.subMeshId = 0;
  23129. /** If a sprite was picked, this will be the sprite the pick collided with */
  23130. this.pickedSprite = null;
  23131. /**
  23132. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  23133. */
  23134. this.originMesh = null;
  23135. /**
  23136. * The ray that was used to perform the picking.
  23137. */
  23138. this.ray = null;
  23139. }
  23140. /**
  23141. * Gets the normal correspodning to the face the pick collided with
  23142. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  23143. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  23144. * @returns The normal correspodning to the face the pick collided with
  23145. */
  23146. PickingInfo.prototype.getNormal = function (useWorldCoordinates, useVerticesNormals) {
  23147. if (useWorldCoordinates === void 0) { useWorldCoordinates = false; }
  23148. if (useVerticesNormals === void 0) { useVerticesNormals = true; }
  23149. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  23150. return null;
  23151. }
  23152. var indices = this.pickedMesh.getIndices();
  23153. if (!indices) {
  23154. return null;
  23155. }
  23156. var result;
  23157. if (useVerticesNormals) {
  23158. var normals = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  23159. var normal0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3] * 3);
  23160. var normal1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 1] * 3);
  23161. var normal2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 2] * 3);
  23162. normal0 = normal0.scale(this.bu);
  23163. normal1 = normal1.scale(this.bv);
  23164. normal2 = normal2.scale(1.0 - this.bu - this.bv);
  23165. 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);
  23166. }
  23167. else {
  23168. var positions = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  23169. var vertex1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3] * 3);
  23170. var vertex2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 1] * 3);
  23171. var vertex3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 2] * 3);
  23172. var p1p2 = vertex1.subtract(vertex2);
  23173. var p3p2 = vertex3.subtract(vertex2);
  23174. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(p1p2, p3p2);
  23175. }
  23176. if (useWorldCoordinates) {
  23177. var wm = this.pickedMesh.getWorldMatrix();
  23178. if (this.pickedMesh.nonUniformScaling) {
  23179. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0].copyFrom(wm);
  23180. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  23181. wm.setTranslationFromFloats(0, 0, 0);
  23182. wm.invert();
  23183. wm.transposeToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1]);
  23184. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  23185. }
  23186. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result, wm);
  23187. }
  23188. result.normalize();
  23189. return result;
  23190. };
  23191. /**
  23192. * Gets the texture coordinates of where the pick occured
  23193. * @returns the vector containing the coordnates of the texture
  23194. */
  23195. PickingInfo.prototype.getTextureCoordinates = function () {
  23196. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  23197. return null;
  23198. }
  23199. var indices = this.pickedMesh.getIndices();
  23200. if (!indices) {
  23201. return null;
  23202. }
  23203. var uvs = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  23204. if (!uvs) {
  23205. return null;
  23206. }
  23207. var uv0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3] * 2);
  23208. var uv1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
  23209. var uv2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
  23210. uv0 = uv0.scale(1.0 - this.bu - this.bv);
  23211. uv1 = uv1.scale(this.bu);
  23212. uv2 = uv2.scale(this.bv);
  23213. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
  23214. };
  23215. return PickingInfo;
  23216. }());
  23217. /***/ }),
  23218. /***/ "./Culling/Octrees/index.ts":
  23219. /*!**********************************!*\
  23220. !*** ./Culling/Octrees/index.ts ***!
  23221. \**********************************/
  23222. /*! exports provided: Octree, OctreeBlock, OctreeSceneComponent */
  23223. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23224. "use strict";
  23225. __webpack_require__.r(__webpack_exports__);
  23226. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  23227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _octree__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  23228. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  23229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]; });
  23230. /* harmony import */ var _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./octreeSceneComponent */ "./Culling/Octrees/octreeSceneComponent.ts");
  23231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__["OctreeSceneComponent"]; });
  23232. /***/ }),
  23233. /***/ "./Culling/Octrees/octree.ts":
  23234. /*!***********************************!*\
  23235. !*** ./Culling/Octrees/octree.ts ***!
  23236. \***********************************/
  23237. /*! exports provided: Octree */
  23238. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23239. "use strict";
  23240. __webpack_require__.r(__webpack_exports__);
  23241. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return Octree; });
  23242. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  23243. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  23244. /**
  23245. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  23246. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23247. */
  23248. var Octree = /** @class */ (function () {
  23249. /**
  23250. * Creates a octree
  23251. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23252. * @param creationFunc function to be used to instatiate the octree
  23253. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  23254. * @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.)
  23255. */
  23256. function Octree(creationFunc, maxBlockCapacity,
  23257. /** 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.) */
  23258. maxDepth) {
  23259. if (maxDepth === void 0) { maxDepth = 2; }
  23260. this.maxDepth = maxDepth;
  23261. /**
  23262. * Content stored in the octree
  23263. */
  23264. this.dynamicContent = new Array();
  23265. this._maxBlockCapacity = maxBlockCapacity || 64;
  23266. this._selectionContent = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"](1024);
  23267. this._creationFunc = creationFunc;
  23268. }
  23269. // Methods
  23270. /**
  23271. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  23272. * @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);
  23273. * @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);
  23274. * @param entries meshes to be added to the octree blocks
  23275. */
  23276. Octree.prototype.update = function (worldMin, worldMax, entries) {
  23277. _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]._CreateBlocks(worldMin, worldMax, entries, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);
  23278. };
  23279. /**
  23280. * Adds a mesh to the octree
  23281. * @param entry Mesh to add to the octree
  23282. */
  23283. Octree.prototype.addMesh = function (entry) {
  23284. for (var index = 0; index < this.blocks.length; index++) {
  23285. var block = this.blocks[index];
  23286. block.addEntry(entry);
  23287. }
  23288. };
  23289. /**
  23290. * Remove an element from the octree
  23291. * @param entry defines the element to remove
  23292. */
  23293. Octree.prototype.removeMesh = function (entry) {
  23294. for (var index = 0; index < this.blocks.length; index++) {
  23295. var block = this.blocks[index];
  23296. block.removeEntry(entry);
  23297. }
  23298. };
  23299. /**
  23300. * Selects an array of meshes within the frustum
  23301. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  23302. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  23303. * @returns array of meshes within the frustum
  23304. */
  23305. Octree.prototype.select = function (frustumPlanes, allowDuplicate) {
  23306. this._selectionContent.reset();
  23307. for (var index = 0; index < this.blocks.length; index++) {
  23308. var block = this.blocks[index];
  23309. block.select(frustumPlanes, this._selectionContent, allowDuplicate);
  23310. }
  23311. if (allowDuplicate) {
  23312. this._selectionContent.concat(this.dynamicContent);
  23313. }
  23314. else {
  23315. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23316. }
  23317. return this._selectionContent;
  23318. };
  23319. /**
  23320. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  23321. * @param sphereCenter defines the bounding sphere center
  23322. * @param sphereRadius defines the bounding sphere radius
  23323. * @param allowDuplicate defines if the selection array can contains duplicated entries
  23324. * @returns an array of objects that intersect the sphere
  23325. */
  23326. Octree.prototype.intersects = function (sphereCenter, sphereRadius, allowDuplicate) {
  23327. this._selectionContent.reset();
  23328. for (var index = 0; index < this.blocks.length; index++) {
  23329. var block = this.blocks[index];
  23330. block.intersects(sphereCenter, sphereRadius, this._selectionContent, allowDuplicate);
  23331. }
  23332. if (allowDuplicate) {
  23333. this._selectionContent.concat(this.dynamicContent);
  23334. }
  23335. else {
  23336. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23337. }
  23338. return this._selectionContent;
  23339. };
  23340. /**
  23341. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  23342. * @param ray defines the ray to test with
  23343. * @returns array of intersected objects
  23344. */
  23345. Octree.prototype.intersectsRay = function (ray) {
  23346. this._selectionContent.reset();
  23347. for (var index = 0; index < this.blocks.length; index++) {
  23348. var block = this.blocks[index];
  23349. block.intersectsRay(ray, this._selectionContent);
  23350. }
  23351. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23352. return this._selectionContent;
  23353. };
  23354. /**
  23355. * Adds a mesh into the octree block if it intersects the block
  23356. */
  23357. Octree.CreationFuncForMeshes = function (entry, block) {
  23358. var boundingInfo = entry.getBoundingInfo();
  23359. if (!entry.isBlocked && boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  23360. block.entries.push(entry);
  23361. }
  23362. };
  23363. /**
  23364. * Adds a submesh into the octree block if it intersects the block
  23365. */
  23366. Octree.CreationFuncForSubMeshes = function (entry, block) {
  23367. var boundingInfo = entry.getBoundingInfo();
  23368. if (boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  23369. block.entries.push(entry);
  23370. }
  23371. };
  23372. return Octree;
  23373. }());
  23374. /***/ }),
  23375. /***/ "./Culling/Octrees/octreeBlock.ts":
  23376. /*!****************************************!*\
  23377. !*** ./Culling/Octrees/octreeBlock.ts ***!
  23378. \****************************************/
  23379. /*! exports provided: OctreeBlock */
  23380. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23381. "use strict";
  23382. __webpack_require__.r(__webpack_exports__);
  23383. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return OctreeBlock; });
  23384. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  23385. /* harmony import */ var _Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Culling/boundingBox */ "./Culling/boundingBox.ts");
  23386. /**
  23387. * Class used to store a cell in an octree
  23388. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23389. */
  23390. var OctreeBlock = /** @class */ (function () {
  23391. /**
  23392. * Creates a new block
  23393. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  23394. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  23395. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  23396. * @param depth defines the current depth of this block in the octree
  23397. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  23398. * @param creationFunc defines a callback to call when an element is added to the block
  23399. */
  23400. function OctreeBlock(minPoint, maxPoint, capacity, depth, maxDepth, creationFunc) {
  23401. /**
  23402. * Gets the content of the current block
  23403. */
  23404. this.entries = new Array();
  23405. this._boundingVectors = new Array();
  23406. this._capacity = capacity;
  23407. this._depth = depth;
  23408. this._maxDepth = maxDepth;
  23409. this._creationFunc = creationFunc;
  23410. this._minPoint = minPoint;
  23411. this._maxPoint = maxPoint;
  23412. this._boundingVectors.push(minPoint.clone());
  23413. this._boundingVectors.push(maxPoint.clone());
  23414. this._boundingVectors.push(minPoint.clone());
  23415. this._boundingVectors[2].x = maxPoint.x;
  23416. this._boundingVectors.push(minPoint.clone());
  23417. this._boundingVectors[3].y = maxPoint.y;
  23418. this._boundingVectors.push(minPoint.clone());
  23419. this._boundingVectors[4].z = maxPoint.z;
  23420. this._boundingVectors.push(maxPoint.clone());
  23421. this._boundingVectors[5].z = minPoint.z;
  23422. this._boundingVectors.push(maxPoint.clone());
  23423. this._boundingVectors[6].x = minPoint.x;
  23424. this._boundingVectors.push(maxPoint.clone());
  23425. this._boundingVectors[7].y = minPoint.y;
  23426. }
  23427. Object.defineProperty(OctreeBlock.prototype, "capacity", {
  23428. // Property
  23429. /**
  23430. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  23431. */
  23432. get: function () {
  23433. return this._capacity;
  23434. },
  23435. enumerable: true,
  23436. configurable: true
  23437. });
  23438. Object.defineProperty(OctreeBlock.prototype, "minPoint", {
  23439. /**
  23440. * Gets the minimum vector (in world space) of the block's bounding box
  23441. */
  23442. get: function () {
  23443. return this._minPoint;
  23444. },
  23445. enumerable: true,
  23446. configurable: true
  23447. });
  23448. Object.defineProperty(OctreeBlock.prototype, "maxPoint", {
  23449. /**
  23450. * Gets the maximum vector (in world space) of the block's bounding box
  23451. */
  23452. get: function () {
  23453. return this._maxPoint;
  23454. },
  23455. enumerable: true,
  23456. configurable: true
  23457. });
  23458. // Methods
  23459. /**
  23460. * Add a new element to this block
  23461. * @param entry defines the element to add
  23462. */
  23463. OctreeBlock.prototype.addEntry = function (entry) {
  23464. if (this.blocks) {
  23465. for (var index = 0; index < this.blocks.length; index++) {
  23466. var block = this.blocks[index];
  23467. block.addEntry(entry);
  23468. }
  23469. return;
  23470. }
  23471. this._creationFunc(entry, this);
  23472. if (this.entries.length > this.capacity && this._depth < this._maxDepth) {
  23473. this.createInnerBlocks();
  23474. }
  23475. };
  23476. /**
  23477. * Remove an element from this block
  23478. * @param entry defines the element to remove
  23479. */
  23480. OctreeBlock.prototype.removeEntry = function (entry) {
  23481. if (this.blocks) {
  23482. for (var index = 0; index < this.blocks.length; index++) {
  23483. var block = this.blocks[index];
  23484. block.removeEntry(entry);
  23485. }
  23486. return;
  23487. }
  23488. var entryIndex = this.entries.indexOf(entry);
  23489. if (entryIndex > -1) {
  23490. this.entries.splice(entryIndex, 1);
  23491. }
  23492. };
  23493. /**
  23494. * Add an array of elements to this block
  23495. * @param entries defines the array of elements to add
  23496. */
  23497. OctreeBlock.prototype.addEntries = function (entries) {
  23498. for (var index = 0; index < entries.length; index++) {
  23499. var mesh = entries[index];
  23500. this.addEntry(mesh);
  23501. }
  23502. };
  23503. /**
  23504. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  23505. * @param frustumPlanes defines the frustum planes to test
  23506. * @param selection defines the array to store current content if selection is positive
  23507. * @param allowDuplicate defines if the selection array can contains duplicated entries
  23508. */
  23509. OctreeBlock.prototype.select = function (frustumPlanes, selection, allowDuplicate) {
  23510. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IsInFrustum(this._boundingVectors, frustumPlanes)) {
  23511. if (this.blocks) {
  23512. for (var index = 0; index < this.blocks.length; index++) {
  23513. var block = this.blocks[index];
  23514. block.select(frustumPlanes, selection, allowDuplicate);
  23515. }
  23516. return;
  23517. }
  23518. if (allowDuplicate) {
  23519. selection.concat(this.entries);
  23520. }
  23521. else {
  23522. selection.concatWithNoDuplicate(this.entries);
  23523. }
  23524. }
  23525. };
  23526. /**
  23527. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  23528. * @param sphereCenter defines the bounding sphere center
  23529. * @param sphereRadius defines the bounding sphere radius
  23530. * @param selection defines the array to store current content if selection is positive
  23531. * @param allowDuplicate defines if the selection array can contains duplicated entries
  23532. */
  23533. OctreeBlock.prototype.intersects = function (sphereCenter, sphereRadius, selection, allowDuplicate) {
  23534. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IntersectsSphere(this._minPoint, this._maxPoint, sphereCenter, sphereRadius)) {
  23535. if (this.blocks) {
  23536. for (var index = 0; index < this.blocks.length; index++) {
  23537. var block = this.blocks[index];
  23538. block.intersects(sphereCenter, sphereRadius, selection, allowDuplicate);
  23539. }
  23540. return;
  23541. }
  23542. if (allowDuplicate) {
  23543. selection.concat(this.entries);
  23544. }
  23545. else {
  23546. selection.concatWithNoDuplicate(this.entries);
  23547. }
  23548. }
  23549. };
  23550. /**
  23551. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  23552. * @param ray defines the ray to test with
  23553. * @param selection defines the array to store current content if selection is positive
  23554. */
  23555. OctreeBlock.prototype.intersectsRay = function (ray, selection) {
  23556. if (ray.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
  23557. if (this.blocks) {
  23558. for (var index = 0; index < this.blocks.length; index++) {
  23559. var block = this.blocks[index];
  23560. block.intersectsRay(ray, selection);
  23561. }
  23562. return;
  23563. }
  23564. selection.concatWithNoDuplicate(this.entries);
  23565. }
  23566. };
  23567. /**
  23568. * Subdivide the content into child blocks (this block will then be empty)
  23569. */
  23570. OctreeBlock.prototype.createInnerBlocks = function () {
  23571. OctreeBlock._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc);
  23572. };
  23573. /**
  23574. * @hidden
  23575. */
  23576. OctreeBlock._CreateBlocks = function (worldMin, worldMax, entries, maxBlockCapacity, currentDepth, maxDepth, target, creationFunc) {
  23577. target.blocks = new Array();
  23578. 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);
  23579. // Segmenting space
  23580. for (var x = 0; x < 2; x++) {
  23581. for (var y = 0; y < 2; y++) {
  23582. for (var z = 0; z < 2; z++) {
  23583. var localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z));
  23584. var localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1));
  23585. var block = new OctreeBlock(localMin, localMax, maxBlockCapacity, currentDepth + 1, maxDepth, creationFunc);
  23586. block.addEntries(entries);
  23587. target.blocks.push(block);
  23588. }
  23589. }
  23590. }
  23591. };
  23592. return OctreeBlock;
  23593. }());
  23594. /***/ }),
  23595. /***/ "./Culling/Octrees/octreeSceneComponent.ts":
  23596. /*!*************************************************!*\
  23597. !*** ./Culling/Octrees/octreeSceneComponent.ts ***!
  23598. \*************************************************/
  23599. /*! exports provided: OctreeSceneComponent */
  23600. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23601. "use strict";
  23602. __webpack_require__.r(__webpack_exports__);
  23603. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return OctreeSceneComponent; });
  23604. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  23605. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  23606. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  23607. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  23608. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  23609. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  23610. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.createOrUpdateSelectionOctree = function (maxCapacity, maxDepth) {
  23611. if (maxCapacity === void 0) { maxCapacity = 64; }
  23612. if (maxDepth === void 0) { maxDepth = 2; }
  23613. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  23614. if (!component) {
  23615. component = new OctreeSceneComponent(this);
  23616. this._addComponent(component);
  23617. }
  23618. if (!this._selectionOctree) {
  23619. this._selectionOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForMeshes, maxCapacity, maxDepth);
  23620. }
  23621. var worldExtends = this.getWorldExtends();
  23622. // Update octree
  23623. this._selectionOctree.update(worldExtends.min, worldExtends.max, this.meshes);
  23624. return this._selectionOctree;
  23625. };
  23626. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "selectionOctree", {
  23627. get: function () {
  23628. return this._selectionOctree;
  23629. },
  23630. enumerable: true,
  23631. configurable: true
  23632. });
  23633. /**
  23634. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  23635. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23636. * @param maxCapacity defines the maximum size of each block (64 by default)
  23637. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  23638. * @returns the new octree
  23639. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  23640. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23641. */
  23642. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.createOrUpdateSubmeshesOctree = function (maxCapacity, maxDepth) {
  23643. if (maxCapacity === void 0) { maxCapacity = 64; }
  23644. if (maxDepth === void 0) { maxDepth = 2; }
  23645. var scene = this.getScene();
  23646. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  23647. if (!component) {
  23648. component = new OctreeSceneComponent(scene);
  23649. scene._addComponent(component);
  23650. }
  23651. if (!this._submeshesOctree) {
  23652. this._submeshesOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForSubMeshes, maxCapacity, maxDepth);
  23653. }
  23654. this.computeWorldMatrix(true);
  23655. var boundingInfo = this.getBoundingInfo();
  23656. // Update octree
  23657. var bbox = boundingInfo.boundingBox;
  23658. this._submeshesOctree.update(bbox.minimumWorld, bbox.maximumWorld, this.subMeshes);
  23659. return this._submeshesOctree;
  23660. };
  23661. /**
  23662. * Defines the octree scene component responsible to manage any octrees
  23663. * in a given scene.
  23664. */
  23665. var OctreeSceneComponent = /** @class */ (function () {
  23666. /**
  23667. * Creates a new instance of the component for the given scene
  23668. * @param scene Defines the scene to register the component in
  23669. */
  23670. function OctreeSceneComponent(scene) {
  23671. /**
  23672. * The component name helpfull to identify the component in the list of scene components.
  23673. */
  23674. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE;
  23675. /**
  23676. * Indicates if the meshes have been checked to make sure they are isEnabled()
  23677. */
  23678. this.checksIsEnabled = true;
  23679. 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));
  23680. this.scene = scene;
  23681. this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this);
  23682. this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this);
  23683. this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this);
  23684. this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this);
  23685. }
  23686. /**
  23687. * Registers the component in a given scene
  23688. */
  23689. OctreeSceneComponent.prototype.register = function () {
  23690. var _this = this;
  23691. this.scene.onMeshRemovedObservable.add(function (mesh) {
  23692. var sceneOctree = _this.scene.selectionOctree;
  23693. if (sceneOctree !== undefined && sceneOctree !== null) {
  23694. var index = sceneOctree.dynamicContent.indexOf(mesh);
  23695. if (index !== -1) {
  23696. sceneOctree.dynamicContent.splice(index, 1);
  23697. }
  23698. }
  23699. });
  23700. this.scene.onMeshImportedObservable.add(function (mesh) {
  23701. var sceneOctree = _this.scene.selectionOctree;
  23702. if (sceneOctree !== undefined && sceneOctree !== null) {
  23703. sceneOctree.addMesh(mesh);
  23704. }
  23705. });
  23706. };
  23707. /**
  23708. * Return the list of active meshes
  23709. * @returns the list of active meshes
  23710. */
  23711. OctreeSceneComponent.prototype.getActiveMeshCandidates = function () {
  23712. if (this.scene._selectionOctree) {
  23713. var selection = this.scene._selectionOctree.select(this.scene.frustumPlanes);
  23714. return selection;
  23715. }
  23716. return this.scene._getDefaultMeshCandidates();
  23717. };
  23718. /**
  23719. * Return the list of active sub meshes
  23720. * @param mesh The mesh to get the candidates sub meshes from
  23721. * @returns the list of active sub meshes
  23722. */
  23723. OctreeSceneComponent.prototype.getActiveSubMeshCandidates = function (mesh) {
  23724. if (mesh._submeshesOctree && mesh.useOctreeForRenderingSelection) {
  23725. var intersections = mesh._submeshesOctree.select(this.scene.frustumPlanes);
  23726. return intersections;
  23727. }
  23728. return this.scene._getDefaultSubMeshCandidates(mesh);
  23729. };
  23730. /**
  23731. * Return the list of sub meshes intersecting with a given local ray
  23732. * @param mesh defines the mesh to find the submesh for
  23733. * @param localRay defines the ray in local space
  23734. * @returns the list of intersecting sub meshes
  23735. */
  23736. OctreeSceneComponent.prototype.getIntersectingSubMeshCandidates = function (mesh, localRay) {
  23737. if (mesh._submeshesOctree && mesh.useOctreeForPicking) {
  23738. _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"].TransformToRef(localRay, mesh.getWorldMatrix(), this._tempRay);
  23739. var intersections = mesh._submeshesOctree.intersectsRay(this._tempRay);
  23740. return intersections;
  23741. }
  23742. return this.scene._getDefaultSubMeshCandidates(mesh);
  23743. };
  23744. /**
  23745. * Return the list of sub meshes colliding with a collider
  23746. * @param mesh defines the mesh to find the submesh for
  23747. * @param collider defines the collider to evaluate the collision against
  23748. * @returns the list of colliding sub meshes
  23749. */
  23750. OctreeSceneComponent.prototype.getCollidingSubMeshCandidates = function (mesh, collider) {
  23751. if (mesh._submeshesOctree && mesh.useOctreeForCollisions) {
  23752. var radius = collider._velocityWorldLength + Math.max(collider._radius.x, collider._radius.y, collider._radius.z);
  23753. var intersections = mesh._submeshesOctree.intersects(collider._basePointWorld, radius);
  23754. return intersections;
  23755. }
  23756. return this.scene._getDefaultSubMeshCandidates(mesh);
  23757. };
  23758. /**
  23759. * Rebuilds the elements related to this component in case of
  23760. * context lost for instance.
  23761. */
  23762. OctreeSceneComponent.prototype.rebuild = function () {
  23763. // Nothing to do here.
  23764. };
  23765. /**
  23766. * Disposes the component and the associated ressources.
  23767. */
  23768. OctreeSceneComponent.prototype.dispose = function () {
  23769. // Nothing to do here.
  23770. };
  23771. return OctreeSceneComponent;
  23772. }());
  23773. /***/ }),
  23774. /***/ "./Culling/boundingBox.ts":
  23775. /*!********************************!*\
  23776. !*** ./Culling/boundingBox.ts ***!
  23777. \********************************/
  23778. /*! exports provided: BoundingBox */
  23779. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23780. "use strict";
  23781. __webpack_require__.r(__webpack_exports__);
  23782. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return BoundingBox; });
  23783. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  23784. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23785. /**
  23786. * Class used to store bounding box information
  23787. */
  23788. var BoundingBox = /** @class */ (function () {
  23789. /**
  23790. * Creates a new bounding box
  23791. * @param min defines the minimum vector (in local space)
  23792. * @param max defines the maximum vector (in local space)
  23793. * @param worldMatrix defines the new world matrix
  23794. */
  23795. function BoundingBox(min, max, worldMatrix) {
  23796. /**
  23797. * Gets the 8 vectors representing the bounding box in local space
  23798. */
  23799. this.vectors = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  23800. /**
  23801. * Gets the center of the bounding box in local space
  23802. */
  23803. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23804. /**
  23805. * Gets the center of the bounding box in world space
  23806. */
  23807. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23808. /**
  23809. * Gets the extend size in local space
  23810. */
  23811. this.extendSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23812. /**
  23813. * Gets the extend size in world space
  23814. */
  23815. this.extendSizeWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23816. /**
  23817. * Gets the OBB (object bounding box) directions
  23818. */
  23819. this.directions = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  23820. /**
  23821. * Gets the 8 vectors representing the bounding box in world space
  23822. */
  23823. this.vectorsWorld = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  23824. /**
  23825. * Gets the minimum vector in world space
  23826. */
  23827. this.minimumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23828. /**
  23829. * Gets the maximum vector in world space
  23830. */
  23831. this.maximumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23832. /**
  23833. * Gets the minimum vector in local space
  23834. */
  23835. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23836. /**
  23837. * Gets the maximum vector in local space
  23838. */
  23839. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23840. this.reConstruct(min, max, worldMatrix);
  23841. }
  23842. // Methods
  23843. /**
  23844. * Recreates the entire bounding box from scratch as if we call the constructor in place
  23845. * @param min defines the new minimum vector (in local space)
  23846. * @param max defines the new maximum vector (in local space)
  23847. * @param worldMatrix defines the new world matrix
  23848. */
  23849. BoundingBox.prototype.reConstruct = function (min, max, worldMatrix) {
  23850. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  23851. var vectors = this.vectors;
  23852. this.minimum.copyFromFloats(minX, minY, minZ);
  23853. this.maximum.copyFromFloats(maxX, maxY, maxZ);
  23854. vectors[0].copyFromFloats(minX, minY, minZ);
  23855. vectors[1].copyFromFloats(maxX, maxY, maxZ);
  23856. vectors[2].copyFromFloats(maxX, minY, minZ);
  23857. vectors[3].copyFromFloats(minX, maxY, minZ);
  23858. vectors[4].copyFromFloats(minX, minY, maxZ);
  23859. vectors[5].copyFromFloats(maxX, maxY, minZ);
  23860. vectors[6].copyFromFloats(minX, maxY, maxZ);
  23861. vectors[7].copyFromFloats(maxX, minY, maxZ);
  23862. // OBB
  23863. max.addToRef(min, this.center).scaleInPlace(0.5);
  23864. max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);
  23865. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  23866. };
  23867. /**
  23868. * Scale the current bounding box by applying a scale factor
  23869. * @param factor defines the scale factor to apply
  23870. * @returns the current bounding box
  23871. */
  23872. BoundingBox.prototype.scale = function (factor) {
  23873. var tmpVectors = BoundingBox.TmpVector3;
  23874. var diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);
  23875. var len = diff.length();
  23876. diff.normalizeFromLength(len);
  23877. var distance = len * factor;
  23878. var newRadius = diff.scaleInPlace(distance * 0.5);
  23879. var min = this.center.subtractToRef(newRadius, tmpVectors[1]);
  23880. var max = this.center.addToRef(newRadius, tmpVectors[2]);
  23881. this.reConstruct(min, max, this._worldMatrix);
  23882. return this;
  23883. };
  23884. /**
  23885. * Gets the world matrix of the bounding box
  23886. * @returns a matrix
  23887. */
  23888. BoundingBox.prototype.getWorldMatrix = function () {
  23889. return this._worldMatrix;
  23890. };
  23891. /** @hidden */
  23892. BoundingBox.prototype._update = function (world) {
  23893. var minWorld = this.minimumWorld;
  23894. var maxWorld = this.maximumWorld;
  23895. var directions = this.directions;
  23896. var vectorsWorld = this.vectorsWorld;
  23897. var vectors = this.vectors;
  23898. if (!world.isIdentity()) {
  23899. minWorld.setAll(Number.MAX_VALUE);
  23900. maxWorld.setAll(-Number.MAX_VALUE);
  23901. for (var index = 0; index < 8; ++index) {
  23902. var v = vectorsWorld[index];
  23903. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vectors[index], world, v);
  23904. minWorld.minimizeInPlace(v);
  23905. maxWorld.maximizeInPlace(v);
  23906. }
  23907. // Extend
  23908. maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);
  23909. maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);
  23910. }
  23911. else {
  23912. minWorld.copyFrom(this.minimum);
  23913. maxWorld.copyFrom(this.maximum);
  23914. for (var index = 0; index < 8; ++index) {
  23915. vectorsWorld[index].copyFrom(vectors[index]);
  23916. }
  23917. // Extend
  23918. this.extendSizeWorld.copyFrom(this.extendSize);
  23919. this.centerWorld.copyFrom(this.center);
  23920. }
  23921. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 0, directions[0]);
  23922. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 4, directions[1]);
  23923. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 8, directions[2]);
  23924. this._worldMatrix = world;
  23925. };
  23926. /**
  23927. * Tests if the bounding box is intersecting the frustum planes
  23928. * @param frustumPlanes defines the frustum planes to test
  23929. * @returns true if there is an intersection
  23930. */
  23931. BoundingBox.prototype.isInFrustum = function (frustumPlanes) {
  23932. return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);
  23933. };
  23934. /**
  23935. * Tests if the bounding box is entirely inside the frustum planes
  23936. * @param frustumPlanes defines the frustum planes to test
  23937. * @returns true if there is an inclusion
  23938. */
  23939. BoundingBox.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  23940. return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);
  23941. };
  23942. /**
  23943. * Tests if a point is inside the bounding box
  23944. * @param point defines the point to test
  23945. * @returns true if the point is inside the bounding box
  23946. */
  23947. BoundingBox.prototype.intersectsPoint = function (point) {
  23948. var min = this.minimumWorld;
  23949. var max = this.maximumWorld;
  23950. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  23951. var pointX = point.x, pointY = point.y, pointZ = point.z;
  23952. var delta = -_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"];
  23953. if (maxX - pointX < delta || delta > pointX - minX) {
  23954. return false;
  23955. }
  23956. if (maxY - pointY < delta || delta > pointY - minY) {
  23957. return false;
  23958. }
  23959. if (maxZ - pointZ < delta || delta > pointZ - minZ) {
  23960. return false;
  23961. }
  23962. return true;
  23963. };
  23964. /**
  23965. * Tests if the bounding box intersects with a bounding sphere
  23966. * @param sphere defines the sphere to test
  23967. * @returns true if there is an intersection
  23968. */
  23969. BoundingBox.prototype.intersectsSphere = function (sphere) {
  23970. return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);
  23971. };
  23972. /**
  23973. * Tests if the bounding box intersects with a box defined by a min and max vectors
  23974. * @param min defines the min vector to use
  23975. * @param max defines the max vector to use
  23976. * @returns true if there is an intersection
  23977. */
  23978. BoundingBox.prototype.intersectsMinMax = function (min, max) {
  23979. var myMin = this.minimumWorld;
  23980. var myMax = this.maximumWorld;
  23981. var myMinX = myMin.x, myMinY = myMin.y, myMinZ = myMin.z, myMaxX = myMax.x, myMaxY = myMax.y, myMaxZ = myMax.z;
  23982. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  23983. if (myMaxX < minX || myMinX > maxX) {
  23984. return false;
  23985. }
  23986. if (myMaxY < minY || myMinY > maxY) {
  23987. return false;
  23988. }
  23989. if (myMaxZ < minZ || myMinZ > maxZ) {
  23990. return false;
  23991. }
  23992. return true;
  23993. };
  23994. // Statics
  23995. /**
  23996. * Tests if two bounding boxes are intersections
  23997. * @param box0 defines the first box to test
  23998. * @param box1 defines the second box to test
  23999. * @returns true if there is an intersection
  24000. */
  24001. BoundingBox.Intersects = function (box0, box1) {
  24002. return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);
  24003. };
  24004. /**
  24005. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  24006. * @param minPoint defines the minimum vector of the bounding box
  24007. * @param maxPoint defines the maximum vector of the bounding box
  24008. * @param sphereCenter defines the sphere center
  24009. * @param sphereRadius defines the sphere radius
  24010. * @returns true if there is an intersection
  24011. */
  24012. BoundingBox.IntersectsSphere = function (minPoint, maxPoint, sphereCenter, sphereRadius) {
  24013. var vector = BoundingBox.TmpVector3[0];
  24014. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ClampToRef(sphereCenter, minPoint, maxPoint, vector);
  24015. var num = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphereCenter, vector);
  24016. return (num <= (sphereRadius * sphereRadius));
  24017. };
  24018. /**
  24019. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  24020. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  24021. * @param frustumPlanes defines the frustum planes to test
  24022. * @return true if there is an inclusion
  24023. */
  24024. BoundingBox.IsCompletelyInFrustum = function (boundingVectors, frustumPlanes) {
  24025. for (var p = 0; p < 6; ++p) {
  24026. var frustumPlane = frustumPlanes[p];
  24027. for (var i = 0; i < 8; ++i) {
  24028. if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {
  24029. return false;
  24030. }
  24031. }
  24032. }
  24033. return true;
  24034. };
  24035. /**
  24036. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  24037. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  24038. * @param frustumPlanes defines the frustum planes to test
  24039. * @return true if there is an intersection
  24040. */
  24041. BoundingBox.IsInFrustum = function (boundingVectors, frustumPlanes) {
  24042. for (var p = 0; p < 6; ++p) {
  24043. var canReturnFalse = true;
  24044. var frustumPlane = frustumPlanes[p];
  24045. for (var i = 0; i < 8; ++i) {
  24046. if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {
  24047. canReturnFalse = false;
  24048. break;
  24049. }
  24050. }
  24051. if (canReturnFalse) {
  24052. return false;
  24053. }
  24054. }
  24055. return true;
  24056. };
  24057. BoundingBox.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24058. return BoundingBox;
  24059. }());
  24060. /***/ }),
  24061. /***/ "./Culling/boundingInfo.ts":
  24062. /*!*********************************!*\
  24063. !*** ./Culling/boundingInfo.ts ***!
  24064. \*********************************/
  24065. /*! exports provided: BoundingInfo */
  24066. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24067. "use strict";
  24068. __webpack_require__.r(__webpack_exports__);
  24069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return BoundingInfo; });
  24070. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24071. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24072. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  24073. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  24074. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  24075. var _result0 = { min: 0, max: 0 };
  24076. var _result1 = { min: 0, max: 0 };
  24077. var computeBoxExtents = function (axis, box, result) {
  24078. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.centerWorld, axis);
  24079. var r0 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[0], axis)) * box.extendSize.x;
  24080. var r1 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[1], axis)) * box.extendSize.y;
  24081. var r2 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[2], axis)) * box.extendSize.z;
  24082. var r = r0 + r1 + r2;
  24083. result.min = p - r;
  24084. result.max = p + r;
  24085. };
  24086. var axisOverlap = function (axis, box0, box1) {
  24087. computeBoxExtents(axis, box0, _result0);
  24088. computeBoxExtents(axis, box1, _result1);
  24089. return !(_result0.min > _result1.max || _result1.min > _result0.max);
  24090. };
  24091. /**
  24092. * Info for a bounding data of a mesh
  24093. */
  24094. var BoundingInfo = /** @class */ (function () {
  24095. /**
  24096. * Constructs bounding info
  24097. * @param minimum min vector of the bounding box/sphere
  24098. * @param maximum max vector of the bounding box/sphere
  24099. * @param worldMatrix defines the new world matrix
  24100. */
  24101. function BoundingInfo(minimum, maximum, worldMatrix) {
  24102. this._isLocked = false;
  24103. this.boundingBox = new _boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"](minimum, maximum, worldMatrix);
  24104. this.boundingSphere = new _boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"](minimum, maximum, worldMatrix);
  24105. }
  24106. /**
  24107. * Recreates the entire bounding info from scratch as if we call the constructor in place
  24108. * @param min defines the new minimum vector (in local space)
  24109. * @param max defines the new maximum vector (in local space)
  24110. * @param worldMatrix defines the new world matrix
  24111. */
  24112. BoundingInfo.prototype.reConstruct = function (min, max, worldMatrix) {
  24113. this.boundingBox.reConstruct(min, max, worldMatrix);
  24114. this.boundingSphere.reConstruct(min, max, worldMatrix);
  24115. };
  24116. Object.defineProperty(BoundingInfo.prototype, "minimum", {
  24117. /**
  24118. * min vector of the bounding box/sphere
  24119. */
  24120. get: function () {
  24121. return this.boundingBox.minimum;
  24122. },
  24123. enumerable: true,
  24124. configurable: true
  24125. });
  24126. Object.defineProperty(BoundingInfo.prototype, "maximum", {
  24127. /**
  24128. * max vector of the bounding box/sphere
  24129. */
  24130. get: function () {
  24131. return this.boundingBox.maximum;
  24132. },
  24133. enumerable: true,
  24134. configurable: true
  24135. });
  24136. Object.defineProperty(BoundingInfo.prototype, "isLocked", {
  24137. /**
  24138. * If the info is locked and won't be updated to avoid perf overhead
  24139. */
  24140. get: function () {
  24141. return this._isLocked;
  24142. },
  24143. set: function (value) {
  24144. this._isLocked = value;
  24145. },
  24146. enumerable: true,
  24147. configurable: true
  24148. });
  24149. // Methods
  24150. /**
  24151. * Updates the bounding sphere and box
  24152. * @param world world matrix to be used to update
  24153. */
  24154. BoundingInfo.prototype.update = function (world) {
  24155. if (this._isLocked) {
  24156. return;
  24157. }
  24158. this.boundingBox._update(world);
  24159. this.boundingSphere._update(world);
  24160. };
  24161. /**
  24162. * Recreate the bounding info to be centered around a specific point given a specific extend.
  24163. * @param center New center of the bounding info
  24164. * @param extend New extend of the bounding info
  24165. * @returns the current bounding info
  24166. */
  24167. BoundingInfo.prototype.centerOn = function (center, extend) {
  24168. var minimum = BoundingInfo.TmpVector3[0].copyFrom(center).subtractInPlace(extend);
  24169. var maximum = BoundingInfo.TmpVector3[1].copyFrom(center).addInPlace(extend);
  24170. this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  24171. this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  24172. return this;
  24173. };
  24174. /**
  24175. * Scale the current bounding info by applying a scale factor
  24176. * @param factor defines the scale factor to apply
  24177. * @returns the current bounding info
  24178. */
  24179. BoundingInfo.prototype.scale = function (factor) {
  24180. this.boundingBox.scale(factor);
  24181. this.boundingSphere.scale(factor);
  24182. return this;
  24183. };
  24184. /**
  24185. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  24186. * @param frustumPlanes defines the frustum to test
  24187. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  24188. * @returns true if the bounding info is in the frustum planes
  24189. */
  24190. BoundingInfo.prototype.isInFrustum = function (frustumPlanes, strategy) {
  24191. if (strategy === void 0) { strategy = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD; }
  24192. 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);
  24193. if (inclusionTest) {
  24194. if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {
  24195. return true;
  24196. }
  24197. }
  24198. if (!this.boundingSphere.isInFrustum(frustumPlanes)) {
  24199. return false;
  24200. }
  24201. 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);
  24202. if (bSphereOnlyTest) {
  24203. return true;
  24204. }
  24205. return this.boundingBox.isInFrustum(frustumPlanes);
  24206. };
  24207. Object.defineProperty(BoundingInfo.prototype, "diagonalLength", {
  24208. /**
  24209. * Gets the world distance between the min and max points of the bounding box
  24210. */
  24211. get: function () {
  24212. var boundingBox = this.boundingBox;
  24213. var diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo.TmpVector3[0]);
  24214. return diag.length();
  24215. },
  24216. enumerable: true,
  24217. configurable: true
  24218. });
  24219. /**
  24220. * Checks if a cullable object (mesh...) is in the camera frustum
  24221. * Unlike isInFrustum this cheks the full bounding box
  24222. * @param frustumPlanes Camera near/planes
  24223. * @returns true if the object is in frustum otherwise false
  24224. */
  24225. BoundingInfo.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  24226. return this.boundingBox.isCompletelyInFrustum(frustumPlanes);
  24227. };
  24228. /** @hidden */
  24229. BoundingInfo.prototype._checkCollision = function (collider) {
  24230. return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
  24231. };
  24232. /**
  24233. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  24234. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24235. * @param point the point to check intersection with
  24236. * @returns if the point intersects
  24237. */
  24238. BoundingInfo.prototype.intersectsPoint = function (point) {
  24239. if (!this.boundingSphere.centerWorld) {
  24240. return false;
  24241. }
  24242. if (!this.boundingSphere.intersectsPoint(point)) {
  24243. return false;
  24244. }
  24245. if (!this.boundingBox.intersectsPoint(point)) {
  24246. return false;
  24247. }
  24248. return true;
  24249. };
  24250. /**
  24251. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  24252. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24253. * @param boundingInfo the bounding info to check intersection with
  24254. * @param precise if the intersection should be done using OBB
  24255. * @returns if the bounding info intersects
  24256. */
  24257. BoundingInfo.prototype.intersects = function (boundingInfo, precise) {
  24258. if (!_boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"].Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {
  24259. return false;
  24260. }
  24261. if (!_boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"].Intersects(this.boundingBox, boundingInfo.boundingBox)) {
  24262. return false;
  24263. }
  24264. if (!precise) {
  24265. return true;
  24266. }
  24267. var box0 = this.boundingBox;
  24268. var box1 = boundingInfo.boundingBox;
  24269. if (!axisOverlap(box0.directions[0], box0, box1)) {
  24270. return false;
  24271. }
  24272. if (!axisOverlap(box0.directions[1], box0, box1)) {
  24273. return false;
  24274. }
  24275. if (!axisOverlap(box0.directions[2], box0, box1)) {
  24276. return false;
  24277. }
  24278. if (!axisOverlap(box1.directions[0], box0, box1)) {
  24279. return false;
  24280. }
  24281. if (!axisOverlap(box1.directions[1], box0, box1)) {
  24282. return false;
  24283. }
  24284. if (!axisOverlap(box1.directions[2], box0, box1)) {
  24285. return false;
  24286. }
  24287. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[0]), box0, box1)) {
  24288. return false;
  24289. }
  24290. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[1]), box0, box1)) {
  24291. return false;
  24292. }
  24293. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[2]), box0, box1)) {
  24294. return false;
  24295. }
  24296. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[0]), box0, box1)) {
  24297. return false;
  24298. }
  24299. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[1]), box0, box1)) {
  24300. return false;
  24301. }
  24302. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[2]), box0, box1)) {
  24303. return false;
  24304. }
  24305. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[0]), box0, box1)) {
  24306. return false;
  24307. }
  24308. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[1]), box0, box1)) {
  24309. return false;
  24310. }
  24311. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[2]), box0, box1)) {
  24312. return false;
  24313. }
  24314. return true;
  24315. };
  24316. BoundingInfo.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24317. return BoundingInfo;
  24318. }());
  24319. /***/ }),
  24320. /***/ "./Culling/boundingSphere.ts":
  24321. /*!***********************************!*\
  24322. !*** ./Culling/boundingSphere.ts ***!
  24323. \***********************************/
  24324. /*! exports provided: BoundingSphere */
  24325. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24326. "use strict";
  24327. __webpack_require__.r(__webpack_exports__);
  24328. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return BoundingSphere; });
  24329. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24330. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24331. /**
  24332. * Class used to store bounding sphere information
  24333. */
  24334. var BoundingSphere = /** @class */ (function () {
  24335. /**
  24336. * Creates a new bounding sphere
  24337. * @param min defines the minimum vector (in local space)
  24338. * @param max defines the maximum vector (in local space)
  24339. * @param worldMatrix defines the new world matrix
  24340. */
  24341. function BoundingSphere(min, max, worldMatrix) {
  24342. /**
  24343. * Gets the center of the bounding sphere in local space
  24344. */
  24345. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24346. /**
  24347. * Gets the center of the bounding sphere in world space
  24348. */
  24349. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24350. /**
  24351. * Gets the minimum vector in local space
  24352. */
  24353. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24354. /**
  24355. * Gets the maximum vector in local space
  24356. */
  24357. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24358. this.reConstruct(min, max, worldMatrix);
  24359. }
  24360. /**
  24361. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  24362. * @param min defines the new minimum vector (in local space)
  24363. * @param max defines the new maximum vector (in local space)
  24364. * @param worldMatrix defines the new world matrix
  24365. */
  24366. BoundingSphere.prototype.reConstruct = function (min, max, worldMatrix) {
  24367. this.minimum.copyFrom(min);
  24368. this.maximum.copyFrom(max);
  24369. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(min, max);
  24370. max.addToRef(min, this.center).scaleInPlace(0.5);
  24371. this.radius = distance * 0.5;
  24372. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  24373. };
  24374. /**
  24375. * Scale the current bounding sphere by applying a scale factor
  24376. * @param factor defines the scale factor to apply
  24377. * @returns the current bounding box
  24378. */
  24379. BoundingSphere.prototype.scale = function (factor) {
  24380. var newRadius = this.radius * factor;
  24381. var tmpVectors = BoundingSphere.TmpVector3;
  24382. var tempRadiusVector = tmpVectors[0].setAll(newRadius);
  24383. var min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);
  24384. var max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);
  24385. this.reConstruct(min, max, this._worldMatrix);
  24386. return this;
  24387. };
  24388. /**
  24389. * Gets the world matrix of the bounding box
  24390. * @returns a matrix
  24391. */
  24392. BoundingSphere.prototype.getWorldMatrix = function () {
  24393. return this._worldMatrix;
  24394. };
  24395. // Methods
  24396. /** @hidden */
  24397. BoundingSphere.prototype._update = function (worldMatrix) {
  24398. if (!worldMatrix.isIdentity()) {
  24399. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);
  24400. var tempVector = BoundingSphere.TmpVector3[0];
  24401. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);
  24402. this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
  24403. }
  24404. else {
  24405. this.centerWorld.copyFrom(this.center);
  24406. this.radiusWorld = this.radius;
  24407. }
  24408. };
  24409. /**
  24410. * Tests if the bounding sphere is intersecting the frustum planes
  24411. * @param frustumPlanes defines the frustum planes to test
  24412. * @returns true if there is an intersection
  24413. */
  24414. BoundingSphere.prototype.isInFrustum = function (frustumPlanes) {
  24415. var center = this.centerWorld;
  24416. var radius = this.radiusWorld;
  24417. for (var i = 0; i < 6; i++) {
  24418. if (frustumPlanes[i].dotCoordinate(center) <= -radius) {
  24419. return false;
  24420. }
  24421. }
  24422. return true;
  24423. };
  24424. /**
  24425. * Tests if the bounding sphere center is in between the frustum planes.
  24426. * Used for optimistic fast inclusion.
  24427. * @param frustumPlanes defines the frustum planes to test
  24428. * @returns true if the sphere center is in between the frustum planes
  24429. */
  24430. BoundingSphere.prototype.isCenterInFrustum = function (frustumPlanes) {
  24431. var center = this.centerWorld;
  24432. for (var i = 0; i < 6; i++) {
  24433. if (frustumPlanes[i].dotCoordinate(center) < 0) {
  24434. return false;
  24435. }
  24436. }
  24437. return true;
  24438. };
  24439. /**
  24440. * Tests if a point is inside the bounding sphere
  24441. * @param point defines the point to test
  24442. * @returns true if the point is inside the bounding sphere
  24443. */
  24444. BoundingSphere.prototype.intersectsPoint = function (point) {
  24445. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.centerWorld, point);
  24446. if (this.radiusWorld * this.radiusWorld < squareDistance) {
  24447. return false;
  24448. }
  24449. return true;
  24450. };
  24451. // Statics
  24452. /**
  24453. * Checks if two sphere intersct
  24454. * @param sphere0 sphere 0
  24455. * @param sphere1 sphere 1
  24456. * @returns true if the speres intersect
  24457. */
  24458. BoundingSphere.Intersects = function (sphere0, sphere1) {
  24459. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);
  24460. var radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;
  24461. if (radiusSum * radiusSum < squareDistance) {
  24462. return false;
  24463. }
  24464. return true;
  24465. };
  24466. BoundingSphere.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24467. return BoundingSphere;
  24468. }());
  24469. /***/ }),
  24470. /***/ "./Culling/index.ts":
  24471. /*!**************************!*\
  24472. !*** ./Culling/index.ts ***!
  24473. \**************************/
  24474. /*! exports provided: BoundingBox, BoundingInfo, BoundingSphere, Ray, Octree, OctreeBlock, OctreeSceneComponent */
  24475. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24476. "use strict";
  24477. __webpack_require__.r(__webpack_exports__);
  24478. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  24479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _boundingBox__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  24480. /* harmony import */ var _boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boundingInfo */ "./Culling/boundingInfo.ts");
  24481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"]; });
  24482. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  24483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"]; });
  24484. /* harmony import */ var _Octrees_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Octrees/index */ "./Culling/Octrees/index.ts");
  24485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["Octree"]; });
  24486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeBlock"]; });
  24487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeSceneComponent"]; });
  24488. /* harmony import */ var _ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ray */ "./Culling/ray.ts");
  24489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _ray__WEBPACK_IMPORTED_MODULE_4__["Ray"]; });
  24490. /***/ }),
  24491. /***/ "./Culling/ray.ts":
  24492. /*!************************!*\
  24493. !*** ./Culling/ray.ts ***!
  24494. \************************/
  24495. /*! exports provided: Ray */
  24496. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24497. "use strict";
  24498. __webpack_require__.r(__webpack_exports__);
  24499. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return Ray; });
  24500. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24501. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24502. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  24503. /**
  24504. * Class representing a ray with position and direction
  24505. */
  24506. var Ray = /** @class */ (function () {
  24507. /**
  24508. * Creates a new ray
  24509. * @param origin origin point
  24510. * @param direction direction
  24511. * @param length length of the ray
  24512. */
  24513. function Ray(
  24514. /** origin point */
  24515. origin,
  24516. /** direction */
  24517. direction,
  24518. /** length of the ray */
  24519. length) {
  24520. if (length === void 0) { length = Number.MAX_VALUE; }
  24521. this.origin = origin;
  24522. this.direction = direction;
  24523. this.length = length;
  24524. }
  24525. // Methods
  24526. /**
  24527. * Checks if the ray intersects a box
  24528. * @param minimum bound of the box
  24529. * @param maximum bound of the box
  24530. * @param intersectionTreshold extra extend to be added to the box in all direction
  24531. * @returns if the box was hit
  24532. */
  24533. Ray.prototype.intersectsBoxMinMax = function (minimum, maximum, intersectionTreshold) {
  24534. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  24535. var newMinimum = Ray.TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
  24536. var newMaximum = Ray.TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
  24537. var d = 0.0;
  24538. var maxValue = Number.MAX_VALUE;
  24539. var inv;
  24540. var min;
  24541. var max;
  24542. var temp;
  24543. if (Math.abs(this.direction.x) < 0.0000001) {
  24544. if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {
  24545. return false;
  24546. }
  24547. }
  24548. else {
  24549. inv = 1.0 / this.direction.x;
  24550. min = (newMinimum.x - this.origin.x) * inv;
  24551. max = (newMaximum.x - this.origin.x) * inv;
  24552. if (max === -Infinity) {
  24553. max = Infinity;
  24554. }
  24555. if (min > max) {
  24556. temp = min;
  24557. min = max;
  24558. max = temp;
  24559. }
  24560. d = Math.max(min, d);
  24561. maxValue = Math.min(max, maxValue);
  24562. if (d > maxValue) {
  24563. return false;
  24564. }
  24565. }
  24566. if (Math.abs(this.direction.y) < 0.0000001) {
  24567. if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {
  24568. return false;
  24569. }
  24570. }
  24571. else {
  24572. inv = 1.0 / this.direction.y;
  24573. min = (newMinimum.y - this.origin.y) * inv;
  24574. max = (newMaximum.y - this.origin.y) * inv;
  24575. if (max === -Infinity) {
  24576. max = Infinity;
  24577. }
  24578. if (min > max) {
  24579. temp = min;
  24580. min = max;
  24581. max = temp;
  24582. }
  24583. d = Math.max(min, d);
  24584. maxValue = Math.min(max, maxValue);
  24585. if (d > maxValue) {
  24586. return false;
  24587. }
  24588. }
  24589. if (Math.abs(this.direction.z) < 0.0000001) {
  24590. if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {
  24591. return false;
  24592. }
  24593. }
  24594. else {
  24595. inv = 1.0 / this.direction.z;
  24596. min = (newMinimum.z - this.origin.z) * inv;
  24597. max = (newMaximum.z - this.origin.z) * inv;
  24598. if (max === -Infinity) {
  24599. max = Infinity;
  24600. }
  24601. if (min > max) {
  24602. temp = min;
  24603. min = max;
  24604. max = temp;
  24605. }
  24606. d = Math.max(min, d);
  24607. maxValue = Math.min(max, maxValue);
  24608. if (d > maxValue) {
  24609. return false;
  24610. }
  24611. }
  24612. return true;
  24613. };
  24614. /**
  24615. * Checks if the ray intersects a box
  24616. * @param box the bounding box to check
  24617. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  24618. * @returns if the box was hit
  24619. */
  24620. Ray.prototype.intersectsBox = function (box, intersectionTreshold) {
  24621. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  24622. return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);
  24623. };
  24624. /**
  24625. * If the ray hits a sphere
  24626. * @param sphere the bounding sphere to check
  24627. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  24628. * @returns true if it hits the sphere
  24629. */
  24630. Ray.prototype.intersectsSphere = function (sphere, intersectionTreshold) {
  24631. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  24632. var x = sphere.center.x - this.origin.x;
  24633. var y = sphere.center.y - this.origin.y;
  24634. var z = sphere.center.z - this.origin.z;
  24635. var pyth = (x * x) + (y * y) + (z * z);
  24636. var radius = sphere.radius + intersectionTreshold;
  24637. var rr = radius * radius;
  24638. if (pyth <= rr) {
  24639. return true;
  24640. }
  24641. var dot = (x * this.direction.x) + (y * this.direction.y) + (z * this.direction.z);
  24642. if (dot < 0.0) {
  24643. return false;
  24644. }
  24645. var temp = pyth - (dot * dot);
  24646. return temp <= rr;
  24647. };
  24648. /**
  24649. * If the ray hits a triange
  24650. * @param vertex0 triangle vertex
  24651. * @param vertex1 triangle vertex
  24652. * @param vertex2 triangle vertex
  24653. * @returns intersection information if hit
  24654. */
  24655. Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) {
  24656. var edge1 = Ray.TmpVector3[0];
  24657. var edge2 = Ray.TmpVector3[1];
  24658. var pvec = Ray.TmpVector3[2];
  24659. var tvec = Ray.TmpVector3[3];
  24660. var qvec = Ray.TmpVector3[4];
  24661. vertex1.subtractToRef(vertex0, edge1);
  24662. vertex2.subtractToRef(vertex0, edge2);
  24663. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(this.direction, edge2, pvec);
  24664. var det = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge1, pvec);
  24665. if (det === 0) {
  24666. return null;
  24667. }
  24668. var invdet = 1 / det;
  24669. this.origin.subtractToRef(vertex0, tvec);
  24670. var bu = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(tvec, pvec) * invdet;
  24671. if (bu < 0 || bu > 1.0) {
  24672. return null;
  24673. }
  24674. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(tvec, edge1, qvec);
  24675. var bv = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this.direction, qvec) * invdet;
  24676. if (bv < 0 || bu + bv > 1.0) {
  24677. return null;
  24678. }
  24679. //check if the distance is longer than the predefined length.
  24680. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge2, qvec) * invdet;
  24681. if (distance > this.length) {
  24682. return null;
  24683. }
  24684. return new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_2__["IntersectionInfo"](bu, bv, distance);
  24685. };
  24686. /**
  24687. * Checks if ray intersects a plane
  24688. * @param plane the plane to check
  24689. * @returns the distance away it was hit
  24690. */
  24691. Ray.prototype.intersectsPlane = function (plane) {
  24692. var distance;
  24693. var result1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.direction);
  24694. if (Math.abs(result1) < 9.99999997475243E-07) {
  24695. return null;
  24696. }
  24697. else {
  24698. var result2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.origin);
  24699. distance = (-plane.d - result2) / result1;
  24700. if (distance < 0.0) {
  24701. if (distance < -9.99999997475243E-07) {
  24702. return null;
  24703. }
  24704. else {
  24705. return 0;
  24706. }
  24707. }
  24708. return distance;
  24709. }
  24710. };
  24711. /**
  24712. * Checks if ray intersects a mesh
  24713. * @param mesh the mesh to check
  24714. * @param fastCheck if only the bounding box should checked
  24715. * @returns picking info of the intersecton
  24716. */
  24717. Ray.prototype.intersectsMesh = function (mesh, fastCheck) {
  24718. var tm = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  24719. mesh.getWorldMatrix().invertToRef(tm);
  24720. if (this._tmpRay) {
  24721. Ray.TransformToRef(this, tm, this._tmpRay);
  24722. }
  24723. else {
  24724. this._tmpRay = Ray.Transform(this, tm);
  24725. }
  24726. return mesh.intersects(this._tmpRay, fastCheck);
  24727. };
  24728. /**
  24729. * Checks if ray intersects a mesh
  24730. * @param meshes the meshes to check
  24731. * @param fastCheck if only the bounding box should checked
  24732. * @param results array to store result in
  24733. * @returns Array of picking infos
  24734. */
  24735. Ray.prototype.intersectsMeshes = function (meshes, fastCheck, results) {
  24736. if (results) {
  24737. results.length = 0;
  24738. }
  24739. else {
  24740. results = [];
  24741. }
  24742. for (var i = 0; i < meshes.length; i++) {
  24743. var pickInfo = this.intersectsMesh(meshes[i], fastCheck);
  24744. if (pickInfo.hit) {
  24745. results.push(pickInfo);
  24746. }
  24747. }
  24748. results.sort(this._comparePickingInfo);
  24749. return results;
  24750. };
  24751. Ray.prototype._comparePickingInfo = function (pickingInfoA, pickingInfoB) {
  24752. if (pickingInfoA.distance < pickingInfoB.distance) {
  24753. return -1;
  24754. }
  24755. else if (pickingInfoA.distance > pickingInfoB.distance) {
  24756. return 1;
  24757. }
  24758. else {
  24759. return 0;
  24760. }
  24761. };
  24762. /**
  24763. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  24764. * @param sega the first point of the segment to test the intersection against
  24765. * @param segb the second point of the segment to test the intersection against
  24766. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  24767. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  24768. */
  24769. Ray.prototype.intersectionSegment = function (sega, segb, threshold) {
  24770. var o = this.origin;
  24771. var u = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  24772. var rsegb = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  24773. var v = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  24774. var w = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  24775. segb.subtractToRef(sega, u);
  24776. this.direction.scaleToRef(Ray.rayl, v);
  24777. o.addToRef(v, rsegb);
  24778. sega.subtractToRef(o, w);
  24779. var a = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, u); // always >= 0
  24780. var b = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, v);
  24781. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, v); // always >= 0
  24782. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, w);
  24783. var e = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, w);
  24784. var D = a * c - b * b; // always >= 0
  24785. var sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
  24786. var tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
  24787. // compute the line parameters of the two closest points
  24788. if (D < Ray.smallnum) { // the lines are almost parallel
  24789. sN = 0.0; // force using point P0 on segment S1
  24790. sD = 1.0; // to prevent possible division by 0.0 later
  24791. tN = e;
  24792. tD = c;
  24793. }
  24794. else { // get the closest points on the infinite lines
  24795. sN = (b * e - c * d);
  24796. tN = (a * e - b * d);
  24797. if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
  24798. sN = 0.0;
  24799. tN = e;
  24800. tD = c;
  24801. }
  24802. else if (sN > sD) { // sc > 1 => the s=1 edge is visible
  24803. sN = sD;
  24804. tN = e + b;
  24805. tD = c;
  24806. }
  24807. }
  24808. if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
  24809. tN = 0.0;
  24810. // recompute sc for this edge
  24811. if (-d < 0.0) {
  24812. sN = 0.0;
  24813. }
  24814. else if (-d > a) {
  24815. sN = sD;
  24816. }
  24817. else {
  24818. sN = -d;
  24819. sD = a;
  24820. }
  24821. }
  24822. else if (tN > tD) { // tc > 1 => the t=1 edge is visible
  24823. tN = tD;
  24824. // recompute sc for this edge
  24825. if ((-d + b) < 0.0) {
  24826. sN = 0;
  24827. }
  24828. else if ((-d + b) > a) {
  24829. sN = sD;
  24830. }
  24831. else {
  24832. sN = (-d + b);
  24833. sD = a;
  24834. }
  24835. }
  24836. // finally do the division to get sc and tc
  24837. sc = (Math.abs(sN) < Ray.smallnum ? 0.0 : sN / sD);
  24838. tc = (Math.abs(tN) < Ray.smallnum ? 0.0 : tN / tD);
  24839. // get the difference of the two closest points
  24840. var qtc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  24841. v.scaleToRef(tc, qtc);
  24842. var qsc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  24843. u.scaleToRef(sc, qsc);
  24844. qsc.addInPlace(w);
  24845. var dP = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  24846. qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)
  24847. var isIntersected = (tc > 0) && (tc <= this.length) && (dP.lengthSquared() < (threshold * threshold)); // return intersection result
  24848. if (isIntersected) {
  24849. return qsc.length();
  24850. }
  24851. return -1;
  24852. };
  24853. /**
  24854. * Update the ray from viewport position
  24855. * @param x position
  24856. * @param y y position
  24857. * @param viewportWidth viewport width
  24858. * @param viewportHeight viewport height
  24859. * @param world world matrix
  24860. * @param view view matrix
  24861. * @param projection projection matrix
  24862. * @returns this ray updated
  24863. */
  24864. Ray.prototype.update = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  24865. this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);
  24866. return this;
  24867. };
  24868. // Statics
  24869. /**
  24870. * Creates a ray with origin and direction of 0,0,0
  24871. * @returns the new ray
  24872. */
  24873. Ray.Zero = function () {
  24874. return new Ray(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero());
  24875. };
  24876. /**
  24877. * Creates a new ray from screen space and viewport
  24878. * @param x position
  24879. * @param y y position
  24880. * @param viewportWidth viewport width
  24881. * @param viewportHeight viewport height
  24882. * @param world world matrix
  24883. * @param view view matrix
  24884. * @param projection projection matrix
  24885. * @returns new ray
  24886. */
  24887. Ray.CreateNew = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  24888. var result = Ray.Zero();
  24889. return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);
  24890. };
  24891. /**
  24892. * 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
  24893. * transformed to the given world matrix.
  24894. * @param origin The origin point
  24895. * @param end The end point
  24896. * @param world a matrix to transform the ray to. Default is the identity matrix.
  24897. * @returns the new ray
  24898. */
  24899. Ray.CreateNewFromTo = function (origin, end, world) {
  24900. if (world === void 0) { world = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly; }
  24901. var direction = end.subtract(origin);
  24902. var length = Math.sqrt((direction.x * direction.x) + (direction.y * direction.y) + (direction.z * direction.z));
  24903. direction.normalize();
  24904. return Ray.Transform(new Ray(origin, direction, length), world);
  24905. };
  24906. /**
  24907. * Transforms a ray by a matrix
  24908. * @param ray ray to transform
  24909. * @param matrix matrix to apply
  24910. * @returns the resulting new ray
  24911. */
  24912. Ray.Transform = function (ray, matrix) {
  24913. 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));
  24914. Ray.TransformToRef(ray, matrix, result);
  24915. return result;
  24916. };
  24917. /**
  24918. * Transforms a ray by a matrix
  24919. * @param ray ray to transform
  24920. * @param matrix matrix to apply
  24921. * @param result ray to store result in
  24922. */
  24923. Ray.TransformToRef = function (ray, matrix, result) {
  24924. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(ray.origin, matrix, result.origin);
  24925. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(ray.direction, matrix, result.direction);
  24926. result.length = ray.length;
  24927. var dir = result.direction;
  24928. var len = dir.length();
  24929. if (!(len === 0 || len === 1)) {
  24930. var num = 1.0 / len;
  24931. dir.x *= num;
  24932. dir.y *= num;
  24933. dir.z *= num;
  24934. result.length *= len;
  24935. }
  24936. };
  24937. /**
  24938. * Unproject a ray from screen space to object space
  24939. * @param sourceX defines the screen space x coordinate to use
  24940. * @param sourceY defines the screen space y coordinate to use
  24941. * @param viewportWidth defines the current width of the viewport
  24942. * @param viewportHeight defines the current height of the viewport
  24943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  24944. * @param view defines the view matrix to use
  24945. * @param projection defines the projection matrix to use
  24946. */
  24947. Ray.prototype.unprojectRayToRef = function (sourceX, sourceY, viewportWidth, viewportHeight, world, view, projection) {
  24948. var matrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  24949. world.multiplyToRef(view, matrix);
  24950. matrix.multiplyToRef(projection, matrix);
  24951. matrix.invert();
  24952. var nearScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  24953. nearScreenSource.x = sourceX / viewportWidth * 2 - 1;
  24954. nearScreenSource.y = -(sourceY / viewportHeight * 2 - 1);
  24955. nearScreenSource.z = -1.0;
  24956. var farScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0);
  24957. var nearVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  24958. var farVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  24959. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);
  24960. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);
  24961. this.origin.copyFrom(nearVec3);
  24962. farVec3.subtractToRef(nearVec3, this.direction);
  24963. this.direction.normalize();
  24964. };
  24965. Ray.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24966. Ray.smallnum = 0.00000001;
  24967. Ray.rayl = 10e8;
  24968. return Ray;
  24969. }());
  24970. /***/ }),
  24971. /***/ "./Debug/axesViewer.ts":
  24972. /*!*****************************!*\
  24973. !*** ./Debug/axesViewer.ts ***!
  24974. \*****************************/
  24975. /*! exports provided: AxesViewer */
  24976. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24977. "use strict";
  24978. __webpack_require__.r(__webpack_exports__);
  24979. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return AxesViewer; });
  24980. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24981. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  24982. /* harmony import */ var _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gizmos/axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  24983. /**
  24984. * The Axes viewer will show 3 axes in a specific point in space
  24985. */
  24986. var AxesViewer = /** @class */ (function () {
  24987. /**
  24988. * Creates a new AxesViewer
  24989. * @param scene defines the hosting scene
  24990. * @param scaleLines defines a number used to scale line length (1 by default)
  24991. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  24992. * @param xAxis defines the node hierarchy used to render the x-axis
  24993. * @param yAxis defines the node hierarchy used to render the y-axis
  24994. * @param zAxis defines the node hierarchy used to render the z-axis
  24995. */
  24996. function AxesViewer(scene, scaleLines, renderingGroupId, xAxis, yAxis, zAxis) {
  24997. if (scaleLines === void 0) { scaleLines = 1; }
  24998. if (renderingGroupId === void 0) { renderingGroupId = 2; }
  24999. this._scaleLinesFactor = 4;
  25000. this._instanced = false;
  25001. /**
  25002. * Gets or sets a number used to scale line length
  25003. */
  25004. this.scaleLines = 1;
  25005. this.scaleLines = scaleLines;
  25006. if (!xAxis) {
  25007. var redColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25008. redColoredMaterial.disableLighting = true;
  25009. redColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Red().scale(0.5);
  25010. xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, redColoredMaterial);
  25011. }
  25012. if (!yAxis) {
  25013. var greenColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25014. greenColoredMaterial.disableLighting = true;
  25015. greenColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Green().scale(0.5);
  25016. yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, greenColoredMaterial);
  25017. }
  25018. if (!zAxis) {
  25019. var blueColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25020. blueColoredMaterial.disableLighting = true;
  25021. blueColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Blue().scale(0.5);
  25022. zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, blueColoredMaterial);
  25023. }
  25024. this._xAxis = xAxis;
  25025. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25026. this._yAxis = yAxis;
  25027. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25028. this._zAxis = zAxis;
  25029. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25030. if (renderingGroupId != null) {
  25031. AxesViewer._SetRenderingGroupId(this._xAxis, renderingGroupId);
  25032. AxesViewer._SetRenderingGroupId(this._yAxis, renderingGroupId);
  25033. AxesViewer._SetRenderingGroupId(this._zAxis, renderingGroupId);
  25034. }
  25035. this.scene = scene;
  25036. 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());
  25037. }
  25038. Object.defineProperty(AxesViewer.prototype, "xAxis", {
  25039. /** Gets the node hierarchy used to render x-axis */
  25040. get: function () {
  25041. return this._xAxis;
  25042. },
  25043. enumerable: true,
  25044. configurable: true
  25045. });
  25046. Object.defineProperty(AxesViewer.prototype, "yAxis", {
  25047. /** Gets the node hierarchy used to render y-axis */
  25048. get: function () {
  25049. return this._yAxis;
  25050. },
  25051. enumerable: true,
  25052. configurable: true
  25053. });
  25054. Object.defineProperty(AxesViewer.prototype, "zAxis", {
  25055. /** Gets the node hierarchy used to render z-axis */
  25056. get: function () {
  25057. return this._zAxis;
  25058. },
  25059. enumerable: true,
  25060. configurable: true
  25061. });
  25062. /**
  25063. * Force the viewer to update
  25064. * @param position defines the position of the viewer
  25065. * @param xaxis defines the x axis of the viewer
  25066. * @param yaxis defines the y axis of the viewer
  25067. * @param zaxis defines the z axis of the viewer
  25068. */
  25069. AxesViewer.prototype.update = function (position, xaxis, yaxis, zaxis) {
  25070. this._xAxis.position.copyFrom(position);
  25071. this._xAxis.setDirection(xaxis);
  25072. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25073. this._yAxis.position.copyFrom(position);
  25074. this._yAxis.setDirection(yaxis);
  25075. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25076. this._zAxis.position.copyFrom(position);
  25077. this._zAxis.setDirection(zaxis);
  25078. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25079. };
  25080. /**
  25081. * Creates an instance of this axes viewer.
  25082. * @returns a new axes viewer with instanced meshes
  25083. */
  25084. AxesViewer.prototype.createInstance = function () {
  25085. var xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._xAxis);
  25086. var yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._yAxis);
  25087. var zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._zAxis);
  25088. var axesViewer = new AxesViewer(this.scene, this.scaleLines, null, xAxis, yAxis, zAxis);
  25089. axesViewer._instanced = true;
  25090. return axesViewer;
  25091. };
  25092. /** Releases resources */
  25093. AxesViewer.prototype.dispose = function () {
  25094. if (this._xAxis) {
  25095. this._xAxis.dispose(false, !this._instanced);
  25096. delete this._xAxis;
  25097. }
  25098. if (this._yAxis) {
  25099. this._yAxis.dispose(false, !this._instanced);
  25100. delete this._yAxis;
  25101. }
  25102. if (this._zAxis) {
  25103. this._zAxis.dispose(false, !this._instanced);
  25104. delete this._zAxis;
  25105. }
  25106. delete this.scene;
  25107. };
  25108. AxesViewer._SetRenderingGroupId = function (node, id) {
  25109. node.getChildMeshes().forEach(function (mesh) {
  25110. mesh.renderingGroupId = id;
  25111. });
  25112. };
  25113. return AxesViewer;
  25114. }());
  25115. /***/ }),
  25116. /***/ "./Debug/boneAxesViewer.ts":
  25117. /*!*********************************!*\
  25118. !*** ./Debug/boneAxesViewer.ts ***!
  25119. \*********************************/
  25120. /*! exports provided: BoneAxesViewer */
  25121. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25122. "use strict";
  25123. __webpack_require__.r(__webpack_exports__);
  25124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return BoneAxesViewer; });
  25125. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  25126. /* harmony import */ var _Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/axesViewer */ "./Debug/axesViewer.ts");
  25127. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25128. /**
  25129. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  25130. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  25131. */
  25132. var BoneAxesViewer = /** @class */ (function (_super) {
  25133. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoneAxesViewer, _super);
  25134. /**
  25135. * Creates a new BoneAxesViewer
  25136. * @param scene defines the hosting scene
  25137. * @param bone defines the target bone
  25138. * @param mesh defines the target mesh
  25139. * @param scaleLines defines a scaling factor for line length (1 by default)
  25140. */
  25141. function BoneAxesViewer(scene, bone, mesh, scaleLines) {
  25142. if (scaleLines === void 0) { scaleLines = 1; }
  25143. var _this = _super.call(this, scene, scaleLines) || this;
  25144. /** Gets current position */
  25145. _this.pos = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25146. /** Gets direction of X axis */
  25147. _this.xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25148. /** Gets direction of Y axis */
  25149. _this.yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25150. /** Gets direction of Z axis */
  25151. _this.zaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25152. _this.mesh = mesh;
  25153. _this.bone = bone;
  25154. return _this;
  25155. }
  25156. /**
  25157. * Force the viewer to update
  25158. */
  25159. BoneAxesViewer.prototype.update = function () {
  25160. if (!this.mesh || !this.bone) {
  25161. return;
  25162. }
  25163. var bone = this.bone;
  25164. bone.getAbsolutePositionToRef(this.mesh, this.pos);
  25165. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].X, this.mesh, this.xaxis);
  25166. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y, this.mesh, this.yaxis);
  25167. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Z, this.mesh, this.zaxis);
  25168. _super.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis);
  25169. };
  25170. /** Releases resources */
  25171. BoneAxesViewer.prototype.dispose = function () {
  25172. if (this.mesh) {
  25173. this.mesh = null;
  25174. this.bone = null;
  25175. _super.prototype.dispose.call(this);
  25176. }
  25177. };
  25178. return BoneAxesViewer;
  25179. }(_Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"]));
  25180. /***/ }),
  25181. /***/ "./Debug/debugLayer.ts":
  25182. /*!*****************************!*\
  25183. !*** ./Debug/debugLayer.ts ***!
  25184. \*****************************/
  25185. /*! exports provided: DebugLayer */
  25186. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25187. "use strict";
  25188. __webpack_require__.r(__webpack_exports__);
  25189. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return DebugLayer; });
  25190. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  25191. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  25192. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  25193. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25194. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype, "debugLayer", {
  25195. get: function () {
  25196. if (!this._debugLayer) {
  25197. this._debugLayer = new DebugLayer(this);
  25198. }
  25199. return this._debugLayer;
  25200. },
  25201. enumerable: true,
  25202. configurable: true
  25203. });
  25204. /**
  25205. * The debug layer (aka Inspector) is the go to tool in order to better understand
  25206. * what is happening in your scene
  25207. * @see http://doc.babylonjs.com/features/playground_debuglayer
  25208. */
  25209. var DebugLayer = /** @class */ (function () {
  25210. /**
  25211. * Instantiates a new debug layer.
  25212. * The debug layer (aka Inspector) is the go to tool in order to better understand
  25213. * what is happening in your scene
  25214. * @see http://doc.babylonjs.com/features/playground_debuglayer
  25215. * @param scene Defines the scene to inspect
  25216. */
  25217. function DebugLayer(scene) {
  25218. var _this = this;
  25219. this.BJSINSPECTOR = this._getGlobalInspector();
  25220. /**
  25221. * Observable triggered when a property is changed through the inspector.
  25222. */
  25223. this.onPropertyChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  25224. this._scene = scene;
  25225. this._scene.onDisposeObservable.add(function () {
  25226. // Debug layer
  25227. if (_this._scene._debugLayer) {
  25228. _this._scene._debugLayer.hide();
  25229. }
  25230. });
  25231. }
  25232. /** Creates the inspector window. */
  25233. DebugLayer.prototype._createInspector = function (config) {
  25234. if (this.isVisible()) {
  25235. return;
  25236. }
  25237. var userOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ overlay: false, showExplorer: true, showInspector: true, embedMode: false, handleResize: true, enablePopup: true }, config);
  25238. this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector();
  25239. this.BJSINSPECTOR.Inspector.Show(this._scene, userOptions);
  25240. };
  25241. /** Get the inspector from bundle or global */
  25242. DebugLayer.prototype._getGlobalInspector = function () {
  25243. // UMD Global name detection from Webpack Bundle UMD Name.
  25244. if (typeof INSPECTOR !== 'undefined') {
  25245. return INSPECTOR;
  25246. }
  25247. // In case of module let s check the global emitted from the Inspector entry point.
  25248. if (typeof BABYLON !== 'undefined' && typeof BABYLON.Inspector !== 'undefined') {
  25249. return BABYLON;
  25250. }
  25251. return undefined;
  25252. };
  25253. /**
  25254. * Get if the inspector is visible or not.
  25255. * @returns true if visible otherwise, false
  25256. */
  25257. DebugLayer.prototype.isVisible = function () {
  25258. return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;
  25259. };
  25260. /**
  25261. * Hide the inspector and close its window.
  25262. */
  25263. DebugLayer.prototype.hide = function () {
  25264. if (this.BJSINSPECTOR) {
  25265. this.BJSINSPECTOR.Inspector.Hide();
  25266. }
  25267. };
  25268. /**
  25269. * Launch the debugLayer.
  25270. * @param config Define the configuration of the inspector
  25271. */
  25272. DebugLayer.prototype.show = function (config) {
  25273. if (typeof this.BJSINSPECTOR == 'undefined') {
  25274. // Load inspector and add it to the DOM
  25275. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadScript(DebugLayer.InspectorURL, this._createInspector.bind(this, config));
  25276. }
  25277. else {
  25278. // Otherwise creates the inspector
  25279. this._createInspector(config);
  25280. }
  25281. };
  25282. /**
  25283. * Define the url to get the inspector script from.
  25284. * By default it uses the babylonjs CDN.
  25285. * @ignoreNaming
  25286. */
  25287. DebugLayer.InspectorURL = 'https://preview.babylonjs.com/inspector/babylon.inspector.bundle.js';
  25288. return DebugLayer;
  25289. }());
  25290. /***/ }),
  25291. /***/ "./Debug/index.ts":
  25292. /*!************************!*\
  25293. !*** ./Debug/index.ts ***!
  25294. \************************/
  25295. /*! exports provided: AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer */
  25296. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25297. "use strict";
  25298. __webpack_require__.r(__webpack_exports__);
  25299. /* harmony import */ var _axesViewer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axesViewer */ "./Debug/axesViewer.ts");
  25300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _axesViewer__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  25301. /* harmony import */ var _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneAxesViewer */ "./Debug/boneAxesViewer.ts");
  25302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"]; });
  25303. /* harmony import */ var _debugLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./debugLayer */ "./Debug/debugLayer.ts");
  25304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _debugLayer__WEBPACK_IMPORTED_MODULE_2__["DebugLayer"]; });
  25305. /* harmony import */ var _physicsViewer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsViewer */ "./Debug/physicsViewer.ts");
  25306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _physicsViewer__WEBPACK_IMPORTED_MODULE_3__["PhysicsViewer"]; });
  25307. /* harmony import */ var _rayHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rayHelper */ "./Debug/rayHelper.ts");
  25308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _rayHelper__WEBPACK_IMPORTED_MODULE_4__["RayHelper"]; });
  25309. /* harmony import */ var _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./skeletonViewer */ "./Debug/skeletonViewer.ts");
  25310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__["SkeletonViewer"]; });
  25311. /***/ }),
  25312. /***/ "./Debug/physicsViewer.ts":
  25313. /*!********************************!*\
  25314. !*** ./Debug/physicsViewer.ts ***!
  25315. \********************************/
  25316. /*! exports provided: PhysicsViewer */
  25317. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25318. "use strict";
  25319. __webpack_require__.r(__webpack_exports__);
  25320. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return PhysicsViewer; });
  25321. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  25322. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25323. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  25324. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  25325. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  25326. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  25327. /**
  25328. * Used to show the physics impostor around the specific mesh
  25329. */
  25330. var PhysicsViewer = /** @class */ (function () {
  25331. /**
  25332. * Creates a new PhysicsViewer
  25333. * @param scene defines the hosting scene
  25334. */
  25335. function PhysicsViewer(scene) {
  25336. /** @hidden */
  25337. this._impostors = [];
  25338. /** @hidden */
  25339. this._meshes = [];
  25340. /** @hidden */
  25341. this._numMeshes = 0;
  25342. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  25343. var physicEngine = this._scene.getPhysicsEngine();
  25344. if (physicEngine) {
  25345. this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();
  25346. }
  25347. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_5__["UtilityLayerRenderer"](this._scene, false);
  25348. this._utilityLayer.pickUtilitySceneFirst = false;
  25349. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  25350. }
  25351. /** @hidden */
  25352. PhysicsViewer.prototype._updateDebugMeshes = function () {
  25353. var plugin = this._physicsEnginePlugin;
  25354. for (var i = 0; i < this._numMeshes; i++) {
  25355. var impostor = this._impostors[i];
  25356. if (!impostor) {
  25357. continue;
  25358. }
  25359. if (impostor.isDisposed) {
  25360. this.hideImpostor(this._impostors[i--]);
  25361. }
  25362. else {
  25363. var mesh = this._meshes[i];
  25364. if (mesh && plugin) {
  25365. plugin.syncMeshWithImpostor(mesh, impostor);
  25366. }
  25367. }
  25368. }
  25369. };
  25370. /**
  25371. * Renders a specified physic impostor
  25372. * @param impostor defines the impostor to render
  25373. * @returns the new debug mesh used to render the impostor
  25374. */
  25375. PhysicsViewer.prototype.showImpostor = function (impostor) {
  25376. if (!this._scene) {
  25377. return null;
  25378. }
  25379. for (var i = 0; i < this._numMeshes; i++) {
  25380. if (this._impostors[i] == impostor) {
  25381. return null;
  25382. }
  25383. }
  25384. var debugMesh = this._getDebugMesh(impostor);
  25385. if (debugMesh) {
  25386. this._impostors[this._numMeshes] = impostor;
  25387. this._meshes[this._numMeshes] = debugMesh;
  25388. if (this._numMeshes === 0) {
  25389. this._renderFunction = this._updateDebugMeshes.bind(this);
  25390. this._scene.registerBeforeRender(this._renderFunction);
  25391. }
  25392. this._numMeshes++;
  25393. }
  25394. return debugMesh;
  25395. };
  25396. /**
  25397. * Hides a specified physic impostor
  25398. * @param impostor defines the impostor to hide
  25399. */
  25400. PhysicsViewer.prototype.hideImpostor = function (impostor) {
  25401. if (!impostor || !this._scene || !this._utilityLayer) {
  25402. return;
  25403. }
  25404. var removed = false;
  25405. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  25406. for (var i = 0; i < this._numMeshes; i++) {
  25407. if (this._impostors[i] == impostor) {
  25408. var mesh = this._meshes[i];
  25409. if (!mesh) {
  25410. continue;
  25411. }
  25412. utilityLayerScene.removeMesh(mesh);
  25413. mesh.dispose();
  25414. this._numMeshes--;
  25415. if (this._numMeshes > 0) {
  25416. this._meshes[i] = this._meshes[this._numMeshes];
  25417. this._impostors[i] = this._impostors[this._numMeshes];
  25418. this._meshes[this._numMeshes] = null;
  25419. this._impostors[this._numMeshes] = null;
  25420. }
  25421. else {
  25422. this._meshes[0] = null;
  25423. this._impostors[0] = null;
  25424. }
  25425. removed = true;
  25426. break;
  25427. }
  25428. }
  25429. if (removed && this._numMeshes === 0) {
  25430. this._scene.unregisterBeforeRender(this._renderFunction);
  25431. }
  25432. };
  25433. PhysicsViewer.prototype._getDebugMaterial = function (scene) {
  25434. if (!this._debugMaterial) {
  25435. this._debugMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_3__["StandardMaterial"]('', scene);
  25436. this._debugMaterial.wireframe = true;
  25437. this._debugMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  25438. this._debugMaterial.disableLighting = true;
  25439. }
  25440. return this._debugMaterial;
  25441. };
  25442. PhysicsViewer.prototype._getDebugBoxMesh = function (scene) {
  25443. if (!this._debugBoxMesh) {
  25444. this._debugBoxMesh = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"].CreateBox('physicsBodyBoxViewMesh', { size: 1 }, scene);
  25445. this._debugBoxMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  25446. this._debugBoxMesh.material = this._getDebugMaterial(scene);
  25447. }
  25448. return this._debugBoxMesh.createInstance('physicsBodyBoxViewInstance');
  25449. };
  25450. PhysicsViewer.prototype._getDebugSphereMesh = function (scene) {
  25451. if (!this._debugSphereMesh) {
  25452. this._debugSphereMesh = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"].CreateSphere('physicsBodySphereViewMesh', { diameter: 1 }, scene);
  25453. this._debugSphereMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  25454. this._debugSphereMesh.material = this._getDebugMaterial(scene);
  25455. }
  25456. return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
  25457. };
  25458. PhysicsViewer.prototype._getDebugMesh = function (impostor) {
  25459. if (!this._utilityLayer) {
  25460. return null;
  25461. }
  25462. var mesh = null;
  25463. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  25464. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_4__["PhysicsImpostor"].BoxImpostor) {
  25465. mesh = this._getDebugBoxMesh(utilityLayerScene);
  25466. impostor.getBoxSizeToRef(mesh.scaling);
  25467. }
  25468. else if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_4__["PhysicsImpostor"].SphereImpostor) {
  25469. mesh = this._getDebugSphereMesh(utilityLayerScene);
  25470. var radius = impostor.getRadius();
  25471. mesh.scaling.x = radius * 2;
  25472. mesh.scaling.y = radius * 2;
  25473. mesh.scaling.z = radius * 2;
  25474. }
  25475. return mesh;
  25476. };
  25477. /** Releases all resources */
  25478. PhysicsViewer.prototype.dispose = function () {
  25479. for (var i = 0; i < this._numMeshes; i++) {
  25480. this.hideImpostor(this._impostors[i]);
  25481. }
  25482. if (this._debugBoxMesh) {
  25483. this._debugBoxMesh.dispose();
  25484. }
  25485. if (this._debugSphereMesh) {
  25486. this._debugSphereMesh.dispose();
  25487. }
  25488. if (this._debugMaterial) {
  25489. this._debugMaterial.dispose();
  25490. }
  25491. this._impostors.length = 0;
  25492. this._scene = null;
  25493. this._physicsEnginePlugin = null;
  25494. if (this._utilityLayer) {
  25495. this._utilityLayer.dispose();
  25496. this._utilityLayer = null;
  25497. }
  25498. };
  25499. return PhysicsViewer;
  25500. }());
  25501. /***/ }),
  25502. /***/ "./Debug/rayHelper.ts":
  25503. /*!****************************!*\
  25504. !*** ./Debug/rayHelper.ts ***!
  25505. \****************************/
  25506. /*! exports provided: RayHelper */
  25507. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25508. "use strict";
  25509. __webpack_require__.r(__webpack_exports__);
  25510. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return RayHelper; });
  25511. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25512. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  25513. /**
  25514. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  25515. * in order to better appreciate the issue one might have.
  25516. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  25517. */
  25518. var RayHelper = /** @class */ (function () {
  25519. /**
  25520. * Instantiate a new ray helper.
  25521. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  25522. * in order to better appreciate the issue one might have.
  25523. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  25524. * @param ray Defines the ray we are currently tryin to visualize
  25525. */
  25526. function RayHelper(ray) {
  25527. this.ray = ray;
  25528. }
  25529. /**
  25530. * Helper function to create a colored helper in a scene in one line.
  25531. * @param ray Defines the ray we are currently tryin to visualize
  25532. * @param scene Defines the scene the ray is used in
  25533. * @param color Defines the color we want to see the ray in
  25534. * @returns The newly created ray helper.
  25535. */
  25536. RayHelper.CreateAndShow = function (ray, scene, color) {
  25537. var helper = new RayHelper(ray);
  25538. helper.show(scene, color);
  25539. return helper;
  25540. };
  25541. /**
  25542. * Shows the ray we are willing to debug.
  25543. * @param scene Defines the scene the ray needs to be rendered in
  25544. * @param color Defines the color the ray needs to be rendered in
  25545. */
  25546. RayHelper.prototype.show = function (scene, color) {
  25547. if (!this._renderFunction && this.ray) {
  25548. var ray = this.ray;
  25549. this._renderFunction = this._render.bind(this);
  25550. this._scene = scene;
  25551. this._renderPoints = [ray.origin, ray.origin.add(ray.direction.scale(ray.length))];
  25552. this._renderLine = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, scene, true);
  25553. if (this._renderFunction) {
  25554. this._scene.registerBeforeRender(this._renderFunction);
  25555. }
  25556. }
  25557. if (color && this._renderLine) {
  25558. this._renderLine.color.copyFrom(color);
  25559. }
  25560. };
  25561. /**
  25562. * Hides the ray we are debugging.
  25563. */
  25564. RayHelper.prototype.hide = function () {
  25565. if (this._renderFunction && this._scene) {
  25566. this._scene.unregisterBeforeRender(this._renderFunction);
  25567. this._scene = null;
  25568. this._renderFunction = null;
  25569. if (this._renderLine) {
  25570. this._renderLine.dispose();
  25571. this._renderLine = null;
  25572. }
  25573. this._renderPoints = [];
  25574. }
  25575. };
  25576. RayHelper.prototype._render = function () {
  25577. var ray = this.ray;
  25578. if (!ray) {
  25579. return;
  25580. }
  25581. var point = this._renderPoints[1];
  25582. var len = Math.min(ray.length, 1000000);
  25583. point.copyFrom(ray.direction);
  25584. point.scaleInPlace(len);
  25585. point.addInPlace(ray.origin);
  25586. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, this._scene, true, this._renderLine);
  25587. };
  25588. /**
  25589. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  25590. * @param mesh Defines the mesh we want the helper attached to
  25591. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  25592. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  25593. * @param length Defines the length of the ray
  25594. */
  25595. RayHelper.prototype.attachToMesh = function (mesh, meshSpaceDirection, meshSpaceOrigin, length) {
  25596. this._attachedToMesh = mesh;
  25597. var ray = this.ray;
  25598. if (!ray) {
  25599. return;
  25600. }
  25601. if (!ray.direction) {
  25602. ray.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  25603. }
  25604. if (!ray.origin) {
  25605. ray.origin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  25606. }
  25607. if (length) {
  25608. ray.length = length;
  25609. }
  25610. if (!meshSpaceOrigin) {
  25611. meshSpaceOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  25612. }
  25613. if (!meshSpaceDirection) {
  25614. // -1 so that this will work with Mesh.lookAt
  25615. meshSpaceDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1);
  25616. }
  25617. if (!this._meshSpaceDirection) {
  25618. this._meshSpaceDirection = meshSpaceDirection.clone();
  25619. this._meshSpaceOrigin = meshSpaceOrigin.clone();
  25620. }
  25621. else {
  25622. this._meshSpaceDirection.copyFrom(meshSpaceDirection);
  25623. this._meshSpaceOrigin.copyFrom(meshSpaceOrigin);
  25624. }
  25625. if (!this._updateToMeshFunction) {
  25626. this._updateToMeshFunction = this._updateToMesh.bind(this);
  25627. this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction);
  25628. }
  25629. this._updateToMesh();
  25630. };
  25631. /**
  25632. * Detach the ray helper from the mesh it has previously been attached to.
  25633. */
  25634. RayHelper.prototype.detachFromMesh = function () {
  25635. if (this._attachedToMesh) {
  25636. if (this._updateToMeshFunction) {
  25637. this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction);
  25638. }
  25639. this._attachedToMesh = null;
  25640. this._updateToMeshFunction = null;
  25641. }
  25642. };
  25643. RayHelper.prototype._updateToMesh = function () {
  25644. var ray = this.ray;
  25645. if (!this._attachedToMesh || !ray) {
  25646. return;
  25647. }
  25648. if (this._attachedToMesh._isDisposed) {
  25649. this.detachFromMesh();
  25650. return;
  25651. }
  25652. this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, ray.direction);
  25653. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), ray.origin);
  25654. };
  25655. /**
  25656. * Dispose the helper and release its associated resources.
  25657. */
  25658. RayHelper.prototype.dispose = function () {
  25659. this.hide();
  25660. this.detachFromMesh();
  25661. this.ray = null;
  25662. };
  25663. return RayHelper;
  25664. }());
  25665. /***/ }),
  25666. /***/ "./Debug/skeletonViewer.ts":
  25667. /*!*********************************!*\
  25668. !*** ./Debug/skeletonViewer.ts ***!
  25669. \*********************************/
  25670. /*! exports provided: SkeletonViewer */
  25671. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25672. "use strict";
  25673. __webpack_require__.r(__webpack_exports__);
  25674. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return SkeletonViewer; });
  25675. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25676. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  25677. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  25678. /**
  25679. * Class used to render a debug view of a given skeleton
  25680. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  25681. */
  25682. var SkeletonViewer = /** @class */ (function () {
  25683. /**
  25684. * Creates a new SkeletonViewer
  25685. * @param skeleton defines the skeleton to render
  25686. * @param mesh defines the mesh attached to the skeleton
  25687. * @param scene defines the hosting scene
  25688. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  25689. * @param renderingGroupId defines the rendering group id to use with the viewer
  25690. */
  25691. function SkeletonViewer(
  25692. /** defines the skeleton to render */
  25693. skeleton,
  25694. /** defines the mesh attached to the skeleton */
  25695. mesh, scene,
  25696. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  25697. autoUpdateBonesMatrices,
  25698. /** defines the rendering group id to use with the viewer */
  25699. renderingGroupId) {
  25700. if (autoUpdateBonesMatrices === void 0) { autoUpdateBonesMatrices = true; }
  25701. if (renderingGroupId === void 0) { renderingGroupId = 1; }
  25702. this.skeleton = skeleton;
  25703. this.mesh = mesh;
  25704. this.autoUpdateBonesMatrices = autoUpdateBonesMatrices;
  25705. this.renderingGroupId = renderingGroupId;
  25706. /** Gets or sets the color used to render the skeleton */
  25707. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  25708. this._debugLines = new Array();
  25709. this._isEnabled = false;
  25710. this._scene = scene;
  25711. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"](this._scene, false);
  25712. this._utilityLayer.pickUtilitySceneFirst = false;
  25713. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  25714. this.update();
  25715. this._renderFunction = this.update.bind(this);
  25716. }
  25717. Object.defineProperty(SkeletonViewer.prototype, "debugMesh", {
  25718. /**
  25719. * Returns the mesh used to render the bones
  25720. */
  25721. get: function () {
  25722. return this._debugMesh;
  25723. },
  25724. enumerable: true,
  25725. configurable: true
  25726. });
  25727. Object.defineProperty(SkeletonViewer.prototype, "isEnabled", {
  25728. get: function () {
  25729. return this._isEnabled;
  25730. },
  25731. /** Gets or sets a boolean indicating if the viewer is enabled */
  25732. set: function (value) {
  25733. if (this._isEnabled === value) {
  25734. return;
  25735. }
  25736. this._isEnabled = value;
  25737. if (value) {
  25738. this._scene.registerBeforeRender(this._renderFunction);
  25739. }
  25740. else {
  25741. this._scene.unregisterBeforeRender(this._renderFunction);
  25742. }
  25743. },
  25744. enumerable: true,
  25745. configurable: true
  25746. });
  25747. SkeletonViewer.prototype._getBonePosition = function (position, bone, meshMat, x, y, z) {
  25748. if (x === void 0) { x = 0; }
  25749. if (y === void 0) { y = 0; }
  25750. if (z === void 0) { z = 0; }
  25751. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  25752. var parentBone = bone.getParent();
  25753. tmat.copyFrom(bone.getLocalMatrix());
  25754. if (x !== 0 || y !== 0 || z !== 0) {
  25755. var tmat2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  25756. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(tmat2);
  25757. tmat2.setTranslationFromFloats(x, y, z);
  25758. tmat2.multiplyToRef(tmat, tmat);
  25759. }
  25760. if (parentBone) {
  25761. tmat.multiplyToRef(parentBone.getAbsoluteTransform(), tmat);
  25762. }
  25763. tmat.multiplyToRef(meshMat, tmat);
  25764. position.x = tmat.m[12];
  25765. position.y = tmat.m[13];
  25766. position.z = tmat.m[14];
  25767. };
  25768. SkeletonViewer.prototype._getLinesForBonesWithLength = function (bones, meshMat) {
  25769. var len = bones.length;
  25770. var meshPos = this.mesh.position;
  25771. for (var i = 0; i < len; i++) {
  25772. var bone = bones[i];
  25773. var points = this._debugLines[i];
  25774. if (!points) {
  25775. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  25776. this._debugLines[i] = points;
  25777. }
  25778. this._getBonePosition(points[0], bone, meshMat);
  25779. this._getBonePosition(points[1], bone, meshMat, 0, bone.length, 0);
  25780. points[0].subtractInPlace(meshPos);
  25781. points[1].subtractInPlace(meshPos);
  25782. }
  25783. };
  25784. SkeletonViewer.prototype._getLinesForBonesNoLength = function (bones, meshMat) {
  25785. var len = bones.length;
  25786. var boneNum = 0;
  25787. var meshPos = this.mesh.position;
  25788. for (var i = len - 1; i >= 0; i--) {
  25789. var childBone = bones[i];
  25790. var parentBone = childBone.getParent();
  25791. if (!parentBone) {
  25792. continue;
  25793. }
  25794. var points = this._debugLines[boneNum];
  25795. if (!points) {
  25796. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  25797. this._debugLines[boneNum] = points;
  25798. }
  25799. childBone.getAbsolutePositionToRef(this.mesh, points[0]);
  25800. parentBone.getAbsolutePositionToRef(this.mesh, points[1]);
  25801. points[0].subtractInPlace(meshPos);
  25802. points[1].subtractInPlace(meshPos);
  25803. boneNum++;
  25804. }
  25805. };
  25806. /** Update the viewer to sync with current skeleton state */
  25807. SkeletonViewer.prototype.update = function () {
  25808. if (!this._utilityLayer) {
  25809. return;
  25810. }
  25811. if (this.autoUpdateBonesMatrices) {
  25812. this.skeleton.computeAbsoluteTransforms();
  25813. }
  25814. if (this.skeleton.bones[0].length === undefined) {
  25815. this._getLinesForBonesNoLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  25816. }
  25817. else {
  25818. this._getLinesForBonesWithLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  25819. }
  25820. var targetScene = this._utilityLayer.utilityLayerScene;
  25821. if (!this._debugMesh) {
  25822. this._debugMesh = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_1__["MeshBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: null }, targetScene);
  25823. this._debugMesh.renderingGroupId = this.renderingGroupId;
  25824. }
  25825. else {
  25826. _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_1__["MeshBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: this._debugMesh }, targetScene);
  25827. }
  25828. this._debugMesh.position.copyFrom(this.mesh.position);
  25829. this._debugMesh.color = this.color;
  25830. };
  25831. /** Release associated resources */
  25832. SkeletonViewer.prototype.dispose = function () {
  25833. this.isEnabled = false;
  25834. if (this._debugMesh) {
  25835. this.isEnabled = false;
  25836. this._debugMesh.dispose();
  25837. this._debugMesh = null;
  25838. }
  25839. if (this._utilityLayer) {
  25840. this._utilityLayer.dispose();
  25841. this._utilityLayer = null;
  25842. }
  25843. };
  25844. return SkeletonViewer;
  25845. }());
  25846. /***/ }),
  25847. /***/ "./Engines/Extensions/engine.occlusionQuery.ts":
  25848. /*!*****************************************************!*\
  25849. !*** ./Engines/Extensions/engine.occlusionQuery.ts ***!
  25850. \*****************************************************/
  25851. /*! exports provided: _OcclusionDataStorage */
  25852. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25853. "use strict";
  25854. __webpack_require__.r(__webpack_exports__);
  25855. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _OcclusionDataStorage; });
  25856. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  25857. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  25858. /* harmony import */ var _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Instrumentation/timeToken */ "./Instrumentation/timeToken.ts");
  25859. /** @hidden */
  25860. var _OcclusionDataStorage = /** @class */ (function () {
  25861. function _OcclusionDataStorage() {
  25862. /** @hidden */
  25863. this.occlusionInternalRetryCounter = 0;
  25864. /** @hidden */
  25865. this.isOcclusionQueryInProgress = false;
  25866. /** @hidden */
  25867. this.isOccluded = false;
  25868. /** @hidden */
  25869. this.occlusionRetryCount = -1;
  25870. /** @hidden */
  25871. this.occlusionType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE;
  25872. /** @hidden */
  25873. this.occlusionQueryAlgorithmType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
  25874. }
  25875. return _OcclusionDataStorage;
  25876. }());
  25877. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createQuery = function () {
  25878. return this._gl.createQuery();
  25879. };
  25880. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteQuery = function (query) {
  25881. this._gl.deleteQuery(query);
  25882. return this;
  25883. };
  25884. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isQueryResultAvailable = function (query) {
  25885. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT_AVAILABLE);
  25886. };
  25887. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.getQueryResult = function (query) {
  25888. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT);
  25889. };
  25890. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginOcclusionQuery = function (algorithmType, query) {
  25891. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  25892. this._gl.beginQuery(glAlgorithm, query);
  25893. return this;
  25894. };
  25895. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endOcclusionQuery = function (algorithmType) {
  25896. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  25897. this._gl.endQuery(glAlgorithm);
  25898. return this;
  25899. };
  25900. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._createTimeQuery = function () {
  25901. var timerQuery = this.getCaps().timerQuery;
  25902. if (timerQuery.createQueryEXT) {
  25903. return timerQuery.createQueryEXT();
  25904. }
  25905. return this.createQuery();
  25906. };
  25907. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._deleteTimeQuery = function (query) {
  25908. var timerQuery = this.getCaps().timerQuery;
  25909. if (timerQuery.deleteQueryEXT) {
  25910. timerQuery.deleteQueryEXT(query);
  25911. return;
  25912. }
  25913. this.deleteQuery(query);
  25914. };
  25915. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryResult = function (query) {
  25916. var timerQuery = this.getCaps().timerQuery;
  25917. if (timerQuery.getQueryObjectEXT) {
  25918. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_EXT);
  25919. }
  25920. return this.getQueryResult(query);
  25921. };
  25922. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryAvailability = function (query) {
  25923. var timerQuery = this.getCaps().timerQuery;
  25924. if (timerQuery.getQueryObjectEXT) {
  25925. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_AVAILABLE_EXT);
  25926. }
  25927. return this.isQueryResultAvailable(query);
  25928. };
  25929. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.startTimeQuery = function () {
  25930. var caps = this.getCaps();
  25931. var timerQuery = caps.timerQuery;
  25932. if (!timerQuery) {
  25933. return null;
  25934. }
  25935. var token = new _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]();
  25936. this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  25937. if (caps.canUseTimestampForTimerQuery) {
  25938. token._startTimeQuery = this._createTimeQuery();
  25939. timerQuery.queryCounterEXT(token._startTimeQuery, timerQuery.TIMESTAMP_EXT);
  25940. }
  25941. else {
  25942. if (this._currentNonTimestampToken) {
  25943. return this._currentNonTimestampToken;
  25944. }
  25945. token._timeElapsedQuery = this._createTimeQuery();
  25946. if (timerQuery.beginQueryEXT) {
  25947. timerQuery.beginQueryEXT(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  25948. }
  25949. else {
  25950. this._gl.beginQuery(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  25951. }
  25952. this._currentNonTimestampToken = token;
  25953. }
  25954. return token;
  25955. };
  25956. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTimeQuery = function (token) {
  25957. var caps = this.getCaps();
  25958. var timerQuery = caps.timerQuery;
  25959. if (!timerQuery || !token) {
  25960. return -1;
  25961. }
  25962. if (caps.canUseTimestampForTimerQuery) {
  25963. if (!token._startTimeQuery) {
  25964. return -1;
  25965. }
  25966. if (!token._endTimeQuery) {
  25967. token._endTimeQuery = this._createTimeQuery();
  25968. timerQuery.queryCounterEXT(token._endTimeQuery, timerQuery.TIMESTAMP_EXT);
  25969. }
  25970. }
  25971. else if (!token._timeElapsedQueryEnded) {
  25972. if (!token._timeElapsedQuery) {
  25973. return -1;
  25974. }
  25975. if (timerQuery.endQueryEXT) {
  25976. timerQuery.endQueryEXT(timerQuery.TIME_ELAPSED_EXT);
  25977. }
  25978. else {
  25979. this._gl.endQuery(timerQuery.TIME_ELAPSED_EXT);
  25980. }
  25981. token._timeElapsedQueryEnded = true;
  25982. }
  25983. var disjoint = this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  25984. var available = false;
  25985. if (token._endTimeQuery) {
  25986. available = this._getTimeQueryAvailability(token._endTimeQuery);
  25987. }
  25988. else if (token._timeElapsedQuery) {
  25989. available = this._getTimeQueryAvailability(token._timeElapsedQuery);
  25990. }
  25991. if (available && !disjoint) {
  25992. var result = 0;
  25993. if (caps.canUseTimestampForTimerQuery) {
  25994. if (!token._startTimeQuery || !token._endTimeQuery) {
  25995. return -1;
  25996. }
  25997. var timeStart = this._getTimeQueryResult(token._startTimeQuery);
  25998. var timeEnd = this._getTimeQueryResult(token._endTimeQuery);
  25999. result = timeEnd - timeStart;
  26000. this._deleteTimeQuery(token._startTimeQuery);
  26001. this._deleteTimeQuery(token._endTimeQuery);
  26002. token._startTimeQuery = null;
  26003. token._endTimeQuery = null;
  26004. }
  26005. else {
  26006. if (!token._timeElapsedQuery) {
  26007. return -1;
  26008. }
  26009. result = this._getTimeQueryResult(token._timeElapsedQuery);
  26010. this._deleteTimeQuery(token._timeElapsedQuery);
  26011. token._timeElapsedQuery = null;
  26012. token._timeElapsedQueryEnded = false;
  26013. this._currentNonTimestampToken = null;
  26014. }
  26015. return result;
  26016. }
  26017. return -1;
  26018. };
  26019. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getGlAlgorithmType = function (algorithmType) {
  26020. return algorithmType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
  26021. };
  26022. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOcclusionQueryInProgress", {
  26023. get: function () {
  26024. return this._occlusionDataStorage.isOcclusionQueryInProgress;
  26025. },
  26026. enumerable: false,
  26027. configurable: true
  26028. });
  26029. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "_occlusionDataStorage", {
  26030. get: function () {
  26031. if (!this.__occlusionDataStorage) {
  26032. this.__occlusionDataStorage = new _OcclusionDataStorage();
  26033. }
  26034. return this.__occlusionDataStorage;
  26035. },
  26036. enumerable: false,
  26037. configurable: true
  26038. });
  26039. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOccluded", {
  26040. get: function () {
  26041. return this._occlusionDataStorage.isOccluded;
  26042. },
  26043. set: function (value) {
  26044. this._occlusionDataStorage.isOccluded = value;
  26045. },
  26046. enumerable: true,
  26047. configurable: true
  26048. });
  26049. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionQueryAlgorithmType", {
  26050. get: function () {
  26051. return this._occlusionDataStorage.occlusionQueryAlgorithmType;
  26052. },
  26053. set: function (value) {
  26054. this._occlusionDataStorage.occlusionQueryAlgorithmType = value;
  26055. },
  26056. enumerable: true,
  26057. configurable: true
  26058. });
  26059. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionType", {
  26060. get: function () {
  26061. return this._occlusionDataStorage.occlusionType;
  26062. },
  26063. set: function (value) {
  26064. this._occlusionDataStorage.occlusionType = value;
  26065. },
  26066. enumerable: true,
  26067. configurable: true
  26068. });
  26069. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionRetryCount", {
  26070. get: function () {
  26071. return this._occlusionDataStorage.occlusionRetryCount;
  26072. },
  26073. set: function (value) {
  26074. this._occlusionDataStorage.occlusionRetryCount = value;
  26075. },
  26076. enumerable: true,
  26077. configurable: true
  26078. });
  26079. // We also need to update AbstractMesh as there is a portion of the code there
  26080. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype._checkOcclusionQuery = function () {
  26081. var dataStorage = this._occlusionDataStorage;
  26082. if (dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE) {
  26083. dataStorage.isOccluded = false;
  26084. return false;
  26085. }
  26086. var engine = this.getEngine();
  26087. if (engine.webGLVersion < 2) {
  26088. dataStorage.isOccluded = false;
  26089. return false;
  26090. }
  26091. if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
  26092. dataStorage.isOccluded = false;
  26093. return false;
  26094. }
  26095. if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
  26096. var isOcclusionQueryAvailable = engine.isQueryResultAvailable(this._occlusionQuery);
  26097. if (isOcclusionQueryAvailable) {
  26098. var occlusionQueryResult = engine.getQueryResult(this._occlusionQuery);
  26099. dataStorage.isOcclusionQueryInProgress = false;
  26100. dataStorage.occlusionInternalRetryCounter = 0;
  26101. dataStorage.isOccluded = occlusionQueryResult === 1 ? false : true;
  26102. }
  26103. else {
  26104. dataStorage.occlusionInternalRetryCounter++;
  26105. if (dataStorage.occlusionRetryCount !== -1 && dataStorage.occlusionInternalRetryCounter > dataStorage.occlusionRetryCount) {
  26106. dataStorage.isOcclusionQueryInProgress = false;
  26107. dataStorage.occlusionInternalRetryCounter = 0;
  26108. // if optimistic set isOccluded to false regardless of the status of isOccluded. (Render in the current render loop)
  26109. // if strict continue the last state of the object.
  26110. dataStorage.isOccluded = dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_OPTIMISTIC ? false : dataStorage.isOccluded;
  26111. }
  26112. else {
  26113. return false;
  26114. }
  26115. }
  26116. }
  26117. var scene = this.getScene();
  26118. if (scene.getBoundingBoxRenderer) {
  26119. var occlusionBoundingBoxRenderer = scene.getBoundingBoxRenderer();
  26120. if (!this._occlusionQuery) {
  26121. this._occlusionQuery = engine.createQuery();
  26122. }
  26123. engine.beginOcclusionQuery(dataStorage.occlusionQueryAlgorithmType, this._occlusionQuery);
  26124. occlusionBoundingBoxRenderer.renderOcclusionBoundingBox(this);
  26125. engine.endOcclusionQuery(dataStorage.occlusionQueryAlgorithmType);
  26126. this._occlusionDataStorage.isOcclusionQueryInProgress = true;
  26127. }
  26128. return dataStorage.isOccluded;
  26129. };
  26130. /***/ }),
  26131. /***/ "./Engines/Extensions/engine.transformFeedback.ts":
  26132. /*!********************************************************!*\
  26133. !*** ./Engines/Extensions/engine.transformFeedback.ts ***!
  26134. \********************************************************/
  26135. /*! exports provided: _forceTransformFeedbackToBundle */
  26136. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26137. "use strict";
  26138. __webpack_require__.r(__webpack_exports__);
  26139. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _forceTransformFeedbackToBundle; });
  26140. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  26141. /** @hidden */
  26142. var _forceTransformFeedbackToBundle = true;
  26143. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createTransformFeedback = function () {
  26144. return this._gl.createTransformFeedback();
  26145. };
  26146. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteTransformFeedback = function (value) {
  26147. this._gl.deleteTransformFeedback(value);
  26148. };
  26149. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedback = function (value) {
  26150. this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, value);
  26151. };
  26152. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginTransformFeedback = function (usePoints) {
  26153. if (usePoints === void 0) { usePoints = true; }
  26154. this._gl.beginTransformFeedback(usePoints ? this._gl.POINTS : this._gl.TRIANGLES);
  26155. };
  26156. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTransformFeedback = function () {
  26157. this._gl.endTransformFeedback();
  26158. };
  26159. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.setTranformFeedbackVaryings = function (program, value) {
  26160. this._gl.transformFeedbackVaryings(program, value, this._gl.INTERLEAVED_ATTRIBS);
  26161. };
  26162. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedbackBuffer = function (value) {
  26163. this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, value);
  26164. };
  26165. /***/ }),
  26166. /***/ "./Engines/Extensions/index.ts":
  26167. /*!*************************************!*\
  26168. !*** ./Engines/Extensions/index.ts ***!
  26169. \*************************************/
  26170. /*! exports provided: _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  26171. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26172. "use strict";
  26173. __webpack_require__.r(__webpack_exports__);
  26174. /* harmony import */ var _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.occlusionQuery */ "./Engines/Extensions/engine.occlusionQuery.ts");
  26175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  26176. /* harmony import */ var _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.transformFeedback */ "./Engines/Extensions/engine.transformFeedback.ts");
  26177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__["_forceTransformFeedbackToBundle"]; });
  26178. /***/ }),
  26179. /***/ "./Engines/constants.ts":
  26180. /*!******************************!*\
  26181. !*** ./Engines/constants.ts ***!
  26182. \******************************/
  26183. /*! exports provided: Constants */
  26184. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26185. "use strict";
  26186. __webpack_require__.r(__webpack_exports__);
  26187. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return Constants; });
  26188. /** Defines the cross module used constants to avoid circular dependncies */
  26189. var Constants = /** @class */ (function () {
  26190. function Constants() {
  26191. }
  26192. /** Defines that alpha blending is disabled */
  26193. Constants.ALPHA_DISABLE = 0;
  26194. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26195. Constants.ALPHA_ADD = 1;
  26196. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26197. Constants.ALPHA_COMBINE = 2;
  26198. /** Defines that alpha blending to DEST - SRC * DEST */
  26199. Constants.ALPHA_SUBTRACT = 3;
  26200. /** Defines that alpha blending to SRC * DEST */
  26201. Constants.ALPHA_MULTIPLY = 4;
  26202. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26203. Constants.ALPHA_MAXIMIZED = 5;
  26204. /** Defines that alpha blending to SRC + DEST */
  26205. Constants.ALPHA_ONEONE = 6;
  26206. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26207. Constants.ALPHA_PREMULTIPLIED = 7;
  26208. /**
  26209. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26210. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26211. */
  26212. Constants.ALPHA_PREMULTIPLIED_PORTERDUFF = 8;
  26213. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26214. Constants.ALPHA_INTERPOLATE = 9;
  26215. /**
  26216. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26217. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26218. */
  26219. Constants.ALPHA_SCREENMODE = 10;
  26220. /** Defines that the ressource is not delayed*/
  26221. Constants.DELAYLOADSTATE_NONE = 0;
  26222. /** Defines that the ressource was successfully delay loaded */
  26223. Constants.DELAYLOADSTATE_LOADED = 1;
  26224. /** Defines that the ressource is currently delay loading */
  26225. Constants.DELAYLOADSTATE_LOADING = 2;
  26226. /** Defines that the ressource is delayed and has not started loading */
  26227. Constants.DELAYLOADSTATE_NOTLOADED = 4;
  26228. // Depht or Stencil test Constants.
  26229. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26230. Constants.NEVER = 0x0200;
  26231. /** 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 */
  26232. Constants.ALWAYS = 0x0207;
  26233. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26234. Constants.LESS = 0x0201;
  26235. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26236. Constants.EQUAL = 0x0202;
  26237. /** 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 */
  26238. Constants.LEQUAL = 0x0203;
  26239. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26240. Constants.GREATER = 0x0204;
  26241. /** 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 */
  26242. Constants.GEQUAL = 0x0206;
  26243. /** 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 */
  26244. Constants.NOTEQUAL = 0x0205;
  26245. // Stencil Actions Constants.
  26246. /** Passed to stencilOperation to specify that stencil value must be kept */
  26247. Constants.KEEP = 0x1E00;
  26248. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26249. Constants.REPLACE = 0x1E01;
  26250. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26251. Constants.INCR = 0x1E02;
  26252. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26253. Constants.DECR = 0x1E03;
  26254. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26255. Constants.INVERT = 0x150A;
  26256. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26257. Constants.INCR_WRAP = 0x8507;
  26258. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26259. Constants.DECR_WRAP = 0x8508;
  26260. /** Texture is not repeating outside of 0..1 UVs */
  26261. Constants.TEXTURE_CLAMP_ADDRESSMODE = 0;
  26262. /** Texture is repeating outside of 0..1 UVs */
  26263. Constants.TEXTURE_WRAP_ADDRESSMODE = 1;
  26264. /** Texture is repeating and mirrored */
  26265. Constants.TEXTURE_MIRROR_ADDRESSMODE = 2;
  26266. /** ALPHA */
  26267. Constants.TEXTUREFORMAT_ALPHA = 0;
  26268. /** LUMINANCE */
  26269. Constants.TEXTUREFORMAT_LUMINANCE = 1;
  26270. /** LUMINANCE_ALPHA */
  26271. Constants.TEXTUREFORMAT_LUMINANCE_ALPHA = 2;
  26272. /** RGB */
  26273. Constants.TEXTUREFORMAT_RGB = 4;
  26274. /** RGBA */
  26275. Constants.TEXTUREFORMAT_RGBA = 5;
  26276. /** RED */
  26277. Constants.TEXTUREFORMAT_RED = 6;
  26278. /** RED (2nd reference) */
  26279. Constants.TEXTUREFORMAT_R = 6;
  26280. /** RG */
  26281. Constants.TEXTUREFORMAT_RG = 7;
  26282. /** RED_INTEGER */
  26283. Constants.TEXTUREFORMAT_RED_INTEGER = 8;
  26284. /** RED_INTEGER (2nd reference) */
  26285. Constants.TEXTUREFORMAT_R_INTEGER = 8;
  26286. /** RG_INTEGER */
  26287. Constants.TEXTUREFORMAT_RG_INTEGER = 9;
  26288. /** RGB_INTEGER */
  26289. Constants.TEXTUREFORMAT_RGB_INTEGER = 10;
  26290. /** RGBA_INTEGER */
  26291. Constants.TEXTUREFORMAT_RGBA_INTEGER = 11;
  26292. /** UNSIGNED_BYTE */
  26293. Constants.TEXTURETYPE_UNSIGNED_BYTE = 0;
  26294. /** UNSIGNED_BYTE (2nd reference) */
  26295. Constants.TEXTURETYPE_UNSIGNED_INT = 0;
  26296. /** FLOAT */
  26297. Constants.TEXTURETYPE_FLOAT = 1;
  26298. /** HALF_FLOAT */
  26299. Constants.TEXTURETYPE_HALF_FLOAT = 2;
  26300. /** BYTE */
  26301. Constants.TEXTURETYPE_BYTE = 3;
  26302. /** SHORT */
  26303. Constants.TEXTURETYPE_SHORT = 4;
  26304. /** UNSIGNED_SHORT */
  26305. Constants.TEXTURETYPE_UNSIGNED_SHORT = 5;
  26306. /** INT */
  26307. Constants.TEXTURETYPE_INT = 6;
  26308. /** UNSIGNED_INT */
  26309. Constants.TEXTURETYPE_UNSIGNED_INTEGER = 7;
  26310. /** UNSIGNED_SHORT_4_4_4_4 */
  26311. Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8;
  26312. /** UNSIGNED_SHORT_5_5_5_1 */
  26313. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9;
  26314. /** UNSIGNED_SHORT_5_6_5 */
  26315. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10;
  26316. /** UNSIGNED_INT_2_10_10_10_REV */
  26317. Constants.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11;
  26318. /** UNSIGNED_INT_24_8 */
  26319. Constants.TEXTURETYPE_UNSIGNED_INT_24_8 = 12;
  26320. /** UNSIGNED_INT_10F_11F_11F_REV */
  26321. Constants.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13;
  26322. /** UNSIGNED_INT_5_9_9_9_REV */
  26323. Constants.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14;
  26324. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26325. Constants.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15;
  26326. /** nearest is mag = nearest and min = nearest and mip = linear */
  26327. Constants.TEXTURE_NEAREST_SAMPLINGMODE = 1;
  26328. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26329. Constants.TEXTURE_BILINEAR_SAMPLINGMODE = 2;
  26330. /** Trilinear is mag = linear and min = linear and mip = linear */
  26331. Constants.TEXTURE_TRILINEAR_SAMPLINGMODE = 3;
  26332. /** nearest is mag = nearest and min = nearest and mip = linear */
  26333. Constants.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 1;
  26334. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26335. Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 2;
  26336. /** Trilinear is mag = linear and min = linear and mip = linear */
  26337. Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3;
  26338. /** mag = nearest and min = nearest and mip = nearest */
  26339. Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4;
  26340. /** mag = nearest and min = linear and mip = nearest */
  26341. Constants.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5;
  26342. /** mag = nearest and min = linear and mip = linear */
  26343. Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6;
  26344. /** mag = nearest and min = linear and mip = none */
  26345. Constants.TEXTURE_NEAREST_LINEAR = 7;
  26346. /** mag = nearest and min = nearest and mip = none */
  26347. Constants.TEXTURE_NEAREST_NEAREST = 8;
  26348. /** mag = linear and min = nearest and mip = nearest */
  26349. Constants.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9;
  26350. /** mag = linear and min = nearest and mip = linear */
  26351. Constants.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10;
  26352. /** mag = linear and min = linear and mip = none */
  26353. Constants.TEXTURE_LINEAR_LINEAR = 11;
  26354. /** mag = linear and min = nearest and mip = none */
  26355. Constants.TEXTURE_LINEAR_NEAREST = 12;
  26356. /** Explicit coordinates mode */
  26357. Constants.TEXTURE_EXPLICIT_MODE = 0;
  26358. /** Spherical coordinates mode */
  26359. Constants.TEXTURE_SPHERICAL_MODE = 1;
  26360. /** Planar coordinates mode */
  26361. Constants.TEXTURE_PLANAR_MODE = 2;
  26362. /** Cubic coordinates mode */
  26363. Constants.TEXTURE_CUBIC_MODE = 3;
  26364. /** Projection coordinates mode */
  26365. Constants.TEXTURE_PROJECTION_MODE = 4;
  26366. /** Skybox coordinates mode */
  26367. Constants.TEXTURE_SKYBOX_MODE = 5;
  26368. /** Inverse Cubic coordinates mode */
  26369. Constants.TEXTURE_INVCUBIC_MODE = 6;
  26370. /** Equirectangular coordinates mode */
  26371. Constants.TEXTURE_EQUIRECTANGULAR_MODE = 7;
  26372. /** Equirectangular Fixed coordinates mode */
  26373. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8;
  26374. /** Equirectangular Fixed Mirrored coordinates mode */
  26375. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9;
  26376. // Texture rescaling mode
  26377. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26378. Constants.SCALEMODE_FLOOR = 1;
  26379. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26380. Constants.SCALEMODE_NEAREST = 2;
  26381. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26382. Constants.SCALEMODE_CEILING = 3;
  26383. /**
  26384. * The dirty texture flag value
  26385. */
  26386. Constants.MATERIAL_TextureDirtyFlag = 1;
  26387. /**
  26388. * The dirty light flag value
  26389. */
  26390. Constants.MATERIAL_LightDirtyFlag = 2;
  26391. /**
  26392. * The dirty fresnel flag value
  26393. */
  26394. Constants.MATERIAL_FresnelDirtyFlag = 4;
  26395. /**
  26396. * The dirty attribute flag value
  26397. */
  26398. Constants.MATERIAL_AttributesDirtyFlag = 8;
  26399. /**
  26400. * The dirty misc flag value
  26401. */
  26402. Constants.MATERIAL_MiscDirtyFlag = 16;
  26403. /**
  26404. * The all dirty flag value
  26405. */
  26406. Constants.MATERIAL_AllDirtyFlag = 31;
  26407. /**
  26408. * Returns the triangle fill mode
  26409. */
  26410. Constants.MATERIAL_TriangleFillMode = 0;
  26411. /**
  26412. * Returns the wireframe mode
  26413. */
  26414. Constants.MATERIAL_WireFrameFillMode = 1;
  26415. /**
  26416. * Returns the point fill mode
  26417. */
  26418. Constants.MATERIAL_PointFillMode = 2;
  26419. /**
  26420. * Returns the point list draw mode
  26421. */
  26422. Constants.MATERIAL_PointListDrawMode = 3;
  26423. /**
  26424. * Returns the line list draw mode
  26425. */
  26426. Constants.MATERIAL_LineListDrawMode = 4;
  26427. /**
  26428. * Returns the line loop draw mode
  26429. */
  26430. Constants.MATERIAL_LineLoopDrawMode = 5;
  26431. /**
  26432. * Returns the line strip draw mode
  26433. */
  26434. Constants.MATERIAL_LineStripDrawMode = 6;
  26435. /**
  26436. * Returns the triangle strip draw mode
  26437. */
  26438. Constants.MATERIAL_TriangleStripDrawMode = 7;
  26439. /**
  26440. * Returns the triangle fan draw mode
  26441. */
  26442. Constants.MATERIAL_TriangleFanDrawMode = 8;
  26443. /**
  26444. * Stores the clock-wise side orientation
  26445. */
  26446. Constants.MATERIAL_ClockWiseSideOrientation = 0;
  26447. /**
  26448. * Stores the counter clock-wise side orientation
  26449. */
  26450. Constants.MATERIAL_CounterClockWiseSideOrientation = 1;
  26451. /**
  26452. * Nothing
  26453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26454. */
  26455. Constants.ACTION_NothingTrigger = 0;
  26456. /**
  26457. * On pick
  26458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26459. */
  26460. Constants.ACTION_OnPickTrigger = 1;
  26461. /**
  26462. * On left pick
  26463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26464. */
  26465. Constants.ACTION_OnLeftPickTrigger = 2;
  26466. /**
  26467. * On right pick
  26468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26469. */
  26470. Constants.ACTION_OnRightPickTrigger = 3;
  26471. /**
  26472. * On center pick
  26473. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26474. */
  26475. Constants.ACTION_OnCenterPickTrigger = 4;
  26476. /**
  26477. * On pick down
  26478. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26479. */
  26480. Constants.ACTION_OnPickDownTrigger = 5;
  26481. /**
  26482. * On double pick
  26483. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26484. */
  26485. Constants.ACTION_OnDoublePickTrigger = 6;
  26486. /**
  26487. * On pick up
  26488. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26489. */
  26490. Constants.ACTION_OnPickUpTrigger = 7;
  26491. /**
  26492. * On pick out.
  26493. * This trigger will only be raised if you also declared a OnPickDown
  26494. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26495. */
  26496. Constants.ACTION_OnPickOutTrigger = 16;
  26497. /**
  26498. * On long press
  26499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26500. */
  26501. Constants.ACTION_OnLongPressTrigger = 8;
  26502. /**
  26503. * On pointer over
  26504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26505. */
  26506. Constants.ACTION_OnPointerOverTrigger = 9;
  26507. /**
  26508. * On pointer out
  26509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26510. */
  26511. Constants.ACTION_OnPointerOutTrigger = 10;
  26512. /**
  26513. * On every frame
  26514. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26515. */
  26516. Constants.ACTION_OnEveryFrameTrigger = 11;
  26517. /**
  26518. * On intersection enter
  26519. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26520. */
  26521. Constants.ACTION_OnIntersectionEnterTrigger = 12;
  26522. /**
  26523. * On intersection exit
  26524. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26525. */
  26526. Constants.ACTION_OnIntersectionExitTrigger = 13;
  26527. /**
  26528. * On key down
  26529. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26530. */
  26531. Constants.ACTION_OnKeyDownTrigger = 14;
  26532. /**
  26533. * On key up
  26534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  26535. */
  26536. Constants.ACTION_OnKeyUpTrigger = 15;
  26537. /**
  26538. * Billboard mode will only apply to Y axis
  26539. */
  26540. Constants.PARTICLES_BILLBOARDMODE_Y = 2;
  26541. /**
  26542. * Billboard mode will apply to all axes
  26543. */
  26544. Constants.PARTICLES_BILLBOARDMODE_ALL = 7;
  26545. /**
  26546. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  26547. */
  26548. Constants.PARTICLES_BILLBOARDMODE_STRETCHED = 8;
  26549. /**
  26550. * Gets or sets base Assets URL
  26551. */
  26552. Constants.PARTICLES_BaseAssetsUrl = "https://assets.babylonjs.com/particles";
  26553. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26554. * Test order :
  26555. * Is the bounding sphere outside the frustum ?
  26556. * If not, are the bounding box vertices outside the frustum ?
  26557. * It not, then the cullable object is in the frustum.
  26558. */
  26559. Constants.MESHES_CULLINGSTRATEGY_STANDARD = 0;
  26560. /** Culling strategy : Bounding Sphere Only.
  26561. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26562. * It's also less accurate than the standard because some not visible objects can still be selected.
  26563. * Test : is the bounding sphere outside the frustum ?
  26564. * If not, then the cullable object is in the frustum.
  26565. */
  26566. Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1;
  26567. /** Culling strategy : Optimistic Inclusion.
  26568. * This in an inclusion test first, then the standard exclusion test.
  26569. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26570. * 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.
  26571. * Anyway, it's as accurate as the standard strategy.
  26572. * Test :
  26573. * Is the cullable object bounding sphere center in the frustum ?
  26574. * If not, apply the default culling strategy.
  26575. */
  26576. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2;
  26577. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26578. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26579. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26580. * 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.
  26581. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26582. * Test :
  26583. * Is the cullable object bounding sphere center in the frustum ?
  26584. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26585. */
  26586. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3;
  26587. /**
  26588. * No logging while loading
  26589. */
  26590. Constants.SCENELOADER_NO_LOGGING = 0;
  26591. /**
  26592. * Minimal logging while loading
  26593. */
  26594. Constants.SCENELOADER_MINIMAL_LOGGING = 1;
  26595. /**
  26596. * Summary logging while loading
  26597. */
  26598. Constants.SCENELOADER_SUMMARY_LOGGING = 2;
  26599. /**
  26600. * Detailled logging while loading
  26601. */
  26602. Constants.SCENELOADER_DETAILED_LOGGING = 3;
  26603. return Constants;
  26604. }());
  26605. /***/ }),
  26606. /***/ "./Engines/engine.ts":
  26607. /*!***************************!*\
  26608. !*** ./Engines/engine.ts ***!
  26609. \***************************/
  26610. /*! exports provided: InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine */
  26611. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26612. "use strict";
  26613. __webpack_require__.r(__webpack_exports__);
  26614. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return InstancingAttributeInfo; });
  26615. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return DepthTextureCreationOptions; });
  26616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return EngineCapabilities; });
  26617. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return Engine; });
  26618. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  26619. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  26620. /* harmony import */ var _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/performanceMonitor */ "./Misc/performanceMonitor.ts");
  26621. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  26622. /* harmony import */ var _Misc_promise__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/promise */ "./Misc/promise.ts");
  26623. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  26624. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26625. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  26626. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  26627. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  26628. /* harmony import */ var _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  26629. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  26630. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../States/index */ "./States/index.ts");
  26631. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  26632. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  26633. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  26634. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  26635. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  26636. /**
  26637. * Keeps track of all the buffer info used in engine.
  26638. */
  26639. var BufferPointer = /** @class */ (function () {
  26640. function BufferPointer() {
  26641. }
  26642. return BufferPointer;
  26643. }());
  26644. /**
  26645. * Interface for attribute information associated with buffer instanciation
  26646. */
  26647. var InstancingAttributeInfo = /** @class */ (function () {
  26648. function InstancingAttributeInfo() {
  26649. }
  26650. return InstancingAttributeInfo;
  26651. }());
  26652. /**
  26653. * Define options used to create a depth texture
  26654. */
  26655. var DepthTextureCreationOptions = /** @class */ (function () {
  26656. function DepthTextureCreationOptions() {
  26657. }
  26658. return DepthTextureCreationOptions;
  26659. }());
  26660. /**
  26661. * Class used to describe the capabilities of the engine relatively to the current browser
  26662. */
  26663. var EngineCapabilities = /** @class */ (function () {
  26664. function EngineCapabilities() {
  26665. }
  26666. return EngineCapabilities;
  26667. }());
  26668. /**
  26669. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26670. */
  26671. var Engine = /** @class */ (function () {
  26672. /**
  26673. * Creates a new engine
  26674. * @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
  26675. * @param antialias defines enable antialiasing (default: false)
  26676. * @param options defines further options to be sent to the getContext() function
  26677. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  26678. */
  26679. function Engine(canvasOrContext, antialias, options, adaptToDeviceRatio) {
  26680. if (adaptToDeviceRatio === void 0) { adaptToDeviceRatio = false; }
  26681. var _this = this;
  26682. // Public members
  26683. /**
  26684. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26685. */
  26686. this.forcePOTTextures = false;
  26687. /**
  26688. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26689. */
  26690. this.isFullscreen = false;
  26691. /**
  26692. * Gets a boolean indicating if the pointer is currently locked
  26693. */
  26694. this.isPointerLock = false;
  26695. /**
  26696. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  26697. */
  26698. this.cullBackFaces = true;
  26699. /**
  26700. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  26701. */
  26702. this.renderEvenInBackground = true;
  26703. /**
  26704. * Gets or sets a boolean indicating that cache can be kept between frames
  26705. */
  26706. this.preventCacheWipeBetweenFrames = false;
  26707. /**
  26708. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  26709. **/
  26710. this.enableOfflineSupport = false;
  26711. /**
  26712. * 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)
  26713. **/
  26714. this.disableManifestCheck = false;
  26715. /**
  26716. * Gets the list of created scenes
  26717. */
  26718. this.scenes = new Array();
  26719. /**
  26720. * Event raised when a new scene is created
  26721. */
  26722. this.onNewSceneAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26723. /**
  26724. * Gets the list of created postprocesses
  26725. */
  26726. this.postProcesses = new Array();
  26727. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  26728. this.validateShaderPrograms = false;
  26729. // Observables
  26730. /**
  26731. * Observable event triggered each time the rendering canvas is resized
  26732. */
  26733. this.onResizeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26734. /**
  26735. * Observable event triggered each time the canvas loses focus
  26736. */
  26737. this.onCanvasBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26738. /**
  26739. * Observable event triggered each time the canvas gains focus
  26740. */
  26741. this.onCanvasFocusObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26742. /**
  26743. * Observable event triggered each time the canvas receives pointerout event
  26744. */
  26745. this.onCanvasPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26746. /**
  26747. * Observable event triggered before each texture is initialized
  26748. */
  26749. this.onBeforeTextureInitObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26750. //WebVR
  26751. this._vrDisplay = undefined;
  26752. this._vrSupported = false;
  26753. this._vrExclusivePointerMode = false;
  26754. // Uniform buffers list
  26755. /**
  26756. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  26757. */
  26758. this.disableUniformBuffers = false;
  26759. /** @hidden */
  26760. this._uniformBuffers = new Array();
  26761. // Observables
  26762. /**
  26763. * Observable raised when the engine begins a new frame
  26764. */
  26765. this.onBeginFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26766. /**
  26767. * If set, will be used to request the next animation frame for the render loop
  26768. */
  26769. this.customAnimationFrameRequester = null;
  26770. /**
  26771. * Observable raised when the engine ends the current frame
  26772. */
  26773. this.onEndFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26774. /**
  26775. * Observable raised when the engine is about to compile a shader
  26776. */
  26777. this.onBeforeShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26778. /**
  26779. * Observable raised when the engine has jsut compiled a shader
  26780. */
  26781. this.onAfterShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26782. this._windowIsBackground = false;
  26783. this._webGLVersion = 1.0;
  26784. /** @hidden */
  26785. this._badOS = false;
  26786. /** @hidden */
  26787. this._badDesktopOS = false;
  26788. /**
  26789. * Gets or sets a value indicating if we want to disable texture binding optimization.
  26790. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  26791. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  26792. */
  26793. this.disableTextureBindingOptimization = false;
  26794. /**
  26795. * Observable signaled when VR display mode changes
  26796. */
  26797. this.onVRDisplayChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26798. /**
  26799. * Observable signaled when VR request present is complete
  26800. */
  26801. this.onVRRequestPresentComplete = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26802. /**
  26803. * Observable signaled when VR request present starts
  26804. */
  26805. this.onVRRequestPresentStart = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26806. this._colorWrite = true;
  26807. /** @hidden */
  26808. this._drawCalls = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  26809. /** @hidden */
  26810. this._textureCollisions = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  26811. this._renderingQueueLaunched = false;
  26812. this._activeRenderLoops = new Array();
  26813. // Deterministic lockstepMaxSteps
  26814. this._deterministicLockstep = false;
  26815. this._lockstepMaxSteps = 4;
  26816. // Lost context
  26817. /**
  26818. * Observable signaled when a context lost event is raised
  26819. */
  26820. this.onContextLostObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26821. /**
  26822. * Observable signaled when a context restored event is raised
  26823. */
  26824. this.onContextRestoredObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  26825. this._contextWasLost = false;
  26826. this._doNotHandleContextLost = false;
  26827. // FPS
  26828. this._performanceMonitor = new _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__["PerformanceMonitor"]();
  26829. this._fps = 60;
  26830. this._deltaTime = 0;
  26831. /**
  26832. * Turn this value on if you want to pause FPS computation when in background
  26833. */
  26834. this.disablePerformanceMonitorInBackground = false;
  26835. // States
  26836. /** @hidden */
  26837. this._depthCullingState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_DepthCullingState"]();
  26838. /** @hidden */
  26839. this._stencilState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_StencilState"]();
  26840. /** @hidden */
  26841. this._alphaState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_AlphaState"]();
  26842. /** @hidden */
  26843. this._alphaMode = Engine.ALPHA_DISABLE;
  26844. // Cache
  26845. this._internalTexturesCache = new Array();
  26846. /** @hidden */
  26847. this._activeChannel = 0;
  26848. this._currentTextureChannel = -1;
  26849. /** @hidden */
  26850. this._boundTexturesCache = {};
  26851. this._compiledEffects = {};
  26852. this._vertexAttribArraysEnabled = [];
  26853. this._uintIndicesCurrentlySet = false;
  26854. this._currentBoundBuffer = new Array();
  26855. /** @hidden */
  26856. this._currentFramebuffer = null;
  26857. this._currentBufferPointers = new Array();
  26858. this._currentInstanceLocations = new Array();
  26859. this._currentInstanceBuffers = new Array();
  26860. this._firstBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  26861. this._lastBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  26862. this._vaoRecordInProgress = false;
  26863. this._mustWipeVertexAttributes = false;
  26864. this._nextFreeTextureSlots = new Array();
  26865. this._maxSimultaneousTextures = 0;
  26866. this._activeRequests = new Array();
  26867. // Hardware supported Compressed Textures
  26868. this._texturesSupported = new Array();
  26869. /**
  26870. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  26871. */
  26872. this.premultipliedAlpha = true;
  26873. this._viewportCached = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](0, 0, 0, 0);
  26874. this._onVRFullScreenTriggered = function () {
  26875. if (_this._vrDisplay && _this._vrDisplay.isPresenting) {
  26876. //get the old size before we change
  26877. _this._oldSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Size"](_this.getRenderWidth(), _this.getRenderHeight());
  26878. _this._oldHardwareScaleFactor = _this.getHardwareScalingLevel();
  26879. //get the width and height, change the render size
  26880. var leftEye = _this._vrDisplay.getEyeParameters('left');
  26881. _this.setHardwareScalingLevel(1);
  26882. _this.setSize(leftEye.renderWidth * 2, leftEye.renderHeight);
  26883. }
  26884. else {
  26885. _this.setHardwareScalingLevel(_this._oldHardwareScaleFactor);
  26886. _this.setSize(_this._oldSize.width, _this._oldSize.height);
  26887. }
  26888. };
  26889. this._unpackFlipYCached = null;
  26890. /**
  26891. * In case you are sharing the context with other applications, it might
  26892. * be interested to not cache the unpack flip y state to ensure a consistent
  26893. * value would be set.
  26894. */
  26895. this.enableUnpackFlipYCached = true;
  26896. this._boundUniforms = {};
  26897. // Register promises
  26898. _Misc_promise__WEBPACK_IMPORTED_MODULE_4__["PromisePolyfill"].Apply();
  26899. var canvas = null;
  26900. Engine.Instances.push(this);
  26901. if (!canvasOrContext) {
  26902. return;
  26903. }
  26904. options = options || {};
  26905. if (canvasOrContext.getContext) {
  26906. canvas = canvasOrContext;
  26907. this._renderingCanvas = canvas;
  26908. if (antialias != null) {
  26909. options.antialias = antialias;
  26910. }
  26911. if (options.deterministicLockstep === undefined) {
  26912. options.deterministicLockstep = false;
  26913. }
  26914. if (options.lockstepMaxSteps === undefined) {
  26915. options.lockstepMaxSteps = 4;
  26916. }
  26917. if (options.preserveDrawingBuffer === undefined) {
  26918. options.preserveDrawingBuffer = false;
  26919. }
  26920. if (options.audioEngine === undefined) {
  26921. options.audioEngine = true;
  26922. }
  26923. if (options.stencil === undefined) {
  26924. options.stencil = true;
  26925. }
  26926. if (options.premultipliedAlpha === false) {
  26927. this.premultipliedAlpha = false;
  26928. }
  26929. this._deterministicLockstep = options.deterministicLockstep;
  26930. this._lockstepMaxSteps = options.lockstepMaxSteps;
  26931. this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
  26932. // Exceptions
  26933. if (navigator && navigator.userAgent) {
  26934. var ua = navigator.userAgent;
  26935. for (var _i = 0, _a = Engine.ExceptionList; _i < _a.length; _i++) {
  26936. var exception = _a[_i];
  26937. var key = exception.key;
  26938. var targets = exception.targets;
  26939. if (ua.indexOf(key) > -1) {
  26940. if (exception.capture && exception.captureConstraint) {
  26941. var capture = exception.capture;
  26942. var constraint = exception.captureConstraint;
  26943. var regex = new RegExp(capture);
  26944. var matches = regex.exec(ua);
  26945. if (matches && matches.length > 0) {
  26946. var capturedValue = parseInt(matches[matches.length - 1]);
  26947. if (capturedValue >= constraint) {
  26948. continue;
  26949. }
  26950. }
  26951. }
  26952. for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
  26953. var target = targets_1[_b];
  26954. switch (target) {
  26955. case "uniformBuffer":
  26956. this.disableUniformBuffers = true;
  26957. break;
  26958. case "textureBindingOptimization":
  26959. this.disableTextureBindingOptimization = true;
  26960. break;
  26961. }
  26962. }
  26963. }
  26964. }
  26965. }
  26966. // GL
  26967. if (!options.disableWebGL2Support) {
  26968. try {
  26969. this._gl = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
  26970. if (this._gl) {
  26971. this._webGLVersion = 2.0;
  26972. // Prevent weird browsers to lie :-)
  26973. if (!this._gl.deleteQuery) {
  26974. this._webGLVersion = 1.0;
  26975. }
  26976. }
  26977. }
  26978. catch (e) {
  26979. // Do nothing
  26980. }
  26981. }
  26982. if (!this._gl) {
  26983. if (!canvas) {
  26984. throw new Error("The provided canvas is null or undefined.");
  26985. }
  26986. try {
  26987. this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
  26988. }
  26989. catch (e) {
  26990. throw new Error("WebGL not supported");
  26991. }
  26992. }
  26993. if (!this._gl) {
  26994. throw new Error("WebGL not supported");
  26995. }
  26996. this._onCanvasFocus = function () {
  26997. _this.onCanvasFocusObservable.notifyObservers(_this);
  26998. };
  26999. this._onCanvasBlur = function () {
  27000. _this.onCanvasBlurObservable.notifyObservers(_this);
  27001. };
  27002. canvas.addEventListener("focus", this._onCanvasFocus);
  27003. canvas.addEventListener("blur", this._onCanvasBlur);
  27004. this._onBlur = function () {
  27005. if (_this.disablePerformanceMonitorInBackground) {
  27006. _this._performanceMonitor.disable();
  27007. }
  27008. _this._windowIsBackground = true;
  27009. };
  27010. this._onFocus = function () {
  27011. if (_this.disablePerformanceMonitorInBackground) {
  27012. _this._performanceMonitor.enable();
  27013. }
  27014. _this._windowIsBackground = false;
  27015. };
  27016. this._onCanvasPointerOut = function (ev) {
  27017. _this.onCanvasPointerOutObservable.notifyObservers(ev);
  27018. };
  27019. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  27020. window.addEventListener("blur", this._onBlur);
  27021. window.addEventListener("focus", this._onFocus);
  27022. }
  27023. canvas.addEventListener("pointerout", this._onCanvasPointerOut);
  27024. // Context lost
  27025. if (!this._doNotHandleContextLost) {
  27026. this._onContextLost = function (evt) {
  27027. evt.preventDefault();
  27028. _this._contextWasLost = true;
  27029. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context lost.");
  27030. _this.onContextLostObservable.notifyObservers(_this);
  27031. };
  27032. this._onContextRestored = function () {
  27033. // Adding a timeout to avoid race condition at browser level
  27034. setTimeout(function () {
  27035. // Rebuild gl context
  27036. _this._initGLContext();
  27037. // Rebuild effects
  27038. _this._rebuildEffects();
  27039. // Rebuild textures
  27040. _this._rebuildInternalTextures();
  27041. // Rebuild buffers
  27042. _this._rebuildBuffers();
  27043. // Cache
  27044. _this.wipeCaches(true);
  27045. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context successfully restored.");
  27046. _this.onContextRestoredObservable.notifyObservers(_this);
  27047. _this._contextWasLost = false;
  27048. }, 0);
  27049. };
  27050. canvas.addEventListener("webglcontextlost", this._onContextLost, false);
  27051. canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
  27052. }
  27053. if (!options.doNotHandleTouchAction) {
  27054. this._disableTouchAction();
  27055. }
  27056. }
  27057. else {
  27058. this._gl = canvasOrContext;
  27059. this._renderingCanvas = this._gl.canvas;
  27060. if (this._gl.renderbufferStorageMultisample) {
  27061. this._webGLVersion = 2.0;
  27062. }
  27063. var attributes = this._gl.getContextAttributes();
  27064. if (attributes) {
  27065. options.stencil = attributes.stencil;
  27066. }
  27067. }
  27068. // Viewport
  27069. var devicePixelRatio = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist() ? (window.devicePixelRatio || 1.0) : 1.0;
  27070. var limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
  27071. this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
  27072. this.resize();
  27073. this._isStencilEnable = options.stencil ? true : false;
  27074. this._initGLContext();
  27075. if (canvas) {
  27076. // Fullscreen
  27077. this._onFullscreenChange = function () {
  27078. if (document.fullscreen !== undefined) {
  27079. _this.isFullscreen = document.fullscreen;
  27080. }
  27081. else if (document.mozFullScreen !== undefined) {
  27082. _this.isFullscreen = document.mozFullScreen;
  27083. }
  27084. else if (document.webkitIsFullScreen !== undefined) {
  27085. _this.isFullscreen = document.webkitIsFullScreen;
  27086. }
  27087. else if (document.msIsFullScreen !== undefined) {
  27088. _this.isFullscreen = document.msIsFullScreen;
  27089. }
  27090. // Pointer lock
  27091. if (_this.isFullscreen && _this._pointerLockRequested && canvas) {
  27092. canvas.requestPointerLock = canvas.requestPointerLock ||
  27093. canvas.msRequestPointerLock ||
  27094. canvas.mozRequestPointerLock ||
  27095. canvas.webkitRequestPointerLock;
  27096. if (canvas.requestPointerLock) {
  27097. canvas.requestPointerLock();
  27098. }
  27099. }
  27100. };
  27101. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  27102. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  27103. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  27104. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  27105. // Pointer lock
  27106. this._onPointerLockChange = function () {
  27107. _this.isPointerLock = (document.mozPointerLockElement === canvas ||
  27108. document.webkitPointerLockElement === canvas ||
  27109. document.msPointerLockElement === canvas ||
  27110. document.pointerLockElement === canvas);
  27111. };
  27112. document.addEventListener("pointerlockchange", this._onPointerLockChange, false);
  27113. document.addEventListener("mspointerlockchange", this._onPointerLockChange, false);
  27114. document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
  27115. document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
  27116. this._onVRDisplayPointerRestricted = function () {
  27117. if (canvas) {
  27118. canvas.requestPointerLock();
  27119. }
  27120. };
  27121. this._onVRDisplayPointerUnrestricted = function () {
  27122. document.exitPointerLock();
  27123. };
  27124. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  27125. window.addEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted, false);
  27126. window.addEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted, false);
  27127. }
  27128. }
  27129. // Create Audio Engine if needed.
  27130. if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {
  27131. Engine.audioEngine = Engine.AudioEngineFactory(this.getRenderingCanvas());
  27132. }
  27133. // Prepare buffer pointers
  27134. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  27135. this._currentBufferPointers[i] = new BufferPointer();
  27136. }
  27137. this._linkTrackers(this._firstBoundInternalTextureTracker, this._lastBoundInternalTextureTracker);
  27138. // Load WebVR Devices
  27139. if (options.autoEnableWebVR) {
  27140. this.initWebVR();
  27141. }
  27142. // Detect if we are running on a faulty buggy OS.
  27143. this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
  27144. // Detect if we are running on a faulty buggy desktop OS.
  27145. this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  27146. console.log("Babylon.js v" + Engine.Version + " - " + this.description);
  27147. this.enableOfflineSupport = Engine.OfflineProviderFactory !== undefined;
  27148. }
  27149. Object.defineProperty(Engine, "Instances", {
  27150. /** Gets the list of created engines */
  27151. get: function () {
  27152. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].Instances;
  27153. },
  27154. enumerable: true,
  27155. configurable: true
  27156. });
  27157. Object.defineProperty(Engine, "LastCreatedEngine", {
  27158. /**
  27159. * Gets the latest created engine
  27160. */
  27161. get: function () {
  27162. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine;
  27163. },
  27164. enumerable: true,
  27165. configurable: true
  27166. });
  27167. Object.defineProperty(Engine, "LastCreatedScene", {
  27168. /**
  27169. * Gets the latest created scene
  27170. */
  27171. get: function () {
  27172. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  27173. },
  27174. enumerable: true,
  27175. configurable: true
  27176. });
  27177. /**
  27178. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27179. * @param flag defines which part of the materials must be marked as dirty
  27180. * @param predicate defines a predicate used to filter which materials should be affected
  27181. */
  27182. Engine.MarkAllMaterialsAsDirty = function (flag, predicate) {
  27183. for (var engineIndex = 0; engineIndex < Engine.Instances.length; engineIndex++) {
  27184. var engine = Engine.Instances[engineIndex];
  27185. for (var sceneIndex = 0; sceneIndex < engine.scenes.length; sceneIndex++) {
  27186. engine.scenes[sceneIndex].markAllMaterialsAsDirty(flag, predicate);
  27187. }
  27188. }
  27189. };
  27190. Object.defineProperty(Engine, "Version", {
  27191. /**
  27192. * Returns the current version of the framework
  27193. */
  27194. get: function () {
  27195. return "4.0.0-alpha.18";
  27196. },
  27197. enumerable: true,
  27198. configurable: true
  27199. });
  27200. Object.defineProperty(Engine.prototype, "description", {
  27201. /**
  27202. * Returns a string describing the current engine
  27203. */
  27204. get: function () {
  27205. var description = "WebGL" + this.webGLVersion;
  27206. if (this._caps.parallelShaderCompile) {
  27207. description += " - Parallel shader compilation";
  27208. }
  27209. return description;
  27210. },
  27211. enumerable: true,
  27212. configurable: true
  27213. });
  27214. Object.defineProperty(Engine, "ShadersRepository", {
  27215. /**
  27216. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27217. */
  27218. get: function () {
  27219. return _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository;
  27220. },
  27221. set: function (value) {
  27222. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository = value;
  27223. },
  27224. enumerable: true,
  27225. configurable: true
  27226. });
  27227. /**
  27228. * Method called to create the default loading screen.
  27229. * This can be overriden in your own app.
  27230. * @param canvas The rendering canvas element
  27231. * @returns The loading screen
  27232. */
  27233. Engine.DefaultLoadingScreenFactory = function (canvas) {
  27234. throw "Import LoadingScreen or set DefaultLoadingScreenFactory on engine before using the loading screen";
  27235. };
  27236. Object.defineProperty(Engine.prototype, "isInVRExclusivePointerMode", {
  27237. /**
  27238. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27239. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27240. */
  27241. get: function () {
  27242. return this._vrExclusivePointerMode;
  27243. },
  27244. enumerable: true,
  27245. configurable: true
  27246. });
  27247. Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
  27248. /**
  27249. * Gets a boolean indicating that the engine supports uniform buffers
  27250. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27251. */
  27252. get: function () {
  27253. return this.webGLVersion > 1 && !this.disableUniformBuffers;
  27254. },
  27255. enumerable: true,
  27256. configurable: true
  27257. });
  27258. Object.defineProperty(Engine.prototype, "needPOTTextures", {
  27259. /**
  27260. * Gets a boolean indicating that only power of 2 textures are supported
  27261. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27262. */
  27263. get: function () {
  27264. return this._webGLVersion < 2 || this.forcePOTTextures;
  27265. },
  27266. enumerable: true,
  27267. configurable: true
  27268. });
  27269. Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
  27270. /**
  27271. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27272. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27273. */
  27274. get: function () {
  27275. return this._doNotHandleContextLost;
  27276. },
  27277. set: function (value) {
  27278. this._doNotHandleContextLost = value;
  27279. },
  27280. enumerable: true,
  27281. configurable: true
  27282. });
  27283. Object.defineProperty(Engine.prototype, "performanceMonitor", {
  27284. /**
  27285. * Gets the performance monitor attached to this engine
  27286. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27287. */
  27288. get: function () {
  27289. return this._performanceMonitor;
  27290. },
  27291. enumerable: true,
  27292. configurable: true
  27293. });
  27294. Object.defineProperty(Engine.prototype, "texturesSupported", {
  27295. /**
  27296. * Gets the list of texture formats supported
  27297. */
  27298. get: function () {
  27299. return this._texturesSupported;
  27300. },
  27301. enumerable: true,
  27302. configurable: true
  27303. });
  27304. Object.defineProperty(Engine.prototype, "textureFormatInUse", {
  27305. /**
  27306. * Gets the list of texture formats in use
  27307. */
  27308. get: function () {
  27309. return this._textureFormatInUse;
  27310. },
  27311. enumerable: true,
  27312. configurable: true
  27313. });
  27314. Object.defineProperty(Engine.prototype, "currentViewport", {
  27315. /**
  27316. * Gets the current viewport
  27317. */
  27318. get: function () {
  27319. return this._cachedViewport;
  27320. },
  27321. enumerable: true,
  27322. configurable: true
  27323. });
  27324. Object.defineProperty(Engine.prototype, "emptyTexture", {
  27325. /**
  27326. * Gets the default empty texture
  27327. */
  27328. get: function () {
  27329. if (!this._emptyTexture) {
  27330. this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  27331. }
  27332. return this._emptyTexture;
  27333. },
  27334. enumerable: true,
  27335. configurable: true
  27336. });
  27337. Object.defineProperty(Engine.prototype, "emptyTexture3D", {
  27338. /**
  27339. * Gets the default empty 3D texture
  27340. */
  27341. get: function () {
  27342. if (!this._emptyTexture3D) {
  27343. this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  27344. }
  27345. return this._emptyTexture3D;
  27346. },
  27347. enumerable: true,
  27348. configurable: true
  27349. });
  27350. Object.defineProperty(Engine.prototype, "emptyCubeTexture", {
  27351. /**
  27352. * Gets the default empty cube texture
  27353. */
  27354. get: function () {
  27355. if (!this._emptyCubeTexture) {
  27356. var faceData = new Uint8Array(4);
  27357. var cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];
  27358. this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, Engine.TEXTUREFORMAT_RGBA, Engine.TEXTURETYPE_UNSIGNED_INT, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  27359. }
  27360. return this._emptyCubeTexture;
  27361. },
  27362. enumerable: true,
  27363. configurable: true
  27364. });
  27365. Engine.prototype._disableTouchAction = function () {
  27366. if (!this._renderingCanvas) {
  27367. return;
  27368. }
  27369. this._renderingCanvas.setAttribute("touch-action", "none");
  27370. this._renderingCanvas.style.touchAction = "none";
  27371. this._renderingCanvas.style.msTouchAction = "none";
  27372. };
  27373. Engine.prototype._rebuildInternalTextures = function () {
  27374. var currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies
  27375. for (var _i = 0, currentState_1 = currentState; _i < currentState_1.length; _i++) {
  27376. var internalTexture = currentState_1[_i];
  27377. internalTexture._rebuild();
  27378. }
  27379. };
  27380. Engine.prototype._rebuildEffects = function () {
  27381. for (var key in this._compiledEffects) {
  27382. var effect = this._compiledEffects[key];
  27383. effect._prepareEffect();
  27384. }
  27385. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  27386. };
  27387. /**
  27388. * Gets a boolean indicating if all created effects are ready
  27389. * @returns true if all effects are ready
  27390. */
  27391. Engine.prototype.areAllEffectsReady = function () {
  27392. for (var key in this._compiledEffects) {
  27393. var effect = this._compiledEffects[key];
  27394. if (!effect.isReady()) {
  27395. return false;
  27396. }
  27397. }
  27398. return true;
  27399. };
  27400. Engine.prototype._rebuildBuffers = function () {
  27401. // Index / Vertex
  27402. for (var _i = 0, _a = this.scenes; _i < _a.length; _i++) {
  27403. var scene = _a[_i];
  27404. scene.resetCachedMaterial();
  27405. scene._rebuildGeometries();
  27406. scene._rebuildTextures();
  27407. }
  27408. // Uniforms
  27409. for (var _b = 0, _c = this._uniformBuffers; _b < _c.length; _b++) {
  27410. var uniformBuffer = _c[_b];
  27411. uniformBuffer._rebuild();
  27412. }
  27413. };
  27414. Engine.prototype._initGLContext = function () {
  27415. // Caps
  27416. this._caps = new EngineCapabilities();
  27417. this._caps.maxTexturesImageUnits = this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);
  27418. this._caps.maxCombinedTexturesImageUnits = this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  27419. this._caps.maxVertexTextureImageUnits = this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
  27420. this._caps.maxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
  27421. this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
  27422. this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
  27423. this._caps.maxVertexAttribs = this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS);
  27424. this._caps.maxVaryingVectors = this._gl.getParameter(this._gl.MAX_VARYING_VECTORS);
  27425. this._caps.maxFragmentUniformVectors = this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS);
  27426. this._caps.maxVertexUniformVectors = this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS);
  27427. // Infos
  27428. this._glVersion = this._gl.getParameter(this._gl.VERSION);
  27429. var rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
  27430. if (rendererInfo != null) {
  27431. this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);
  27432. this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);
  27433. }
  27434. if (!this._glVendor) {
  27435. this._glVendor = "Unknown vendor";
  27436. }
  27437. if (!this._glRenderer) {
  27438. this._glRenderer = "Unknown renderer";
  27439. }
  27440. // Constants
  27441. this._gl.HALF_FLOAT_OES = 0x8D61; // Half floating-point type (16-bit).
  27442. if (this._gl.RGBA16F !== 0x881A) {
  27443. this._gl.RGBA16F = 0x881A; // RGBA 16-bit floating-point color-renderable internal sized format.
  27444. }
  27445. if (this._gl.RGBA32F !== 0x8814) {
  27446. this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.
  27447. }
  27448. if (this._gl.DEPTH24_STENCIL8 !== 35056) {
  27449. this._gl.DEPTH24_STENCIL8 = 35056;
  27450. }
  27451. // Extensions
  27452. this._caps.standardDerivatives = this._webGLVersion > 1 || (this._gl.getExtension('OES_standard_derivatives') !== null);
  27453. this._caps.astc = this._gl.getExtension('WEBGL_compressed_texture_astc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_astc');
  27454. this._caps.s3tc = this._gl.getExtension('WEBGL_compressed_texture_s3tc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
  27455. this._caps.pvrtc = this._gl.getExtension('WEBGL_compressed_texture_pvrtc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
  27456. this._caps.etc1 = this._gl.getExtension('WEBGL_compressed_texture_etc1') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1');
  27457. this._caps.etc2 = this._gl.getExtension('WEBGL_compressed_texture_etc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc') ||
  27458. this._gl.getExtension('WEBGL_compressed_texture_es3_0'); // also a requirement of OpenGL ES 3
  27459. 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');
  27460. this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
  27461. this._caps.uintIndices = this._webGLVersion > 1 || this._gl.getExtension('OES_element_index_uint') !== null;
  27462. this._caps.fragmentDepthSupported = this._webGLVersion > 1 || this._gl.getExtension('EXT_frag_depth') !== null;
  27463. this._caps.highPrecisionShaderSupported = false;
  27464. this._caps.timerQuery = this._gl.getExtension('EXT_disjoint_timer_query_webgl2') || this._gl.getExtension("EXT_disjoint_timer_query");
  27465. if (this._caps.timerQuery) {
  27466. if (this._webGLVersion === 1) {
  27467. this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);
  27468. }
  27469. this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0;
  27470. }
  27471. // Checks if some of the format renders first to allow the use of webgl inspector.
  27472. this._caps.colorBufferFloat = this._webGLVersion > 1 && this._gl.getExtension('EXT_color_buffer_float');
  27473. this._caps.textureFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_float')) ? true : false;
  27474. this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension('OES_texture_float_linear') ? true : false;
  27475. this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;
  27476. this._caps.textureHalfFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_half_float')) ? true : false;
  27477. this._caps.textureHalfFloatLinearFiltering = (this._webGLVersion > 1 || (this._caps.textureHalfFloat && this._gl.getExtension('OES_texture_half_float_linear'))) ? true : false;
  27478. if (this._webGLVersion > 1) {
  27479. this._gl.HALF_FLOAT_OES = 0x140B;
  27480. }
  27481. this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();
  27482. this._caps.textureLOD = (this._webGLVersion > 1 || this._gl.getExtension('EXT_shader_texture_lod')) ? true : false;
  27483. // Draw buffers
  27484. if (this._webGLVersion > 1) {
  27485. this._caps.drawBuffersExtension = true;
  27486. }
  27487. else {
  27488. var drawBuffersExtension = this._gl.getExtension('WEBGL_draw_buffers');
  27489. if (drawBuffersExtension !== null) {
  27490. this._caps.drawBuffersExtension = true;
  27491. this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);
  27492. this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
  27493. for (var i = 0; i < 16; i++) {
  27494. this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = drawBuffersExtension["COLOR_ATTACHMENT" + i + "_WEBGL"];
  27495. }
  27496. }
  27497. else {
  27498. this._caps.drawBuffersExtension = false;
  27499. }
  27500. }
  27501. // Shader compiler threads
  27502. this._caps.parallelShaderCompile = this._gl.getExtension('KHR_parallel_shader_compile');
  27503. if (this._caps.parallelShaderCompile) {
  27504. var threads = this._gl.getParameter(this._caps.parallelShaderCompile.MAX_SHADER_COMPILER_THREADS_KHR);
  27505. this._caps.parallelShaderCompile.maxShaderCompilerThreadsKHR(threads);
  27506. }
  27507. // Depth Texture
  27508. if (this._webGLVersion > 1) {
  27509. this._caps.depthTextureExtension = true;
  27510. }
  27511. else {
  27512. var depthTextureExtension = this._gl.getExtension('WEBGL_depth_texture');
  27513. if (depthTextureExtension != null) {
  27514. this._caps.depthTextureExtension = true;
  27515. this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;
  27516. }
  27517. }
  27518. // Vertex array object
  27519. if (this._webGLVersion > 1) {
  27520. this._caps.vertexArrayObject = true;
  27521. }
  27522. else {
  27523. var vertexArrayObjectExtension = this._gl.getExtension('OES_vertex_array_object');
  27524. if (vertexArrayObjectExtension != null) {
  27525. this._caps.vertexArrayObject = true;
  27526. this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);
  27527. this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);
  27528. this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);
  27529. }
  27530. else {
  27531. this._caps.vertexArrayObject = false;
  27532. }
  27533. }
  27534. // Instances count
  27535. if (this._webGLVersion > 1) {
  27536. this._caps.instancedArrays = true;
  27537. }
  27538. else {
  27539. var instanceExtension = this._gl.getExtension('ANGLE_instanced_arrays');
  27540. if (instanceExtension != null) {
  27541. this._caps.instancedArrays = true;
  27542. this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);
  27543. this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);
  27544. this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);
  27545. }
  27546. else {
  27547. this._caps.instancedArrays = false;
  27548. }
  27549. }
  27550. // Intelligently add supported compressed formats in order to check for.
  27551. // Check for ASTC support first as it is most powerful and to be very cross platform.
  27552. // Next PVRTC & DXT, which are probably superior to ETC1/2.
  27553. // Likely no hardware which supports both PVR & DXT, so order matters little.
  27554. // ETC2 is newer and handles ETC1 (no alpha capability), so check for first.
  27555. if (this._caps.astc) {
  27556. this.texturesSupported.push('-astc.ktx');
  27557. }
  27558. if (this._caps.s3tc) {
  27559. this.texturesSupported.push('-dxt.ktx');
  27560. }
  27561. if (this._caps.pvrtc) {
  27562. this.texturesSupported.push('-pvrtc.ktx');
  27563. }
  27564. if (this._caps.etc2) {
  27565. this.texturesSupported.push('-etc2.ktx');
  27566. }
  27567. if (this._caps.etc1) {
  27568. this.texturesSupported.push('-etc1.ktx');
  27569. }
  27570. if (this._gl.getShaderPrecisionFormat) {
  27571. var vertex_highp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);
  27572. var fragment_highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
  27573. if (vertex_highp && fragment_highp) {
  27574. this._caps.highPrecisionShaderSupported = vertex_highp.precision !== 0 && fragment_highp.precision !== 0;
  27575. }
  27576. }
  27577. // Depth buffer
  27578. this.setDepthBuffer(true);
  27579. this.setDepthFunctionToLessOrEqual();
  27580. this.setDepthWrite(true);
  27581. // Texture maps
  27582. this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
  27583. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  27584. this._nextFreeTextureSlots.push(slot);
  27585. }
  27586. };
  27587. Object.defineProperty(Engine.prototype, "webGLVersion", {
  27588. /**
  27589. * Gets version of the current webGL context
  27590. */
  27591. get: function () {
  27592. return this._webGLVersion;
  27593. },
  27594. enumerable: true,
  27595. configurable: true
  27596. });
  27597. Object.defineProperty(Engine.prototype, "isStencilEnable", {
  27598. /**
  27599. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27600. */
  27601. get: function () {
  27602. return this._isStencilEnable;
  27603. },
  27604. enumerable: true,
  27605. configurable: true
  27606. });
  27607. Engine.prototype._prepareWorkingCanvas = function () {
  27608. if (this._workingCanvas) {
  27609. return;
  27610. }
  27611. this._workingCanvas = document.createElement("canvas");
  27612. var context = this._workingCanvas.getContext("2d");
  27613. if (context) {
  27614. this._workingContext = context;
  27615. }
  27616. };
  27617. /**
  27618. * Reset the texture cache to empty state
  27619. */
  27620. Engine.prototype.resetTextureCache = function () {
  27621. for (var key in this._boundTexturesCache) {
  27622. if (!this._boundTexturesCache.hasOwnProperty(key)) {
  27623. continue;
  27624. }
  27625. var boundTexture = this._boundTexturesCache[key];
  27626. if (boundTexture) {
  27627. this._removeDesignatedSlot(boundTexture);
  27628. }
  27629. this._boundTexturesCache[key] = null;
  27630. }
  27631. if (!this.disableTextureBindingOptimization) {
  27632. this._nextFreeTextureSlots = [];
  27633. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  27634. this._nextFreeTextureSlots.push(slot);
  27635. }
  27636. }
  27637. this._currentTextureChannel = -1;
  27638. };
  27639. /**
  27640. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27641. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27642. * @returns true if engine is in deterministic lock step mode
  27643. */
  27644. Engine.prototype.isDeterministicLockStep = function () {
  27645. return this._deterministicLockstep;
  27646. };
  27647. /**
  27648. * Gets the max steps when engine is running in deterministic lock step
  27649. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27650. * @returns the max steps
  27651. */
  27652. Engine.prototype.getLockstepMaxSteps = function () {
  27653. return this._lockstepMaxSteps;
  27654. };
  27655. /**
  27656. * Gets an object containing information about the current webGL context
  27657. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27658. */
  27659. Engine.prototype.getGlInfo = function () {
  27660. return {
  27661. vendor: this._glVendor,
  27662. renderer: this._glRenderer,
  27663. version: this._glVersion
  27664. };
  27665. };
  27666. /**
  27667. * Gets current aspect ratio
  27668. * @param camera defines the camera to use to get the aspect ratio
  27669. * @param useScreen defines if screen size must be used (or the current render target if any)
  27670. * @returns a number defining the aspect ratio
  27671. */
  27672. Engine.prototype.getAspectRatio = function (camera, useScreen) {
  27673. if (useScreen === void 0) { useScreen = false; }
  27674. var viewport = camera.viewport;
  27675. return (this.getRenderWidth(useScreen) * viewport.width) / (this.getRenderHeight(useScreen) * viewport.height);
  27676. };
  27677. /**
  27678. * Gets current screen aspect ratio
  27679. * @returns a number defining the aspect ratio
  27680. */
  27681. Engine.prototype.getScreenAspectRatio = function () {
  27682. return (this.getRenderWidth(true)) / (this.getRenderHeight(true));
  27683. };
  27684. /**
  27685. * Gets the current render width
  27686. * @param useScreen defines if screen size must be used (or the current render target if any)
  27687. * @returns a number defining the current render width
  27688. */
  27689. Engine.prototype.getRenderWidth = function (useScreen) {
  27690. if (useScreen === void 0) { useScreen = false; }
  27691. if (!useScreen && this._currentRenderTarget) {
  27692. return this._currentRenderTarget.width;
  27693. }
  27694. return this._gl.drawingBufferWidth;
  27695. };
  27696. /**
  27697. * Gets the current render height
  27698. * @param useScreen defines if screen size must be used (or the current render target if any)
  27699. * @returns a number defining the current render height
  27700. */
  27701. Engine.prototype.getRenderHeight = function (useScreen) {
  27702. if (useScreen === void 0) { useScreen = false; }
  27703. if (!useScreen && this._currentRenderTarget) {
  27704. return this._currentRenderTarget.height;
  27705. }
  27706. return this._gl.drawingBufferHeight;
  27707. };
  27708. /**
  27709. * Gets the HTML canvas attached with the current webGL context
  27710. * @returns a HTML canvas
  27711. */
  27712. Engine.prototype.getRenderingCanvas = function () {
  27713. return this._renderingCanvas;
  27714. };
  27715. /**
  27716. * Gets the client rect of the HTML canvas attached with the current webGL context
  27717. * @returns a client rectanglee
  27718. */
  27719. Engine.prototype.getRenderingCanvasClientRect = function () {
  27720. if (!this._renderingCanvas) {
  27721. return null;
  27722. }
  27723. return this._renderingCanvas.getBoundingClientRect();
  27724. };
  27725. /**
  27726. * Defines the hardware scaling level.
  27727. * By default the hardware scaling level is computed from the window device ratio.
  27728. * 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.
  27729. * @param level defines the level to use
  27730. */
  27731. Engine.prototype.setHardwareScalingLevel = function (level) {
  27732. this._hardwareScalingLevel = level;
  27733. this.resize();
  27734. };
  27735. /**
  27736. * Gets the current hardware scaling level.
  27737. * By default the hardware scaling level is computed from the window device ratio.
  27738. * 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.
  27739. * @returns a number indicating the current hardware scaling level
  27740. */
  27741. Engine.prototype.getHardwareScalingLevel = function () {
  27742. return this._hardwareScalingLevel;
  27743. };
  27744. /**
  27745. * Gets the list of loaded textures
  27746. * @returns an array containing all loaded textures
  27747. */
  27748. Engine.prototype.getLoadedTexturesCache = function () {
  27749. return this._internalTexturesCache;
  27750. };
  27751. /**
  27752. * Gets the object containing all engine capabilities
  27753. * @returns the EngineCapabilities object
  27754. */
  27755. Engine.prototype.getCaps = function () {
  27756. return this._caps;
  27757. };
  27758. /**
  27759. * Gets the current depth function
  27760. * @returns a number defining the depth function
  27761. */
  27762. Engine.prototype.getDepthFunction = function () {
  27763. return this._depthCullingState.depthFunc;
  27764. };
  27765. /**
  27766. * Sets the current depth function
  27767. * @param depthFunc defines the function to use
  27768. */
  27769. Engine.prototype.setDepthFunction = function (depthFunc) {
  27770. this._depthCullingState.depthFunc = depthFunc;
  27771. };
  27772. /**
  27773. * Sets the current depth function to GREATER
  27774. */
  27775. Engine.prototype.setDepthFunctionToGreater = function () {
  27776. this._depthCullingState.depthFunc = this._gl.GREATER;
  27777. };
  27778. /**
  27779. * Sets the current depth function to GEQUAL
  27780. */
  27781. Engine.prototype.setDepthFunctionToGreaterOrEqual = function () {
  27782. this._depthCullingState.depthFunc = this._gl.GEQUAL;
  27783. };
  27784. /**
  27785. * Sets the current depth function to LESS
  27786. */
  27787. Engine.prototype.setDepthFunctionToLess = function () {
  27788. this._depthCullingState.depthFunc = this._gl.LESS;
  27789. };
  27790. /**
  27791. * Sets the current depth function to LEQUAL
  27792. */
  27793. Engine.prototype.setDepthFunctionToLessOrEqual = function () {
  27794. this._depthCullingState.depthFunc = this._gl.LEQUAL;
  27795. };
  27796. /**
  27797. * Gets a boolean indicating if stencil buffer is enabled
  27798. * @returns the current stencil buffer state
  27799. */
  27800. Engine.prototype.getStencilBuffer = function () {
  27801. return this._stencilState.stencilTest;
  27802. };
  27803. /**
  27804. * Enable or disable the stencil buffer
  27805. * @param enable defines if the stencil buffer must be enabled or disabled
  27806. */
  27807. Engine.prototype.setStencilBuffer = function (enable) {
  27808. this._stencilState.stencilTest = enable;
  27809. };
  27810. /**
  27811. * Gets the current stencil mask
  27812. * @returns a number defining the new stencil mask to use
  27813. */
  27814. Engine.prototype.getStencilMask = function () {
  27815. return this._stencilState.stencilMask;
  27816. };
  27817. /**
  27818. * Sets the current stencil mask
  27819. * @param mask defines the new stencil mask to use
  27820. */
  27821. Engine.prototype.setStencilMask = function (mask) {
  27822. this._stencilState.stencilMask = mask;
  27823. };
  27824. /**
  27825. * Gets the current stencil function
  27826. * @returns a number defining the stencil function to use
  27827. */
  27828. Engine.prototype.getStencilFunction = function () {
  27829. return this._stencilState.stencilFunc;
  27830. };
  27831. /**
  27832. * Gets the current stencil reference value
  27833. * @returns a number defining the stencil reference value to use
  27834. */
  27835. Engine.prototype.getStencilFunctionReference = function () {
  27836. return this._stencilState.stencilFuncRef;
  27837. };
  27838. /**
  27839. * Gets the current stencil mask
  27840. * @returns a number defining the stencil mask to use
  27841. */
  27842. Engine.prototype.getStencilFunctionMask = function () {
  27843. return this._stencilState.stencilFuncMask;
  27844. };
  27845. /**
  27846. * Sets the current stencil function
  27847. * @param stencilFunc defines the new stencil function to use
  27848. */
  27849. Engine.prototype.setStencilFunction = function (stencilFunc) {
  27850. this._stencilState.stencilFunc = stencilFunc;
  27851. };
  27852. /**
  27853. * Sets the current stencil reference
  27854. * @param reference defines the new stencil reference to use
  27855. */
  27856. Engine.prototype.setStencilFunctionReference = function (reference) {
  27857. this._stencilState.stencilFuncRef = reference;
  27858. };
  27859. /**
  27860. * Sets the current stencil mask
  27861. * @param mask defines the new stencil mask to use
  27862. */
  27863. Engine.prototype.setStencilFunctionMask = function (mask) {
  27864. this._stencilState.stencilFuncMask = mask;
  27865. };
  27866. /**
  27867. * Gets the current stencil operation when stencil fails
  27868. * @returns a number defining stencil operation to use when stencil fails
  27869. */
  27870. Engine.prototype.getStencilOperationFail = function () {
  27871. return this._stencilState.stencilOpStencilFail;
  27872. };
  27873. /**
  27874. * Gets the current stencil operation when depth fails
  27875. * @returns a number defining stencil operation to use when depth fails
  27876. */
  27877. Engine.prototype.getStencilOperationDepthFail = function () {
  27878. return this._stencilState.stencilOpDepthFail;
  27879. };
  27880. /**
  27881. * Gets the current stencil operation when stencil passes
  27882. * @returns a number defining stencil operation to use when stencil passes
  27883. */
  27884. Engine.prototype.getStencilOperationPass = function () {
  27885. return this._stencilState.stencilOpStencilDepthPass;
  27886. };
  27887. /**
  27888. * Sets the stencil operation to use when stencil fails
  27889. * @param operation defines the stencil operation to use when stencil fails
  27890. */
  27891. Engine.prototype.setStencilOperationFail = function (operation) {
  27892. this._stencilState.stencilOpStencilFail = operation;
  27893. };
  27894. /**
  27895. * Sets the stencil operation to use when depth fails
  27896. * @param operation defines the stencil operation to use when depth fails
  27897. */
  27898. Engine.prototype.setStencilOperationDepthFail = function (operation) {
  27899. this._stencilState.stencilOpDepthFail = operation;
  27900. };
  27901. /**
  27902. * Sets the stencil operation to use when stencil passes
  27903. * @param operation defines the stencil operation to use when stencil passes
  27904. */
  27905. Engine.prototype.setStencilOperationPass = function (operation) {
  27906. this._stencilState.stencilOpStencilDepthPass = operation;
  27907. };
  27908. /**
  27909. * Sets a boolean indicating if the dithering state is enabled or disabled
  27910. * @param value defines the dithering state
  27911. */
  27912. Engine.prototype.setDitheringState = function (value) {
  27913. if (value) {
  27914. this._gl.enable(this._gl.DITHER);
  27915. }
  27916. else {
  27917. this._gl.disable(this._gl.DITHER);
  27918. }
  27919. };
  27920. /**
  27921. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27922. * @param value defines the rasterizer state
  27923. */
  27924. Engine.prototype.setRasterizerState = function (value) {
  27925. if (value) {
  27926. this._gl.disable(this._gl.RASTERIZER_DISCARD);
  27927. }
  27928. else {
  27929. this._gl.enable(this._gl.RASTERIZER_DISCARD);
  27930. }
  27931. };
  27932. /**
  27933. * stop executing a render loop function and remove it from the execution array
  27934. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27935. */
  27936. Engine.prototype.stopRenderLoop = function (renderFunction) {
  27937. if (!renderFunction) {
  27938. this._activeRenderLoops = [];
  27939. return;
  27940. }
  27941. var index = this._activeRenderLoops.indexOf(renderFunction);
  27942. if (index >= 0) {
  27943. this._activeRenderLoops.splice(index, 1);
  27944. }
  27945. };
  27946. /** @hidden */
  27947. Engine.prototype._renderLoop = function () {
  27948. if (!this._contextWasLost) {
  27949. var shouldRender = true;
  27950. if (!this.renderEvenInBackground && this._windowIsBackground) {
  27951. shouldRender = false;
  27952. }
  27953. if (shouldRender) {
  27954. // Start new frame
  27955. this.beginFrame();
  27956. for (var index = 0; index < this._activeRenderLoops.length; index++) {
  27957. var renderFunction = this._activeRenderLoops[index];
  27958. renderFunction();
  27959. }
  27960. // Present
  27961. this.endFrame();
  27962. }
  27963. }
  27964. if (this._activeRenderLoops.length > 0) {
  27965. // Register new frame
  27966. if (this.customAnimationFrameRequester) {
  27967. this.customAnimationFrameRequester.requestID = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this.customAnimationFrameRequester.renderFunction || this._bindedRenderFunction, this.customAnimationFrameRequester);
  27968. this._frameHandler = this.customAnimationFrameRequester.requestID;
  27969. }
  27970. else if (this._vrDisplay && this._vrDisplay.isPresenting) {
  27971. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction, this._vrDisplay);
  27972. }
  27973. else {
  27974. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  27975. }
  27976. }
  27977. else {
  27978. this._renderingQueueLaunched = false;
  27979. }
  27980. };
  27981. /**
  27982. * Register and execute a render loop. The engine can have more than one render function
  27983. * @param renderFunction defines the function to continuously execute
  27984. */
  27985. Engine.prototype.runRenderLoop = function (renderFunction) {
  27986. if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
  27987. return;
  27988. }
  27989. this._activeRenderLoops.push(renderFunction);
  27990. if (!this._renderingQueueLaunched) {
  27991. this._renderingQueueLaunched = true;
  27992. this._bindedRenderFunction = this._renderLoop.bind(this);
  27993. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  27994. }
  27995. };
  27996. /**
  27997. * Toggle full screen mode
  27998. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27999. */
  28000. Engine.prototype.switchFullscreen = function (requestPointerLock) {
  28001. if (this.isFullscreen) {
  28002. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].ExitFullscreen();
  28003. }
  28004. else {
  28005. this._pointerLockRequested = requestPointerLock;
  28006. if (this._renderingCanvas) {
  28007. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].RequestFullscreen(this._renderingCanvas);
  28008. }
  28009. }
  28010. };
  28011. /**
  28012. * Clear the current render buffer or the current render target (if any is set up)
  28013. * @param color defines the color to use
  28014. * @param backBuffer defines if the back buffer must be cleared
  28015. * @param depth defines if the depth buffer must be cleared
  28016. * @param stencil defines if the stencil buffer must be cleared
  28017. */
  28018. Engine.prototype.clear = function (color, backBuffer, depth, stencil) {
  28019. if (stencil === void 0) { stencil = false; }
  28020. this.applyStates();
  28021. var mode = 0;
  28022. if (backBuffer && color) {
  28023. this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
  28024. mode |= this._gl.COLOR_BUFFER_BIT;
  28025. }
  28026. if (depth) {
  28027. this._gl.clearDepth(1.0);
  28028. mode |= this._gl.DEPTH_BUFFER_BIT;
  28029. }
  28030. if (stencil) {
  28031. this._gl.clearStencil(0);
  28032. mode |= this._gl.STENCIL_BUFFER_BIT;
  28033. }
  28034. this._gl.clear(mode);
  28035. };
  28036. /**
  28037. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28038. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28039. * @param y defines the y-coordinate of the corner of the clear rectangle
  28040. * @param width defines the width of the clear rectangle
  28041. * @param height defines the height of the clear rectangle
  28042. * @param clearColor defines the clear color
  28043. */
  28044. Engine.prototype.scissorClear = function (x, y, width, height, clearColor) {
  28045. this.enableScissor(x, y, width, height);
  28046. this.clear(clearColor, true, true, true);
  28047. this.disableScissor();
  28048. };
  28049. /**
  28050. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28051. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28052. * @param y defines the y-coordinate of the corner of the clear rectangle
  28053. * @param width defines the width of the clear rectangle
  28054. * @param height defines the height of the clear rectangle
  28055. */
  28056. Engine.prototype.enableScissor = function (x, y, width, height) {
  28057. var gl = this._gl;
  28058. // Change state
  28059. gl.enable(gl.SCISSOR_TEST);
  28060. gl.scissor(x, y, width, height);
  28061. };
  28062. /**
  28063. * Disable previously set scissor test rectangle
  28064. */
  28065. Engine.prototype.disableScissor = function () {
  28066. var gl = this._gl;
  28067. gl.disable(gl.SCISSOR_TEST);
  28068. };
  28069. /** @hidden */
  28070. Engine.prototype._viewport = function (x, y, width, height) {
  28071. if (x !== this._viewportCached.x ||
  28072. y !== this._viewportCached.y ||
  28073. width !== this._viewportCached.z ||
  28074. height !== this._viewportCached.w) {
  28075. this._viewportCached.x = x;
  28076. this._viewportCached.y = y;
  28077. this._viewportCached.z = width;
  28078. this._viewportCached.w = height;
  28079. this._gl.viewport(x, y, width, height);
  28080. }
  28081. };
  28082. /**
  28083. * Set the WebGL's viewport
  28084. * @param viewport defines the viewport element to be used
  28085. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28086. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28087. */
  28088. Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  28089. var width = requiredWidth || this.getRenderWidth();
  28090. var height = requiredHeight || this.getRenderHeight();
  28091. var x = viewport.x || 0;
  28092. var y = viewport.y || 0;
  28093. this._cachedViewport = viewport;
  28094. this._viewport(x * width, y * height, width * viewport.width, height * viewport.height);
  28095. };
  28096. /**
  28097. * Directly set the WebGL Viewport
  28098. * @param x defines the x coordinate of the viewport (in screen space)
  28099. * @param y defines the y coordinate of the viewport (in screen space)
  28100. * @param width defines the width of the viewport (in screen space)
  28101. * @param height defines the height of the viewport (in screen space)
  28102. * @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
  28103. */
  28104. Engine.prototype.setDirectViewport = function (x, y, width, height) {
  28105. var currentViewport = this._cachedViewport;
  28106. this._cachedViewport = null;
  28107. this._viewport(x, y, width, height);
  28108. return currentViewport;
  28109. };
  28110. /**
  28111. * Begin a new frame
  28112. */
  28113. Engine.prototype.beginFrame = function () {
  28114. this.onBeginFrameObservable.notifyObservers(this);
  28115. this._measureFps();
  28116. };
  28117. /**
  28118. * Enf the current frame
  28119. */
  28120. Engine.prototype.endFrame = function () {
  28121. // Force a flush in case we are using a bad OS.
  28122. if (this._badOS) {
  28123. this.flushFramebuffer();
  28124. }
  28125. // Submit frame to the vr device, if enabled
  28126. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28127. // TODO: We should only submit the frame if we read frameData successfully.
  28128. this._vrDisplay.submitFrame();
  28129. }
  28130. this.onEndFrameObservable.notifyObservers(this);
  28131. };
  28132. /**
  28133. * Resize the view according to the canvas' size
  28134. */
  28135. Engine.prototype.resize = function () {
  28136. // We're not resizing the size of the canvas while in VR mode & presenting
  28137. if (!(this._vrDisplay && this._vrDisplay.isPresenting)) {
  28138. var width = this._renderingCanvas ? this._renderingCanvas.clientWidth : window.innerWidth;
  28139. var height = this._renderingCanvas ? this._renderingCanvas.clientHeight : window.innerHeight;
  28140. this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
  28141. }
  28142. };
  28143. /**
  28144. * Force a specific size of the canvas
  28145. * @param width defines the new canvas' width
  28146. * @param height defines the new canvas' height
  28147. */
  28148. Engine.prototype.setSize = function (width, height) {
  28149. if (!this._renderingCanvas) {
  28150. return;
  28151. }
  28152. if (this._renderingCanvas.width === width && this._renderingCanvas.height === height) {
  28153. return;
  28154. }
  28155. this._renderingCanvas.width = width;
  28156. this._renderingCanvas.height = height;
  28157. for (var index = 0; index < this.scenes.length; index++) {
  28158. var scene = this.scenes[index];
  28159. for (var camIndex = 0; camIndex < scene.cameras.length; camIndex++) {
  28160. var cam = scene.cameras[camIndex];
  28161. cam._currentRenderId = 0;
  28162. }
  28163. }
  28164. if (this.onResizeObservable.hasObservers) {
  28165. this.onResizeObservable.notifyObservers(this);
  28166. }
  28167. };
  28168. // WebVR functions
  28169. /**
  28170. * Gets a boolean indicating if a webVR device was detected
  28171. * @returns true if a webVR device was detected
  28172. */
  28173. Engine.prototype.isVRDevicePresent = function () {
  28174. return !!this._vrDisplay;
  28175. };
  28176. /**
  28177. * Gets the current webVR device
  28178. * @returns the current webVR device (or null)
  28179. */
  28180. Engine.prototype.getVRDevice = function () {
  28181. return this._vrDisplay;
  28182. };
  28183. /**
  28184. * Initializes a webVR display and starts listening to display change events
  28185. * The onVRDisplayChangedObservable will be notified upon these changes
  28186. * @returns The onVRDisplayChangedObservable
  28187. */
  28188. Engine.prototype.initWebVR = function () {
  28189. this.initWebVRAsync();
  28190. return this.onVRDisplayChangedObservable;
  28191. };
  28192. /**
  28193. * Initializes a webVR display and starts listening to display change events
  28194. * The onVRDisplayChangedObservable will be notified upon these changes
  28195. * @returns A promise containing a VRDisplay and if vr is supported
  28196. */
  28197. Engine.prototype.initWebVRAsync = function () {
  28198. var _this = this;
  28199. var notifyObservers = function () {
  28200. var eventArgs = {
  28201. vrDisplay: _this._vrDisplay,
  28202. vrSupported: _this._vrSupported
  28203. };
  28204. _this.onVRDisplayChangedObservable.notifyObservers(eventArgs);
  28205. _this._webVRInitPromise = new Promise(function (res) { res(eventArgs); });
  28206. };
  28207. if (!this._onVrDisplayConnect) {
  28208. this._onVrDisplayConnect = function (event) {
  28209. _this._vrDisplay = event.display;
  28210. notifyObservers();
  28211. };
  28212. this._onVrDisplayDisconnect = function () {
  28213. _this._vrDisplay.cancelAnimationFrame(_this._frameHandler);
  28214. _this._vrDisplay = undefined;
  28215. _this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(_this._bindedRenderFunction);
  28216. notifyObservers();
  28217. };
  28218. this._onVrDisplayPresentChange = function () {
  28219. _this._vrExclusivePointerMode = _this._vrDisplay && _this._vrDisplay.isPresenting;
  28220. };
  28221. window.addEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  28222. window.addEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  28223. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  28224. }
  28225. this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync();
  28226. this._webVRInitPromise.then(notifyObservers);
  28227. return this._webVRInitPromise;
  28228. };
  28229. /**
  28230. * Call this function to switch to webVR mode
  28231. * Will do nothing if webVR is not supported or if there is no webVR device
  28232. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28233. */
  28234. Engine.prototype.enableVR = function () {
  28235. var _this = this;
  28236. if (this._vrDisplay && !this._vrDisplay.isPresenting) {
  28237. var onResolved = function () {
  28238. _this.onVRRequestPresentComplete.notifyObservers(true);
  28239. _this._onVRFullScreenTriggered();
  28240. };
  28241. var onRejected = function () {
  28242. _this.onVRRequestPresentComplete.notifyObservers(false);
  28243. };
  28244. this.onVRRequestPresentStart.notifyObservers(this);
  28245. this._vrDisplay.requestPresent([{ source: this.getRenderingCanvas() }]).then(onResolved).catch(onRejected);
  28246. }
  28247. };
  28248. /**
  28249. * Call this function to leave webVR mode
  28250. * Will do nothing if webVR is not supported or if there is no webVR device
  28251. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28252. */
  28253. Engine.prototype.disableVR = function () {
  28254. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28255. this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered);
  28256. }
  28257. };
  28258. Engine.prototype._getVRDisplaysAsync = function () {
  28259. var _this = this;
  28260. return new Promise(function (res) {
  28261. if (navigator.getVRDisplays) {
  28262. navigator.getVRDisplays().then(function (devices) {
  28263. _this._vrSupported = true;
  28264. // note that devices may actually be an empty array. This is fine;
  28265. // we expect this._vrDisplay to be undefined in this case.
  28266. _this._vrDisplay = devices[0];
  28267. res({
  28268. vrDisplay: _this._vrDisplay,
  28269. vrSupported: _this._vrSupported
  28270. });
  28271. });
  28272. }
  28273. else {
  28274. _this._vrDisplay = undefined;
  28275. _this._vrSupported = false;
  28276. res({
  28277. vrDisplay: _this._vrDisplay,
  28278. vrSupported: _this._vrSupported
  28279. });
  28280. }
  28281. });
  28282. };
  28283. /**
  28284. * Binds the frame buffer to the specified texture.
  28285. * @param texture The texture to render to or null for the default canvas
  28286. * @param faceIndex The face of the texture to render to in case of cube texture
  28287. * @param requiredWidth The width of the target to render to
  28288. * @param requiredHeight The height of the target to render to
  28289. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28290. * @param depthStencilTexture The depth stencil texture to use to render
  28291. * @param lodLevel defines le lod level to bind to the frame buffer
  28292. */
  28293. Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport, depthStencilTexture, lodLevel) {
  28294. if (lodLevel === void 0) { lodLevel = 0; }
  28295. if (this._currentRenderTarget) {
  28296. this.unBindFramebuffer(this._currentRenderTarget);
  28297. }
  28298. this._currentRenderTarget = texture;
  28299. this.bindUnboundFramebuffer(texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer);
  28300. var gl = this._gl;
  28301. if (texture.isCube) {
  28302. if (faceIndex === undefined) {
  28303. faceIndex = 0;
  28304. }
  28305. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, lodLevel);
  28306. if (depthStencilTexture) {
  28307. if (depthStencilTexture._generateStencilBuffer) {
  28308. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  28309. }
  28310. else {
  28311. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  28312. }
  28313. }
  28314. }
  28315. if (this._cachedViewport && !forceFullscreenViewport) {
  28316. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  28317. }
  28318. else {
  28319. if (!requiredWidth) {
  28320. requiredWidth = texture.width;
  28321. if (lodLevel) {
  28322. requiredWidth = requiredWidth / Math.pow(2, lodLevel);
  28323. }
  28324. }
  28325. if (!requiredHeight) {
  28326. requiredHeight = texture.height;
  28327. if (lodLevel) {
  28328. requiredHeight = requiredHeight / Math.pow(2, lodLevel);
  28329. }
  28330. }
  28331. this._viewport(0, 0, requiredWidth, requiredHeight);
  28332. }
  28333. this.wipeCaches();
  28334. };
  28335. Engine.prototype.bindUnboundFramebuffer = function (framebuffer) {
  28336. if (this._currentFramebuffer !== framebuffer) {
  28337. this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);
  28338. this._currentFramebuffer = framebuffer;
  28339. }
  28340. };
  28341. /**
  28342. * Unbind the current render target texture from the webGL context
  28343. * @param texture defines the render target texture to unbind
  28344. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28345. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28346. */
  28347. Engine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  28348. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  28349. this._currentRenderTarget = null;
  28350. // If MSAA, we need to bitblt back to main texture
  28351. var gl = this._gl;
  28352. if (texture._MSAAFramebuffer) {
  28353. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, texture._MSAAFramebuffer);
  28354. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, texture._framebuffer);
  28355. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  28356. }
  28357. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  28358. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  28359. gl.generateMipmap(gl.TEXTURE_2D);
  28360. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  28361. }
  28362. if (onBeforeUnbind) {
  28363. if (texture._MSAAFramebuffer) {
  28364. // Bind the correct framebuffer
  28365. this.bindUnboundFramebuffer(texture._framebuffer);
  28366. }
  28367. onBeforeUnbind();
  28368. }
  28369. this.bindUnboundFramebuffer(null);
  28370. };
  28371. /**
  28372. * Unbind a list of render target textures from the webGL context
  28373. * This is used only when drawBuffer extension or webGL2 are active
  28374. * @param textures defines the render target textures to unbind
  28375. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28376. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28377. */
  28378. Engine.prototype.unBindMultiColorAttachmentFramebuffer = function (textures, disableGenerateMipMaps, onBeforeUnbind) {
  28379. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  28380. this._currentRenderTarget = null;
  28381. // If MSAA, we need to bitblt back to main texture
  28382. var gl = this._gl;
  28383. if (textures[0]._MSAAFramebuffer) {
  28384. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, textures[0]._MSAAFramebuffer);
  28385. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, textures[0]._framebuffer);
  28386. var attachments = textures[0]._attachments;
  28387. if (!attachments) {
  28388. attachments = new Array(textures.length);
  28389. textures[0]._attachments = attachments;
  28390. }
  28391. for (var i = 0; i < textures.length; i++) {
  28392. var texture = textures[i];
  28393. for (var j = 0; j < attachments.length; j++) {
  28394. attachments[j] = gl.NONE;
  28395. }
  28396. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  28397. gl.readBuffer(attachments[i]);
  28398. gl.drawBuffers(attachments);
  28399. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  28400. }
  28401. for (var i = 0; i < attachments.length; i++) {
  28402. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  28403. }
  28404. gl.drawBuffers(attachments);
  28405. }
  28406. for (var i = 0; i < textures.length; i++) {
  28407. var texture = textures[i];
  28408. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  28409. this._bindTextureDirectly(gl.TEXTURE_2D, texture);
  28410. gl.generateMipmap(gl.TEXTURE_2D);
  28411. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  28412. }
  28413. }
  28414. if (onBeforeUnbind) {
  28415. if (textures[0]._MSAAFramebuffer) {
  28416. // Bind the correct framebuffer
  28417. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  28418. }
  28419. onBeforeUnbind();
  28420. }
  28421. this.bindUnboundFramebuffer(null);
  28422. };
  28423. /**
  28424. * Force the mipmap generation for the given render target texture
  28425. * @param texture defines the render target texture to use
  28426. */
  28427. Engine.prototype.generateMipMapsForCubemap = function (texture) {
  28428. if (texture.generateMipMaps) {
  28429. var gl = this._gl;
  28430. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  28431. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  28432. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  28433. }
  28434. };
  28435. /**
  28436. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28437. */
  28438. Engine.prototype.flushFramebuffer = function () {
  28439. this._gl.flush();
  28440. };
  28441. /**
  28442. * Unbind the current render target and bind the default framebuffer
  28443. */
  28444. Engine.prototype.restoreDefaultFramebuffer = function () {
  28445. if (this._currentRenderTarget) {
  28446. this.unBindFramebuffer(this._currentRenderTarget);
  28447. }
  28448. else {
  28449. this.bindUnboundFramebuffer(null);
  28450. }
  28451. if (this._cachedViewport) {
  28452. this.setViewport(this._cachedViewport);
  28453. }
  28454. this.wipeCaches();
  28455. };
  28456. // UBOs
  28457. /**
  28458. * Create an uniform buffer
  28459. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28460. * @param elements defines the content of the uniform buffer
  28461. * @returns the webGL uniform buffer
  28462. */
  28463. Engine.prototype.createUniformBuffer = function (elements) {
  28464. var ubo = this._gl.createBuffer();
  28465. if (!ubo) {
  28466. throw new Error("Unable to create uniform buffer");
  28467. }
  28468. this.bindUniformBuffer(ubo);
  28469. if (elements instanceof Float32Array) {
  28470. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.STATIC_DRAW);
  28471. }
  28472. else {
  28473. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.STATIC_DRAW);
  28474. }
  28475. this.bindUniformBuffer(null);
  28476. ubo.references = 1;
  28477. return ubo;
  28478. };
  28479. /**
  28480. * Create a dynamic uniform buffer
  28481. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28482. * @param elements defines the content of the uniform buffer
  28483. * @returns the webGL uniform buffer
  28484. */
  28485. Engine.prototype.createDynamicUniformBuffer = function (elements) {
  28486. var ubo = this._gl.createBuffer();
  28487. if (!ubo) {
  28488. throw new Error("Unable to create dynamic uniform buffer");
  28489. }
  28490. this.bindUniformBuffer(ubo);
  28491. if (elements instanceof Float32Array) {
  28492. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.DYNAMIC_DRAW);
  28493. }
  28494. else {
  28495. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.DYNAMIC_DRAW);
  28496. }
  28497. this.bindUniformBuffer(null);
  28498. ubo.references = 1;
  28499. return ubo;
  28500. };
  28501. /**
  28502. * Update an existing uniform buffer
  28503. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28504. * @param uniformBuffer defines the target uniform buffer
  28505. * @param elements defines the content to update
  28506. * @param offset defines the offset in the uniform buffer where update should start
  28507. * @param count defines the size of the data to update
  28508. */
  28509. Engine.prototype.updateUniformBuffer = function (uniformBuffer, elements, offset, count) {
  28510. this.bindUniformBuffer(uniformBuffer);
  28511. if (offset === undefined) {
  28512. offset = 0;
  28513. }
  28514. if (count === undefined) {
  28515. if (elements instanceof Float32Array) {
  28516. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, elements);
  28517. }
  28518. else {
  28519. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, new Float32Array(elements));
  28520. }
  28521. }
  28522. else {
  28523. if (elements instanceof Float32Array) {
  28524. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, elements.subarray(offset, offset + count));
  28525. }
  28526. else {
  28527. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(elements).subarray(offset, offset + count));
  28528. }
  28529. }
  28530. this.bindUniformBuffer(null);
  28531. };
  28532. // VBOs
  28533. Engine.prototype._resetVertexBufferBinding = function () {
  28534. this.bindArrayBuffer(null);
  28535. this._cachedVertexBuffers = null;
  28536. };
  28537. /**
  28538. * Creates a vertex buffer
  28539. * @param data the data for the vertex buffer
  28540. * @returns the new WebGL static buffer
  28541. */
  28542. Engine.prototype.createVertexBuffer = function (data) {
  28543. var vbo = this._gl.createBuffer();
  28544. if (!vbo) {
  28545. throw new Error("Unable to create vertex buffer");
  28546. }
  28547. this.bindArrayBuffer(vbo);
  28548. if (data instanceof Array) {
  28549. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.STATIC_DRAW);
  28550. }
  28551. else {
  28552. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.STATIC_DRAW);
  28553. }
  28554. this._resetVertexBufferBinding();
  28555. vbo.references = 1;
  28556. return vbo;
  28557. };
  28558. /**
  28559. * Creates a dynamic vertex buffer
  28560. * @param data the data for the dynamic vertex buffer
  28561. * @returns the new WebGL dynamic buffer
  28562. */
  28563. Engine.prototype.createDynamicVertexBuffer = function (data) {
  28564. var vbo = this._gl.createBuffer();
  28565. if (!vbo) {
  28566. throw new Error("Unable to create dynamic vertex buffer");
  28567. }
  28568. this.bindArrayBuffer(vbo);
  28569. if (data instanceof Array) {
  28570. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.DYNAMIC_DRAW);
  28571. }
  28572. else {
  28573. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.DYNAMIC_DRAW);
  28574. }
  28575. this._resetVertexBufferBinding();
  28576. vbo.references = 1;
  28577. return vbo;
  28578. };
  28579. /**
  28580. * Update a dynamic index buffer
  28581. * @param indexBuffer defines the target index buffer
  28582. * @param indices defines the data to update
  28583. * @param offset defines the offset in the target index buffer where update should start
  28584. */
  28585. Engine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  28586. if (offset === void 0) { offset = 0; }
  28587. // Force cache update
  28588. this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
  28589. this.bindIndexBuffer(indexBuffer);
  28590. var arrayBuffer;
  28591. if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
  28592. arrayBuffer = indices;
  28593. }
  28594. else {
  28595. arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  28596. }
  28597. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
  28598. this._resetIndexBufferBinding();
  28599. };
  28600. /**
  28601. * Updates a dynamic vertex buffer.
  28602. * @param vertexBuffer the vertex buffer to update
  28603. * @param data the data used to update the vertex buffer
  28604. * @param byteOffset the byte offset of the data
  28605. * @param byteLength the byte length of the data
  28606. */
  28607. Engine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, data, byteOffset, byteLength) {
  28608. this.bindArrayBuffer(vertexBuffer);
  28609. if (byteOffset === undefined) {
  28610. byteOffset = 0;
  28611. }
  28612. if (byteLength === undefined) {
  28613. if (data instanceof Array) {
  28614. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data));
  28615. }
  28616. else {
  28617. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);
  28618. }
  28619. }
  28620. else {
  28621. if (data instanceof Array) {
  28622. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(data).subarray(byteOffset, byteOffset + byteLength));
  28623. }
  28624. else {
  28625. if (data instanceof ArrayBuffer) {
  28626. data = new Uint8Array(data, byteOffset, byteLength);
  28627. }
  28628. else {
  28629. data = new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);
  28630. }
  28631. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  28632. }
  28633. }
  28634. this._resetVertexBufferBinding();
  28635. };
  28636. Engine.prototype._resetIndexBufferBinding = function () {
  28637. this.bindIndexBuffer(null);
  28638. this._cachedIndexBuffer = null;
  28639. };
  28640. /**
  28641. * Creates a new index buffer
  28642. * @param indices defines the content of the index buffer
  28643. * @param updatable defines if the index buffer must be updatable
  28644. * @returns a new webGL buffer
  28645. */
  28646. Engine.prototype.createIndexBuffer = function (indices, updatable) {
  28647. var vbo = this._gl.createBuffer();
  28648. if (!vbo) {
  28649. throw new Error("Unable to create index buffer");
  28650. }
  28651. this.bindIndexBuffer(vbo);
  28652. // Check for 32 bits indices
  28653. var arrayBuffer;
  28654. var need32Bits = false;
  28655. if (indices instanceof Uint16Array) {
  28656. arrayBuffer = indices;
  28657. }
  28658. else {
  28659. //check 32 bit support
  28660. if (this._caps.uintIndices) {
  28661. if (indices instanceof Uint32Array) {
  28662. arrayBuffer = indices;
  28663. need32Bits = true;
  28664. }
  28665. else {
  28666. //number[] or Int32Array, check if 32 bit is necessary
  28667. for (var index = 0; index < indices.length; index++) {
  28668. if (indices[index] > 65535) {
  28669. need32Bits = true;
  28670. break;
  28671. }
  28672. }
  28673. arrayBuffer = need32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  28674. }
  28675. }
  28676. else {
  28677. //no 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)
  28678. arrayBuffer = new Uint16Array(indices);
  28679. }
  28680. }
  28681. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
  28682. this._resetIndexBufferBinding();
  28683. vbo.references = 1;
  28684. vbo.is32Bits = need32Bits;
  28685. return vbo;
  28686. };
  28687. /**
  28688. * Bind a webGL buffer to the webGL context
  28689. * @param buffer defines the buffer to bind
  28690. */
  28691. Engine.prototype.bindArrayBuffer = function (buffer) {
  28692. if (!this._vaoRecordInProgress) {
  28693. this._unbindVertexArrayObject();
  28694. }
  28695. this.bindBuffer(buffer, this._gl.ARRAY_BUFFER);
  28696. };
  28697. /**
  28698. * Bind an uniform buffer to the current webGL context
  28699. * @param buffer defines the buffer to bind
  28700. */
  28701. Engine.prototype.bindUniformBuffer = function (buffer) {
  28702. this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, buffer);
  28703. };
  28704. /**
  28705. * Bind a buffer to the current webGL context at a given location
  28706. * @param buffer defines the buffer to bind
  28707. * @param location defines the index where to bind the buffer
  28708. */
  28709. Engine.prototype.bindUniformBufferBase = function (buffer, location) {
  28710. this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, location, buffer);
  28711. };
  28712. /**
  28713. * Bind a specific block at a given index in a specific shader program
  28714. * @param shaderProgram defines the shader program
  28715. * @param blockName defines the block name
  28716. * @param index defines the index where to bind the block
  28717. */
  28718. Engine.prototype.bindUniformBlock = function (shaderProgram, blockName, index) {
  28719. var uniformLocation = this._gl.getUniformBlockIndex(shaderProgram, blockName);
  28720. this._gl.uniformBlockBinding(shaderProgram, uniformLocation, index);
  28721. };
  28722. Engine.prototype.bindIndexBuffer = function (buffer) {
  28723. if (!this._vaoRecordInProgress) {
  28724. this._unbindVertexArrayObject();
  28725. }
  28726. this.bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);
  28727. };
  28728. Engine.prototype.bindBuffer = function (buffer, target) {
  28729. if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {
  28730. this._gl.bindBuffer(target, buffer);
  28731. this._currentBoundBuffer[target] = buffer;
  28732. }
  28733. };
  28734. /**
  28735. * update the bound buffer with the given data
  28736. * @param data defines the data to update
  28737. */
  28738. Engine.prototype.updateArrayBuffer = function (data) {
  28739. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  28740. };
  28741. Engine.prototype._vertexAttribPointer = function (buffer, indx, size, type, normalized, stride, offset) {
  28742. var pointer = this._currentBufferPointers[indx];
  28743. var changed = false;
  28744. if (!pointer.active) {
  28745. changed = true;
  28746. pointer.active = true;
  28747. pointer.index = indx;
  28748. pointer.size = size;
  28749. pointer.type = type;
  28750. pointer.normalized = normalized;
  28751. pointer.stride = stride;
  28752. pointer.offset = offset;
  28753. pointer.buffer = buffer;
  28754. }
  28755. else {
  28756. if (pointer.buffer !== buffer) {
  28757. pointer.buffer = buffer;
  28758. changed = true;
  28759. }
  28760. if (pointer.size !== size) {
  28761. pointer.size = size;
  28762. changed = true;
  28763. }
  28764. if (pointer.type !== type) {
  28765. pointer.type = type;
  28766. changed = true;
  28767. }
  28768. if (pointer.normalized !== normalized) {
  28769. pointer.normalized = normalized;
  28770. changed = true;
  28771. }
  28772. if (pointer.stride !== stride) {
  28773. pointer.stride = stride;
  28774. changed = true;
  28775. }
  28776. if (pointer.offset !== offset) {
  28777. pointer.offset = offset;
  28778. changed = true;
  28779. }
  28780. }
  28781. if (changed || this._vaoRecordInProgress) {
  28782. this.bindArrayBuffer(buffer);
  28783. this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);
  28784. }
  28785. };
  28786. Engine.prototype._bindIndexBufferWithCache = function (indexBuffer) {
  28787. if (indexBuffer == null) {
  28788. return;
  28789. }
  28790. if (this._cachedIndexBuffer !== indexBuffer) {
  28791. this._cachedIndexBuffer = indexBuffer;
  28792. this.bindIndexBuffer(indexBuffer);
  28793. this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
  28794. }
  28795. };
  28796. Engine.prototype._bindVertexBuffersAttributes = function (vertexBuffers, effect) {
  28797. var attributes = effect.getAttributesNames();
  28798. if (!this._vaoRecordInProgress) {
  28799. this._unbindVertexArrayObject();
  28800. }
  28801. this.unbindAllAttributes();
  28802. for (var index = 0; index < attributes.length; index++) {
  28803. var order = effect.getAttributeLocation(index);
  28804. if (order >= 0) {
  28805. var vertexBuffer = vertexBuffers[attributes[index]];
  28806. if (!vertexBuffer) {
  28807. continue;
  28808. }
  28809. this._gl.enableVertexAttribArray(order);
  28810. if (!this._vaoRecordInProgress) {
  28811. this._vertexAttribArraysEnabled[order] = true;
  28812. }
  28813. var buffer = vertexBuffer.getBuffer();
  28814. if (buffer) {
  28815. this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);
  28816. if (vertexBuffer.getIsInstanced()) {
  28817. this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());
  28818. if (!this._vaoRecordInProgress) {
  28819. this._currentInstanceLocations.push(order);
  28820. this._currentInstanceBuffers.push(buffer);
  28821. }
  28822. }
  28823. }
  28824. }
  28825. }
  28826. };
  28827. /**
  28828. * Records a vertex array object
  28829. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28830. * @param vertexBuffers defines the list of vertex buffers to store
  28831. * @param indexBuffer defines the index buffer to store
  28832. * @param effect defines the effect to store
  28833. * @returns the new vertex array object
  28834. */
  28835. Engine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect) {
  28836. var vao = this._gl.createVertexArray();
  28837. this._vaoRecordInProgress = true;
  28838. this._gl.bindVertexArray(vao);
  28839. this._mustWipeVertexAttributes = true;
  28840. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  28841. this.bindIndexBuffer(indexBuffer);
  28842. this._vaoRecordInProgress = false;
  28843. this._gl.bindVertexArray(null);
  28844. return vao;
  28845. };
  28846. /**
  28847. * Bind a specific vertex array object
  28848. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28849. * @param vertexArrayObject defines the vertex array object to bind
  28850. * @param indexBuffer defines the index buffer to bind
  28851. */
  28852. Engine.prototype.bindVertexArrayObject = function (vertexArrayObject, indexBuffer) {
  28853. if (this._cachedVertexArrayObject !== vertexArrayObject) {
  28854. this._cachedVertexArrayObject = vertexArrayObject;
  28855. this._gl.bindVertexArray(vertexArrayObject);
  28856. this._cachedVertexBuffers = null;
  28857. this._cachedIndexBuffer = null;
  28858. this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;
  28859. this._mustWipeVertexAttributes = true;
  28860. }
  28861. };
  28862. /**
  28863. * Bind webGl buffers directly to the webGL context
  28864. * @param vertexBuffer defines the vertex buffer to bind
  28865. * @param indexBuffer defines the index buffer to bind
  28866. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28867. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28868. * @param effect defines the effect associated with the vertex buffer
  28869. */
  28870. Engine.prototype.bindBuffersDirectly = function (vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {
  28871. if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
  28872. this._cachedVertexBuffers = vertexBuffer;
  28873. this._cachedEffectForVertexBuffers = effect;
  28874. var attributesCount = effect.getAttributesCount();
  28875. this._unbindVertexArrayObject();
  28876. this.unbindAllAttributes();
  28877. var offset = 0;
  28878. for (var index = 0; index < attributesCount; index++) {
  28879. if (index < vertexDeclaration.length) {
  28880. var order = effect.getAttributeLocation(index);
  28881. if (order >= 0) {
  28882. this._gl.enableVertexAttribArray(order);
  28883. this._vertexAttribArraysEnabled[order] = true;
  28884. this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);
  28885. }
  28886. offset += vertexDeclaration[index] * 4;
  28887. }
  28888. }
  28889. }
  28890. this._bindIndexBufferWithCache(indexBuffer);
  28891. };
  28892. Engine.prototype._unbindVertexArrayObject = function () {
  28893. if (!this._cachedVertexArrayObject) {
  28894. return;
  28895. }
  28896. this._cachedVertexArrayObject = null;
  28897. this._gl.bindVertexArray(null);
  28898. };
  28899. /**
  28900. * Bind a list of vertex buffers to the webGL context
  28901. * @param vertexBuffers defines the list of vertex buffers to bind
  28902. * @param indexBuffer defines the index buffer to bind
  28903. * @param effect defines the effect associated with the vertex buffers
  28904. */
  28905. Engine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  28906. if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
  28907. this._cachedVertexBuffers = vertexBuffers;
  28908. this._cachedEffectForVertexBuffers = effect;
  28909. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  28910. }
  28911. this._bindIndexBufferWithCache(indexBuffer);
  28912. };
  28913. /**
  28914. * Unbind all instance attributes
  28915. */
  28916. Engine.prototype.unbindInstanceAttributes = function () {
  28917. var boundBuffer;
  28918. for (var i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {
  28919. var instancesBuffer = this._currentInstanceBuffers[i];
  28920. if (boundBuffer != instancesBuffer && instancesBuffer.references) {
  28921. boundBuffer = instancesBuffer;
  28922. this.bindArrayBuffer(instancesBuffer);
  28923. }
  28924. var offsetLocation = this._currentInstanceLocations[i];
  28925. this._gl.vertexAttribDivisor(offsetLocation, 0);
  28926. }
  28927. this._currentInstanceBuffers.length = 0;
  28928. this._currentInstanceLocations.length = 0;
  28929. };
  28930. /**
  28931. * Release and free the memory of a vertex array object
  28932. * @param vao defines the vertex array object to delete
  28933. */
  28934. Engine.prototype.releaseVertexArrayObject = function (vao) {
  28935. this._gl.deleteVertexArray(vao);
  28936. };
  28937. /** @hidden */
  28938. Engine.prototype._releaseBuffer = function (buffer) {
  28939. buffer.references--;
  28940. if (buffer.references === 0) {
  28941. this._gl.deleteBuffer(buffer);
  28942. return true;
  28943. }
  28944. return false;
  28945. };
  28946. /**
  28947. * Creates a webGL buffer to use with instanciation
  28948. * @param capacity defines the size of the buffer
  28949. * @returns the webGL buffer
  28950. */
  28951. Engine.prototype.createInstancesBuffer = function (capacity) {
  28952. var buffer = this._gl.createBuffer();
  28953. if (!buffer) {
  28954. throw new Error("Unable to create instance buffer");
  28955. }
  28956. buffer.capacity = capacity;
  28957. this.bindArrayBuffer(buffer);
  28958. this._gl.bufferData(this._gl.ARRAY_BUFFER, capacity, this._gl.DYNAMIC_DRAW);
  28959. return buffer;
  28960. };
  28961. /**
  28962. * Delete a webGL buffer used with instanciation
  28963. * @param buffer defines the webGL buffer to delete
  28964. */
  28965. Engine.prototype.deleteInstancesBuffer = function (buffer) {
  28966. this._gl.deleteBuffer(buffer);
  28967. };
  28968. /**
  28969. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28970. * @param instancesBuffer defines the webGL buffer to update and bind
  28971. * @param data defines the data to store in the buffer
  28972. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28973. */
  28974. Engine.prototype.updateAndBindInstancesBuffer = function (instancesBuffer, data, offsetLocations) {
  28975. this.bindArrayBuffer(instancesBuffer);
  28976. if (data) {
  28977. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  28978. }
  28979. if (offsetLocations[0].index !== undefined) {
  28980. var stride = 0;
  28981. for (var i = 0; i < offsetLocations.length; i++) {
  28982. var ai = offsetLocations[i];
  28983. stride += ai.attributeSize * 4;
  28984. }
  28985. for (var i = 0; i < offsetLocations.length; i++) {
  28986. var ai = offsetLocations[i];
  28987. if (!this._vertexAttribArraysEnabled[ai.index]) {
  28988. this._gl.enableVertexAttribArray(ai.index);
  28989. this._vertexAttribArraysEnabled[ai.index] = true;
  28990. }
  28991. this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attribyteType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);
  28992. this._gl.vertexAttribDivisor(ai.index, 1);
  28993. this._currentInstanceLocations.push(ai.index);
  28994. this._currentInstanceBuffers.push(instancesBuffer);
  28995. }
  28996. }
  28997. else {
  28998. for (var index = 0; index < 4; index++) {
  28999. var offsetLocation = offsetLocations[index];
  29000. if (!this._vertexAttribArraysEnabled[offsetLocation]) {
  29001. this._gl.enableVertexAttribArray(offsetLocation);
  29002. this._vertexAttribArraysEnabled[offsetLocation] = true;
  29003. }
  29004. this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);
  29005. this._gl.vertexAttribDivisor(offsetLocation, 1);
  29006. this._currentInstanceLocations.push(offsetLocation);
  29007. this._currentInstanceBuffers.push(instancesBuffer);
  29008. }
  29009. }
  29010. };
  29011. /**
  29012. * Apply all cached states (depth, culling, stencil and alpha)
  29013. */
  29014. Engine.prototype.applyStates = function () {
  29015. this._depthCullingState.apply(this._gl);
  29016. this._stencilState.apply(this._gl);
  29017. this._alphaState.apply(this._gl);
  29018. };
  29019. /**
  29020. * Send a draw order
  29021. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29022. * @param indexStart defines the starting index
  29023. * @param indexCount defines the number of index to draw
  29024. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29025. */
  29026. Engine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  29027. this.drawElementsType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, indexStart, indexCount, instancesCount);
  29028. };
  29029. /**
  29030. * Draw a list of points
  29031. * @param verticesStart defines the index of first vertex to draw
  29032. * @param verticesCount defines the count of vertices to draw
  29033. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29034. */
  29035. Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {
  29036. this.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode, verticesStart, verticesCount, instancesCount);
  29037. };
  29038. /**
  29039. * Draw a list of unindexed primitives
  29040. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29041. * @param verticesStart defines the index of first vertex to draw
  29042. * @param verticesCount defines the count of vertices to draw
  29043. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29044. */
  29045. Engine.prototype.drawUnIndexed = function (useTriangles, verticesStart, verticesCount, instancesCount) {
  29046. this.drawArraysType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, verticesStart, verticesCount, instancesCount);
  29047. };
  29048. /**
  29049. * Draw a list of indexed primitives
  29050. * @param fillMode defines the primitive to use
  29051. * @param indexStart defines the starting index
  29052. * @param indexCount defines the number of index to draw
  29053. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29054. */
  29055. Engine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  29056. // Apply states
  29057. this.applyStates();
  29058. this._drawCalls.addCount(1, false);
  29059. // Render
  29060. var drawMode = this._drawMode(fillMode);
  29061. var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
  29062. var mult = this._uintIndicesCurrentlySet ? 4 : 2;
  29063. if (instancesCount) {
  29064. this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);
  29065. }
  29066. else {
  29067. this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);
  29068. }
  29069. };
  29070. /**
  29071. * Draw a list of unindexed primitives
  29072. * @param fillMode defines the primitive to use
  29073. * @param verticesStart defines the index of first vertex to draw
  29074. * @param verticesCount defines the count of vertices to draw
  29075. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29076. */
  29077. Engine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  29078. // Apply states
  29079. this.applyStates();
  29080. this._drawCalls.addCount(1, false);
  29081. var drawMode = this._drawMode(fillMode);
  29082. if (instancesCount) {
  29083. this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);
  29084. }
  29085. else {
  29086. this._gl.drawArrays(drawMode, verticesStart, verticesCount);
  29087. }
  29088. };
  29089. Engine.prototype._drawMode = function (fillMode) {
  29090. switch (fillMode) {
  29091. // Triangle views
  29092. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode:
  29093. return this._gl.TRIANGLES;
  29094. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode:
  29095. return this._gl.POINTS;
  29096. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode:
  29097. return this._gl.LINES;
  29098. // Draw modes
  29099. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointListDrawMode:
  29100. return this._gl.POINTS;
  29101. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineListDrawMode:
  29102. return this._gl.LINES;
  29103. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineLoopDrawMode:
  29104. return this._gl.LINE_LOOP;
  29105. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineStripDrawMode:
  29106. return this._gl.LINE_STRIP;
  29107. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleStripDrawMode:
  29108. return this._gl.TRIANGLE_STRIP;
  29109. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFanDrawMode:
  29110. return this._gl.TRIANGLE_FAN;
  29111. default:
  29112. return this._gl.TRIANGLES;
  29113. }
  29114. };
  29115. // Shaders
  29116. /** @hidden */
  29117. Engine.prototype._releaseEffect = function (effect) {
  29118. if (this._compiledEffects[effect._key]) {
  29119. delete this._compiledEffects[effect._key];
  29120. this._deleteProgram(effect.getProgram());
  29121. }
  29122. };
  29123. /** @hidden */
  29124. Engine.prototype._deleteProgram = function (program) {
  29125. if (program) {
  29126. program.__SPECTOR_rebuildProgram = null;
  29127. if (program.transformFeedback) {
  29128. this.deleteTransformFeedback(program.transformFeedback);
  29129. program.transformFeedback = null;
  29130. }
  29131. this._gl.deleteProgram(program);
  29132. }
  29133. };
  29134. /**
  29135. * Create a new effect (used to store vertex/fragment shaders)
  29136. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29137. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29138. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29139. * @param samplers defines an array of string used to represent textures
  29140. * @param defines defines the string containing the defines to use to compile the shaders
  29141. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29142. * @param onCompiled defines a function to call when the effect creation is successful
  29143. * @param onError defines a function to call when the effect creation has failed
  29144. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29145. * @returns the new Effect
  29146. */
  29147. Engine.prototype.createEffect = function (baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters) {
  29148. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  29149. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  29150. var name = vertex + "+" + fragment + "@" + (defines ? defines : attributesNamesOrOptions.defines);
  29151. if (this._compiledEffects[name]) {
  29152. var compiledEffect = this._compiledEffects[name];
  29153. if (onCompiled && compiledEffect.isReady()) {
  29154. onCompiled(compiledEffect);
  29155. }
  29156. return compiledEffect;
  29157. }
  29158. var effect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"](baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters);
  29159. effect._key = name;
  29160. this._compiledEffects[name] = effect;
  29161. return effect;
  29162. };
  29163. Engine.prototype._compileShader = function (source, type, defines, shaderVersion) {
  29164. return this._compileRawShader(shaderVersion + (defines ? defines + "\n" : "") + source, type);
  29165. };
  29166. Engine.prototype._compileRawShader = function (source, type) {
  29167. var gl = this._gl;
  29168. var shader = gl.createShader(type === "vertex" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
  29169. if (!shader) {
  29170. throw new Error("Something went wrong while compile the shader.");
  29171. }
  29172. gl.shaderSource(shader, source);
  29173. gl.compileShader(shader);
  29174. if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
  29175. var log = gl.getShaderInfoLog(shader);
  29176. if (log) {
  29177. throw new Error(log);
  29178. }
  29179. }
  29180. return shader;
  29181. };
  29182. /**
  29183. * Directly creates a webGL program
  29184. * @param vertexCode defines the vertex shader code to use
  29185. * @param fragmentCode defines the fragment shader code to use
  29186. * @param context defines the webGL context to use (if not set, the current one will be used)
  29187. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29188. * @returns the new webGL program
  29189. */
  29190. Engine.prototype.createRawShaderProgram = function (vertexCode, fragmentCode, context, transformFeedbackVaryings) {
  29191. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  29192. context = context || this._gl;
  29193. var vertexShader = this._compileRawShader(vertexCode, "vertex");
  29194. var fragmentShader = this._compileRawShader(fragmentCode, "fragment");
  29195. return this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  29196. };
  29197. /**
  29198. * Creates a webGL program
  29199. * @param vertexCode defines the vertex shader code to use
  29200. * @param fragmentCode defines the fragment shader code to use
  29201. * @param defines defines the string containing the defines to use to compile the shaders
  29202. * @param context defines the webGL context to use (if not set, the current one will be used)
  29203. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29204. * @returns the new webGL program
  29205. */
  29206. Engine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context, transformFeedbackVaryings) {
  29207. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  29208. context = context || this._gl;
  29209. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  29210. var shaderVersion = (this._webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  29211. var vertexShader = this._compileShader(vertexCode, "vertex", defines, shaderVersion);
  29212. var fragmentShader = this._compileShader(fragmentCode, "fragment", defines, shaderVersion);
  29213. var program = this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  29214. this.onAfterShaderCompilationObservable.notifyObservers(this);
  29215. return program;
  29216. };
  29217. Engine.prototype._createShaderProgram = function (vertexShader, fragmentShader, context, transformFeedbackVaryings) {
  29218. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  29219. var shaderProgram = context.createProgram();
  29220. if (!shaderProgram) {
  29221. throw new Error("Unable to create program");
  29222. }
  29223. context.attachShader(shaderProgram, vertexShader);
  29224. context.attachShader(shaderProgram, fragmentShader);
  29225. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  29226. var transformFeedback = this.createTransformFeedback();
  29227. this.bindTransformFeedback(transformFeedback);
  29228. this.setTranformFeedbackVaryings(shaderProgram, transformFeedbackVaryings);
  29229. shaderProgram.transformFeedback = transformFeedback;
  29230. }
  29231. context.linkProgram(shaderProgram);
  29232. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  29233. this.bindTransformFeedback(null);
  29234. }
  29235. shaderProgram.context = context;
  29236. shaderProgram.vertexShader = vertexShader;
  29237. shaderProgram.fragmentShader = fragmentShader;
  29238. if (!this._caps.parallelShaderCompile) {
  29239. this._finalizeProgram(shaderProgram);
  29240. }
  29241. else {
  29242. shaderProgram.isParallelCompiled = true;
  29243. }
  29244. return shaderProgram;
  29245. };
  29246. Engine.prototype._finalizeProgram = function (shaderProgram) {
  29247. var context = shaderProgram.context;
  29248. var vertexShader = shaderProgram.vertexShader;
  29249. var fragmentShader = shaderProgram.fragmentShader;
  29250. var linked = context.getProgramParameter(shaderProgram, context.LINK_STATUS);
  29251. if (!linked) {
  29252. var error = context.getProgramInfoLog(shaderProgram);
  29253. if (error) {
  29254. throw new Error(error);
  29255. }
  29256. }
  29257. if (this.validateShaderPrograms) {
  29258. context.validateProgram(shaderProgram);
  29259. var validated = context.getProgramParameter(shaderProgram, context.VALIDATE_STATUS);
  29260. if (!validated) {
  29261. var error = context.getProgramInfoLog(shaderProgram);
  29262. if (error) {
  29263. throw new Error(error);
  29264. }
  29265. }
  29266. }
  29267. context.deleteShader(vertexShader);
  29268. context.deleteShader(fragmentShader);
  29269. shaderProgram.context = undefined;
  29270. shaderProgram.vertexShader = undefined;
  29271. shaderProgram.fragmentShader = undefined;
  29272. if (shaderProgram.onCompiled) {
  29273. shaderProgram.onCompiled();
  29274. shaderProgram.onCompiled = undefined;
  29275. }
  29276. };
  29277. /** @hidden */
  29278. Engine.prototype._isProgramCompiled = function (shaderProgram) {
  29279. if (!shaderProgram.isParallelCompiled) {
  29280. return true;
  29281. }
  29282. if (this._gl.getProgramParameter(shaderProgram, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
  29283. this._finalizeProgram(shaderProgram);
  29284. return true;
  29285. }
  29286. return false;
  29287. };
  29288. /** @hidden */
  29289. Engine.prototype._executeWhenProgramIsCompiled = function (shaderProgram, action) {
  29290. if (!shaderProgram.isParallelCompiled) {
  29291. action();
  29292. return;
  29293. }
  29294. shaderProgram.onCompiled = action;
  29295. };
  29296. /**
  29297. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29298. * @param shaderProgram defines the webGL program to use
  29299. * @param uniformsNames defines the list of uniform names
  29300. * @returns an array of webGL uniform locations
  29301. */
  29302. Engine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  29303. var results = new Array();
  29304. for (var index = 0; index < uniformsNames.length; index++) {
  29305. results.push(this._gl.getUniformLocation(shaderProgram, uniformsNames[index]));
  29306. }
  29307. return results;
  29308. };
  29309. /**
  29310. * Gets the lsit of active attributes for a given webGL program
  29311. * @param shaderProgram defines the webGL program to use
  29312. * @param attributesNames defines the list of attribute names to get
  29313. * @returns an array of indices indicating the offset of each attribute
  29314. */
  29315. Engine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  29316. var results = [];
  29317. for (var index = 0; index < attributesNames.length; index++) {
  29318. try {
  29319. results.push(this._gl.getAttribLocation(shaderProgram, attributesNames[index]));
  29320. }
  29321. catch (e) {
  29322. results.push(-1);
  29323. }
  29324. }
  29325. return results;
  29326. };
  29327. /**
  29328. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29329. * @param effect defines the effect to activate
  29330. */
  29331. Engine.prototype.enableEffect = function (effect) {
  29332. if (!effect || effect === this._currentEffect) {
  29333. return;
  29334. }
  29335. // Use program
  29336. this.bindSamplers(effect);
  29337. this._currentEffect = effect;
  29338. if (effect.onBind) {
  29339. effect.onBind(effect);
  29340. }
  29341. if (effect._onBindObservable) {
  29342. effect._onBindObservable.notifyObservers(effect);
  29343. }
  29344. };
  29345. /**
  29346. * Set the value of an uniform to an array of int32
  29347. * @param uniform defines the webGL uniform location where to store the value
  29348. * @param array defines the array of int32 to store
  29349. */
  29350. Engine.prototype.setIntArray = function (uniform, array) {
  29351. if (!uniform) {
  29352. return;
  29353. }
  29354. this._gl.uniform1iv(uniform, array);
  29355. };
  29356. /**
  29357. * Set the value of an uniform to an array of int32 (stored as vec2)
  29358. * @param uniform defines the webGL uniform location where to store the value
  29359. * @param array defines the array of int32 to store
  29360. */
  29361. Engine.prototype.setIntArray2 = function (uniform, array) {
  29362. if (!uniform || array.length % 2 !== 0) {
  29363. return;
  29364. }
  29365. this._gl.uniform2iv(uniform, array);
  29366. };
  29367. /**
  29368. * Set the value of an uniform to an array of int32 (stored as vec3)
  29369. * @param uniform defines the webGL uniform location where to store the value
  29370. * @param array defines the array of int32 to store
  29371. */
  29372. Engine.prototype.setIntArray3 = function (uniform, array) {
  29373. if (!uniform || array.length % 3 !== 0) {
  29374. return;
  29375. }
  29376. this._gl.uniform3iv(uniform, array);
  29377. };
  29378. /**
  29379. * Set the value of an uniform to an array of int32 (stored as vec4)
  29380. * @param uniform defines the webGL uniform location where to store the value
  29381. * @param array defines the array of int32 to store
  29382. */
  29383. Engine.prototype.setIntArray4 = function (uniform, array) {
  29384. if (!uniform || array.length % 4 !== 0) {
  29385. return;
  29386. }
  29387. this._gl.uniform4iv(uniform, array);
  29388. };
  29389. /**
  29390. * Set the value of an uniform to an array of float32
  29391. * @param uniform defines the webGL uniform location where to store the value
  29392. * @param array defines the array of float32 to store
  29393. */
  29394. Engine.prototype.setFloatArray = function (uniform, array) {
  29395. if (!uniform) {
  29396. return;
  29397. }
  29398. this._gl.uniform1fv(uniform, array);
  29399. };
  29400. /**
  29401. * Set the value of an uniform to an array of float32 (stored as vec2)
  29402. * @param uniform defines the webGL uniform location where to store the value
  29403. * @param array defines the array of float32 to store
  29404. */
  29405. Engine.prototype.setFloatArray2 = function (uniform, array) {
  29406. if (!uniform || array.length % 2 !== 0) {
  29407. return;
  29408. }
  29409. this._gl.uniform2fv(uniform, array);
  29410. };
  29411. /**
  29412. * Set the value of an uniform to an array of float32 (stored as vec3)
  29413. * @param uniform defines the webGL uniform location where to store the value
  29414. * @param array defines the array of float32 to store
  29415. */
  29416. Engine.prototype.setFloatArray3 = function (uniform, array) {
  29417. if (!uniform || array.length % 3 !== 0) {
  29418. return;
  29419. }
  29420. this._gl.uniform3fv(uniform, array);
  29421. };
  29422. /**
  29423. * Set the value of an uniform to an array of float32 (stored as vec4)
  29424. * @param uniform defines the webGL uniform location where to store the value
  29425. * @param array defines the array of float32 to store
  29426. */
  29427. Engine.prototype.setFloatArray4 = function (uniform, array) {
  29428. if (!uniform || array.length % 4 !== 0) {
  29429. return;
  29430. }
  29431. this._gl.uniform4fv(uniform, array);
  29432. };
  29433. /**
  29434. * Set the value of an uniform to an array of number
  29435. * @param uniform defines the webGL uniform location where to store the value
  29436. * @param array defines the array of number to store
  29437. */
  29438. Engine.prototype.setArray = function (uniform, array) {
  29439. if (!uniform) {
  29440. return;
  29441. }
  29442. this._gl.uniform1fv(uniform, array);
  29443. };
  29444. /**
  29445. * Set the value of an uniform to an array of number (stored as vec2)
  29446. * @param uniform defines the webGL uniform location where to store the value
  29447. * @param array defines the array of number to store
  29448. */
  29449. Engine.prototype.setArray2 = function (uniform, array) {
  29450. if (!uniform || array.length % 2 !== 0) {
  29451. return;
  29452. }
  29453. this._gl.uniform2fv(uniform, array);
  29454. };
  29455. /**
  29456. * Set the value of an uniform to an array of number (stored as vec3)
  29457. * @param uniform defines the webGL uniform location where to store the value
  29458. * @param array defines the array of number to store
  29459. */
  29460. Engine.prototype.setArray3 = function (uniform, array) {
  29461. if (!uniform || array.length % 3 !== 0) {
  29462. return;
  29463. }
  29464. this._gl.uniform3fv(uniform, array);
  29465. };
  29466. /**
  29467. * Set the value of an uniform to an array of number (stored as vec4)
  29468. * @param uniform defines the webGL uniform location where to store the value
  29469. * @param array defines the array of number to store
  29470. */
  29471. Engine.prototype.setArray4 = function (uniform, array) {
  29472. if (!uniform || array.length % 4 !== 0) {
  29473. return;
  29474. }
  29475. this._gl.uniform4fv(uniform, array);
  29476. };
  29477. /**
  29478. * Set the value of an uniform to an array of float32 (stored as matrices)
  29479. * @param uniform defines the webGL uniform location where to store the value
  29480. * @param matrices defines the array of float32 to store
  29481. */
  29482. Engine.prototype.setMatrices = function (uniform, matrices) {
  29483. if (!uniform) {
  29484. return;
  29485. }
  29486. this._gl.uniformMatrix4fv(uniform, false, matrices);
  29487. };
  29488. /**
  29489. * Set the value of an uniform to a matrix
  29490. * @param uniform defines the webGL uniform location where to store the value
  29491. * @param matrix defines the matrix to store
  29492. */
  29493. Engine.prototype.setMatrix = function (uniform, matrix) {
  29494. if (!uniform) {
  29495. return;
  29496. }
  29497. this._gl.uniformMatrix4fv(uniform, false, matrix.toArray());
  29498. };
  29499. /**
  29500. * Set the value of an uniform to a matrix (3x3)
  29501. * @param uniform defines the webGL uniform location where to store the value
  29502. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29503. */
  29504. Engine.prototype.setMatrix3x3 = function (uniform, matrix) {
  29505. if (!uniform) {
  29506. return;
  29507. }
  29508. this._gl.uniformMatrix3fv(uniform, false, matrix);
  29509. };
  29510. /**
  29511. * Set the value of an uniform to a matrix (2x2)
  29512. * @param uniform defines the webGL uniform location where to store the value
  29513. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29514. */
  29515. Engine.prototype.setMatrix2x2 = function (uniform, matrix) {
  29516. if (!uniform) {
  29517. return;
  29518. }
  29519. this._gl.uniformMatrix2fv(uniform, false, matrix);
  29520. };
  29521. /**
  29522. * Set the value of an uniform to a number (int)
  29523. * @param uniform defines the webGL uniform location where to store the value
  29524. * @param value defines the int number to store
  29525. */
  29526. Engine.prototype.setInt = function (uniform, value) {
  29527. if (!uniform) {
  29528. return;
  29529. }
  29530. this._gl.uniform1i(uniform, value);
  29531. };
  29532. /**
  29533. * Set the value of an uniform to a number (float)
  29534. * @param uniform defines the webGL uniform location where to store the value
  29535. * @param value defines the float number to store
  29536. */
  29537. Engine.prototype.setFloat = function (uniform, value) {
  29538. if (!uniform) {
  29539. return;
  29540. }
  29541. this._gl.uniform1f(uniform, value);
  29542. };
  29543. /**
  29544. * Set the value of an uniform to a vec2
  29545. * @param uniform defines the webGL uniform location where to store the value
  29546. * @param x defines the 1st component of the value
  29547. * @param y defines the 2nd component of the value
  29548. */
  29549. Engine.prototype.setFloat2 = function (uniform, x, y) {
  29550. if (!uniform) {
  29551. return;
  29552. }
  29553. this._gl.uniform2f(uniform, x, y);
  29554. };
  29555. /**
  29556. * Set the value of an uniform to a vec3
  29557. * @param uniform defines the webGL uniform location where to store the value
  29558. * @param x defines the 1st component of the value
  29559. * @param y defines the 2nd component of the value
  29560. * @param z defines the 3rd component of the value
  29561. */
  29562. Engine.prototype.setFloat3 = function (uniform, x, y, z) {
  29563. if (!uniform) {
  29564. return;
  29565. }
  29566. this._gl.uniform3f(uniform, x, y, z);
  29567. };
  29568. /**
  29569. * Set the value of an uniform to a boolean
  29570. * @param uniform defines the webGL uniform location where to store the value
  29571. * @param bool defines the boolean to store
  29572. */
  29573. Engine.prototype.setBool = function (uniform, bool) {
  29574. if (!uniform) {
  29575. return;
  29576. }
  29577. this._gl.uniform1i(uniform, bool);
  29578. };
  29579. /**
  29580. * Set the value of an uniform to a vec4
  29581. * @param uniform defines the webGL uniform location where to store the value
  29582. * @param x defines the 1st component of the value
  29583. * @param y defines the 2nd component of the value
  29584. * @param z defines the 3rd component of the value
  29585. * @param w defines the 4th component of the value
  29586. */
  29587. Engine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  29588. if (!uniform) {
  29589. return;
  29590. }
  29591. this._gl.uniform4f(uniform, x, y, z, w);
  29592. };
  29593. /**
  29594. * Set the value of an uniform to a Color3
  29595. * @param uniform defines the webGL uniform location where to store the value
  29596. * @param color3 defines the color to store
  29597. */
  29598. Engine.prototype.setColor3 = function (uniform, color3) {
  29599. if (!uniform) {
  29600. return;
  29601. }
  29602. this._gl.uniform3f(uniform, color3.r, color3.g, color3.b);
  29603. };
  29604. /**
  29605. * Set the value of an uniform to a Color3 and an alpha value
  29606. * @param uniform defines the webGL uniform location where to store the value
  29607. * @param color3 defines the color to store
  29608. * @param alpha defines the alpha component to store
  29609. */
  29610. Engine.prototype.setColor4 = function (uniform, color3, alpha) {
  29611. if (!uniform) {
  29612. return;
  29613. }
  29614. this._gl.uniform4f(uniform, color3.r, color3.g, color3.b, alpha);
  29615. };
  29616. /**
  29617. * Sets a Color4 on a uniform variable
  29618. * @param uniform defines the uniform location
  29619. * @param color4 defines the value to be set
  29620. */
  29621. Engine.prototype.setDirectColor4 = function (uniform, color4) {
  29622. if (!uniform) {
  29623. return;
  29624. }
  29625. this._gl.uniform4f(uniform, color4.r, color4.g, color4.b, color4.a);
  29626. };
  29627. // States
  29628. /**
  29629. * Set various states to the webGL context
  29630. * @param culling defines backface culling state
  29631. * @param zOffset defines the value to apply to zOffset (0 by default)
  29632. * @param force defines if states must be applied even if cache is up to date
  29633. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29634. */
  29635. Engine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  29636. if (zOffset === void 0) { zOffset = 0; }
  29637. if (reverseSide === void 0) { reverseSide = false; }
  29638. // Culling
  29639. if (this._depthCullingState.cull !== culling || force) {
  29640. this._depthCullingState.cull = culling;
  29641. }
  29642. // Cull face
  29643. var cullFace = this.cullBackFaces ? this._gl.BACK : this._gl.FRONT;
  29644. if (this._depthCullingState.cullFace !== cullFace || force) {
  29645. this._depthCullingState.cullFace = cullFace;
  29646. }
  29647. // Z offset
  29648. this.setZOffset(zOffset);
  29649. // Front face
  29650. var frontFace = reverseSide ? this._gl.CW : this._gl.CCW;
  29651. if (this._depthCullingState.frontFace !== frontFace || force) {
  29652. this._depthCullingState.frontFace = frontFace;
  29653. }
  29654. };
  29655. /**
  29656. * Set the z offset to apply to current rendering
  29657. * @param value defines the offset to apply
  29658. */
  29659. Engine.prototype.setZOffset = function (value) {
  29660. this._depthCullingState.zOffset = value;
  29661. };
  29662. /**
  29663. * Gets the current value of the zOffset
  29664. * @returns the current zOffset state
  29665. */
  29666. Engine.prototype.getZOffset = function () {
  29667. return this._depthCullingState.zOffset;
  29668. };
  29669. /**
  29670. * Enable or disable depth buffering
  29671. * @param enable defines the state to set
  29672. */
  29673. Engine.prototype.setDepthBuffer = function (enable) {
  29674. this._depthCullingState.depthTest = enable;
  29675. };
  29676. /**
  29677. * Gets a boolean indicating if depth writing is enabled
  29678. * @returns the current depth writing state
  29679. */
  29680. Engine.prototype.getDepthWrite = function () {
  29681. return this._depthCullingState.depthMask;
  29682. };
  29683. /**
  29684. * Enable or disable depth writing
  29685. * @param enable defines the state to set
  29686. */
  29687. Engine.prototype.setDepthWrite = function (enable) {
  29688. this._depthCullingState.depthMask = enable;
  29689. };
  29690. /**
  29691. * Enable or disable color writing
  29692. * @param enable defines the state to set
  29693. */
  29694. Engine.prototype.setColorWrite = function (enable) {
  29695. this._gl.colorMask(enable, enable, enable, enable);
  29696. this._colorWrite = enable;
  29697. };
  29698. /**
  29699. * Gets a boolean indicating if color writing is enabled
  29700. * @returns the current color writing state
  29701. */
  29702. Engine.prototype.getColorWrite = function () {
  29703. return this._colorWrite;
  29704. };
  29705. /**
  29706. * Sets alpha constants used by some alpha blending modes
  29707. * @param r defines the red component
  29708. * @param g defines the green component
  29709. * @param b defines the blue component
  29710. * @param a defines the alpha component
  29711. */
  29712. Engine.prototype.setAlphaConstants = function (r, g, b, a) {
  29713. this._alphaState.setAlphaBlendConstants(r, g, b, a);
  29714. };
  29715. /**
  29716. * Sets the current alpha mode
  29717. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29718. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29719. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29720. */
  29721. Engine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  29722. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  29723. if (this._alphaMode === mode) {
  29724. return;
  29725. }
  29726. switch (mode) {
  29727. case Engine.ALPHA_DISABLE:
  29728. this._alphaState.alphaBlend = false;
  29729. break;
  29730. case Engine.ALPHA_PREMULTIPLIED:
  29731. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  29732. this._alphaState.alphaBlend = true;
  29733. break;
  29734. case Engine.ALPHA_PREMULTIPLIED_PORTERDUFF:
  29735. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  29736. this._alphaState.alphaBlend = true;
  29737. break;
  29738. case Engine.ALPHA_COMBINE:
  29739. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  29740. this._alphaState.alphaBlend = true;
  29741. break;
  29742. case Engine.ALPHA_ONEONE:
  29743. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  29744. this._alphaState.alphaBlend = true;
  29745. break;
  29746. case Engine.ALPHA_ADD:
  29747. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  29748. this._alphaState.alphaBlend = true;
  29749. break;
  29750. case Engine.ALPHA_SUBTRACT:
  29751. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  29752. this._alphaState.alphaBlend = true;
  29753. break;
  29754. case Engine.ALPHA_MULTIPLY:
  29755. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE);
  29756. this._alphaState.alphaBlend = true;
  29757. break;
  29758. case Engine.ALPHA_MAXIMIZED:
  29759. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  29760. this._alphaState.alphaBlend = true;
  29761. break;
  29762. case Engine.ALPHA_INTERPOLATE:
  29763. this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA);
  29764. this._alphaState.alphaBlend = true;
  29765. break;
  29766. case Engine.ALPHA_SCREENMODE:
  29767. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  29768. this._alphaState.alphaBlend = true;
  29769. break;
  29770. }
  29771. if (!noDepthWriteChange) {
  29772. this.setDepthWrite(mode === Engine.ALPHA_DISABLE);
  29773. }
  29774. this._alphaMode = mode;
  29775. };
  29776. /**
  29777. * Gets the current alpha mode
  29778. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29779. * @returns the current alpha mode
  29780. */
  29781. Engine.prototype.getAlphaMode = function () {
  29782. return this._alphaMode;
  29783. };
  29784. // Textures
  29785. /**
  29786. * Clears the list of texture accessible through engine.
  29787. * This can help preventing texture load conflict due to name collision.
  29788. */
  29789. Engine.prototype.clearInternalTexturesCache = function () {
  29790. this._internalTexturesCache = [];
  29791. };
  29792. /**
  29793. * Force the entire cache to be cleared
  29794. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29795. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29796. */
  29797. Engine.prototype.wipeCaches = function (bruteForce) {
  29798. if (this.preventCacheWipeBetweenFrames && !bruteForce) {
  29799. return;
  29800. }
  29801. this._currentEffect = null;
  29802. this._viewportCached.x = 0;
  29803. this._viewportCached.y = 0;
  29804. this._viewportCached.z = 0;
  29805. this._viewportCached.w = 0;
  29806. if (bruteForce) {
  29807. this.resetTextureCache();
  29808. this._currentProgram = null;
  29809. this._stencilState.reset();
  29810. this._depthCullingState.reset();
  29811. this.setDepthFunctionToLessOrEqual();
  29812. this._alphaState.reset();
  29813. this._unpackFlipYCached = null;
  29814. }
  29815. this._resetVertexBufferBinding();
  29816. this._cachedIndexBuffer = null;
  29817. this._cachedEffectForVertexBuffers = null;
  29818. this._unbindVertexArrayObject();
  29819. this.bindIndexBuffer(null);
  29820. };
  29821. /**
  29822. * Set the compressed texture format to use, based on the formats you have, and the formats
  29823. * supported by the hardware / browser.
  29824. *
  29825. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29826. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29827. * to API arguments needed to compressed textures. This puts the burden on the container
  29828. * generator to house the arcane code for determining these for current & future formats.
  29829. *
  29830. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29831. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29832. *
  29833. * Note: The result of this call is not taken into account when a texture is base64.
  29834. *
  29835. * @param formatsAvailable defines the list of those format families you have created
  29836. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29837. *
  29838. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29839. * @returns The extension selected.
  29840. */
  29841. Engine.prototype.setTextureFormatToUse = function (formatsAvailable) {
  29842. for (var i = 0, len1 = this.texturesSupported.length; i < len1; i++) {
  29843. for (var j = 0, len2 = formatsAvailable.length; j < len2; j++) {
  29844. if (this._texturesSupported[i] === formatsAvailable[j].toLowerCase()) {
  29845. return this._textureFormatInUse = this._texturesSupported[i];
  29846. }
  29847. }
  29848. }
  29849. // actively set format to nothing, to allow this to be called more than once
  29850. // and possibly fail the 2nd time
  29851. this._textureFormatInUse = null;
  29852. return null;
  29853. };
  29854. Engine.prototype._getSamplingParameters = function (samplingMode, generateMipMaps) {
  29855. var gl = this._gl;
  29856. var magFilter = gl.NEAREST;
  29857. var minFilter = gl.NEAREST;
  29858. switch (samplingMode) {
  29859. case Engine.TEXTURE_BILINEAR_SAMPLINGMODE:
  29860. magFilter = gl.LINEAR;
  29861. if (generateMipMaps) {
  29862. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  29863. }
  29864. else {
  29865. minFilter = gl.LINEAR;
  29866. }
  29867. break;
  29868. case Engine.TEXTURE_TRILINEAR_SAMPLINGMODE:
  29869. magFilter = gl.LINEAR;
  29870. if (generateMipMaps) {
  29871. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  29872. }
  29873. else {
  29874. minFilter = gl.LINEAR;
  29875. }
  29876. break;
  29877. case Engine.TEXTURE_NEAREST_SAMPLINGMODE:
  29878. magFilter = gl.NEAREST;
  29879. if (generateMipMaps) {
  29880. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  29881. }
  29882. else {
  29883. minFilter = gl.NEAREST;
  29884. }
  29885. break;
  29886. case Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
  29887. magFilter = gl.NEAREST;
  29888. if (generateMipMaps) {
  29889. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  29890. }
  29891. else {
  29892. minFilter = gl.NEAREST;
  29893. }
  29894. break;
  29895. case Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
  29896. magFilter = gl.NEAREST;
  29897. if (generateMipMaps) {
  29898. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  29899. }
  29900. else {
  29901. minFilter = gl.LINEAR;
  29902. }
  29903. break;
  29904. case Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
  29905. magFilter = gl.NEAREST;
  29906. if (generateMipMaps) {
  29907. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  29908. }
  29909. else {
  29910. minFilter = gl.LINEAR;
  29911. }
  29912. break;
  29913. case Engine.TEXTURE_NEAREST_LINEAR:
  29914. magFilter = gl.NEAREST;
  29915. minFilter = gl.LINEAR;
  29916. break;
  29917. case Engine.TEXTURE_NEAREST_NEAREST:
  29918. magFilter = gl.NEAREST;
  29919. minFilter = gl.NEAREST;
  29920. break;
  29921. case Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
  29922. magFilter = gl.LINEAR;
  29923. if (generateMipMaps) {
  29924. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  29925. }
  29926. else {
  29927. minFilter = gl.NEAREST;
  29928. }
  29929. break;
  29930. case Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
  29931. magFilter = gl.LINEAR;
  29932. if (generateMipMaps) {
  29933. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  29934. }
  29935. else {
  29936. minFilter = gl.NEAREST;
  29937. }
  29938. break;
  29939. case Engine.TEXTURE_LINEAR_LINEAR:
  29940. magFilter = gl.LINEAR;
  29941. minFilter = gl.LINEAR;
  29942. break;
  29943. case Engine.TEXTURE_LINEAR_NEAREST:
  29944. magFilter = gl.LINEAR;
  29945. minFilter = gl.NEAREST;
  29946. break;
  29947. }
  29948. return {
  29949. min: minFilter,
  29950. mag: magFilter
  29951. };
  29952. };
  29953. Engine.prototype._partialLoadImg = function (url, index, loadedImages, scene, onfinish, onErrorCallBack) {
  29954. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  29955. var img;
  29956. var onload = function () {
  29957. loadedImages[index] = img;
  29958. loadedImages._internalCount++;
  29959. if (scene) {
  29960. scene._removePendingData(img);
  29961. }
  29962. if (loadedImages._internalCount === 6) {
  29963. onfinish(loadedImages);
  29964. }
  29965. };
  29966. var onerror = function (message, exception) {
  29967. if (scene) {
  29968. scene._removePendingData(img);
  29969. }
  29970. if (onErrorCallBack) {
  29971. onErrorCallBack(message, exception);
  29972. }
  29973. };
  29974. img = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null);
  29975. if (scene) {
  29976. scene._addPendingData(img);
  29977. }
  29978. };
  29979. Engine.prototype._cascadeLoadImgs = function (scene, onfinish, files, onError) {
  29980. if (onError === void 0) { onError = null; }
  29981. var loadedImages = [];
  29982. loadedImages._internalCount = 0;
  29983. for (var index = 0; index < 6; index++) {
  29984. this._partialLoadImg(files[index], index, loadedImages, scene, onfinish, onError);
  29985. }
  29986. };
  29987. /** @hidden */
  29988. Engine.prototype._createTexture = function () {
  29989. var texture = this._gl.createTexture();
  29990. if (!texture) {
  29991. throw new Error("Unable to create texture");
  29992. }
  29993. return texture;
  29994. };
  29995. /**
  29996. * Usually called from Texture.ts.
  29997. * Passed information to create a WebGLTexture
  29998. * @param urlArg defines a value which contains one of the following:
  29999. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30000. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30001. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30002. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30003. * @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)
  30004. * @param scene needed for loading to the correct scene
  30005. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30006. * @param onLoad optional callback to be called upon successful completion
  30007. * @param onError optional callback to be called upon failure
  30008. * @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
  30009. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30010. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30011. * @param forcedExtension defines the extension to use to pick the right loader
  30012. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30013. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30014. */
  30015. Engine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, excludeLoaders) {
  30016. var _this = this;
  30017. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  30018. if (onLoad === void 0) { onLoad = null; }
  30019. if (onError === void 0) { onError = null; }
  30020. if (buffer === void 0) { buffer = null; }
  30021. if (fallback === void 0) { fallback = null; }
  30022. if (format === void 0) { format = null; }
  30023. if (forcedExtension === void 0) { forcedExtension = null; }
  30024. if (excludeLoaders === void 0) { excludeLoaders = []; }
  30025. var url = String(urlArg); // assign a new string, so that the original is still available in case of fallback
  30026. var fromData = url.substr(0, 5) === "data:";
  30027. var fromBlob = url.substr(0, 5) === "blob:";
  30028. var isBase64 = fromData && url.indexOf(";base64,") !== -1;
  30029. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_URL);
  30030. // establish the file extension, if possible
  30031. var lastDot = url.lastIndexOf('.');
  30032. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? url.substring(lastDot).toLowerCase() : "");
  30033. var loader = null;
  30034. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  30035. var availableLoader = _a[_i];
  30036. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, isBase64, buffer ? true : false)) {
  30037. loader = availableLoader;
  30038. break;
  30039. }
  30040. }
  30041. if (loader) {
  30042. url = loader.transformUrl(url, this._textureFormatInUse);
  30043. }
  30044. if (scene) {
  30045. scene._addPendingData(texture);
  30046. }
  30047. texture.url = url;
  30048. texture.generateMipMaps = !noMipmap;
  30049. texture.samplingMode = samplingMode;
  30050. texture.invertY = invertY;
  30051. if (!this._doNotHandleContextLost) {
  30052. // Keep a link to the buffer only if we plan to handle context lost
  30053. texture._buffer = buffer;
  30054. }
  30055. var onLoadObserver = null;
  30056. if (onLoad && !fallback) {
  30057. onLoadObserver = texture.onLoadedObservable.add(onLoad);
  30058. }
  30059. if (!fallback) {
  30060. this._internalTexturesCache.push(texture);
  30061. }
  30062. var onInternalError = function (message, exception) {
  30063. if (scene) {
  30064. scene._removePendingData(texture);
  30065. }
  30066. var customFallback = false;
  30067. if (loader) {
  30068. var fallbackUrl = loader.getFallbackTextureUrl(url, _this._textureFormatInUse);
  30069. if (fallbackUrl) {
  30070. // Add Back
  30071. customFallback = true;
  30072. excludeLoaders.push(loader);
  30073. _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");
  30074. _this.createTexture(urlArg, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture, undefined, undefined, excludeLoaders);
  30075. }
  30076. }
  30077. if (!customFallback) {
  30078. if (onLoadObserver) {
  30079. texture.onLoadedObservable.remove(onLoadObserver);
  30080. }
  30081. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].UseFallbackTexture) {
  30082. _this.createTexture(_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].fallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture);
  30083. }
  30084. }
  30085. if (onError) {
  30086. onError(message || "Unknown error", exception);
  30087. }
  30088. };
  30089. // processing for non-image formats
  30090. if (loader) {
  30091. var callback = function (data) {
  30092. loader.loadData(data, texture, function (width, height, loadMipmap, isCompressed, done, loadFailed) {
  30093. if (loadFailed) {
  30094. onInternalError("TextureLoader failed to load data");
  30095. }
  30096. else {
  30097. _this._prepareWebGLTexture(texture, scene, width, height, texture.invertY, !loadMipmap, isCompressed, function () {
  30098. done();
  30099. return false;
  30100. }, samplingMode);
  30101. }
  30102. });
  30103. };
  30104. if (!buffer) {
  30105. this._loadFile(url, callback, undefined, scene ? scene.offlineProvider : undefined, true, function (request, exception) {
  30106. onInternalError("Unable to load " + (request ? request.responseURL : url, exception));
  30107. });
  30108. }
  30109. else {
  30110. callback(buffer);
  30111. }
  30112. }
  30113. else {
  30114. var onload = function (img) {
  30115. if (fromBlob && !_this._doNotHandleContextLost) {
  30116. // We need to store the image if we need to rebuild the texture
  30117. // in case of a webgl context lost
  30118. texture._buffer = img;
  30119. }
  30120. _this._prepareWebGLTexture(texture, scene, img.width, img.height, texture.invertY, noMipmap, false, function (potWidth, potHeight, continuationCallback) {
  30121. var gl = _this._gl;
  30122. var isPot = (img.width === potWidth && img.height === potHeight);
  30123. var internalFormat = format ? _this._getInternalFormat(format) : ((extension === ".jpg") ? gl.RGB : gl.RGBA);
  30124. if (isPot) {
  30125. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  30126. return false;
  30127. }
  30128. var maxTextureSize = _this._caps.maxTextureSize;
  30129. if (img.width > maxTextureSize || img.height > maxTextureSize || Engine._RescalePostProcessFactory === null) {
  30130. _this._prepareWorkingCanvas();
  30131. if (!_this._workingCanvas || !_this._workingContext) {
  30132. return false;
  30133. }
  30134. _this._workingCanvas.width = potWidth;
  30135. _this._workingCanvas.height = potHeight;
  30136. _this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
  30137. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  30138. texture.width = potWidth;
  30139. texture.height = potHeight;
  30140. return false;
  30141. }
  30142. else {
  30143. // Using shaders when possible to rescale because canvas.drawImage is lossy
  30144. var source_1 = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_TEMP);
  30145. _this._bindTextureDirectly(gl.TEXTURE_2D, source_1, true);
  30146. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  30147. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  30148. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  30149. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  30150. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30151. _this._rescaleTexture(source_1, texture, scene, internalFormat, function () {
  30152. _this._releaseTexture(source_1);
  30153. _this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  30154. continuationCallback();
  30155. });
  30156. }
  30157. return true;
  30158. }, samplingMode);
  30159. };
  30160. if (!fromData || isBase64) {
  30161. if (buffer instanceof HTMLImageElement) {
  30162. onload(buffer);
  30163. }
  30164. else {
  30165. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null);
  30166. }
  30167. }
  30168. else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
  30169. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null);
  30170. }
  30171. else {
  30172. onload(buffer);
  30173. }
  30174. }
  30175. return texture;
  30176. };
  30177. Engine.prototype._rescaleTexture = function (source, destination, scene, internalFormat, onComplete) {
  30178. var _this = this;
  30179. var rtt = this.createRenderTargetTexture({
  30180. width: destination.width,
  30181. height: destination.height,
  30182. }, {
  30183. generateMipMaps: false,
  30184. type: Engine.TEXTURETYPE_UNSIGNED_INT,
  30185. samplingMode: Engine.TEXTURE_BILINEAR_SAMPLINGMODE,
  30186. generateDepthBuffer: false,
  30187. generateStencilBuffer: false
  30188. });
  30189. if (!this._rescalePostProcess && Engine._RescalePostProcessFactory) {
  30190. this._rescalePostProcess = Engine._RescalePostProcessFactory(this);
  30191. }
  30192. this._rescalePostProcess.getEffect().executeWhenCompiled(function () {
  30193. _this._rescalePostProcess.onApply = function (effect) {
  30194. effect._bindTexture("textureSampler", source);
  30195. };
  30196. var hostingScene = scene;
  30197. if (!hostingScene) {
  30198. hostingScene = _this.scenes[_this.scenes.length - 1];
  30199. }
  30200. hostingScene.postProcessManager.directRender([_this._rescalePostProcess], rtt, true);
  30201. _this._bindTextureDirectly(_this._gl.TEXTURE_2D, destination, true);
  30202. _this._gl.copyTexImage2D(_this._gl.TEXTURE_2D, 0, internalFormat, 0, 0, destination.width, destination.height, 0);
  30203. _this.unBindFramebuffer(rtt);
  30204. _this._releaseTexture(rtt);
  30205. if (onComplete) {
  30206. onComplete();
  30207. }
  30208. });
  30209. };
  30210. /**
  30211. * Update a raw texture
  30212. * @param texture defines the texture to update
  30213. * @param data defines the data to store in the texture
  30214. * @param format defines the format of the data
  30215. * @param invertY defines if data must be stored with Y axis inverted
  30216. * @param compression defines the compression used (null by default)
  30217. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30218. */
  30219. Engine.prototype.updateRawTexture = function (texture, data, format, invertY, compression, type) {
  30220. if (compression === void 0) { compression = null; }
  30221. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  30222. if (!texture) {
  30223. return;
  30224. }
  30225. // babylon's internalSizedFomat but gl's texImage2D internalFormat
  30226. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type, format);
  30227. // babylon's internalFormat but gl's texImage2D format
  30228. var internalFormat = this._getInternalFormat(format);
  30229. var textureType = this._getWebGLTextureType(type);
  30230. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  30231. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  30232. if (!this._doNotHandleContextLost) {
  30233. texture._bufferView = data;
  30234. texture.format = format;
  30235. texture.type = type;
  30236. texture.invertY = invertY;
  30237. texture._compression = compression;
  30238. }
  30239. if (texture.width % 4 !== 0) {
  30240. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  30241. }
  30242. if (compression && data) {
  30243. this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, 0, data);
  30244. }
  30245. else {
  30246. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, data);
  30247. }
  30248. if (texture.generateMipMaps) {
  30249. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  30250. }
  30251. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  30252. // this.resetTextureCache();
  30253. texture.isReady = true;
  30254. };
  30255. /**
  30256. * Creates a raw texture
  30257. * @param data defines the data to store in the texture
  30258. * @param width defines the width of the texture
  30259. * @param height defines the height of the texture
  30260. * @param format defines the format of the data
  30261. * @param generateMipMaps defines if the engine should generate the mip levels
  30262. * @param invertY defines if data must be stored with Y axis inverted
  30263. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30264. * @param compression defines the compression used (null by default)
  30265. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30266. * @returns the raw texture inside an InternalTexture
  30267. */
  30268. Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
  30269. if (compression === void 0) { compression = null; }
  30270. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  30271. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW);
  30272. texture.baseWidth = width;
  30273. texture.baseHeight = height;
  30274. texture.width = width;
  30275. texture.height = height;
  30276. texture.format = format;
  30277. texture.generateMipMaps = generateMipMaps;
  30278. texture.samplingMode = samplingMode;
  30279. texture.invertY = invertY;
  30280. texture._compression = compression;
  30281. texture.type = type;
  30282. if (!this._doNotHandleContextLost) {
  30283. texture._bufferView = data;
  30284. }
  30285. this.updateRawTexture(texture, data, format, invertY, compression, type);
  30286. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  30287. // Filters
  30288. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  30289. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  30290. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  30291. if (generateMipMaps) {
  30292. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  30293. }
  30294. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  30295. this._internalTexturesCache.push(texture);
  30296. return texture;
  30297. };
  30298. /** @hidden */
  30299. Engine.prototype._unpackFlipY = function (value) {
  30300. if (this._unpackFlipYCached !== value) {
  30301. this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);
  30302. if (this.enableUnpackFlipYCached) {
  30303. this._unpackFlipYCached = value;
  30304. }
  30305. }
  30306. };
  30307. /** @hidden */
  30308. Engine.prototype._getUnpackAlignement = function () {
  30309. return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);
  30310. };
  30311. /**
  30312. * Creates a dynamic texture
  30313. * @param width defines the width of the texture
  30314. * @param height defines the height of the texture
  30315. * @param generateMipMaps defines if the engine should generate the mip levels
  30316. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30317. * @returns the dynamic texture inside an InternalTexture
  30318. */
  30319. Engine.prototype.createDynamicTexture = function (width, height, generateMipMaps, samplingMode) {
  30320. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DYNAMIC);
  30321. texture.baseWidth = width;
  30322. texture.baseHeight = height;
  30323. if (generateMipMaps) {
  30324. width = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, this._caps.maxTextureSize) : width;
  30325. height = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, this._caps.maxTextureSize) : height;
  30326. }
  30327. // this.resetTextureCache();
  30328. texture.width = width;
  30329. texture.height = height;
  30330. texture.isReady = false;
  30331. texture.generateMipMaps = generateMipMaps;
  30332. texture.samplingMode = samplingMode;
  30333. this.updateTextureSamplingMode(samplingMode, texture);
  30334. this._internalTexturesCache.push(texture);
  30335. return texture;
  30336. };
  30337. /**
  30338. * Update the sampling mode of a given texture
  30339. * @param samplingMode defines the required sampling mode
  30340. * @param texture defines the texture to update
  30341. */
  30342. Engine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  30343. var filters = this._getSamplingParameters(samplingMode, texture.generateMipMaps);
  30344. if (texture.isCube) {
  30345. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  30346. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MIN_FILTER, filters.min);
  30347. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  30348. }
  30349. else if (texture.is3D) {
  30350. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  30351. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  30352. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  30353. }
  30354. else {
  30355. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  30356. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  30357. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  30358. }
  30359. texture.samplingMode = samplingMode;
  30360. };
  30361. /**
  30362. * Update the content of a dynamic texture
  30363. * @param texture defines the texture to update
  30364. * @param canvas defines the canvas containing the source
  30365. * @param invertY defines if data must be stored with Y axis inverted
  30366. * @param premulAlpha defines if alpha is stored as premultiplied
  30367. * @param format defines the format of the data
  30368. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  30369. */
  30370. Engine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format, forceBindTexture) {
  30371. if (premulAlpha === void 0) { premulAlpha = false; }
  30372. if (forceBindTexture === void 0) { forceBindTexture = false; }
  30373. if (!texture) {
  30374. return;
  30375. }
  30376. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true, forceBindTexture);
  30377. this._unpackFlipY(invertY);
  30378. if (premulAlpha) {
  30379. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
  30380. }
  30381. var internalFormat = format ? this._getInternalFormat(format) : this._gl.RGBA;
  30382. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, internalFormat, this._gl.UNSIGNED_BYTE, canvas);
  30383. if (texture.generateMipMaps) {
  30384. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  30385. }
  30386. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  30387. if (premulAlpha) {
  30388. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
  30389. }
  30390. texture.isReady = true;
  30391. };
  30392. /**
  30393. * Update a video texture
  30394. * @param texture defines the texture to update
  30395. * @param video defines the video element to use
  30396. * @param invertY defines if data must be stored with Y axis inverted
  30397. */
  30398. Engine.prototype.updateVideoTexture = function (texture, video, invertY) {
  30399. if (!texture || texture._isDisabled) {
  30400. return;
  30401. }
  30402. var wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  30403. this._unpackFlipY(!invertY); // Video are upside down by default
  30404. try {
  30405. // Testing video texture support
  30406. if (this._videoTextureSupported === undefined) {
  30407. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  30408. if (this._gl.getError() !== 0) {
  30409. this._videoTextureSupported = false;
  30410. }
  30411. else {
  30412. this._videoTextureSupported = true;
  30413. }
  30414. }
  30415. // Copy video through the current working canvas if video texture is not supported
  30416. if (!this._videoTextureSupported) {
  30417. if (!texture._workingCanvas) {
  30418. texture._workingCanvas = document.createElement("canvas");
  30419. var context = texture._workingCanvas.getContext("2d");
  30420. if (!context) {
  30421. throw new Error("Unable to get 2d context");
  30422. }
  30423. texture._workingContext = context;
  30424. texture._workingCanvas.width = texture.width;
  30425. texture._workingCanvas.height = texture.height;
  30426. }
  30427. texture._workingContext.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);
  30428. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, texture._workingCanvas);
  30429. }
  30430. else {
  30431. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  30432. }
  30433. if (texture.generateMipMaps) {
  30434. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  30435. }
  30436. if (!wasPreviouslyBound) {
  30437. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  30438. }
  30439. // this.resetTextureCache();
  30440. texture.isReady = true;
  30441. }
  30442. catch (ex) {
  30443. // Something unexpected
  30444. // Let's disable the texture
  30445. texture._isDisabled = true;
  30446. }
  30447. };
  30448. /**
  30449. * Updates a depth texture Comparison Mode and Function.
  30450. * If the comparison Function is equal to 0, the mode will be set to none.
  30451. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30452. * @param texture The texture to set the comparison function for
  30453. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30454. */
  30455. Engine.prototype.updateTextureComparisonFunction = function (texture, comparisonFunction) {
  30456. if (this.webGLVersion === 1) {
  30457. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("WebGL 1 does not support texture comparison.");
  30458. return;
  30459. }
  30460. var gl = this._gl;
  30461. if (texture.isCube) {
  30462. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  30463. if (comparisonFunction === 0) {
  30464. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  30465. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  30466. }
  30467. else {
  30468. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  30469. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  30470. }
  30471. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  30472. }
  30473. else {
  30474. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  30475. if (comparisonFunction === 0) {
  30476. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  30477. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  30478. }
  30479. else {
  30480. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  30481. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  30482. }
  30483. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  30484. }
  30485. texture._comparisonFunction = comparisonFunction;
  30486. };
  30487. Engine.prototype._setupDepthStencilTexture = function (internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction) {
  30488. var width = size.width || size;
  30489. var height = size.height || size;
  30490. internalTexture.baseWidth = width;
  30491. internalTexture.baseHeight = height;
  30492. internalTexture.width = width;
  30493. internalTexture.height = height;
  30494. internalTexture.isReady = true;
  30495. internalTexture.samples = 1;
  30496. internalTexture.generateMipMaps = false;
  30497. internalTexture._generateDepthBuffer = true;
  30498. internalTexture._generateStencilBuffer = generateStencil;
  30499. internalTexture.samplingMode = bilinearFiltering ? Engine.TEXTURE_BILINEAR_SAMPLINGMODE : Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  30500. internalTexture.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  30501. internalTexture._comparisonFunction = comparisonFunction;
  30502. var gl = this._gl;
  30503. var target = internalTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  30504. var samplingParameters = this._getSamplingParameters(internalTexture.samplingMode, false);
  30505. gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, samplingParameters.mag);
  30506. gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, samplingParameters.min);
  30507. gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  30508. gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30509. if (comparisonFunction === 0) {
  30510. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  30511. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  30512. }
  30513. else {
  30514. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  30515. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  30516. }
  30517. };
  30518. /**
  30519. * Creates a depth stencil texture.
  30520. * This is only available in WebGL 2 or with the depth texture extension available.
  30521. * @param size The size of face edge in the texture.
  30522. * @param options The options defining the texture.
  30523. * @returns The texture
  30524. */
  30525. Engine.prototype.createDepthStencilTexture = function (size, options) {
  30526. if (options.isCube) {
  30527. var width = size.width || size;
  30528. return this._createDepthStencilCubeTexture(width, options);
  30529. }
  30530. else {
  30531. return this._createDepthStencilTexture(size, options);
  30532. }
  30533. };
  30534. /**
  30535. * Creates a depth stencil texture.
  30536. * This is only available in WebGL 2 or with the depth texture extension available.
  30537. * @param size The size of face edge in the texture.
  30538. * @param options The options defining the texture.
  30539. * @returns The texture
  30540. */
  30541. Engine.prototype._createDepthStencilTexture = function (size, options) {
  30542. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DEPTHTEXTURE);
  30543. if (!this._caps.depthTextureExtension) {
  30544. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth texture is not supported by your browser or hardware.");
  30545. return internalTexture;
  30546. }
  30547. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  30548. var gl = this._gl;
  30549. this._bindTextureDirectly(gl.TEXTURE_2D, internalTexture, true);
  30550. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  30551. if (this.webGLVersion > 1) {
  30552. if (internalOptions.generateStencil) {
  30553. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH24_STENCIL8, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  30554. }
  30555. else {
  30556. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT24, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  30557. }
  30558. }
  30559. else {
  30560. if (internalOptions.generateStencil) {
  30561. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  30562. }
  30563. else {
  30564. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  30565. }
  30566. }
  30567. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  30568. return internalTexture;
  30569. };
  30570. /**
  30571. * Creates a depth stencil cube texture.
  30572. * This is only available in WebGL 2.
  30573. * @param size The size of face edge in the cube texture.
  30574. * @param options The options defining the cube texture.
  30575. * @returns The cube texture
  30576. */
  30577. Engine.prototype._createDepthStencilCubeTexture = function (size, options) {
  30578. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_UNKNOWN);
  30579. internalTexture.isCube = true;
  30580. if (this.webGLVersion === 1) {
  30581. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth cube texture is not supported by WebGL 1.");
  30582. return internalTexture;
  30583. }
  30584. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  30585. var gl = this._gl;
  30586. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, internalTexture, true);
  30587. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  30588. // Create the depth/stencil buffer
  30589. for (var face = 0; face < 6; face++) {
  30590. if (internalOptions.generateStencil) {
  30591. 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);
  30592. }
  30593. else {
  30594. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH_COMPONENT24, size, size, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  30595. }
  30596. }
  30597. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  30598. return internalTexture;
  30599. };
  30600. /**
  30601. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  30602. * @param renderTarget The render target to set the frame buffer for
  30603. */
  30604. Engine.prototype.setFrameBufferDepthStencilTexture = function (renderTarget) {
  30605. // Create the framebuffer
  30606. var internalTexture = renderTarget.getInternalTexture();
  30607. if (!internalTexture || !internalTexture._framebuffer || !renderTarget.depthStencilTexture) {
  30608. return;
  30609. }
  30610. var gl = this._gl;
  30611. var depthStencilTexture = renderTarget.depthStencilTexture;
  30612. this.bindUnboundFramebuffer(internalTexture._framebuffer);
  30613. if (depthStencilTexture.isCube) {
  30614. if (depthStencilTexture._generateStencilBuffer) {
  30615. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  30616. }
  30617. else {
  30618. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  30619. }
  30620. }
  30621. else {
  30622. if (depthStencilTexture._generateStencilBuffer) {
  30623. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  30624. }
  30625. else {
  30626. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  30627. }
  30628. }
  30629. this.bindUnboundFramebuffer(null);
  30630. };
  30631. /**
  30632. * Creates a new render target texture
  30633. * @param size defines the size of the texture
  30634. * @param options defines the options used to create the texture
  30635. * @returns a new render target texture stored in an InternalTexture
  30636. */
  30637. Engine.prototype.createRenderTargetTexture = function (size, options) {
  30638. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__["RenderTargetCreationOptions"]();
  30639. if (options !== undefined && typeof options === "object") {
  30640. fullOptions.generateMipMaps = options.generateMipMaps;
  30641. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  30642. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  30643. fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
  30644. fullOptions.samplingMode = options.samplingMode === undefined ? Engine.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  30645. fullOptions.format = options.format === undefined ? Engine.TEXTUREFORMAT_RGBA : options.format;
  30646. }
  30647. else {
  30648. fullOptions.generateMipMaps = options;
  30649. fullOptions.generateDepthBuffer = true;
  30650. fullOptions.generateStencilBuffer = false;
  30651. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  30652. fullOptions.samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  30653. fullOptions.format = Engine.TEXTUREFORMAT_RGBA;
  30654. }
  30655. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  30656. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  30657. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  30658. }
  30659. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  30660. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  30661. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  30662. }
  30663. var gl = this._gl;
  30664. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  30665. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  30666. var width = size.width || size;
  30667. var height = size.height || size;
  30668. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps ? true : false);
  30669. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  30670. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  30671. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  30672. }
  30673. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  30674. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  30675. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  30676. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30677. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type, fullOptions.format), width, height, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
  30678. // Create the framebuffer
  30679. var currentFrameBuffer = this._currentFramebuffer;
  30680. var framebuffer = gl.createFramebuffer();
  30681. this.bindUnboundFramebuffer(framebuffer);
  30682. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
  30683. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer ? true : false, fullOptions.generateDepthBuffer, width, height);
  30684. if (fullOptions.generateMipMaps) {
  30685. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  30686. }
  30687. // Unbind
  30688. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  30689. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  30690. this.bindUnboundFramebuffer(currentFrameBuffer);
  30691. texture._framebuffer = framebuffer;
  30692. texture.baseWidth = width;
  30693. texture.baseHeight = height;
  30694. texture.width = width;
  30695. texture.height = height;
  30696. texture.isReady = true;
  30697. texture.samples = 1;
  30698. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  30699. texture.samplingMode = fullOptions.samplingMode;
  30700. texture.type = fullOptions.type;
  30701. texture.format = fullOptions.format;
  30702. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  30703. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  30704. // this.resetTextureCache();
  30705. this._internalTexturesCache.push(texture);
  30706. return texture;
  30707. };
  30708. /**
  30709. * Create a multi render target texture
  30710. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  30711. * @param size defines the size of the texture
  30712. * @param options defines the creation options
  30713. * @returns the cube texture as an InternalTexture
  30714. */
  30715. Engine.prototype.createMultipleRenderTarget = function (size, options) {
  30716. var generateMipMaps = false;
  30717. var generateDepthBuffer = true;
  30718. var generateStencilBuffer = false;
  30719. var generateDepthTexture = false;
  30720. var textureCount = 1;
  30721. var defaultType = Engine.TEXTURETYPE_UNSIGNED_INT;
  30722. var defaultSamplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  30723. var types = new Array();
  30724. var samplingModes = new Array();
  30725. if (options !== undefined) {
  30726. generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;
  30727. generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  30728. generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  30729. generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;
  30730. textureCount = options.textureCount || 1;
  30731. if (options.types) {
  30732. types = options.types;
  30733. }
  30734. if (options.samplingModes) {
  30735. samplingModes = options.samplingModes;
  30736. }
  30737. }
  30738. var gl = this._gl;
  30739. // Create the framebuffer
  30740. var framebuffer = gl.createFramebuffer();
  30741. this.bindUnboundFramebuffer(framebuffer);
  30742. var width = size.width || size;
  30743. var height = size.height || size;
  30744. var textures = [];
  30745. var attachments = [];
  30746. var depthStencilBuffer = this._setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height);
  30747. for (var i = 0; i < textureCount; i++) {
  30748. var samplingMode = samplingModes[i] || defaultSamplingMode;
  30749. var type = types[i] || defaultType;
  30750. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  30751. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  30752. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  30753. }
  30754. else if (type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  30755. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  30756. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  30757. }
  30758. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  30759. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  30760. type = Engine.TEXTURETYPE_UNSIGNED_INT;
  30761. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  30762. }
  30763. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  30764. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  30765. textures.push(texture);
  30766. attachments.push(attachment);
  30767. gl.activeTexture(gl["TEXTURE" + i]);
  30768. gl.bindTexture(gl.TEXTURE_2D, texture._webGLTexture);
  30769. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  30770. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  30771. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  30772. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30773. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), width, height, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  30774. gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._webGLTexture, 0);
  30775. if (generateMipMaps) {
  30776. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  30777. }
  30778. // Unbind
  30779. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  30780. texture._framebuffer = framebuffer;
  30781. texture._depthStencilBuffer = depthStencilBuffer;
  30782. texture.baseWidth = width;
  30783. texture.baseHeight = height;
  30784. texture.width = width;
  30785. texture.height = height;
  30786. texture.isReady = true;
  30787. texture.samples = 1;
  30788. texture.generateMipMaps = generateMipMaps;
  30789. texture.samplingMode = samplingMode;
  30790. texture.type = type;
  30791. texture._generateDepthBuffer = generateDepthBuffer;
  30792. texture._generateStencilBuffer = generateStencilBuffer;
  30793. texture._attachments = attachments;
  30794. this._internalTexturesCache.push(texture);
  30795. }
  30796. if (generateDepthTexture && this._caps.depthTextureExtension) {
  30797. // Depth texture
  30798. var depthTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  30799. gl.activeTexture(gl.TEXTURE0);
  30800. gl.bindTexture(gl.TEXTURE_2D, depthTexture._webGLTexture);
  30801. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  30802. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  30803. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  30804. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30805. 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);
  30806. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTexture._webGLTexture, 0);
  30807. depthTexture._framebuffer = framebuffer;
  30808. depthTexture.baseWidth = width;
  30809. depthTexture.baseHeight = height;
  30810. depthTexture.width = width;
  30811. depthTexture.height = height;
  30812. depthTexture.isReady = true;
  30813. depthTexture.samples = 1;
  30814. depthTexture.generateMipMaps = generateMipMaps;
  30815. depthTexture.samplingMode = gl.NEAREST;
  30816. depthTexture._generateDepthBuffer = generateDepthBuffer;
  30817. depthTexture._generateStencilBuffer = generateStencilBuffer;
  30818. textures.push(depthTexture);
  30819. this._internalTexturesCache.push(depthTexture);
  30820. }
  30821. gl.drawBuffers(attachments);
  30822. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  30823. this.bindUnboundFramebuffer(null);
  30824. this.resetTextureCache();
  30825. return textures;
  30826. };
  30827. Engine.prototype._setupFramebufferDepthAttachments = function (generateStencilBuffer, generateDepthBuffer, width, height, samples) {
  30828. if (samples === void 0) { samples = 1; }
  30829. var depthStencilBuffer = null;
  30830. var gl = this._gl;
  30831. // Create the depth/stencil buffer
  30832. if (generateStencilBuffer) {
  30833. depthStencilBuffer = gl.createRenderbuffer();
  30834. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  30835. if (samples > 1) {
  30836. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH24_STENCIL8, width, height);
  30837. }
  30838. else {
  30839. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
  30840. }
  30841. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  30842. }
  30843. else if (generateDepthBuffer) {
  30844. depthStencilBuffer = gl.createRenderbuffer();
  30845. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  30846. if (samples > 1) {
  30847. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT16, width, height);
  30848. }
  30849. else {
  30850. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
  30851. }
  30852. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  30853. }
  30854. return depthStencilBuffer;
  30855. };
  30856. /**
  30857. * Updates the sample count of a render target texture
  30858. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  30859. * @param texture defines the texture to update
  30860. * @param samples defines the sample count to set
  30861. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  30862. */
  30863. Engine.prototype.updateRenderTargetTextureSampleCount = function (texture, samples) {
  30864. if (this.webGLVersion < 2 || !texture) {
  30865. return 1;
  30866. }
  30867. if (texture.samples === samples) {
  30868. return samples;
  30869. }
  30870. var gl = this._gl;
  30871. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  30872. // Dispose previous render buffers
  30873. if (texture._depthStencilBuffer) {
  30874. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  30875. texture._depthStencilBuffer = null;
  30876. }
  30877. if (texture._MSAAFramebuffer) {
  30878. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  30879. texture._MSAAFramebuffer = null;
  30880. }
  30881. if (texture._MSAARenderBuffer) {
  30882. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  30883. texture._MSAARenderBuffer = null;
  30884. }
  30885. if (samples > 1) {
  30886. var framebuffer = gl.createFramebuffer();
  30887. if (!framebuffer) {
  30888. throw new Error("Unable to create multi sampled framebuffer");
  30889. }
  30890. texture._MSAAFramebuffer = framebuffer;
  30891. this.bindUnboundFramebuffer(texture._MSAAFramebuffer);
  30892. var colorRenderbuffer = gl.createRenderbuffer();
  30893. if (!colorRenderbuffer) {
  30894. throw new Error("Unable to create multi sampled framebuffer");
  30895. }
  30896. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  30897. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  30898. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorRenderbuffer);
  30899. texture._MSAARenderBuffer = colorRenderbuffer;
  30900. }
  30901. else {
  30902. this.bindUnboundFramebuffer(texture._framebuffer);
  30903. }
  30904. texture.samples = samples;
  30905. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(texture._generateStencilBuffer, texture._generateDepthBuffer, texture.width, texture.height, samples);
  30906. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  30907. this.bindUnboundFramebuffer(null);
  30908. return samples;
  30909. };
  30910. /**
  30911. * Update the sample count for a given multiple render target texture
  30912. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  30913. * @param textures defines the textures to update
  30914. * @param samples defines the sample count to set
  30915. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  30916. */
  30917. Engine.prototype.updateMultipleRenderTargetTextureSampleCount = function (textures, samples) {
  30918. if (this.webGLVersion < 2 || !textures || textures.length == 0) {
  30919. return 1;
  30920. }
  30921. if (textures[0].samples === samples) {
  30922. return samples;
  30923. }
  30924. var gl = this._gl;
  30925. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  30926. // Dispose previous render buffers
  30927. if (textures[0]._depthStencilBuffer) {
  30928. gl.deleteRenderbuffer(textures[0]._depthStencilBuffer);
  30929. textures[0]._depthStencilBuffer = null;
  30930. }
  30931. if (textures[0]._MSAAFramebuffer) {
  30932. gl.deleteFramebuffer(textures[0]._MSAAFramebuffer);
  30933. textures[0]._MSAAFramebuffer = null;
  30934. }
  30935. for (var i = 0; i < textures.length; i++) {
  30936. if (textures[i]._MSAARenderBuffer) {
  30937. gl.deleteRenderbuffer(textures[i]._MSAARenderBuffer);
  30938. textures[i]._MSAARenderBuffer = null;
  30939. }
  30940. }
  30941. if (samples > 1) {
  30942. var framebuffer = gl.createFramebuffer();
  30943. if (!framebuffer) {
  30944. throw new Error("Unable to create multi sampled framebuffer");
  30945. }
  30946. this.bindUnboundFramebuffer(framebuffer);
  30947. var depthStencilBuffer = this._setupFramebufferDepthAttachments(textures[0]._generateStencilBuffer, textures[0]._generateDepthBuffer, textures[0].width, textures[0].height, samples);
  30948. var attachments = [];
  30949. for (var i = 0; i < textures.length; i++) {
  30950. var texture = textures[i];
  30951. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  30952. var colorRenderbuffer = gl.createRenderbuffer();
  30953. if (!colorRenderbuffer) {
  30954. throw new Error("Unable to create multi sampled framebuffer");
  30955. }
  30956. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  30957. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  30958. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, colorRenderbuffer);
  30959. texture._MSAAFramebuffer = framebuffer;
  30960. texture._MSAARenderBuffer = colorRenderbuffer;
  30961. texture.samples = samples;
  30962. texture._depthStencilBuffer = depthStencilBuffer;
  30963. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  30964. attachments.push(attachment);
  30965. }
  30966. gl.drawBuffers(attachments);
  30967. }
  30968. else {
  30969. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  30970. }
  30971. this.bindUnboundFramebuffer(null);
  30972. return samples;
  30973. };
  30974. /** @hidden */
  30975. Engine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  30976. if (faceIndex === void 0) { faceIndex = 0; }
  30977. if (lod === void 0) { lod = 0; }
  30978. var gl = this._gl;
  30979. var target = gl.TEXTURE_2D;
  30980. if (texture.isCube) {
  30981. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  30982. }
  30983. this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
  30984. };
  30985. /** @hidden */
  30986. Engine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  30987. if (faceIndex === void 0) { faceIndex = 0; }
  30988. if (lod === void 0) { lod = 0; }
  30989. var gl = this._gl;
  30990. var textureType = this._getWebGLTextureType(texture.type);
  30991. var format = this._getInternalFormat(texture.format);
  30992. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  30993. this._unpackFlipY(texture.invertY);
  30994. var target = gl.TEXTURE_2D;
  30995. if (texture.isCube) {
  30996. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  30997. }
  30998. var lodMaxWidth = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.width));
  30999. var lodMaxHeight = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.height));
  31000. var width = Math.pow(2, Math.max(lodMaxWidth - lod, 0));
  31001. var height = Math.pow(2, Math.max(lodMaxHeight - lod, 0));
  31002. gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);
  31003. };
  31004. /** @hidden */
  31005. Engine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  31006. if (faceIndex === void 0) { faceIndex = 0; }
  31007. if (lod === void 0) { lod = 0; }
  31008. var gl = this._gl;
  31009. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31010. this._bindTextureDirectly(bindTarget, texture, true);
  31011. this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);
  31012. this._bindTextureDirectly(bindTarget, null, true);
  31013. };
  31014. /** @hidden */
  31015. Engine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  31016. if (faceIndex === void 0) { faceIndex = 0; }
  31017. if (lod === void 0) { lod = 0; }
  31018. var gl = this._gl;
  31019. var textureType = this._getWebGLTextureType(texture.type);
  31020. var format = this._getInternalFormat(texture.format);
  31021. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  31022. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31023. this._bindTextureDirectly(bindTarget, texture, true);
  31024. this._unpackFlipY(texture.invertY);
  31025. var target = gl.TEXTURE_2D;
  31026. if (texture.isCube) {
  31027. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  31028. }
  31029. gl.texImage2D(target, lod, internalFormat, format, textureType, image);
  31030. this._bindTextureDirectly(bindTarget, null, true);
  31031. };
  31032. /**
  31033. * Creates a new render target cube texture
  31034. * @param size defines the size of the texture
  31035. * @param options defines the options used to create the texture
  31036. * @returns a new render target cube texture stored in an InternalTexture
  31037. */
  31038. Engine.prototype.createRenderTargetCubeTexture = function (size, options) {
  31039. 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);
  31040. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && fullOptions.generateStencilBuffer;
  31041. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  31042. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  31043. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31044. }
  31045. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  31046. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  31047. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31048. }
  31049. var gl = this._gl;
  31050. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  31051. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31052. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps);
  31053. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  31054. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31055. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type");
  31056. }
  31057. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  31058. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  31059. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31060. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31061. for (var face = 0; face < 6; face++) {
  31062. 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);
  31063. }
  31064. // Create the framebuffer
  31065. var framebuffer = gl.createFramebuffer();
  31066. this.bindUnboundFramebuffer(framebuffer);
  31067. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer, fullOptions.generateDepthBuffer, size, size);
  31068. // MipMaps
  31069. if (fullOptions.generateMipMaps) {
  31070. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  31071. }
  31072. // Unbind
  31073. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31074. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31075. this.bindUnboundFramebuffer(null);
  31076. texture._framebuffer = framebuffer;
  31077. texture.width = size;
  31078. texture.height = size;
  31079. texture.isReady = true;
  31080. texture.isCube = true;
  31081. texture.samples = 1;
  31082. texture.generateMipMaps = fullOptions.generateMipMaps;
  31083. texture.samplingMode = fullOptions.samplingMode;
  31084. texture.type = fullOptions.type;
  31085. texture.format = fullOptions.format;
  31086. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  31087. texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
  31088. this._internalTexturesCache.push(texture);
  31089. return texture;
  31090. };
  31091. /**
  31092. * Creates a cube texture
  31093. * @param rootUrl defines the url where the files to load is located
  31094. * @param scene defines the current scene
  31095. * @param files defines the list of files to load (1 per face)
  31096. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  31097. * @param onLoad defines an optional callback raised when the texture is loaded
  31098. * @param onError defines an optional callback raised if there is an issue to load the texture
  31099. * @param format defines the format of the data
  31100. * @param forcedExtension defines the extension to use to pick the right loader
  31101. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  31102. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  31103. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  31104. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  31105. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  31106. * @returns the cube texture as an InternalTexture
  31107. */
  31108. Engine.prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, excludeLoaders) {
  31109. var _this = this;
  31110. if (onLoad === void 0) { onLoad = null; }
  31111. if (onError === void 0) { onError = null; }
  31112. if (forcedExtension === void 0) { forcedExtension = null; }
  31113. if (createPolynomials === void 0) { createPolynomials = false; }
  31114. if (lodScale === void 0) { lodScale = 0; }
  31115. if (lodOffset === void 0) { lodOffset = 0; }
  31116. if (fallback === void 0) { fallback = null; }
  31117. if (excludeLoaders === void 0) { excludeLoaders = []; }
  31118. var gl = this._gl;
  31119. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBE);
  31120. texture.isCube = true;
  31121. texture.url = rootUrl;
  31122. texture.generateMipMaps = !noMipmap;
  31123. texture._lodGenerationScale = lodScale;
  31124. texture._lodGenerationOffset = lodOffset;
  31125. if (!this._doNotHandleContextLost) {
  31126. texture._extension = forcedExtension;
  31127. texture._files = files;
  31128. }
  31129. var lastDot = rootUrl.lastIndexOf('.');
  31130. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  31131. var loader = null;
  31132. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  31133. var availableLoader = _a[_i];
  31134. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, false, false)) {
  31135. loader = availableLoader;
  31136. break;
  31137. }
  31138. }
  31139. var onInternalError = function (request, exception) {
  31140. if (loader) {
  31141. var fallbackUrl = loader.getFallbackTextureUrl(texture.url, _this._textureFormatInUse);
  31142. _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");
  31143. if (fallbackUrl) {
  31144. excludeLoaders.push(loader);
  31145. _this.createCubeTexture(fallbackUrl, scene, files, noMipmap, onLoad, onError, format, extension, createPolynomials, lodScale, lodOffset, texture, excludeLoaders);
  31146. return;
  31147. }
  31148. }
  31149. if (onError && request) {
  31150. onError(request.status + " " + request.statusText, exception);
  31151. }
  31152. };
  31153. if (loader) {
  31154. rootUrl = loader.transformUrl(rootUrl, this._textureFormatInUse);
  31155. var onloaddata = function (data) {
  31156. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31157. loader.loadCubeData(data, texture, createPolynomials, onLoad, onError);
  31158. };
  31159. if (files && files.length === 6) {
  31160. if (loader.supportCascades) {
  31161. this._cascadeLoadFiles(scene, onloaddata, files, onError);
  31162. }
  31163. else if (onError) {
  31164. onError("Textures type does not support cascades.");
  31165. }
  31166. }
  31167. else {
  31168. this._loadFile(rootUrl, onloaddata, undefined, undefined, true, onInternalError);
  31169. }
  31170. }
  31171. else {
  31172. if (!files) {
  31173. throw new Error("Cannot load cubemap because files were not defined");
  31174. }
  31175. this._cascadeLoadImgs(scene, function (imgs) {
  31176. var width = _this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(imgs[0].width, _this._caps.maxCubemapTextureSize) : imgs[0].width;
  31177. var height = width;
  31178. _this._prepareWorkingCanvas();
  31179. if (!_this._workingCanvas || !_this._workingContext) {
  31180. return;
  31181. }
  31182. _this._workingCanvas.width = width;
  31183. _this._workingCanvas.height = height;
  31184. var faces = [
  31185. gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
  31186. gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
  31187. ];
  31188. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31189. _this._unpackFlipY(false);
  31190. var internalFormat = format ? _this._getInternalFormat(format) : _this._gl.RGBA;
  31191. for (var index = 0; index < faces.length; index++) {
  31192. _this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height);
  31193. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  31194. }
  31195. if (!noMipmap) {
  31196. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  31197. }
  31198. _this._setCubeMapTextureParams(!noMipmap);
  31199. texture.width = width;
  31200. texture.height = height;
  31201. texture.isReady = true;
  31202. if (format) {
  31203. texture.format = format;
  31204. }
  31205. texture.onLoadedObservable.notifyObservers(texture);
  31206. texture.onLoadedObservable.clear();
  31207. if (onLoad) {
  31208. onLoad();
  31209. }
  31210. }, files, onError);
  31211. }
  31212. this._internalTexturesCache.push(texture);
  31213. return texture;
  31214. };
  31215. /**
  31216. * @hidden
  31217. */
  31218. Engine.prototype._setCubeMapTextureParams = function (loadMipmap) {
  31219. var gl = this._gl;
  31220. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  31221. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, loadMipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
  31222. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31223. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31224. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31225. // this.resetTextureCache();
  31226. };
  31227. /**
  31228. * Update a raw cube texture
  31229. * @param texture defines the texture to udpdate
  31230. * @param data defines the data to store
  31231. * @param format defines the data format
  31232. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31233. * @param invertY defines if data must be stored with Y axis inverted
  31234. * @param compression defines the compression used (null by default)
  31235. * @param level defines which level of the texture to update
  31236. */
  31237. Engine.prototype.updateRawCubeTexture = function (texture, data, format, type, invertY, compression, level) {
  31238. if (compression === void 0) { compression = null; }
  31239. if (level === void 0) { level = 0; }
  31240. texture._bufferViewArray = data;
  31241. texture.format = format;
  31242. texture.type = type;
  31243. texture.invertY = invertY;
  31244. texture._compression = compression;
  31245. var gl = this._gl;
  31246. var textureType = this._getWebGLTextureType(type);
  31247. var internalFormat = this._getInternalFormat(format);
  31248. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);
  31249. var needConversion = false;
  31250. if (internalFormat === gl.RGB) {
  31251. internalFormat = gl.RGBA;
  31252. needConversion = true;
  31253. }
  31254. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31255. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31256. if (texture.width % 4 !== 0) {
  31257. gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
  31258. }
  31259. // Data are known to be in +X +Y +Z -X -Y -Z
  31260. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  31261. var faceData = data[faceIndex];
  31262. if (compression) {
  31263. gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, (this.getCaps().s3tc)[compression], texture.width, texture.height, 0, faceData);
  31264. }
  31265. else {
  31266. if (needConversion) {
  31267. faceData = this._convertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);
  31268. }
  31269. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, faceData);
  31270. }
  31271. }
  31272. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  31273. if (isPot && texture.generateMipMaps && level === 0) {
  31274. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  31275. }
  31276. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31277. // this.resetTextureCache();
  31278. texture.isReady = true;
  31279. };
  31280. /**
  31281. * Creates a new raw cube texture
  31282. * @param data defines the array of data to use to create each face
  31283. * @param size defines the size of the textures
  31284. * @param format defines the format of the data
  31285. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31286. * @param generateMipMaps defines if the engine should generate the mip levels
  31287. * @param invertY defines if data must be stored with Y axis inverted
  31288. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31289. * @param compression defines the compression used (null by default)
  31290. * @returns the cube texture as an InternalTexture
  31291. */
  31292. Engine.prototype.createRawCubeTexture = function (data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  31293. if (compression === void 0) { compression = null; }
  31294. var gl = this._gl;
  31295. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBERAW);
  31296. texture.isCube = true;
  31297. texture.format = format;
  31298. texture.type = type;
  31299. if (!this._doNotHandleContextLost) {
  31300. texture._bufferViewArray = data;
  31301. }
  31302. var textureType = this._getWebGLTextureType(type);
  31303. var internalFormat = this._getInternalFormat(format);
  31304. if (internalFormat === gl.RGB) {
  31305. internalFormat = gl.RGBA;
  31306. }
  31307. // Mipmap generation needs a sized internal format that is both color-renderable and texture-filterable
  31308. if (textureType === gl.FLOAT && !this._caps.textureFloatLinearFiltering) {
  31309. generateMipMaps = false;
  31310. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31311. _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.");
  31312. }
  31313. else if (textureType === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering) {
  31314. generateMipMaps = false;
  31315. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31316. _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.");
  31317. }
  31318. else if (textureType === gl.FLOAT && !this._caps.textureFloatRender) {
  31319. generateMipMaps = false;
  31320. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to float textures is not supported. Mipmap generation forced to false.");
  31321. }
  31322. else if (textureType === gl.HALF_FLOAT && !this._caps.colorBufferFloat) {
  31323. generateMipMaps = false;
  31324. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to half float textures is not supported. Mipmap generation forced to false.");
  31325. }
  31326. var width = size;
  31327. var height = width;
  31328. texture.width = width;
  31329. texture.height = height;
  31330. // Double check on POT to generate Mips.
  31331. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  31332. if (!isPot) {
  31333. generateMipMaps = false;
  31334. }
  31335. // Upload data if needed. The texture won't be ready until then.
  31336. if (data) {
  31337. this.updateRawCubeTexture(texture, data, format, type, invertY, compression);
  31338. }
  31339. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  31340. // Filters
  31341. if (data && generateMipMaps) {
  31342. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  31343. }
  31344. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31345. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  31346. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  31347. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31348. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31349. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31350. texture.generateMipMaps = generateMipMaps;
  31351. return texture;
  31352. };
  31353. /**
  31354. * Creates a new raw cube texture from a specified url
  31355. * @param url defines the url where the data is located
  31356. * @param scene defines the current scene
  31357. * @param size defines the size of the textures
  31358. * @param format defines the format of the data
  31359. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31360. * @param noMipmap defines if the engine should avoid generating the mip levels
  31361. * @param callback defines a callback used to extract texture data from loaded data
  31362. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  31363. * @param onLoad defines a callback called when texture is loaded
  31364. * @param onError defines a callback called if there is an error
  31365. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31366. * @param invertY defines if data must be stored with Y axis inverted
  31367. * @returns the cube texture as an InternalTexture
  31368. */
  31369. Engine.prototype.createRawCubeTextureFromUrl = function (url, scene, size, format, type, noMipmap, callback, mipmapGenerator, onLoad, onError, samplingMode, invertY) {
  31370. var _this = this;
  31371. if (onLoad === void 0) { onLoad = null; }
  31372. if (onError === void 0) { onError = null; }
  31373. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  31374. if (invertY === void 0) { invertY = false; }
  31375. var gl = this._gl;
  31376. var texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode);
  31377. scene._addPendingData(texture);
  31378. texture.url = url;
  31379. this._internalTexturesCache.push(texture);
  31380. var onerror = function (request, exception) {
  31381. scene._removePendingData(texture);
  31382. if (onError && request) {
  31383. onError(request.status + " " + request.statusText, exception);
  31384. }
  31385. };
  31386. var internalCallback = function (data) {
  31387. var width = texture.width;
  31388. var faceDataArrays = callback(data);
  31389. if (!faceDataArrays) {
  31390. return;
  31391. }
  31392. if (mipmapGenerator) {
  31393. var textureType = _this._getWebGLTextureType(type);
  31394. var internalFormat = _this._getInternalFormat(format);
  31395. var internalSizedFomat = _this._getRGBABufferInternalSizedFormat(type);
  31396. var needConversion = false;
  31397. if (internalFormat === gl.RGB) {
  31398. internalFormat = gl.RGBA;
  31399. needConversion = true;
  31400. }
  31401. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31402. _this._unpackFlipY(false);
  31403. var mipData = mipmapGenerator(faceDataArrays);
  31404. for (var level = 0; level < mipData.length; level++) {
  31405. var mipSize = width >> level;
  31406. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  31407. var mipFaceData = mipData[level][faceIndex];
  31408. if (needConversion) {
  31409. mipFaceData = _this._convertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);
  31410. }
  31411. gl.texImage2D(faceIndex, level, internalSizedFomat, mipSize, mipSize, 0, internalFormat, textureType, mipFaceData);
  31412. }
  31413. }
  31414. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31415. }
  31416. else {
  31417. _this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);
  31418. }
  31419. texture.isReady = true;
  31420. // this.resetTextureCache();
  31421. scene._removePendingData(texture);
  31422. if (onLoad) {
  31423. onLoad();
  31424. }
  31425. };
  31426. this._loadFile(url, function (data) {
  31427. internalCallback(data);
  31428. }, undefined, scene.offlineProvider, true, onerror);
  31429. return texture;
  31430. };
  31431. /**
  31432. * Update a raw 3D texture
  31433. * @param texture defines the texture to update
  31434. * @param data defines the data to store
  31435. * @param format defines the data format
  31436. * @param invertY defines if data must be stored with Y axis inverted
  31437. * @param compression defines the used compression (can be null)
  31438. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  31439. */
  31440. Engine.prototype.updateRawTexture3D = function (texture, data, format, invertY, compression, textureType) {
  31441. if (compression === void 0) { compression = null; }
  31442. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31443. var internalType = this._getWebGLTextureType(textureType);
  31444. var internalFormat = this._getInternalFormat(format);
  31445. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(textureType, format);
  31446. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  31447. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31448. if (!this._doNotHandleContextLost) {
  31449. texture._bufferView = data;
  31450. texture.format = format;
  31451. texture.invertY = invertY;
  31452. texture._compression = compression;
  31453. }
  31454. if (texture.width % 4 !== 0) {
  31455. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  31456. }
  31457. if (compression && data) {
  31458. this._gl.compressedTexImage3D(this._gl.TEXTURE_3D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, texture.depth, 0, data);
  31459. }
  31460. else {
  31461. this._gl.texImage3D(this._gl.TEXTURE_3D, 0, internalSizedFomat, texture.width, texture.height, texture.depth, 0, internalFormat, internalType, data);
  31462. }
  31463. if (texture.generateMipMaps) {
  31464. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  31465. }
  31466. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  31467. // this.resetTextureCache();
  31468. texture.isReady = true;
  31469. };
  31470. /**
  31471. * Creates a new raw 3D texture
  31472. * @param data defines the data used to create the texture
  31473. * @param width defines the width of the texture
  31474. * @param height defines the height of the texture
  31475. * @param depth defines the depth of the texture
  31476. * @param format defines the format of the texture
  31477. * @param generateMipMaps defines if the engine must generate mip levels
  31478. * @param invertY defines if data must be stored with Y axis inverted
  31479. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31480. * @param compression defines the compressed used (can be null)
  31481. * @param textureType defines the compressed used (can be null)
  31482. * @returns a new raw 3D texture (stored in an InternalTexture)
  31483. */
  31484. Engine.prototype.createRawTexture3D = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {
  31485. if (compression === void 0) { compression = null; }
  31486. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31487. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW3D);
  31488. texture.baseWidth = width;
  31489. texture.baseHeight = height;
  31490. texture.baseDepth = depth;
  31491. texture.width = width;
  31492. texture.height = height;
  31493. texture.depth = depth;
  31494. texture.format = format;
  31495. texture.type = textureType;
  31496. texture.generateMipMaps = generateMipMaps;
  31497. texture.samplingMode = samplingMode;
  31498. texture.is3D = true;
  31499. if (!this._doNotHandleContextLost) {
  31500. texture._bufferView = data;
  31501. }
  31502. this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);
  31503. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  31504. // Filters
  31505. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31506. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  31507. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31508. if (generateMipMaps) {
  31509. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  31510. }
  31511. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  31512. this._internalTexturesCache.push(texture);
  31513. return texture;
  31514. };
  31515. Engine.prototype._prepareWebGLTextureContinuation = function (texture, scene, noMipmap, isCompressed, samplingMode) {
  31516. var gl = this._gl;
  31517. if (!gl) {
  31518. return;
  31519. }
  31520. var filters = this._getSamplingParameters(samplingMode, !noMipmap);
  31521. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  31522. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  31523. if (!noMipmap && !isCompressed) {
  31524. gl.generateMipmap(gl.TEXTURE_2D);
  31525. }
  31526. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31527. // this.resetTextureCache();
  31528. if (scene) {
  31529. scene._removePendingData(texture);
  31530. }
  31531. texture.onLoadedObservable.notifyObservers(texture);
  31532. texture.onLoadedObservable.clear();
  31533. };
  31534. Engine.prototype._prepareWebGLTexture = function (texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {
  31535. var _this = this;
  31536. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  31537. var maxTextureSize = this.getCaps().maxTextureSize;
  31538. var potWidth = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, maxTextureSize) : width);
  31539. var potHeight = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, maxTextureSize) : height);
  31540. var gl = this._gl;
  31541. if (!gl) {
  31542. return;
  31543. }
  31544. if (!texture._webGLTexture) {
  31545. // this.resetTextureCache();
  31546. if (scene) {
  31547. scene._removePendingData(texture);
  31548. }
  31549. return;
  31550. }
  31551. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  31552. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31553. texture.baseWidth = width;
  31554. texture.baseHeight = height;
  31555. texture.width = potWidth;
  31556. texture.height = potHeight;
  31557. texture.isReady = true;
  31558. if (processFunction(potWidth, potHeight, function () {
  31559. _this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  31560. })) {
  31561. // Returning as texture needs extra async steps
  31562. return;
  31563. }
  31564. this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  31565. };
  31566. Engine.prototype._convertRGBtoRGBATextureData = function (rgbData, width, height, textureType) {
  31567. // Create new RGBA data container.
  31568. var rgbaData;
  31569. if (textureType === Engine.TEXTURETYPE_FLOAT) {
  31570. rgbaData = new Float32Array(width * height * 4);
  31571. }
  31572. else {
  31573. rgbaData = new Uint32Array(width * height * 4);
  31574. }
  31575. // Convert each pixel.
  31576. for (var x = 0; x < width; x++) {
  31577. for (var y = 0; y < height; y++) {
  31578. var index = (y * width + x) * 3;
  31579. var newIndex = (y * width + x) * 4;
  31580. // Map Old Value to new value.
  31581. rgbaData[newIndex + 0] = rgbData[index + 0];
  31582. rgbaData[newIndex + 1] = rgbData[index + 1];
  31583. rgbaData[newIndex + 2] = rgbData[index + 2];
  31584. // Add fully opaque alpha channel.
  31585. rgbaData[newIndex + 3] = 1;
  31586. }
  31587. }
  31588. return rgbaData;
  31589. };
  31590. /** @hidden */
  31591. Engine.prototype._releaseFramebufferObjects = function (texture) {
  31592. var gl = this._gl;
  31593. if (texture._framebuffer) {
  31594. gl.deleteFramebuffer(texture._framebuffer);
  31595. texture._framebuffer = null;
  31596. }
  31597. if (texture._depthStencilBuffer) {
  31598. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  31599. texture._depthStencilBuffer = null;
  31600. }
  31601. if (texture._MSAAFramebuffer) {
  31602. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  31603. texture._MSAAFramebuffer = null;
  31604. }
  31605. if (texture._MSAARenderBuffer) {
  31606. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  31607. texture._MSAARenderBuffer = null;
  31608. }
  31609. };
  31610. /** @hidden */
  31611. Engine.prototype._releaseTexture = function (texture) {
  31612. var gl = this._gl;
  31613. this._releaseFramebufferObjects(texture);
  31614. gl.deleteTexture(texture._webGLTexture);
  31615. // Unbind channels
  31616. this.unbindAllTextures();
  31617. var index = this._internalTexturesCache.indexOf(texture);
  31618. if (index !== -1) {
  31619. this._internalTexturesCache.splice(index, 1);
  31620. }
  31621. // Integrated fixed lod samplers.
  31622. if (texture._lodTextureHigh) {
  31623. texture._lodTextureHigh.dispose();
  31624. }
  31625. if (texture._lodTextureMid) {
  31626. texture._lodTextureMid.dispose();
  31627. }
  31628. if (texture._lodTextureLow) {
  31629. texture._lodTextureLow.dispose();
  31630. }
  31631. // Set output texture of post process to null if the texture has been released/disposed
  31632. this.scenes.forEach(function (scene) {
  31633. scene.postProcesses.forEach(function (postProcess) {
  31634. if (postProcess._outputTexture == texture) {
  31635. postProcess._outputTexture = null;
  31636. }
  31637. });
  31638. scene.cameras.forEach(function (camera) {
  31639. camera._postProcesses.forEach(function (postProcess) {
  31640. if (postProcess) {
  31641. if (postProcess._outputTexture == texture) {
  31642. postProcess._outputTexture = null;
  31643. }
  31644. }
  31645. });
  31646. });
  31647. });
  31648. };
  31649. Engine.prototype.setProgram = function (program) {
  31650. if (this._currentProgram !== program) {
  31651. this._gl.useProgram(program);
  31652. this._currentProgram = program;
  31653. }
  31654. };
  31655. /**
  31656. * Binds an effect to the webGL context
  31657. * @param effect defines the effect to bind
  31658. */
  31659. Engine.prototype.bindSamplers = function (effect) {
  31660. this.setProgram(effect.getProgram());
  31661. var samplers = effect.getSamplers();
  31662. for (var index = 0; index < samplers.length; index++) {
  31663. var uniform = effect.getUniform(samplers[index]);
  31664. if (uniform) {
  31665. this._boundUniforms[index] = uniform;
  31666. }
  31667. }
  31668. this._currentEffect = null;
  31669. };
  31670. Engine.prototype._moveBoundTextureOnTop = function (internalTexture) {
  31671. if (this.disableTextureBindingOptimization || this._lastBoundInternalTextureTracker.previous === internalTexture) {
  31672. return;
  31673. }
  31674. // Remove
  31675. this._linkTrackers(internalTexture.previous, internalTexture.next);
  31676. // Bind last to it
  31677. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, internalTexture);
  31678. // Bind to dummy
  31679. this._linkTrackers(internalTexture, this._lastBoundInternalTextureTracker);
  31680. };
  31681. Engine.prototype._getCorrectTextureChannel = function (channel, internalTexture) {
  31682. if (!internalTexture) {
  31683. return -1;
  31684. }
  31685. internalTexture._initialSlot = channel;
  31686. if (this.disableTextureBindingOptimization) { // We want texture sampler ID === texture channel
  31687. if (channel !== internalTexture._designatedSlot) {
  31688. this._textureCollisions.addCount(1, false);
  31689. }
  31690. }
  31691. else {
  31692. if (channel !== internalTexture._designatedSlot) {
  31693. if (internalTexture._designatedSlot > -1) { // Texture is already assigned to a slot
  31694. return internalTexture._designatedSlot;
  31695. }
  31696. else {
  31697. // No slot for this texture, let's pick a new one (if we find a free slot)
  31698. if (this._nextFreeTextureSlots.length) {
  31699. return this._nextFreeTextureSlots[0];
  31700. }
  31701. // We need to recycle the oldest bound texture, sorry.
  31702. this._textureCollisions.addCount(1, false);
  31703. return this._removeDesignatedSlot(this._firstBoundInternalTextureTracker.next);
  31704. }
  31705. }
  31706. }
  31707. return channel;
  31708. };
  31709. Engine.prototype._linkTrackers = function (previous, next) {
  31710. previous.next = next;
  31711. next.previous = previous;
  31712. };
  31713. Engine.prototype._removeDesignatedSlot = function (internalTexture) {
  31714. var currentSlot = internalTexture._designatedSlot;
  31715. if (currentSlot === -1) {
  31716. return -1;
  31717. }
  31718. internalTexture._designatedSlot = -1;
  31719. if (this.disableTextureBindingOptimization) {
  31720. return -1;
  31721. }
  31722. // Remove from bound list
  31723. this._linkTrackers(internalTexture.previous, internalTexture.next);
  31724. // Free the slot
  31725. this._boundTexturesCache[currentSlot] = null;
  31726. this._nextFreeTextureSlots.push(currentSlot);
  31727. return currentSlot;
  31728. };
  31729. Engine.prototype._activateCurrentTexture = function () {
  31730. if (this._currentTextureChannel !== this._activeChannel) {
  31731. this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);
  31732. this._currentTextureChannel = this._activeChannel;
  31733. }
  31734. };
  31735. /** @hidden */
  31736. Engine.prototype._bindTextureDirectly = function (target, texture, forTextureDataUpdate, force) {
  31737. if (forTextureDataUpdate === void 0) { forTextureDataUpdate = false; }
  31738. if (force === void 0) { force = false; }
  31739. var wasPreviouslyBound = false;
  31740. if (forTextureDataUpdate && texture && texture._designatedSlot > -1) {
  31741. this._activeChannel = texture._designatedSlot;
  31742. }
  31743. var currentTextureBound = this._boundTexturesCache[this._activeChannel];
  31744. var isTextureForRendering = texture && texture._initialSlot > -1;
  31745. if (currentTextureBound !== texture || force) {
  31746. if (currentTextureBound) {
  31747. this._removeDesignatedSlot(currentTextureBound);
  31748. }
  31749. this._activateCurrentTexture();
  31750. this._gl.bindTexture(target, texture ? texture._webGLTexture : null);
  31751. this._boundTexturesCache[this._activeChannel] = texture;
  31752. if (texture) {
  31753. if (!this.disableTextureBindingOptimization) {
  31754. var slotIndex = this._nextFreeTextureSlots.indexOf(this._activeChannel);
  31755. if (slotIndex > -1) {
  31756. this._nextFreeTextureSlots.splice(slotIndex, 1);
  31757. }
  31758. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, texture);
  31759. this._linkTrackers(texture, this._lastBoundInternalTextureTracker);
  31760. }
  31761. texture._designatedSlot = this._activeChannel;
  31762. }
  31763. }
  31764. else if (forTextureDataUpdate) {
  31765. wasPreviouslyBound = true;
  31766. this._activateCurrentTexture();
  31767. }
  31768. if (isTextureForRendering && !forTextureDataUpdate) {
  31769. this._bindSamplerUniformToChannel(texture._initialSlot, this._activeChannel);
  31770. }
  31771. return wasPreviouslyBound;
  31772. };
  31773. /** @hidden */
  31774. Engine.prototype._bindTexture = function (channel, texture) {
  31775. if (channel < 0) {
  31776. return;
  31777. }
  31778. if (texture) {
  31779. channel = this._getCorrectTextureChannel(channel, texture);
  31780. }
  31781. this._activeChannel = channel;
  31782. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
  31783. };
  31784. /**
  31785. * Sets a texture to the webGL context from a postprocess
  31786. * @param channel defines the channel to use
  31787. * @param postProcess defines the source postprocess
  31788. */
  31789. Engine.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  31790. this._bindTexture(channel, postProcess ? postProcess._textures.data[postProcess._currentRenderTextureInd] : null);
  31791. };
  31792. /**
  31793. * Binds the output of the passed in post process to the texture channel specified
  31794. * @param channel The channel the texture should be bound to
  31795. * @param postProcess The post process which's output should be bound
  31796. */
  31797. Engine.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  31798. this._bindTexture(channel, postProcess ? postProcess._outputTexture : null);
  31799. };
  31800. /**
  31801. * Unbind all textures from the webGL context
  31802. */
  31803. Engine.prototype.unbindAllTextures = function () {
  31804. for (var channel = 0; channel < this._maxSimultaneousTextures; channel++) {
  31805. this._activeChannel = channel;
  31806. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31807. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31808. if (this.webGLVersion > 1) {
  31809. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  31810. }
  31811. }
  31812. };
  31813. /**
  31814. * Sets a texture to the according uniform.
  31815. * @param channel The texture channel
  31816. * @param uniform The uniform to set
  31817. * @param texture The texture to apply
  31818. */
  31819. Engine.prototype.setTexture = function (channel, uniform, texture) {
  31820. if (channel < 0) {
  31821. return;
  31822. }
  31823. if (uniform) {
  31824. this._boundUniforms[channel] = uniform;
  31825. }
  31826. this._setTexture(channel, texture);
  31827. };
  31828. /**
  31829. * Sets a depth stencil texture from a render target to the according uniform.
  31830. * @param channel The texture channel
  31831. * @param uniform The uniform to set
  31832. * @param texture The render target texture containing the depth stencil texture to apply
  31833. */
  31834. Engine.prototype.setDepthStencilTexture = function (channel, uniform, texture) {
  31835. if (channel < 0) {
  31836. return;
  31837. }
  31838. if (uniform) {
  31839. this._boundUniforms[channel] = uniform;
  31840. }
  31841. if (!texture || !texture.depthStencilTexture) {
  31842. this._setTexture(channel, null);
  31843. }
  31844. else {
  31845. this._setTexture(channel, texture, false, true);
  31846. }
  31847. };
  31848. Engine.prototype._bindSamplerUniformToChannel = function (sourceSlot, destination) {
  31849. var uniform = this._boundUniforms[sourceSlot];
  31850. if (uniform._currentState === destination) {
  31851. return;
  31852. }
  31853. this._gl.uniform1i(uniform, destination);
  31854. uniform._currentState = destination;
  31855. };
  31856. Engine.prototype._getTextureWrapMode = function (mode) {
  31857. switch (mode) {
  31858. case Engine.TEXTURE_WRAP_ADDRESSMODE:
  31859. return this._gl.REPEAT;
  31860. case Engine.TEXTURE_CLAMP_ADDRESSMODE:
  31861. return this._gl.CLAMP_TO_EDGE;
  31862. case Engine.TEXTURE_MIRROR_ADDRESSMODE:
  31863. return this._gl.MIRRORED_REPEAT;
  31864. }
  31865. return this._gl.REPEAT;
  31866. };
  31867. Engine.prototype._setTexture = function (channel, texture, isPartOfTextureArray, depthStencilTexture) {
  31868. if (isPartOfTextureArray === void 0) { isPartOfTextureArray = false; }
  31869. if (depthStencilTexture === void 0) { depthStencilTexture = false; }
  31870. // Not ready?
  31871. if (!texture) {
  31872. if (this._boundTexturesCache[channel] != null) {
  31873. this._activeChannel = channel;
  31874. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31875. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31876. if (this.webGLVersion > 1) {
  31877. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  31878. }
  31879. }
  31880. return false;
  31881. }
  31882. // Video
  31883. if (texture.video) {
  31884. this._activeChannel = channel;
  31885. texture.update();
  31886. }
  31887. else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
  31888. texture.delayLoad();
  31889. return false;
  31890. }
  31891. var internalTexture;
  31892. if (depthStencilTexture) {
  31893. internalTexture = texture.depthStencilTexture;
  31894. }
  31895. else if (texture.isReady()) {
  31896. internalTexture = texture.getInternalTexture();
  31897. }
  31898. else if (texture.isCube) {
  31899. internalTexture = this.emptyCubeTexture;
  31900. }
  31901. else if (texture.is3D) {
  31902. internalTexture = this.emptyTexture3D;
  31903. }
  31904. else {
  31905. internalTexture = this.emptyTexture;
  31906. }
  31907. if (!isPartOfTextureArray) {
  31908. channel = this._getCorrectTextureChannel(channel, internalTexture);
  31909. }
  31910. var needToBind = true;
  31911. if (this._boundTexturesCache[channel] === internalTexture) {
  31912. this._moveBoundTextureOnTop(internalTexture);
  31913. if (!isPartOfTextureArray) {
  31914. this._bindSamplerUniformToChannel(internalTexture._initialSlot, channel);
  31915. }
  31916. needToBind = false;
  31917. }
  31918. this._activeChannel = channel;
  31919. if (internalTexture && internalTexture.is3D) {
  31920. if (needToBind) {
  31921. this._bindTextureDirectly(this._gl.TEXTURE_3D, internalTexture, isPartOfTextureArray);
  31922. }
  31923. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  31924. internalTexture._cachedWrapU = texture.wrapU;
  31925. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  31926. }
  31927. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  31928. internalTexture._cachedWrapV = texture.wrapV;
  31929. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  31930. }
  31931. if (internalTexture && internalTexture._cachedWrapR !== texture.wrapR) {
  31932. internalTexture._cachedWrapR = texture.wrapR;
  31933. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);
  31934. }
  31935. this._setAnisotropicLevel(this._gl.TEXTURE_3D, texture);
  31936. }
  31937. else if (internalTexture && internalTexture.isCube) {
  31938. if (needToBind) {
  31939. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, internalTexture, isPartOfTextureArray);
  31940. }
  31941. if (internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {
  31942. internalTexture._cachedCoordinatesMode = texture.coordinatesMode;
  31943. // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.
  31944. var textureWrapMode = (texture.coordinatesMode !== Engine.TEXTURE_CUBIC_MODE && texture.coordinatesMode !== Engine.TEXTURE_SKYBOX_MODE) ? this._gl.REPEAT : this._gl.CLAMP_TO_EDGE;
  31945. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_S, textureWrapMode, internalTexture);
  31946. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_T, textureWrapMode);
  31947. }
  31948. this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP, texture);
  31949. }
  31950. else {
  31951. if (needToBind) {
  31952. this._bindTextureDirectly(this._gl.TEXTURE_2D, internalTexture, isPartOfTextureArray);
  31953. }
  31954. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  31955. internalTexture._cachedWrapU = texture.wrapU;
  31956. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  31957. }
  31958. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  31959. internalTexture._cachedWrapV = texture.wrapV;
  31960. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  31961. }
  31962. this._setAnisotropicLevel(this._gl.TEXTURE_2D, texture);
  31963. }
  31964. return true;
  31965. };
  31966. /**
  31967. * Sets an array of texture to the webGL context
  31968. * @param channel defines the channel where the texture array must be set
  31969. * @param uniform defines the associated uniform location
  31970. * @param textures defines the array of textures to bind
  31971. */
  31972. Engine.prototype.setTextureArray = function (channel, uniform, textures) {
  31973. if (channel < 0 || !uniform) {
  31974. return;
  31975. }
  31976. if (!this._textureUnits || this._textureUnits.length !== textures.length) {
  31977. this._textureUnits = new Int32Array(textures.length);
  31978. }
  31979. for (var i = 0; i < textures.length; i++) {
  31980. this._textureUnits[i] = this._getCorrectTextureChannel(channel + i, textures[i].getInternalTexture());
  31981. }
  31982. this._gl.uniform1iv(uniform, this._textureUnits);
  31983. for (var index = 0; index < textures.length; index++) {
  31984. this._setTexture(this._textureUnits[index], textures[index], true);
  31985. }
  31986. };
  31987. /** @hidden */
  31988. Engine.prototype._setAnisotropicLevel = function (target, texture) {
  31989. var internalTexture = texture.getInternalTexture();
  31990. if (!internalTexture) {
  31991. return;
  31992. }
  31993. var anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
  31994. var value = texture.anisotropicFilteringLevel;
  31995. if (internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST
  31996. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR
  31997. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR) {
  31998. value = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear
  31999. }
  32000. if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== value) {
  32001. this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(value, this._caps.maxAnisotropy), internalTexture);
  32002. internalTexture._cachedAnisotropicFilteringLevel = value;
  32003. }
  32004. };
  32005. Engine.prototype._setTextureParameterFloat = function (target, parameter, value, texture) {
  32006. this._bindTextureDirectly(target, texture, true, true);
  32007. this._gl.texParameterf(target, parameter, value);
  32008. };
  32009. Engine.prototype._setTextureParameterInteger = function (target, parameter, value, texture) {
  32010. if (texture) {
  32011. this._bindTextureDirectly(target, texture, true, true);
  32012. }
  32013. this._gl.texParameteri(target, parameter, value);
  32014. };
  32015. /**
  32016. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32017. * @param x defines the x coordinate of the rectangle where pixels must be read
  32018. * @param y defines the y coordinate of the rectangle where pixels must be read
  32019. * @param width defines the width of the rectangle where pixels must be read
  32020. * @param height defines the height of the rectangle where pixels must be read
  32021. * @returns a Uint8Array containing RGBA colors
  32022. */
  32023. Engine.prototype.readPixels = function (x, y, width, height) {
  32024. var data = new Uint8Array(height * width * 4);
  32025. this._gl.readPixels(x, y, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data);
  32026. return data;
  32027. };
  32028. /**
  32029. * Add an externaly attached data from its key.
  32030. * This method call will fail and return false, if such key already exists.
  32031. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32032. * @param key the unique key that identifies the data
  32033. * @param data the data object to associate to the key for this Engine instance
  32034. * @return true if no such key were already present and the data was added successfully, false otherwise
  32035. */
  32036. Engine.prototype.addExternalData = function (key, data) {
  32037. if (!this._externalData) {
  32038. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32039. }
  32040. return this._externalData.add(key, data);
  32041. };
  32042. /**
  32043. * Get an externaly attached data from its key
  32044. * @param key the unique key that identifies the data
  32045. * @return the associated data, if present (can be null), or undefined if not present
  32046. */
  32047. Engine.prototype.getExternalData = function (key) {
  32048. if (!this._externalData) {
  32049. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32050. }
  32051. return this._externalData.get(key);
  32052. };
  32053. /**
  32054. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32055. * @param key the unique key that identifies the data
  32056. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32057. * @return the associated data, can be null if the factory returned null.
  32058. */
  32059. Engine.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  32060. if (!this._externalData) {
  32061. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32062. }
  32063. return this._externalData.getOrAddWithFactory(key, factory);
  32064. };
  32065. /**
  32066. * Remove an externaly attached data from the Engine instance
  32067. * @param key the unique key that identifies the data
  32068. * @return true if the data was successfully removed, false if it doesn't exist
  32069. */
  32070. Engine.prototype.removeExternalData = function (key) {
  32071. if (!this._externalData) {
  32072. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32073. }
  32074. return this._externalData.remove(key);
  32075. };
  32076. /**
  32077. * Unbind all vertex attributes from the webGL context
  32078. */
  32079. Engine.prototype.unbindAllAttributes = function () {
  32080. if (this._mustWipeVertexAttributes) {
  32081. this._mustWipeVertexAttributes = false;
  32082. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  32083. this._gl.disableVertexAttribArray(i);
  32084. this._vertexAttribArraysEnabled[i] = false;
  32085. this._currentBufferPointers[i].active = false;
  32086. }
  32087. return;
  32088. }
  32089. for (var i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
  32090. if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {
  32091. continue;
  32092. }
  32093. this._gl.disableVertexAttribArray(i);
  32094. this._vertexAttribArraysEnabled[i] = false;
  32095. this._currentBufferPointers[i].active = false;
  32096. }
  32097. };
  32098. /**
  32099. * 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
  32100. */
  32101. Engine.prototype.releaseEffects = function () {
  32102. for (var name in this._compiledEffects) {
  32103. this._deleteProgram(this._compiledEffects[name]._program);
  32104. }
  32105. this._compiledEffects = {};
  32106. };
  32107. /**
  32108. * Dispose and release all associated resources
  32109. */
  32110. Engine.prototype.dispose = function () {
  32111. this.hideLoadingUI();
  32112. this.stopRenderLoop();
  32113. this.onNewSceneAddedObservable.clear();
  32114. // Release postProcesses
  32115. while (this.postProcesses.length) {
  32116. this.postProcesses[0].dispose();
  32117. }
  32118. // Empty texture
  32119. if (this._emptyTexture) {
  32120. this._releaseTexture(this._emptyTexture);
  32121. this._emptyTexture = null;
  32122. }
  32123. if (this._emptyCubeTexture) {
  32124. this._releaseTexture(this._emptyCubeTexture);
  32125. this._emptyCubeTexture = null;
  32126. }
  32127. // Rescale PP
  32128. if (this._rescalePostProcess) {
  32129. this._rescalePostProcess.dispose();
  32130. }
  32131. // Release scenes
  32132. while (this.scenes.length) {
  32133. this.scenes[0].dispose();
  32134. }
  32135. // Release audio engine
  32136. if (Engine.Instances.length === 1 && Engine.audioEngine) {
  32137. Engine.audioEngine.dispose();
  32138. }
  32139. // Release effects
  32140. this.releaseEffects();
  32141. // Unbind
  32142. this.unbindAllAttributes();
  32143. this._boundUniforms = [];
  32144. if (this._dummyFramebuffer) {
  32145. this._gl.deleteFramebuffer(this._dummyFramebuffer);
  32146. }
  32147. //WebVR
  32148. this.disableVR();
  32149. // Events
  32150. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  32151. window.removeEventListener("blur", this._onBlur);
  32152. window.removeEventListener("focus", this._onFocus);
  32153. window.removeEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted);
  32154. window.removeEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted);
  32155. if (this._renderingCanvas) {
  32156. this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus);
  32157. this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur);
  32158. this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut);
  32159. if (!this._doNotHandleContextLost) {
  32160. this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
  32161. this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
  32162. }
  32163. }
  32164. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  32165. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  32166. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  32167. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  32168. document.removeEventListener("pointerlockchange", this._onPointerLockChange);
  32169. document.removeEventListener("mspointerlockchange", this._onPointerLockChange);
  32170. document.removeEventListener("mozpointerlockchange", this._onPointerLockChange);
  32171. document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange);
  32172. if (this._onVrDisplayConnect) {
  32173. window.removeEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  32174. if (this._onVrDisplayDisconnect) {
  32175. window.removeEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  32176. }
  32177. if (this._onVrDisplayPresentChange) {
  32178. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  32179. }
  32180. this._onVrDisplayConnect = null;
  32181. this._onVrDisplayDisconnect = null;
  32182. }
  32183. }
  32184. // Remove from Instances
  32185. var index = Engine.Instances.indexOf(this);
  32186. if (index >= 0) {
  32187. Engine.Instances.splice(index, 1);
  32188. }
  32189. this._workingCanvas = null;
  32190. this._workingContext = null;
  32191. this._currentBufferPointers = [];
  32192. this._renderingCanvas = null;
  32193. this._currentProgram = null;
  32194. this._bindedRenderFunction = null;
  32195. this.onResizeObservable.clear();
  32196. this.onCanvasBlurObservable.clear();
  32197. this.onCanvasFocusObservable.clear();
  32198. this.onCanvasPointerOutObservable.clear();
  32199. this.onBeginFrameObservable.clear();
  32200. this.onEndFrameObservable.clear();
  32201. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  32202. // Abort active requests
  32203. for (var _i = 0, _a = this._activeRequests; _i < _a.length; _i++) {
  32204. var request = _a[_i];
  32205. request.abort();
  32206. }
  32207. };
  32208. // Loading screen
  32209. /**
  32210. * Display the loading screen
  32211. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32212. */
  32213. Engine.prototype.displayLoadingUI = function () {
  32214. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  32215. return;
  32216. }
  32217. var loadingScreen = this.loadingScreen;
  32218. if (loadingScreen) {
  32219. loadingScreen.displayLoadingUI();
  32220. }
  32221. };
  32222. /**
  32223. * Hide the loading screen
  32224. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32225. */
  32226. Engine.prototype.hideLoadingUI = function () {
  32227. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  32228. return;
  32229. }
  32230. var loadingScreen = this.loadingScreen;
  32231. if (loadingScreen) {
  32232. loadingScreen.hideLoadingUI();
  32233. }
  32234. };
  32235. Object.defineProperty(Engine.prototype, "loadingScreen", {
  32236. /**
  32237. * Gets the current loading screen object
  32238. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32239. */
  32240. get: function () {
  32241. if (!this._loadingScreen && this._renderingCanvas) {
  32242. this._loadingScreen = Engine.DefaultLoadingScreenFactory(this._renderingCanvas);
  32243. }
  32244. return this._loadingScreen;
  32245. },
  32246. /**
  32247. * Sets the current loading screen object
  32248. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32249. */
  32250. set: function (loadingScreen) {
  32251. this._loadingScreen = loadingScreen;
  32252. },
  32253. enumerable: true,
  32254. configurable: true
  32255. });
  32256. Object.defineProperty(Engine.prototype, "loadingUIText", {
  32257. /**
  32258. * Sets the current loading screen text
  32259. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32260. */
  32261. set: function (text) {
  32262. this.loadingScreen.loadingUIText = text;
  32263. },
  32264. enumerable: true,
  32265. configurable: true
  32266. });
  32267. Object.defineProperty(Engine.prototype, "loadingUIBackgroundColor", {
  32268. /**
  32269. * Sets the current loading screen background color
  32270. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32271. */
  32272. set: function (color) {
  32273. this.loadingScreen.loadingUIBackgroundColor = color;
  32274. },
  32275. enumerable: true,
  32276. configurable: true
  32277. });
  32278. /**
  32279. * Attach a new callback raised when context lost event is fired
  32280. * @param callback defines the callback to call
  32281. */
  32282. Engine.prototype.attachContextLostEvent = function (callback) {
  32283. if (this._renderingCanvas) {
  32284. this._renderingCanvas.addEventListener("webglcontextlost", callback, false);
  32285. }
  32286. };
  32287. /**
  32288. * Attach a new callback raised when context restored event is fired
  32289. * @param callback defines the callback to call
  32290. */
  32291. Engine.prototype.attachContextRestoredEvent = function (callback) {
  32292. if (this._renderingCanvas) {
  32293. this._renderingCanvas.addEventListener("webglcontextrestored", callback, false);
  32294. }
  32295. };
  32296. /**
  32297. * Gets the source code of the vertex shader associated with a specific webGL program
  32298. * @param program defines the program to use
  32299. * @returns a string containing the source code of the vertex shader associated with the program
  32300. */
  32301. Engine.prototype.getVertexShaderSource = function (program) {
  32302. var shaders = this._gl.getAttachedShaders(program);
  32303. if (!shaders) {
  32304. return null;
  32305. }
  32306. return this._gl.getShaderSource(shaders[0]);
  32307. };
  32308. /**
  32309. * Gets the source code of the fragment shader associated with a specific webGL program
  32310. * @param program defines the program to use
  32311. * @returns a string containing the source code of the fragment shader associated with the program
  32312. */
  32313. Engine.prototype.getFragmentShaderSource = function (program) {
  32314. var shaders = this._gl.getAttachedShaders(program);
  32315. if (!shaders) {
  32316. return null;
  32317. }
  32318. return this._gl.getShaderSource(shaders[1]);
  32319. };
  32320. /**
  32321. * Get the current error code of the webGL context
  32322. * @returns the error code
  32323. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32324. */
  32325. Engine.prototype.getError = function () {
  32326. return this._gl.getError();
  32327. };
  32328. // FPS
  32329. /**
  32330. * Gets the current framerate
  32331. * @returns a number representing the framerate
  32332. */
  32333. Engine.prototype.getFps = function () {
  32334. return this._fps;
  32335. };
  32336. /**
  32337. * Gets the time spent between current and previous frame
  32338. * @returns a number representing the delta time in ms
  32339. */
  32340. Engine.prototype.getDeltaTime = function () {
  32341. return this._deltaTime;
  32342. };
  32343. Engine.prototype._measureFps = function () {
  32344. this._performanceMonitor.sampleFrame();
  32345. this._fps = this._performanceMonitor.averageFPS;
  32346. this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;
  32347. };
  32348. /** @hidden */
  32349. Engine.prototype._readTexturePixels = function (texture, width, height, faceIndex, level, buffer) {
  32350. if (faceIndex === void 0) { faceIndex = -1; }
  32351. if (level === void 0) { level = 0; }
  32352. if (buffer === void 0) { buffer = null; }
  32353. var gl = this._gl;
  32354. if (!this._dummyFramebuffer) {
  32355. var dummy = gl.createFramebuffer();
  32356. if (!dummy) {
  32357. throw new Error("Unable to create dummy framebuffer");
  32358. }
  32359. this._dummyFramebuffer = dummy;
  32360. }
  32361. gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);
  32362. if (faceIndex > -1) {
  32363. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, level);
  32364. }
  32365. else {
  32366. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, level);
  32367. }
  32368. var readType = (texture.type !== undefined) ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;
  32369. switch (readType) {
  32370. case gl.UNSIGNED_BYTE:
  32371. if (!buffer) {
  32372. buffer = new Uint8Array(4 * width * height);
  32373. }
  32374. readType = gl.UNSIGNED_BYTE;
  32375. break;
  32376. default:
  32377. if (!buffer) {
  32378. buffer = new Float32Array(4 * width * height);
  32379. }
  32380. readType = gl.FLOAT;
  32381. break;
  32382. }
  32383. gl.readPixels(0, 0, width, height, gl.RGBA, readType, buffer);
  32384. gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);
  32385. return buffer;
  32386. };
  32387. Engine.prototype._canRenderToFloatFramebuffer = function () {
  32388. if (this._webGLVersion > 1) {
  32389. return this._caps.colorBufferFloat;
  32390. }
  32391. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_FLOAT);
  32392. };
  32393. Engine.prototype._canRenderToHalfFloatFramebuffer = function () {
  32394. if (this._webGLVersion > 1) {
  32395. return this._caps.colorBufferFloat;
  32396. }
  32397. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_HALF_FLOAT);
  32398. };
  32399. // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture
  32400. Engine.prototype._canRenderToFramebuffer = function (type) {
  32401. var gl = this._gl;
  32402. //clear existing errors
  32403. while (gl.getError() !== gl.NO_ERROR) { }
  32404. var successful = true;
  32405. var texture = gl.createTexture();
  32406. gl.bindTexture(gl.TEXTURE_2D, texture);
  32407. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  32408. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  32409. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  32410. var fb = gl.createFramebuffer();
  32411. gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
  32412. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
  32413. var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
  32414. successful = successful && (status === gl.FRAMEBUFFER_COMPLETE);
  32415. successful = successful && (gl.getError() === gl.NO_ERROR);
  32416. //try render by clearing frame buffer's color buffer
  32417. if (successful) {
  32418. gl.clear(gl.COLOR_BUFFER_BIT);
  32419. successful = successful && (gl.getError() === gl.NO_ERROR);
  32420. }
  32421. //try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)
  32422. if (successful) {
  32423. //in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture
  32424. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  32425. var readFormat = gl.RGBA;
  32426. var readType = gl.UNSIGNED_BYTE;
  32427. var buffer = new Uint8Array(4);
  32428. gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);
  32429. successful = successful && (gl.getError() === gl.NO_ERROR);
  32430. }
  32431. //clean up
  32432. gl.deleteTexture(texture);
  32433. gl.deleteFramebuffer(fb);
  32434. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  32435. //clear accumulated errors
  32436. while (!successful && (gl.getError() !== gl.NO_ERROR)) { }
  32437. return successful;
  32438. };
  32439. /** @hidden */
  32440. Engine.prototype._getWebGLTextureType = function (type) {
  32441. if (this._webGLVersion === 1) {
  32442. switch (type) {
  32443. case Engine.TEXTURETYPE_FLOAT:
  32444. return this._gl.FLOAT;
  32445. case Engine.TEXTURETYPE_HALF_FLOAT:
  32446. return this._gl.HALF_FLOAT_OES;
  32447. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  32448. return this._gl.UNSIGNED_BYTE;
  32449. }
  32450. return this._gl.UNSIGNED_BYTE;
  32451. }
  32452. switch (type) {
  32453. case Engine.TEXTURETYPE_BYTE:
  32454. return this._gl.BYTE;
  32455. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  32456. return this._gl.UNSIGNED_BYTE;
  32457. case Engine.TEXTURETYPE_SHORT:
  32458. return this._gl.SHORT;
  32459. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  32460. return this._gl.UNSIGNED_SHORT;
  32461. case Engine.TEXTURETYPE_INT:
  32462. return this._gl.INT;
  32463. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  32464. return this._gl.UNSIGNED_INT;
  32465. case Engine.TEXTURETYPE_FLOAT:
  32466. return this._gl.FLOAT;
  32467. case Engine.TEXTURETYPE_HALF_FLOAT:
  32468. return this._gl.HALF_FLOAT;
  32469. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  32470. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  32471. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  32472. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  32473. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  32474. return this._gl.UNSIGNED_SHORT_5_6_5;
  32475. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  32476. return this._gl.UNSIGNED_INT_2_10_10_10_REV;
  32477. case Engine.TEXTURETYPE_UNSIGNED_INT_24_8:
  32478. return this._gl.UNSIGNED_INT_24_8;
  32479. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  32480. return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
  32481. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  32482. return this._gl.UNSIGNED_INT_5_9_9_9_REV;
  32483. case Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
  32484. return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
  32485. }
  32486. return this._gl.UNSIGNED_BYTE;
  32487. };
  32488. Engine.prototype._getInternalFormat = function (format) {
  32489. var internalFormat = this._gl.RGBA;
  32490. switch (format) {
  32491. case Engine.TEXTUREFORMAT_ALPHA:
  32492. internalFormat = this._gl.ALPHA;
  32493. break;
  32494. case Engine.TEXTUREFORMAT_LUMINANCE:
  32495. internalFormat = this._gl.LUMINANCE;
  32496. break;
  32497. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  32498. internalFormat = this._gl.LUMINANCE_ALPHA;
  32499. break;
  32500. case Engine.TEXTUREFORMAT_RED:
  32501. internalFormat = this._gl.RED;
  32502. break;
  32503. case Engine.TEXTUREFORMAT_RG:
  32504. internalFormat = this._gl.RG;
  32505. break;
  32506. case Engine.TEXTUREFORMAT_RGB:
  32507. internalFormat = this._gl.RGB;
  32508. break;
  32509. case Engine.TEXTUREFORMAT_RGBA:
  32510. internalFormat = this._gl.RGBA;
  32511. break;
  32512. }
  32513. if (this._webGLVersion > 1) {
  32514. switch (format) {
  32515. case Engine.TEXTUREFORMAT_RED_INTEGER:
  32516. internalFormat = this._gl.RED_INTEGER;
  32517. break;
  32518. case Engine.TEXTUREFORMAT_RG_INTEGER:
  32519. internalFormat = this._gl.RG_INTEGER;
  32520. break;
  32521. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  32522. internalFormat = this._gl.RGB_INTEGER;
  32523. break;
  32524. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32525. internalFormat = this._gl.RGBA_INTEGER;
  32526. break;
  32527. }
  32528. }
  32529. return internalFormat;
  32530. };
  32531. /** @hidden */
  32532. Engine.prototype._getRGBABufferInternalSizedFormat = function (type, format) {
  32533. if (this._webGLVersion === 1) {
  32534. if (format !== undefined) {
  32535. switch (format) {
  32536. case Engine.TEXTUREFORMAT_ALPHA:
  32537. return this._gl.ALPHA;
  32538. case Engine.TEXTUREFORMAT_LUMINANCE:
  32539. return this._gl.LUMINANCE;
  32540. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  32541. return this._gl.LUMINANCE_ALPHA;
  32542. }
  32543. }
  32544. return this._gl.RGBA;
  32545. }
  32546. switch (type) {
  32547. case Engine.TEXTURETYPE_BYTE:
  32548. switch (format) {
  32549. case Engine.TEXTUREFORMAT_RED:
  32550. return this._gl.R8_SNORM;
  32551. case Engine.TEXTUREFORMAT_RG:
  32552. return this._gl.RG8_SNORM;
  32553. case Engine.TEXTUREFORMAT_RGB:
  32554. return this._gl.RGB8_SNORM;
  32555. case Engine.TEXTUREFORMAT_RED_INTEGER:
  32556. return this._gl.R8I;
  32557. case Engine.TEXTUREFORMAT_RG_INTEGER:
  32558. return this._gl.RG8I;
  32559. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  32560. return this._gl.RGB8I;
  32561. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32562. return this._gl.RGBA8I;
  32563. default:
  32564. return this._gl.RGBA8_SNORM;
  32565. }
  32566. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  32567. switch (format) {
  32568. case Engine.TEXTUREFORMAT_RED:
  32569. return this._gl.R8;
  32570. case Engine.TEXTUREFORMAT_RG:
  32571. return this._gl.RG8;
  32572. case Engine.TEXTUREFORMAT_RGB:
  32573. return this._gl.RGB8; // By default. Other possibilities are RGB565, SRGB8.
  32574. case Engine.TEXTUREFORMAT_RGBA:
  32575. return this._gl.RGBA8; // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.
  32576. case Engine.TEXTUREFORMAT_RED_INTEGER:
  32577. return this._gl.R8UI;
  32578. case Engine.TEXTUREFORMAT_RG_INTEGER:
  32579. return this._gl.RG8UI;
  32580. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  32581. return this._gl.RGB8UI;
  32582. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32583. return this._gl.RGBA8UI;
  32584. default:
  32585. return this._gl.RGBA8;
  32586. }
  32587. case Engine.TEXTURETYPE_SHORT:
  32588. switch (format) {
  32589. case Engine.TEXTUREFORMAT_RED_INTEGER:
  32590. return this._gl.R16I;
  32591. case Engine.TEXTUREFORMAT_RG_INTEGER:
  32592. return this._gl.RG16I;
  32593. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  32594. return this._gl.RGB16I;
  32595. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32596. return this._gl.RGBA16I;
  32597. default:
  32598. return this._gl.RGBA16I;
  32599. }
  32600. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  32601. switch (format) {
  32602. case Engine.TEXTUREFORMAT_RED_INTEGER:
  32603. return this._gl.R16UI;
  32604. case Engine.TEXTUREFORMAT_RG_INTEGER:
  32605. return this._gl.RG16UI;
  32606. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  32607. return this._gl.RGB16UI;
  32608. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32609. return this._gl.RGBA16UI;
  32610. default:
  32611. return this._gl.RGBA16UI;
  32612. }
  32613. case Engine.TEXTURETYPE_INT:
  32614. switch (format) {
  32615. case Engine.TEXTUREFORMAT_RED_INTEGER:
  32616. return this._gl.R32I;
  32617. case Engine.TEXTUREFORMAT_RG_INTEGER:
  32618. return this._gl.RG32I;
  32619. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  32620. return this._gl.RGB32I;
  32621. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32622. return this._gl.RGBA32I;
  32623. default:
  32624. return this._gl.RGBA32I;
  32625. }
  32626. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  32627. switch (format) {
  32628. case Engine.TEXTUREFORMAT_RED_INTEGER:
  32629. return this._gl.R32UI;
  32630. case Engine.TEXTUREFORMAT_RG_INTEGER:
  32631. return this._gl.RG32UI;
  32632. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  32633. return this._gl.RGB32UI;
  32634. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32635. return this._gl.RGBA32UI;
  32636. default:
  32637. return this._gl.RGBA32UI;
  32638. }
  32639. case Engine.TEXTURETYPE_FLOAT:
  32640. switch (format) {
  32641. case Engine.TEXTUREFORMAT_RED:
  32642. return this._gl.R32F; // By default. Other possibility is R16F.
  32643. case Engine.TEXTUREFORMAT_RG:
  32644. return this._gl.RG32F; // By default. Other possibility is RG16F.
  32645. case Engine.TEXTUREFORMAT_RGB:
  32646. return this._gl.RGB32F; // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.
  32647. case Engine.TEXTUREFORMAT_RGBA:
  32648. return this._gl.RGBA32F; // By default. Other possibility is RGBA16F.
  32649. default:
  32650. return this._gl.RGBA32F;
  32651. }
  32652. case Engine.TEXTURETYPE_HALF_FLOAT:
  32653. switch (format) {
  32654. case Engine.TEXTUREFORMAT_RED:
  32655. return this._gl.R16F;
  32656. case Engine.TEXTUREFORMAT_RG:
  32657. return this._gl.RG16F;
  32658. case Engine.TEXTUREFORMAT_RGB:
  32659. return this._gl.RGB16F; // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.
  32660. case Engine.TEXTUREFORMAT_RGBA:
  32661. return this._gl.RGBA16F;
  32662. default:
  32663. return this._gl.RGBA16F;
  32664. }
  32665. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  32666. return this._gl.RGB565;
  32667. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  32668. return this._gl.R11F_G11F_B10F;
  32669. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  32670. return this._gl.RGB9_E5;
  32671. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  32672. return this._gl.RGBA4;
  32673. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  32674. return this._gl.RGB5_A1;
  32675. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  32676. switch (format) {
  32677. case Engine.TEXTUREFORMAT_RGBA:
  32678. return this._gl.RGB10_A2; // By default. Other possibility is RGB5_A1.
  32679. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  32680. return this._gl.RGB10_A2UI;
  32681. default:
  32682. return this._gl.RGB10_A2;
  32683. }
  32684. }
  32685. return this._gl.RGBA8;
  32686. };
  32687. /** @hidden */
  32688. Engine.prototype._getRGBAMultiSampleBufferFormat = function (type) {
  32689. if (type === Engine.TEXTURETYPE_FLOAT) {
  32690. return this._gl.RGBA32F;
  32691. }
  32692. else if (type === Engine.TEXTURETYPE_HALF_FLOAT) {
  32693. return this._gl.RGBA16F;
  32694. }
  32695. return this._gl.RGBA8;
  32696. };
  32697. /** @hidden */
  32698. Engine.prototype._loadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  32699. var _this = this;
  32700. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);
  32701. this._activeRequests.push(request);
  32702. request.onCompleteObservable.add(function (request) {
  32703. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  32704. });
  32705. return request;
  32706. };
  32707. /** @hidden */
  32708. Engine.prototype._loadFileAsync = function (url, offlineProvider, useArrayBuffer) {
  32709. var _this = this;
  32710. return new Promise(function (resolve, reject) {
  32711. _this._loadFile(url, function (data) {
  32712. resolve(data);
  32713. }, undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  32714. reject(exception);
  32715. });
  32716. });
  32717. };
  32718. Engine.prototype._partialLoadFile = function (url, index, loadedFiles, onfinish, onErrorCallBack) {
  32719. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  32720. var onload = function (data) {
  32721. loadedFiles[index] = data;
  32722. loadedFiles._internalCount++;
  32723. if (loadedFiles._internalCount === 6) {
  32724. onfinish(loadedFiles);
  32725. }
  32726. };
  32727. var onerror = function (request, exception) {
  32728. if (onErrorCallBack && request) {
  32729. onErrorCallBack(request.status + " " + request.statusText, exception);
  32730. }
  32731. };
  32732. this._loadFile(url, onload, undefined, undefined, true, onerror);
  32733. };
  32734. Engine.prototype._cascadeLoadFiles = function (scene, onfinish, files, onError) {
  32735. if (onError === void 0) { onError = null; }
  32736. var loadedFiles = [];
  32737. loadedFiles._internalCount = 0;
  32738. for (var index = 0; index < 6; index++) {
  32739. this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);
  32740. }
  32741. };
  32742. // Statics
  32743. /**
  32744. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32745. * @returns true if the engine can be created
  32746. * @ignorenaming
  32747. */
  32748. Engine.isSupported = function () {
  32749. try {
  32750. var tempcanvas = document.createElement("canvas");
  32751. var gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
  32752. return gl != null && !!window.WebGLRenderingContext;
  32753. }
  32754. catch (e) {
  32755. return false;
  32756. }
  32757. };
  32758. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  32759. Engine.ExceptionList = [
  32760. { key: "Chrome/63.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
  32761. { key: "Firefox/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  32762. { key: "Firefox/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  32763. { key: "Macintosh", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  32764. { key: "iPhone", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  32765. { key: "iPad", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] }
  32766. ];
  32767. /**
  32768. * Hidden
  32769. */
  32770. Engine._TextureLoaders = [];
  32771. // Const statics
  32772. /** Defines that alpha blending is disabled */
  32773. Engine.ALPHA_DISABLE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_DISABLE;
  32774. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32775. Engine.ALPHA_ADD = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ADD;
  32776. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32777. Engine.ALPHA_COMBINE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_COMBINE;
  32778. /** Defines that alpha blending to DEST - SRC * DEST */
  32779. Engine.ALPHA_SUBTRACT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SUBTRACT;
  32780. /** Defines that alpha blending to SRC * DEST */
  32781. Engine.ALPHA_MULTIPLY = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MULTIPLY;
  32782. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32783. Engine.ALPHA_MAXIMIZED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MAXIMIZED;
  32784. /** Defines that alpha blending to SRC + DEST */
  32785. Engine.ALPHA_ONEONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ONEONE;
  32786. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32787. Engine.ALPHA_PREMULTIPLIED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED;
  32788. /**
  32789. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32790. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32791. */
  32792. Engine.ALPHA_PREMULTIPLIED_PORTERDUFF = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  32793. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32794. Engine.ALPHA_INTERPOLATE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_INTERPOLATE;
  32795. /**
  32796. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32797. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32798. */
  32799. Engine.ALPHA_SCREENMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SCREENMODE;
  32800. /** Defines that the ressource is not delayed*/
  32801. Engine.DELAYLOADSTATE_NONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NONE;
  32802. /** Defines that the ressource was successfully delay loaded */
  32803. Engine.DELAYLOADSTATE_LOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADED;
  32804. /** Defines that the ressource is currently delay loading */
  32805. Engine.DELAYLOADSTATE_LOADING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADING;
  32806. /** Defines that the ressource is delayed and has not started loading */
  32807. Engine.DELAYLOADSTATE_NOTLOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NOTLOADED;
  32808. // Depht or Stencil test Constants.
  32809. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32810. Engine.NEVER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NEVER;
  32811. /** 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 */
  32812. Engine.ALWAYS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALWAYS;
  32813. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32814. Engine.LESS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LESS;
  32815. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32816. Engine.EQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].EQUAL;
  32817. /** 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 */
  32818. Engine.LEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LEQUAL;
  32819. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32820. Engine.GREATER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GREATER;
  32821. /** 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 */
  32822. Engine.GEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GEQUAL;
  32823. /** 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 */
  32824. Engine.NOTEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NOTEQUAL;
  32825. // Stencil Actions Constants.
  32826. /** Passed to stencilOperation to specify that stencil value must be kept */
  32827. Engine.KEEP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].KEEP;
  32828. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32829. Engine.REPLACE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].REPLACE;
  32830. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32831. Engine.INCR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR;
  32832. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32833. Engine.DECR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR;
  32834. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32835. Engine.INVERT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INVERT;
  32836. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32837. Engine.INCR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR_WRAP;
  32838. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32839. Engine.DECR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR_WRAP;
  32840. /** Texture is not repeating outside of 0..1 UVs */
  32841. Engine.TEXTURE_CLAMP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  32842. /** Texture is repeating outside of 0..1 UVs */
  32843. Engine.TEXTURE_WRAP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  32844. /** Texture is repeating and mirrored */
  32845. Engine.TEXTURE_MIRROR_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  32846. /** ALPHA */
  32847. Engine.TEXTUREFORMAT_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_ALPHA;
  32848. /** LUMINANCE */
  32849. Engine.TEXTUREFORMAT_LUMINANCE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE;
  32850. /** LUMINANCE_ALPHA */
  32851. Engine.TEXTUREFORMAT_LUMINANCE_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA;
  32852. /** RGB */
  32853. Engine.TEXTUREFORMAT_RGB = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB;
  32854. /** RGBA */
  32855. Engine.TEXTUREFORMAT_RGBA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA;
  32856. /** RED */
  32857. Engine.TEXTUREFORMAT_RED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED;
  32858. /** RED (2nd reference) */
  32859. Engine.TEXTUREFORMAT_R = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R;
  32860. /** RG */
  32861. Engine.TEXTUREFORMAT_RG = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG;
  32862. /** RED_INTEGER */
  32863. Engine.TEXTUREFORMAT_RED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED_INTEGER;
  32864. /** RED_INTEGER (2nd reference) */
  32865. Engine.TEXTUREFORMAT_R_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R_INTEGER;
  32866. /** RG_INTEGER */
  32867. Engine.TEXTUREFORMAT_RG_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG_INTEGER;
  32868. /** RGB_INTEGER */
  32869. Engine.TEXTUREFORMAT_RGB_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB_INTEGER;
  32870. /** RGBA_INTEGER */
  32871. Engine.TEXTUREFORMAT_RGBA_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA_INTEGER;
  32872. /** UNSIGNED_BYTE */
  32873. Engine.TEXTURETYPE_UNSIGNED_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_BYTE;
  32874. /** UNSIGNED_BYTE (2nd reference) */
  32875. Engine.TEXTURETYPE_UNSIGNED_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  32876. /** FLOAT */
  32877. Engine.TEXTURETYPE_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT;
  32878. /** HALF_FLOAT */
  32879. Engine.TEXTURETYPE_HALF_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_HALF_FLOAT;
  32880. /** BYTE */
  32881. Engine.TEXTURETYPE_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_BYTE;
  32882. /** SHORT */
  32883. Engine.TEXTURETYPE_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_SHORT;
  32884. /** UNSIGNED_SHORT */
  32885. Engine.TEXTURETYPE_UNSIGNED_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT;
  32886. /** INT */
  32887. Engine.TEXTURETYPE_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_INT;
  32888. /** UNSIGNED_INT */
  32889. Engine.TEXTURETYPE_UNSIGNED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INTEGER;
  32890. /** UNSIGNED_SHORT_4_4_4_4 */
  32891. Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4;
  32892. /** UNSIGNED_SHORT_5_5_5_1 */
  32893. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1;
  32894. /** UNSIGNED_SHORT_5_6_5 */
  32895. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_6_5;
  32896. /** UNSIGNED_INT_2_10_10_10_REV */
  32897. Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV;
  32898. /** UNSIGNED_INT_24_8 */
  32899. Engine.TEXTURETYPE_UNSIGNED_INT_24_8 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_24_8;
  32900. /** UNSIGNED_INT_10F_11F_11F_REV */
  32901. Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV;
  32902. /** UNSIGNED_INT_5_9_9_9_REV */
  32903. Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV;
  32904. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32905. Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV;
  32906. /** nearest is mag = nearest and min = nearest and mip = linear */
  32907. Engine.TEXTURE_NEAREST_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  32908. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32909. Engine.TEXTURE_BILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  32910. /** Trilinear is mag = linear and min = linear and mip = linear */
  32911. Engine.TEXTURE_TRILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  32912. /** nearest is mag = nearest and min = nearest and mip = linear */
  32913. Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPLINEAR;
  32914. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32915. Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPNEAREST;
  32916. /** Trilinear is mag = linear and min = linear and mip = linear */
  32917. Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPLINEAR;
  32918. /** mag = nearest and min = nearest and mip = nearest */
  32919. Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  32920. /** mag = nearest and min = linear and mip = nearest */
  32921. Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  32922. /** mag = nearest and min = linear and mip = linear */
  32923. Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  32924. /** mag = nearest and min = linear and mip = none */
  32925. Engine.TEXTURE_NEAREST_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR;
  32926. /** mag = nearest and min = nearest and mip = none */
  32927. Engine.TEXTURE_NEAREST_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST;
  32928. /** mag = linear and min = nearest and mip = nearest */
  32929. Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  32930. /** mag = linear and min = nearest and mip = linear */
  32931. Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  32932. /** mag = linear and min = linear and mip = none */
  32933. Engine.TEXTURE_LINEAR_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR;
  32934. /** mag = linear and min = nearest and mip = none */
  32935. Engine.TEXTURE_LINEAR_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST;
  32936. /** Explicit coordinates mode */
  32937. Engine.TEXTURE_EXPLICIT_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EXPLICIT_MODE;
  32938. /** Spherical coordinates mode */
  32939. Engine.TEXTURE_SPHERICAL_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SPHERICAL_MODE;
  32940. /** Planar coordinates mode */
  32941. Engine.TEXTURE_PLANAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PLANAR_MODE;
  32942. /** Cubic coordinates mode */
  32943. Engine.TEXTURE_CUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CUBIC_MODE;
  32944. /** Projection coordinates mode */
  32945. Engine.TEXTURE_PROJECTION_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PROJECTION_MODE;
  32946. /** Skybox coordinates mode */
  32947. Engine.TEXTURE_SKYBOX_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SKYBOX_MODE;
  32948. /** Inverse Cubic coordinates mode */
  32949. Engine.TEXTURE_INVCUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_INVCUBIC_MODE;
  32950. /** Equirectangular coordinates mode */
  32951. Engine.TEXTURE_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  32952. /** Equirectangular Fixed coordinates mode */
  32953. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  32954. /** Equirectangular Fixed Mirrored coordinates mode */
  32955. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  32956. // Texture rescaling mode
  32957. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32958. Engine.SCALEMODE_FLOOR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_FLOOR;
  32959. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32960. Engine.SCALEMODE_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_NEAREST;
  32961. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32962. Engine.SCALEMODE_CEILING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_CEILING;
  32963. // Updatable statics so stick with vars here
  32964. /**
  32965. * Gets or sets the epsilon value used by collision engine
  32966. */
  32967. Engine.CollisionsEpsilon = 0.001;
  32968. /**
  32969. * Method called to create the default rescale post process on each engine.
  32970. */
  32971. Engine._RescalePostProcessFactory = null;
  32972. return Engine;
  32973. }());
  32974. /***/ }),
  32975. /***/ "./Engines/engineStore.ts":
  32976. /*!********************************!*\
  32977. !*** ./Engines/engineStore.ts ***!
  32978. \********************************/
  32979. /*! exports provided: EngineStore */
  32980. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  32981. "use strict";
  32982. __webpack_require__.r(__webpack_exports__);
  32983. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return EngineStore; });
  32984. /**
  32985. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32986. * during the life time of the application.
  32987. */
  32988. var EngineStore = /** @class */ (function () {
  32989. function EngineStore() {
  32990. }
  32991. Object.defineProperty(EngineStore, "LastCreatedEngine", {
  32992. /**
  32993. * Gets the latest created engine
  32994. */
  32995. get: function () {
  32996. if (this.Instances.length === 0) {
  32997. return null;
  32998. }
  32999. return this.Instances[this.Instances.length - 1];
  33000. },
  33001. enumerable: true,
  33002. configurable: true
  33003. });
  33004. Object.defineProperty(EngineStore, "LastCreatedScene", {
  33005. /**
  33006. * Gets the latest created scene
  33007. */
  33008. get: function () {
  33009. var lastCreatedEngine = this.LastCreatedEngine;
  33010. if (!lastCreatedEngine) {
  33011. return null;
  33012. }
  33013. if (lastCreatedEngine.scenes.length === 0) {
  33014. return null;
  33015. }
  33016. return lastCreatedEngine.scenes[lastCreatedEngine.scenes.length - 1];
  33017. },
  33018. enumerable: true,
  33019. configurable: true
  33020. });
  33021. /** Gets the list of created engines */
  33022. EngineStore.Instances = new Array();
  33023. return EngineStore;
  33024. }());
  33025. /***/ }),
  33026. /***/ "./Engines/index.ts":
  33027. /*!**************************!*\
  33028. !*** ./Engines/index.ts ***!
  33029. \**************************/
  33030. /*! exports provided: Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  33031. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33032. "use strict";
  33033. __webpack_require__.r(__webpack_exports__);
  33034. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  33035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _constants__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  33036. /* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine */ "./Engines/engine.ts");
  33037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["InstancingAttributeInfo"]; });
  33038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["DepthTextureCreationOptions"]; });
  33039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["EngineCapabilities"]; });
  33040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]; });
  33041. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  33042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"]; });
  33043. /* harmony import */ var _nullEngine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nullEngine */ "./Engines/nullEngine.ts");
  33044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngineOptions"]; });
  33045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngine"]; });
  33046. /* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Extensions/index */ "./Engines/Extensions/index.ts");
  33047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_OcclusionDataStorage"]; });
  33048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_forceTransformFeedbackToBundle"]; });
  33049. /***/ }),
  33050. /***/ "./Engines/nullEngine.ts":
  33051. /*!*******************************!*\
  33052. !*** ./Engines/nullEngine.ts ***!
  33053. \*******************************/
  33054. /*! exports provided: NullEngineOptions, NullEngine */
  33055. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33056. "use strict";
  33057. __webpack_require__.r(__webpack_exports__);
  33058. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return NullEngineOptions; });
  33059. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return NullEngine; });
  33060. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  33061. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  33062. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  33063. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  33064. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  33065. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  33066. /**
  33067. * Options to create the null engine
  33068. */
  33069. var NullEngineOptions = /** @class */ (function () {
  33070. function NullEngineOptions() {
  33071. /**
  33072. * Render width (Default: 512)
  33073. */
  33074. this.renderWidth = 512;
  33075. /**
  33076. * Render height (Default: 256)
  33077. */
  33078. this.renderHeight = 256;
  33079. /**
  33080. * Texture size (Default: 512)
  33081. */
  33082. this.textureSize = 512;
  33083. /**
  33084. * If delta time between frames should be constant
  33085. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33086. */
  33087. this.deterministicLockstep = false;
  33088. /**
  33089. * Maximum about of steps between frames (Default: 4)
  33090. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33091. */
  33092. this.lockstepMaxSteps = 4;
  33093. }
  33094. return NullEngineOptions;
  33095. }());
  33096. /**
  33097. * The null engine class provides support for headless version of babylon.js.
  33098. * This can be used in server side scenario or for testing purposes
  33099. */
  33100. var NullEngine = /** @class */ (function (_super) {
  33101. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NullEngine, _super);
  33102. function NullEngine(options) {
  33103. if (options === void 0) { options = new NullEngineOptions(); }
  33104. var _this = _super.call(this, null) || this;
  33105. if (options.deterministicLockstep === undefined) {
  33106. options.deterministicLockstep = false;
  33107. }
  33108. if (options.lockstepMaxSteps === undefined) {
  33109. options.lockstepMaxSteps = 4;
  33110. }
  33111. _this._options = options;
  33112. // Init caps
  33113. // We consider we are on a webgl1 capable device
  33114. _this._caps = new _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["EngineCapabilities"]();
  33115. _this._caps.maxTexturesImageUnits = 16;
  33116. _this._caps.maxVertexTextureImageUnits = 16;
  33117. _this._caps.maxTextureSize = 512;
  33118. _this._caps.maxCubemapTextureSize = 512;
  33119. _this._caps.maxRenderTextureSize = 512;
  33120. _this._caps.maxVertexAttribs = 16;
  33121. _this._caps.maxVaryingVectors = 16;
  33122. _this._caps.maxFragmentUniformVectors = 16;
  33123. _this._caps.maxVertexUniformVectors = 16;
  33124. // Extensions
  33125. _this._caps.standardDerivatives = false;
  33126. _this._caps.astc = null;
  33127. _this._caps.s3tc = null;
  33128. _this._caps.pvrtc = null;
  33129. _this._caps.etc1 = null;
  33130. _this._caps.etc2 = null;
  33131. _this._caps.textureAnisotropicFilterExtension = null;
  33132. _this._caps.maxAnisotropy = 0;
  33133. _this._caps.uintIndices = false;
  33134. _this._caps.fragmentDepthSupported = false;
  33135. _this._caps.highPrecisionShaderSupported = true;
  33136. _this._caps.colorBufferFloat = false;
  33137. _this._caps.textureFloat = false;
  33138. _this._caps.textureFloatLinearFiltering = false;
  33139. _this._caps.textureFloatRender = false;
  33140. _this._caps.textureHalfFloat = false;
  33141. _this._caps.textureHalfFloatLinearFiltering = false;
  33142. _this._caps.textureHalfFloatRender = false;
  33143. _this._caps.textureLOD = false;
  33144. _this._caps.drawBuffersExtension = false;
  33145. _this._caps.depthTextureExtension = false;
  33146. _this._caps.vertexArrayObject = false;
  33147. _this._caps.instancedArrays = false;
  33148. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("Babylon.js v" + _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].Version + " - Null engine");
  33149. // Wrappers
  33150. if (typeof URL === "undefined") {
  33151. URL = {
  33152. createObjectURL: function () { },
  33153. revokeObjectURL: function () { }
  33154. };
  33155. }
  33156. if (typeof Blob === "undefined") {
  33157. Blob = function () { };
  33158. }
  33159. return _this;
  33160. }
  33161. /**
  33162. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33163. */
  33164. NullEngine.prototype.isDeterministicLockStep = function () {
  33165. return this._options.deterministicLockstep;
  33166. };
  33167. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  33168. NullEngine.prototype.getLockstepMaxSteps = function () {
  33169. return this._options.lockstepMaxSteps;
  33170. };
  33171. /**
  33172. * Sets hardware scaling, used to save performance if needed
  33173. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  33174. */
  33175. NullEngine.prototype.getHardwareScalingLevel = function () {
  33176. return 1.0;
  33177. };
  33178. NullEngine.prototype.createVertexBuffer = function (vertices) {
  33179. return {
  33180. capacity: 0,
  33181. references: 1,
  33182. is32Bits: false
  33183. };
  33184. };
  33185. NullEngine.prototype.createIndexBuffer = function (indices) {
  33186. return {
  33187. capacity: 0,
  33188. references: 1,
  33189. is32Bits: false
  33190. };
  33191. };
  33192. NullEngine.prototype.clear = function (color, backBuffer, depth, stencil) {
  33193. if (stencil === void 0) { stencil = false; }
  33194. };
  33195. NullEngine.prototype.getRenderWidth = function (useScreen) {
  33196. if (useScreen === void 0) { useScreen = false; }
  33197. if (!useScreen && this._currentRenderTarget) {
  33198. return this._currentRenderTarget.width;
  33199. }
  33200. return this._options.renderWidth;
  33201. };
  33202. NullEngine.prototype.getRenderHeight = function (useScreen) {
  33203. if (useScreen === void 0) { useScreen = false; }
  33204. if (!useScreen && this._currentRenderTarget) {
  33205. return this._currentRenderTarget.height;
  33206. }
  33207. return this._options.renderHeight;
  33208. };
  33209. NullEngine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  33210. this._cachedViewport = viewport;
  33211. };
  33212. NullEngine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context) {
  33213. return {
  33214. transformFeedback: null,
  33215. __SPECTOR_rebuildProgram: null,
  33216. isParallelCompiled: false
  33217. };
  33218. };
  33219. NullEngine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  33220. return [];
  33221. };
  33222. NullEngine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  33223. return [];
  33224. };
  33225. NullEngine.prototype.bindSamplers = function (effect) {
  33226. this._currentEffect = null;
  33227. };
  33228. NullEngine.prototype.enableEffect = function (effect) {
  33229. this._currentEffect = effect;
  33230. if (effect.onBind) {
  33231. effect.onBind(effect);
  33232. }
  33233. if (effect._onBindObservable) {
  33234. effect._onBindObservable.notifyObservers(effect);
  33235. }
  33236. };
  33237. NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  33238. if (zOffset === void 0) { zOffset = 0; }
  33239. if (reverseSide === void 0) { reverseSide = false; }
  33240. };
  33241. NullEngine.prototype.setIntArray = function (uniform, array) {
  33242. };
  33243. NullEngine.prototype.setIntArray2 = function (uniform, array) {
  33244. };
  33245. NullEngine.prototype.setIntArray3 = function (uniform, array) {
  33246. };
  33247. NullEngine.prototype.setIntArray4 = function (uniform, array) {
  33248. };
  33249. NullEngine.prototype.setFloatArray = function (uniform, array) {
  33250. };
  33251. NullEngine.prototype.setFloatArray2 = function (uniform, array) {
  33252. };
  33253. NullEngine.prototype.setFloatArray3 = function (uniform, array) {
  33254. };
  33255. NullEngine.prototype.setFloatArray4 = function (uniform, array) {
  33256. };
  33257. NullEngine.prototype.setArray = function (uniform, array) {
  33258. };
  33259. NullEngine.prototype.setArray2 = function (uniform, array) {
  33260. };
  33261. NullEngine.prototype.setArray3 = function (uniform, array) {
  33262. };
  33263. NullEngine.prototype.setArray4 = function (uniform, array) {
  33264. };
  33265. NullEngine.prototype.setMatrices = function (uniform, matrices) {
  33266. };
  33267. NullEngine.prototype.setMatrix = function (uniform, matrix) {
  33268. };
  33269. NullEngine.prototype.setMatrix3x3 = function (uniform, matrix) {
  33270. };
  33271. NullEngine.prototype.setMatrix2x2 = function (uniform, matrix) {
  33272. };
  33273. NullEngine.prototype.setFloat = function (uniform, value) {
  33274. };
  33275. NullEngine.prototype.setFloat2 = function (uniform, x, y) {
  33276. };
  33277. NullEngine.prototype.setFloat3 = function (uniform, x, y, z) {
  33278. };
  33279. NullEngine.prototype.setBool = function (uniform, bool) {
  33280. };
  33281. NullEngine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  33282. };
  33283. NullEngine.prototype.setColor3 = function (uniform, color3) {
  33284. };
  33285. NullEngine.prototype.setColor4 = function (uniform, color3, alpha) {
  33286. };
  33287. NullEngine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  33288. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  33289. if (this._alphaMode === mode) {
  33290. return;
  33291. }
  33292. this._alphaState.alphaBlend = (mode !== _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  33293. if (!noDepthWriteChange) {
  33294. this.setDepthWrite(mode === _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  33295. }
  33296. this._alphaMode = mode;
  33297. };
  33298. NullEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  33299. };
  33300. NullEngine.prototype.wipeCaches = function (bruteForce) {
  33301. if (this.preventCacheWipeBetweenFrames) {
  33302. return;
  33303. }
  33304. this.resetTextureCache();
  33305. this._currentEffect = null;
  33306. if (bruteForce) {
  33307. this._currentProgram = null;
  33308. this._stencilState.reset();
  33309. this._depthCullingState.reset();
  33310. this._alphaState.reset();
  33311. }
  33312. this._cachedVertexBuffers = null;
  33313. this._cachedIndexBuffer = null;
  33314. this._cachedEffectForVertexBuffers = null;
  33315. };
  33316. NullEngine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  33317. };
  33318. NullEngine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  33319. };
  33320. NullEngine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  33321. };
  33322. /** @hidden */
  33323. NullEngine.prototype._createTexture = function () {
  33324. return {};
  33325. };
  33326. /** @hidden */
  33327. NullEngine.prototype._releaseTexture = function (texture) {
  33328. };
  33329. NullEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallBack, format) {
  33330. if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  33331. if (onLoad === void 0) { onLoad = null; }
  33332. if (onError === void 0) { onError = null; }
  33333. if (buffer === void 0) { buffer = null; }
  33334. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_URL);
  33335. var url = String(urlArg);
  33336. texture.url = url;
  33337. texture.generateMipMaps = !noMipmap;
  33338. texture.samplingMode = samplingMode;
  33339. texture.invertY = invertY;
  33340. texture.baseWidth = this._options.textureSize;
  33341. texture.baseHeight = this._options.textureSize;
  33342. texture.width = this._options.textureSize;
  33343. texture.height = this._options.textureSize;
  33344. if (format) {
  33345. texture.format = format;
  33346. }
  33347. texture.isReady = true;
  33348. if (onLoad) {
  33349. onLoad();
  33350. }
  33351. this._internalTexturesCache.push(texture);
  33352. return texture;
  33353. };
  33354. NullEngine.prototype.createRenderTargetTexture = function (size, options) {
  33355. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__["RenderTargetCreationOptions"]();
  33356. if (options !== undefined && typeof options === "object") {
  33357. fullOptions.generateMipMaps = options.generateMipMaps;
  33358. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  33359. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  33360. fullOptions.type = options.type === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT : options.type;
  33361. fullOptions.samplingMode = options.samplingMode === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  33362. }
  33363. else {
  33364. fullOptions.generateMipMaps = options;
  33365. fullOptions.generateDepthBuffer = true;
  33366. fullOptions.generateStencilBuffer = false;
  33367. fullOptions.type = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  33368. fullOptions.samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  33369. }
  33370. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_RENDERTARGET);
  33371. var width = size.width || size;
  33372. var height = size.height || size;
  33373. texture._depthStencilBuffer = {};
  33374. texture._framebuffer = {};
  33375. texture.baseWidth = width;
  33376. texture.baseHeight = height;
  33377. texture.width = width;
  33378. texture.height = height;
  33379. texture.isReady = true;
  33380. texture.samples = 1;
  33381. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  33382. texture.samplingMode = fullOptions.samplingMode;
  33383. texture.type = fullOptions.type;
  33384. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  33385. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  33386. this._internalTexturesCache.push(texture);
  33387. return texture;
  33388. };
  33389. NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  33390. texture.samplingMode = samplingMode;
  33391. };
  33392. NullEngine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
  33393. if (this._currentRenderTarget) {
  33394. this.unBindFramebuffer(this._currentRenderTarget);
  33395. }
  33396. this._currentRenderTarget = texture;
  33397. this._currentFramebuffer = texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer;
  33398. if (this._cachedViewport && !forceFullscreenViewport) {
  33399. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  33400. }
  33401. };
  33402. NullEngine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  33403. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  33404. this._currentRenderTarget = null;
  33405. if (onBeforeUnbind) {
  33406. if (texture._MSAAFramebuffer) {
  33407. this._currentFramebuffer = texture._framebuffer;
  33408. }
  33409. onBeforeUnbind();
  33410. }
  33411. this._currentFramebuffer = null;
  33412. };
  33413. NullEngine.prototype.createDynamicVertexBuffer = function (vertices) {
  33414. var vbo = {
  33415. capacity: 1,
  33416. references: 1,
  33417. is32Bits: false
  33418. };
  33419. return vbo;
  33420. };
  33421. NullEngine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format) {
  33422. if (premulAlpha === void 0) { premulAlpha = false; }
  33423. };
  33424. NullEngine.prototype.areAllEffectsReady = function () {
  33425. return true;
  33426. };
  33427. /**
  33428. * @hidden
  33429. * Get the current error code of the webGL context
  33430. * @returns the error code
  33431. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33432. */
  33433. NullEngine.prototype.getError = function () {
  33434. return 0;
  33435. };
  33436. /** @hidden */
  33437. NullEngine.prototype._getUnpackAlignement = function () {
  33438. return 1;
  33439. };
  33440. /** @hidden */
  33441. NullEngine.prototype._unpackFlipY = function (value) {
  33442. };
  33443. NullEngine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  33444. if (offset === void 0) { offset = 0; }
  33445. };
  33446. /**
  33447. * Updates a dynamic vertex buffer.
  33448. * @param vertexBuffer the vertex buffer to update
  33449. * @param data the data used to update the vertex buffer
  33450. * @param byteOffset the byte offset of the data (optional)
  33451. * @param byteLength the byte length of the data (optional)
  33452. */
  33453. NullEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, byteOffset, byteLength) {
  33454. };
  33455. NullEngine.prototype._bindTextureDirectly = function (target, texture) {
  33456. if (this._boundTexturesCache[this._activeChannel] !== texture) {
  33457. this._boundTexturesCache[this._activeChannel] = texture;
  33458. return true;
  33459. }
  33460. return false;
  33461. };
  33462. /** @hidden */
  33463. NullEngine.prototype._bindTexture = function (channel, texture) {
  33464. if (channel < 0) {
  33465. return;
  33466. }
  33467. this._bindTextureDirectly(0, texture);
  33468. };
  33469. /** @hidden */
  33470. NullEngine.prototype._releaseBuffer = function (buffer) {
  33471. buffer.references--;
  33472. if (buffer.references === 0) {
  33473. return true;
  33474. }
  33475. return false;
  33476. };
  33477. NullEngine.prototype.releaseEffects = function () {
  33478. };
  33479. NullEngine.prototype.displayLoadingUI = function () {
  33480. };
  33481. NullEngine.prototype.hideLoadingUI = function () {
  33482. };
  33483. /** @hidden */
  33484. NullEngine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  33485. if (faceIndex === void 0) { faceIndex = 0; }
  33486. if (lod === void 0) { lod = 0; }
  33487. };
  33488. /** @hidden */
  33489. NullEngine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  33490. if (faceIndex === void 0) { faceIndex = 0; }
  33491. if (lod === void 0) { lod = 0; }
  33492. };
  33493. /** @hidden */
  33494. NullEngine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  33495. if (faceIndex === void 0) { faceIndex = 0; }
  33496. if (lod === void 0) { lod = 0; }
  33497. };
  33498. /** @hidden */
  33499. NullEngine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  33500. if (faceIndex === void 0) { faceIndex = 0; }
  33501. if (lod === void 0) { lod = 0; }
  33502. };
  33503. return NullEngine;
  33504. }(_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"]));
  33505. /***/ }),
  33506. /***/ "./Events/clipboardEvents.ts":
  33507. /*!***********************************!*\
  33508. !*** ./Events/clipboardEvents.ts ***!
  33509. \***********************************/
  33510. /*! exports provided: ClipboardEventTypes, ClipboardInfo */
  33511. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33512. "use strict";
  33513. __webpack_require__.r(__webpack_exports__);
  33514. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return ClipboardEventTypes; });
  33515. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return ClipboardInfo; });
  33516. /**
  33517. * Gather the list of clipboard event types as constants.
  33518. */
  33519. var ClipboardEventTypes = /** @class */ (function () {
  33520. function ClipboardEventTypes() {
  33521. }
  33522. /**
  33523. * The clipboard event is fired when a copy command is active (pressed).
  33524. */
  33525. ClipboardEventTypes.COPY = 0x01; //
  33526. /**
  33527. * The clipboard event is fired when a cut command is active (pressed).
  33528. */
  33529. ClipboardEventTypes.CUT = 0x02;
  33530. /**
  33531. * The clipboard event is fired when a paste command is active (pressed).
  33532. */
  33533. ClipboardEventTypes.PASTE = 0x03;
  33534. return ClipboardEventTypes;
  33535. }());
  33536. /**
  33537. * This class is used to store clipboard related info for the onClipboardObservable event.
  33538. */
  33539. var ClipboardInfo = /** @class */ (function () {
  33540. /**
  33541. *Creates an instance of ClipboardInfo.
  33542. * @param {number} type
  33543. * @param {ClipboardEvent} event
  33544. */
  33545. function ClipboardInfo(
  33546. /**
  33547. * Defines the type of event (BABYLON.ClipboardEventTypes)
  33548. */
  33549. type,
  33550. /**
  33551. * Defines the related dom event
  33552. */
  33553. event) {
  33554. this.type = type;
  33555. this.event = event;
  33556. }
  33557. /**
  33558. * Get the clipboard event's type from the keycode.
  33559. * @param keyCode Defines the keyCode for the current keyboard event.
  33560. * @return {number}
  33561. */
  33562. ClipboardInfo.GetTypeFromCharacter = function (keyCode) {
  33563. var charCode = keyCode;
  33564. //TODO: add codes for extended ASCII
  33565. switch (charCode) {
  33566. case 67: return ClipboardEventTypes.COPY;
  33567. case 86: return ClipboardEventTypes.PASTE;
  33568. case 88: return ClipboardEventTypes.CUT;
  33569. default: return -1;
  33570. }
  33571. };
  33572. return ClipboardInfo;
  33573. }());
  33574. /***/ }),
  33575. /***/ "./Events/index.ts":
  33576. /*!*************************!*\
  33577. !*** ./Events/index.ts ***!
  33578. \*************************/
  33579. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo */
  33580. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33581. "use strict";
  33582. __webpack_require__.r(__webpack_exports__);
  33583. /* harmony import */ var _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keyboardEvents */ "./Events/keyboardEvents.ts");
  33584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  33585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  33586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  33587. /* harmony import */ var _pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pointerEvents */ "./Events/pointerEvents.ts");
  33588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"]; });
  33589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoBase"]; });
  33590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoPre"]; });
  33591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfo"]; });
  33592. /* harmony import */ var _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./clipboardEvents */ "./Events/clipboardEvents.ts");
  33593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardEventTypes"]; });
  33594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardInfo"]; });
  33595. /***/ }),
  33596. /***/ "./Events/keyboardEvents.ts":
  33597. /*!**********************************!*\
  33598. !*** ./Events/keyboardEvents.ts ***!
  33599. \**********************************/
  33600. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre */
  33601. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33602. "use strict";
  33603. __webpack_require__.r(__webpack_exports__);
  33604. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return KeyboardEventTypes; });
  33605. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return KeyboardInfo; });
  33606. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return KeyboardInfoPre; });
  33607. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  33608. /**
  33609. * Gather the list of keyboard event types as constants.
  33610. */
  33611. var KeyboardEventTypes = /** @class */ (function () {
  33612. function KeyboardEventTypes() {
  33613. }
  33614. /**
  33615. * The keydown event is fired when a key becomes active (pressed).
  33616. */
  33617. KeyboardEventTypes.KEYDOWN = 0x01;
  33618. /**
  33619. * The keyup event is fired when a key has been released.
  33620. */
  33621. KeyboardEventTypes.KEYUP = 0x02;
  33622. return KeyboardEventTypes;
  33623. }());
  33624. /**
  33625. * This class is used to store keyboard related info for the onKeyboardObservable event.
  33626. */
  33627. var KeyboardInfo = /** @class */ (function () {
  33628. /**
  33629. * Instantiates a new keyboard info.
  33630. * This class is used to store keyboard related info for the onKeyboardObservable event.
  33631. * @param type Defines the type of event (KeyboardEventTypes)
  33632. * @param event Defines the related dom event
  33633. */
  33634. function KeyboardInfo(
  33635. /**
  33636. * Defines the type of event (KeyboardEventTypes)
  33637. */
  33638. type,
  33639. /**
  33640. * Defines the related dom event
  33641. */
  33642. event) {
  33643. this.type = type;
  33644. this.event = event;
  33645. }
  33646. return KeyboardInfo;
  33647. }());
  33648. /**
  33649. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  33650. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  33651. */
  33652. var KeyboardInfoPre = /** @class */ (function (_super) {
  33653. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeyboardInfoPre, _super);
  33654. /**
  33655. * Instantiates a new keyboard pre info.
  33656. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  33657. * @param type Defines the type of event (KeyboardEventTypes)
  33658. * @param event Defines the related dom event
  33659. */
  33660. function KeyboardInfoPre(
  33661. /**
  33662. * Defines the type of event (KeyboardEventTypes)
  33663. */
  33664. type,
  33665. /**
  33666. * Defines the related dom event
  33667. */
  33668. event) {
  33669. var _this = _super.call(this, type, event) || this;
  33670. _this.type = type;
  33671. _this.event = event;
  33672. _this.skipOnPointerObservable = false;
  33673. return _this;
  33674. }
  33675. return KeyboardInfoPre;
  33676. }(KeyboardInfo));
  33677. /***/ }),
  33678. /***/ "./Events/pointerEvents.ts":
  33679. /*!*********************************!*\
  33680. !*** ./Events/pointerEvents.ts ***!
  33681. \*********************************/
  33682. /*! exports provided: PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo */
  33683. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33684. "use strict";
  33685. __webpack_require__.r(__webpack_exports__);
  33686. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return PointerEventTypes; });
  33687. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return PointerInfoBase; });
  33688. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return PointerInfoPre; });
  33689. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return PointerInfo; });
  33690. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  33691. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  33692. /**
  33693. * Gather the list of pointer event types as constants.
  33694. */
  33695. var PointerEventTypes = /** @class */ (function () {
  33696. function PointerEventTypes() {
  33697. }
  33698. /**
  33699. * 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.
  33700. */
  33701. PointerEventTypes.POINTERDOWN = 0x01;
  33702. /**
  33703. * The pointerup event is fired when a pointer is no longer active.
  33704. */
  33705. PointerEventTypes.POINTERUP = 0x02;
  33706. /**
  33707. * The pointermove event is fired when a pointer changes coordinates.
  33708. */
  33709. PointerEventTypes.POINTERMOVE = 0x04;
  33710. /**
  33711. * The pointerwheel event is fired when a mouse wheel has been rotated.
  33712. */
  33713. PointerEventTypes.POINTERWHEEL = 0x08;
  33714. /**
  33715. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  33716. */
  33717. PointerEventTypes.POINTERPICK = 0x10;
  33718. /**
  33719. * The pointertap event is fired when a the object has been touched and released without drag.
  33720. */
  33721. PointerEventTypes.POINTERTAP = 0x20;
  33722. /**
  33723. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  33724. */
  33725. PointerEventTypes.POINTERDOUBLETAP = 0x40;
  33726. return PointerEventTypes;
  33727. }());
  33728. /**
  33729. * Base class of pointer info types.
  33730. */
  33731. var PointerInfoBase = /** @class */ (function () {
  33732. /**
  33733. * Instantiates the base class of pointers info.
  33734. * @param type Defines the type of event (PointerEventTypes)
  33735. * @param event Defines the related dom event
  33736. */
  33737. function PointerInfoBase(
  33738. /**
  33739. * Defines the type of event (PointerEventTypes)
  33740. */
  33741. type,
  33742. /**
  33743. * Defines the related dom event
  33744. */
  33745. event) {
  33746. this.type = type;
  33747. this.event = event;
  33748. }
  33749. return PointerInfoBase;
  33750. }());
  33751. /**
  33752. * This class is used to store pointer related info for the onPrePointerObservable event.
  33753. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  33754. */
  33755. var PointerInfoPre = /** @class */ (function (_super) {
  33756. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfoPre, _super);
  33757. /**
  33758. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  33759. * @param type Defines the type of event (PointerEventTypes)
  33760. * @param event Defines the related dom event
  33761. * @param localX Defines the local x coordinates of the pointer when the event occured
  33762. * @param localY Defines the local y coordinates of the pointer when the event occured
  33763. */
  33764. function PointerInfoPre(type, event, localX, localY) {
  33765. var _this = _super.call(this, type, event) || this;
  33766. /**
  33767. * Ray from a pointer if availible (eg. 6dof controller)
  33768. */
  33769. _this.ray = null;
  33770. _this.skipOnPointerObservable = false;
  33771. _this.localPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](localX, localY);
  33772. return _this;
  33773. }
  33774. return PointerInfoPre;
  33775. }(PointerInfoBase));
  33776. /**
  33777. * This type contains all the data related to a pointer event in Babylon.js.
  33778. * 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.
  33779. */
  33780. var PointerInfo = /** @class */ (function (_super) {
  33781. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfo, _super);
  33782. /**
  33783. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  33784. * @param type Defines the type of event (PointerEventTypes)
  33785. * @param event Defines the related dom event
  33786. * @param pickInfo Defines the picking info associated to the info (if any)\
  33787. */
  33788. function PointerInfo(type, event,
  33789. /**
  33790. * Defines the picking info associated to the info (if any)\
  33791. */
  33792. pickInfo) {
  33793. var _this = _super.call(this, type, event) || this;
  33794. _this.pickInfo = pickInfo;
  33795. return _this;
  33796. }
  33797. return PointerInfo;
  33798. }(PointerInfoBase));
  33799. /***/ }),
  33800. /***/ "./Gamepads/Controllers/daydreamController.ts":
  33801. /*!****************************************************!*\
  33802. !*** ./Gamepads/Controllers/daydreamController.ts ***!
  33803. \****************************************************/
  33804. /*! exports provided: DaydreamController */
  33805. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33806. "use strict";
  33807. __webpack_require__.r(__webpack_exports__);
  33808. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return DaydreamController; });
  33809. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  33810. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  33811. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  33812. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  33813. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  33814. /**
  33815. * Google Daydream controller
  33816. */
  33817. var DaydreamController = /** @class */ (function (_super) {
  33818. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DaydreamController, _super);
  33819. /**
  33820. * Creates a new DaydreamController from a gamepad
  33821. * @param vrGamepad the gamepad that the controller should be created from
  33822. */
  33823. function DaydreamController(vrGamepad) {
  33824. var _this = _super.call(this, vrGamepad) || this;
  33825. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].DAYDREAM;
  33826. return _this;
  33827. }
  33828. /**
  33829. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33830. * @param scene scene in which to add meshes
  33831. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33832. */
  33833. DaydreamController.prototype.initControllerMesh = function (scene, meshLoaded) {
  33834. var _this = this;
  33835. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", DaydreamController.MODEL_BASE_URL, DaydreamController.MODEL_FILENAME, scene, function (newMeshes) {
  33836. _this._defaultModel = newMeshes[1];
  33837. _this.attachToMesh(_this._defaultModel);
  33838. if (meshLoaded) {
  33839. meshLoaded(_this._defaultModel);
  33840. }
  33841. });
  33842. };
  33843. /**
  33844. * Called once for each button that changed state since the last frame
  33845. * @param buttonIdx Which button index changed
  33846. * @param state New state of the button
  33847. * @param changes Which properties on the state changed since last frame
  33848. */
  33849. DaydreamController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  33850. // Daydream controller only has 1 GamepadButton (on the trackpad).
  33851. if (buttonIdx === 0) {
  33852. var observable = this.onTriggerStateChangedObservable;
  33853. if (observable) {
  33854. observable.notifyObservers(state);
  33855. }
  33856. }
  33857. else {
  33858. // If the app or home buttons are ever made available
  33859. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Unrecognized Daydream button index: " + buttonIdx);
  33860. }
  33861. };
  33862. /**
  33863. * Base Url for the controller model.
  33864. */
  33865. DaydreamController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  33866. /**
  33867. * File name for the controller model.
  33868. */
  33869. DaydreamController.MODEL_FILENAME = 'generic.babylon';
  33870. /**
  33871. * Gamepad Id prefix used to identify Daydream Controller.
  33872. */
  33873. DaydreamController.GAMEPAD_ID_PREFIX = 'Daydream'; // id is 'Daydream Controller'
  33874. return DaydreamController;
  33875. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  33876. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  33877. canCreate: function (gamepadInfo) {
  33878. return gamepadInfo.id.indexOf(DaydreamController.GAMEPAD_ID_PREFIX) === 0;
  33879. },
  33880. create: function (gamepadInfo) {
  33881. return new DaydreamController(gamepadInfo);
  33882. }
  33883. });
  33884. /***/ }),
  33885. /***/ "./Gamepads/Controllers/gearVRController.ts":
  33886. /*!**************************************************!*\
  33887. !*** ./Gamepads/Controllers/gearVRController.ts ***!
  33888. \**************************************************/
  33889. /*! exports provided: GearVRController */
  33890. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33891. "use strict";
  33892. __webpack_require__.r(__webpack_exports__);
  33893. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return GearVRController; });
  33894. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  33895. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  33896. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  33897. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  33898. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  33899. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  33900. /**
  33901. * Gear VR Controller
  33902. */
  33903. var GearVRController = /** @class */ (function (_super) {
  33904. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GearVRController, _super);
  33905. /**
  33906. * Creates a new GearVRController from a gamepad
  33907. * @param vrGamepad the gamepad that the controller should be created from
  33908. */
  33909. function GearVRController(vrGamepad) {
  33910. var _this = _super.call(this, vrGamepad) || this;
  33911. _this._buttonIndexToObservableNameMap = [
  33912. 'onTrackpadChangedObservable',
  33913. 'onTriggerStateChangedObservable' // Trigger
  33914. ];
  33915. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerType"].GEAR_VR;
  33916. // Initial starting position defaults to where hand would be (incase of only 3dof controller)
  33917. _this._calculatedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](_this.hand == "left" ? -0.15 : 0.15, -0.5, 0.25);
  33918. _this._disableTrackPosition(_this._calculatedPosition);
  33919. return _this;
  33920. }
  33921. /**
  33922. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33923. * @param scene scene in which to add meshes
  33924. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33925. */
  33926. GearVRController.prototype.initControllerMesh = function (scene, meshLoaded) {
  33927. var _this = this;
  33928. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__["SceneLoader"].ImportMesh("", GearVRController.MODEL_BASE_URL, GearVRController.MODEL_FILENAME, scene, function (newMeshes) {
  33929. // Offset the controller so it will rotate around the users wrist
  33930. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", scene);
  33931. newMeshes[1].parent = mesh;
  33932. newMeshes[1].position.z = -0.15;
  33933. _this._defaultModel = mesh;
  33934. _this.attachToMesh(_this._defaultModel);
  33935. if (meshLoaded) {
  33936. meshLoaded(_this._defaultModel);
  33937. }
  33938. });
  33939. };
  33940. /**
  33941. * Called once for each button that changed state since the last frame
  33942. * @param buttonIdx Which button index changed
  33943. * @param state New state of the button
  33944. * @param changes Which properties on the state changed since last frame
  33945. */
  33946. GearVRController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  33947. if (buttonIdx < this._buttonIndexToObservableNameMap.length) {
  33948. var observableName = this._buttonIndexToObservableNameMap[buttonIdx];
  33949. // Only emit events for buttons that we know how to map from index to observable
  33950. var observable = this[observableName];
  33951. if (observable) {
  33952. observable.notifyObservers(state);
  33953. }
  33954. }
  33955. };
  33956. /**
  33957. * Base Url for the controller model.
  33958. */
  33959. GearVRController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  33960. /**
  33961. * File name for the controller model.
  33962. */
  33963. GearVRController.MODEL_FILENAME = 'generic.babylon';
  33964. /**
  33965. * Gamepad Id prefix used to identify this controller.
  33966. */
  33967. GearVRController.GAMEPAD_ID_PREFIX = 'Gear VR'; // id is 'Gear VR Controller'
  33968. return GearVRController;
  33969. }(_webVRController__WEBPACK_IMPORTED_MODULE_4__["WebVRController"]));
  33970. _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  33971. canCreate: function (gamepadInfo) {
  33972. return gamepadInfo.id.indexOf(GearVRController.GAMEPAD_ID_PREFIX) === 0 ||
  33973. gamepadInfo.id.indexOf('Oculus Go') !== -1;
  33974. },
  33975. create: function (gamepadInfo) {
  33976. return new GearVRController(gamepadInfo);
  33977. }
  33978. });
  33979. /***/ }),
  33980. /***/ "./Gamepads/Controllers/genericController.ts":
  33981. /*!***************************************************!*\
  33982. !*** ./Gamepads/Controllers/genericController.ts ***!
  33983. \***************************************************/
  33984. /*! exports provided: GenericController */
  33985. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33986. "use strict";
  33987. __webpack_require__.r(__webpack_exports__);
  33988. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return GenericController; });
  33989. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  33990. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  33991. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  33992. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  33993. /**
  33994. * Generic Controller
  33995. */
  33996. var GenericController = /** @class */ (function (_super) {
  33997. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericController, _super);
  33998. /**
  33999. * Creates a new GenericController from a gamepad
  34000. * @param vrGamepad the gamepad that the controller should be created from
  34001. */
  34002. function GenericController(vrGamepad) {
  34003. return _super.call(this, vrGamepad) || this;
  34004. }
  34005. /**
  34006. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34007. * @param scene scene in which to add meshes
  34008. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34009. */
  34010. GenericController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34011. var _this = this;
  34012. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", GenericController.MODEL_BASE_URL, GenericController.MODEL_FILENAME, scene, function (newMeshes) {
  34013. _this._defaultModel = newMeshes[1];
  34014. _this.attachToMesh(_this._defaultModel);
  34015. if (meshLoaded) {
  34016. meshLoaded(_this._defaultModel);
  34017. }
  34018. });
  34019. };
  34020. /**
  34021. * Called once for each button that changed state since the last frame
  34022. * @param buttonIdx Which button index changed
  34023. * @param state New state of the button
  34024. * @param changes Which properties on the state changed since last frame
  34025. */
  34026. GenericController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34027. console.log("Button id: " + buttonIdx + "state: ");
  34028. console.dir(state);
  34029. };
  34030. /**
  34031. * Base Url for the controller model.
  34032. */
  34033. GenericController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  34034. /**
  34035. * File name for the controller model.
  34036. */
  34037. GenericController.MODEL_FILENAME = 'generic.babylon';
  34038. return GenericController;
  34039. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  34040. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._DefaultControllerFactory = function (gamepadInfo) { return new GenericController(gamepadInfo); };
  34041. /***/ }),
  34042. /***/ "./Gamepads/Controllers/index.ts":
  34043. /*!***************************************!*\
  34044. !*** ./Gamepads/Controllers/index.ts ***!
  34045. \***************************************/
  34046. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  34047. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34048. "use strict";
  34049. __webpack_require__.r(__webpack_exports__);
  34050. /* harmony import */ var _daydreamController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./daydreamController */ "./Gamepads/Controllers/daydreamController.ts");
  34051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _daydreamController__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  34052. /* harmony import */ var _gearVRController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gearVRController */ "./Gamepads/Controllers/gearVRController.ts");
  34053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _gearVRController__WEBPACK_IMPORTED_MODULE_1__["GearVRController"]; });
  34054. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  34055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _genericController__WEBPACK_IMPORTED_MODULE_2__["GenericController"]; });
  34056. /* harmony import */ var _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./oculusTouchController */ "./Gamepads/Controllers/oculusTouchController.ts");
  34057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__["OculusTouchController"]; });
  34058. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"]; });
  34060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]; });
  34061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledController"]; });
  34062. /* harmony import */ var _viveController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./viveController */ "./Gamepads/Controllers/viveController.ts");
  34063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _viveController__WEBPACK_IMPORTED_MODULE_5__["ViveController"]; });
  34064. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _webVRController__WEBPACK_IMPORTED_MODULE_6__["WebVRController"]; });
  34066. /* harmony import */ var _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./windowsMotionController */ "./Gamepads/Controllers/windowsMotionController.ts");
  34067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__["WindowsMotionController"]; });
  34068. /***/ }),
  34069. /***/ "./Gamepads/Controllers/oculusTouchController.ts":
  34070. /*!*******************************************************!*\
  34071. !*** ./Gamepads/Controllers/oculusTouchController.ts ***!
  34072. \*******************************************************/
  34073. /*! exports provided: OculusTouchController */
  34074. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34075. "use strict";
  34076. __webpack_require__.r(__webpack_exports__);
  34077. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return OculusTouchController; });
  34078. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34079. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  34080. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34081. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34082. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34083. /**
  34084. * Oculus Touch Controller
  34085. */
  34086. var OculusTouchController = /** @class */ (function (_super) {
  34087. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](OculusTouchController, _super);
  34088. /**
  34089. * Creates a new OculusTouchController from a gamepad
  34090. * @param vrGamepad the gamepad that the controller should be created from
  34091. */
  34092. function OculusTouchController(vrGamepad) {
  34093. var _this = _super.call(this, vrGamepad) || this;
  34094. /**
  34095. * Fired when the secondary trigger on this controller is modified
  34096. */
  34097. _this.onSecondaryTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34098. /**
  34099. * Fired when the thumb rest on this controller is modified
  34100. */
  34101. _this.onThumbRestChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34102. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].OCULUS;
  34103. return _this;
  34104. }
  34105. /**
  34106. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34107. * @param scene scene in which to add meshes
  34108. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34109. */
  34110. OculusTouchController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34111. var _this = this;
  34112. var meshName;
  34113. // Hand
  34114. if (this.hand === 'left') {
  34115. meshName = OculusTouchController.MODEL_LEFT_FILENAME;
  34116. }
  34117. else { // Right is the default if no hand is specified
  34118. meshName = OculusTouchController.MODEL_RIGHT_FILENAME;
  34119. }
  34120. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", OculusTouchController.MODEL_BASE_URL, meshName, scene, function (newMeshes) {
  34121. /*
  34122. Parent Mesh name: oculus_touch_left
  34123. - body
  34124. - trigger
  34125. - thumbstick
  34126. - grip
  34127. - button_y
  34128. - button_x
  34129. - button_enter
  34130. */
  34131. _this._defaultModel = newMeshes[1];
  34132. _this.attachToMesh(_this._defaultModel);
  34133. if (meshLoaded) {
  34134. meshLoaded(_this._defaultModel);
  34135. }
  34136. });
  34137. };
  34138. Object.defineProperty(OculusTouchController.prototype, "onAButtonStateChangedObservable", {
  34139. /**
  34140. * Fired when the A button on this controller is modified
  34141. */
  34142. get: function () {
  34143. if (this.hand === 'right') {
  34144. return this.onMainButtonStateChangedObservable;
  34145. }
  34146. else {
  34147. throw new Error('No A button on left hand');
  34148. }
  34149. },
  34150. enumerable: true,
  34151. configurable: true
  34152. });
  34153. Object.defineProperty(OculusTouchController.prototype, "onBButtonStateChangedObservable", {
  34154. /**
  34155. * Fired when the B button on this controller is modified
  34156. */
  34157. get: function () {
  34158. if (this.hand === 'right') {
  34159. return this.onSecondaryButtonStateChangedObservable;
  34160. }
  34161. else {
  34162. throw new Error('No B button on left hand');
  34163. }
  34164. },
  34165. enumerable: true,
  34166. configurable: true
  34167. });
  34168. Object.defineProperty(OculusTouchController.prototype, "onXButtonStateChangedObservable", {
  34169. /**
  34170. * Fired when the X button on this controller is modified
  34171. */
  34172. get: function () {
  34173. if (this.hand === 'left') {
  34174. return this.onMainButtonStateChangedObservable;
  34175. }
  34176. else {
  34177. throw new Error('No X button on right hand');
  34178. }
  34179. },
  34180. enumerable: true,
  34181. configurable: true
  34182. });
  34183. Object.defineProperty(OculusTouchController.prototype, "onYButtonStateChangedObservable", {
  34184. /**
  34185. * Fired when the Y button on this controller is modified
  34186. */
  34187. get: function () {
  34188. if (this.hand === 'left') {
  34189. return this.onSecondaryButtonStateChangedObservable;
  34190. }
  34191. else {
  34192. throw new Error('No Y button on right hand');
  34193. }
  34194. },
  34195. enumerable: true,
  34196. configurable: true
  34197. });
  34198. /**
  34199. * Called once for each button that changed state since the last frame
  34200. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  34201. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  34202. * 2) secondary trigger (same)
  34203. * 3) A (right) X (left), touch, pressed = value
  34204. * 4) B / Y
  34205. * 5) thumb rest
  34206. * @param buttonIdx Which button index changed
  34207. * @param state New state of the button
  34208. * @param changes Which properties on the state changed since last frame
  34209. */
  34210. OculusTouchController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34211. var notifyObject = state; //{ state: state, changes: changes };
  34212. var triggerDirection = this.hand === 'right' ? -1 : 1;
  34213. switch (buttonIdx) {
  34214. case 0:
  34215. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  34216. return;
  34217. case 1: // index trigger
  34218. if (this._defaultModel) {
  34219. (this._defaultModel.getChildren()[3]).rotation.x = -notifyObject.value * 0.20;
  34220. (this._defaultModel.getChildren()[3]).position.y = -notifyObject.value * 0.005;
  34221. (this._defaultModel.getChildren()[3]).position.z = -notifyObject.value * 0.005;
  34222. }
  34223. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  34224. return;
  34225. case 2: // secondary trigger
  34226. if (this._defaultModel) {
  34227. (this._defaultModel.getChildren()[4]).position.x = triggerDirection * notifyObject.value * 0.0035;
  34228. }
  34229. this.onSecondaryTriggerStateChangedObservable.notifyObservers(notifyObject);
  34230. return;
  34231. case 3:
  34232. if (this._defaultModel) {
  34233. if (notifyObject.pressed) {
  34234. (this._defaultModel.getChildren()[1]).position.y = -0.001;
  34235. }
  34236. else {
  34237. (this._defaultModel.getChildren()[1]).position.y = 0;
  34238. }
  34239. }
  34240. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  34241. return;
  34242. case 4:
  34243. if (this._defaultModel) {
  34244. if (notifyObject.pressed) {
  34245. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  34246. }
  34247. else {
  34248. (this._defaultModel.getChildren()[2]).position.y = 0;
  34249. }
  34250. }
  34251. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  34252. return;
  34253. case 5:
  34254. this.onThumbRestChangedObservable.notifyObservers(notifyObject);
  34255. return;
  34256. }
  34257. };
  34258. /**
  34259. * Base Url for the controller model.
  34260. */
  34261. OculusTouchController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/oculus/';
  34262. /**
  34263. * File name for the left controller model.
  34264. */
  34265. OculusTouchController.MODEL_LEFT_FILENAME = 'left.babylon';
  34266. /**
  34267. * File name for the right controller model.
  34268. */
  34269. OculusTouchController.MODEL_RIGHT_FILENAME = 'right.babylon';
  34270. return OculusTouchController;
  34271. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  34272. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  34273. canCreate: function (gamepadInfo) {
  34274. return gamepadInfo.id.indexOf('Oculus Touch') !== -1;
  34275. },
  34276. create: function (gamepadInfo) {
  34277. return new OculusTouchController(gamepadInfo);
  34278. }
  34279. });
  34280. /***/ }),
  34281. /***/ "./Gamepads/Controllers/poseEnabledController.ts":
  34282. /*!*******************************************************!*\
  34283. !*** ./Gamepads/Controllers/poseEnabledController.ts ***!
  34284. \*******************************************************/
  34285. /*! exports provided: PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController */
  34286. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34287. "use strict";
  34288. __webpack_require__.r(__webpack_exports__);
  34289. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return PoseEnabledControllerType; });
  34290. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return PoseEnabledControllerHelper; });
  34291. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return PoseEnabledController; });
  34292. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34293. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  34294. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  34295. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  34296. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  34297. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  34298. /**
  34299. * Defines the types of pose enabled controllers that are supported
  34300. */
  34301. var PoseEnabledControllerType;
  34302. (function (PoseEnabledControllerType) {
  34303. /**
  34304. * HTC Vive
  34305. */
  34306. PoseEnabledControllerType[PoseEnabledControllerType["VIVE"] = 0] = "VIVE";
  34307. /**
  34308. * Oculus Rift
  34309. */
  34310. PoseEnabledControllerType[PoseEnabledControllerType["OCULUS"] = 1] = "OCULUS";
  34311. /**
  34312. * Windows mixed reality
  34313. */
  34314. PoseEnabledControllerType[PoseEnabledControllerType["WINDOWS"] = 2] = "WINDOWS";
  34315. /**
  34316. * Samsung gear VR
  34317. */
  34318. PoseEnabledControllerType[PoseEnabledControllerType["GEAR_VR"] = 3] = "GEAR_VR";
  34319. /**
  34320. * Google Daydream
  34321. */
  34322. PoseEnabledControllerType[PoseEnabledControllerType["DAYDREAM"] = 4] = "DAYDREAM";
  34323. /**
  34324. * Generic
  34325. */
  34326. PoseEnabledControllerType[PoseEnabledControllerType["GENERIC"] = 5] = "GENERIC";
  34327. })(PoseEnabledControllerType || (PoseEnabledControllerType = {}));
  34328. /**
  34329. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  34330. */
  34331. var PoseEnabledControllerHelper = /** @class */ (function () {
  34332. function PoseEnabledControllerHelper() {
  34333. }
  34334. /**
  34335. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  34336. * @param vrGamepad the gamepad to initialized
  34337. * @returns a vr controller of the type the gamepad identified as
  34338. */
  34339. PoseEnabledControllerHelper.InitiateController = function (vrGamepad) {
  34340. for (var _i = 0, _a = this._ControllerFactories; _i < _a.length; _i++) {
  34341. var factory = _a[_i];
  34342. if (factory.canCreate(vrGamepad)) {
  34343. return factory.create(vrGamepad);
  34344. }
  34345. }
  34346. if (this._DefaultControllerFactory) {
  34347. return this._DefaultControllerFactory(vrGamepad);
  34348. }
  34349. throw "The type of gamepad you are trying to load needs to be imported first or is not supported.";
  34350. };
  34351. /** @hidden */
  34352. PoseEnabledControllerHelper._ControllerFactories = [];
  34353. /** @hidden */
  34354. PoseEnabledControllerHelper._DefaultControllerFactory = null;
  34355. return PoseEnabledControllerHelper;
  34356. }());
  34357. /**
  34358. * Defines the PoseEnabledController object that contains state of a vr capable controller
  34359. */
  34360. var PoseEnabledController = /** @class */ (function (_super) {
  34361. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PoseEnabledController, _super);
  34362. /**
  34363. * Creates a new PoseEnabledController from a gamepad
  34364. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  34365. */
  34366. function PoseEnabledController(browserGamepad) {
  34367. var _this = _super.call(this, browserGamepad.id, browserGamepad.index, browserGamepad) || this;
  34368. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  34369. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  34370. _this._deviceRoomRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  34371. /**
  34372. * The device position in babylon space
  34373. */
  34374. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  34375. /**
  34376. * The device rotation in babylon space
  34377. */
  34378. _this.deviceRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  34379. /**
  34380. * The scale factor of the device in babylon space
  34381. */
  34382. _this.deviceScaleFactor = 1;
  34383. // Used to convert 6dof controllers to 3dof
  34384. _this._trackPosition = true;
  34385. _this._maxRotationDistFromHeadset = Math.PI / 5;
  34386. _this._draggedRoomRotation = 0;
  34387. _this._leftHandSystemQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  34388. /**
  34389. * Internal, matrix used to convert room space to babylon space
  34390. * @hidden
  34391. */
  34392. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  34393. /**
  34394. * Node to be used when casting a ray from the controller
  34395. * @hidden
  34396. */
  34397. _this._pointingPoseNode = null;
  34398. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  34399. /**
  34400. * @hidden
  34401. */
  34402. _this._meshAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34403. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED;
  34404. _this.controllerType = PoseEnabledControllerType.GENERIC;
  34405. _this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  34406. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  34407. _this._calculatedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  34408. _this._calculatedRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  34409. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(Math.PI, 0, 0, _this._leftHandSystemQuaternion);
  34410. return _this;
  34411. }
  34412. /**
  34413. * @hidden
  34414. */
  34415. PoseEnabledController.prototype._disableTrackPosition = function (fixedPosition) {
  34416. if (this._trackPosition) {
  34417. this._calculatedPosition.copyFrom(fixedPosition);
  34418. this._trackPosition = false;
  34419. }
  34420. };
  34421. /**
  34422. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  34423. */
  34424. PoseEnabledController.prototype.update = function () {
  34425. _super.prototype.update.call(this);
  34426. this._updatePoseAndMesh();
  34427. };
  34428. /**
  34429. * Updates only the pose device and mesh without doing any button event checking
  34430. */
  34431. PoseEnabledController.prototype._updatePoseAndMesh = function () {
  34432. var pose = this.browserGamepad.pose;
  34433. this.updateFromDevice(pose);
  34434. 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) {
  34435. var camera = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene.activeCamera;
  34436. camera._computeDevicePosition();
  34437. this._deviceToWorld.setTranslation(camera.devicePosition);
  34438. if (camera.deviceRotationQuaternion) {
  34439. var camera = camera;
  34440. camera._deviceRoomRotationQuaternion.toEulerAnglesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0]);
  34441. // Find the radian distance away that the headset is from the controllers rotation
  34442. 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));
  34443. if (Math.abs(distanceAway) > this._maxRotationDistFromHeadset) {
  34444. // Only rotate enouph to be within the _maxRotationDistFromHeadset
  34445. var rotationAmount = distanceAway - (distanceAway < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
  34446. this._draggedRoomRotation += rotationAmount;
  34447. // Rotate controller around headset
  34448. var sin = Math.sin(-rotationAmount);
  34449. var cos = Math.cos(-rotationAmount);
  34450. this._calculatedPosition.x = this._calculatedPosition.x * cos - this._calculatedPosition.z * sin;
  34451. this._calculatedPosition.z = this._calculatedPosition.x * sin + this._calculatedPosition.z * cos;
  34452. }
  34453. }
  34454. }
  34455. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition);
  34456. this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix);
  34457. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  34458. this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation);
  34459. if (this._mesh) {
  34460. this._mesh.position.copyFrom(this.devicePosition);
  34461. if (this._mesh.rotationQuaternion) {
  34462. this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion);
  34463. }
  34464. }
  34465. };
  34466. /**
  34467. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  34468. * @param poseData raw pose fromthe device
  34469. */
  34470. PoseEnabledController.prototype.updateFromDevice = function (poseData) {
  34471. if (poseData) {
  34472. this.rawPose = poseData;
  34473. if (poseData.position) {
  34474. this._deviceRoomPosition.copyFromFloats(poseData.position[0], poseData.position[1], -poseData.position[2]);
  34475. if (this._mesh && this._mesh.getScene().useRightHandedSystem) {
  34476. this._deviceRoomPosition.z *= -1;
  34477. }
  34478. if (this._trackPosition) {
  34479. this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition);
  34480. }
  34481. this._calculatedPosition.addInPlace(this.position);
  34482. }
  34483. var pose = this.rawPose;
  34484. if (poseData.orientation && pose.orientation) {
  34485. this._deviceRoomRotationQuaternion.copyFromFloats(pose.orientation[0], pose.orientation[1], -pose.orientation[2], -pose.orientation[3]);
  34486. if (this._mesh) {
  34487. if (this._mesh.getScene().useRightHandedSystem) {
  34488. this._deviceRoomRotationQuaternion.z *= -1;
  34489. this._deviceRoomRotationQuaternion.w *= -1;
  34490. }
  34491. else {
  34492. this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion);
  34493. }
  34494. }
  34495. // if the camera is set, rotate to the camera's rotation
  34496. this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation);
  34497. }
  34498. }
  34499. };
  34500. /**
  34501. * Attaches a mesh to the controller
  34502. * @param mesh the mesh to be attached
  34503. */
  34504. PoseEnabledController.prototype.attachToMesh = function (mesh) {
  34505. if (this._mesh) {
  34506. this._mesh.parent = null;
  34507. }
  34508. this._mesh = mesh;
  34509. if (this._poseControlledCamera) {
  34510. this._mesh.parent = this._poseControlledCamera;
  34511. }
  34512. if (!this._mesh.rotationQuaternion) {
  34513. this._mesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  34514. }
  34515. // 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
  34516. this._updatePoseAndMesh();
  34517. if (this._pointingPoseNode) {
  34518. var parents = [];
  34519. var obj = this._pointingPoseNode;
  34520. while (obj.parent) {
  34521. parents.push(obj.parent);
  34522. obj = obj.parent;
  34523. }
  34524. parents.reverse().forEach(function (p) { p.computeWorldMatrix(true); });
  34525. }
  34526. this._meshAttachedObservable.notifyObservers(mesh);
  34527. };
  34528. /**
  34529. * Attaches the controllers mesh to a camera
  34530. * @param camera the camera the mesh should be attached to
  34531. */
  34532. PoseEnabledController.prototype.attachToPoseControlledCamera = function (camera) {
  34533. this._poseControlledCamera = camera;
  34534. if (this._mesh) {
  34535. this._mesh.parent = this._poseControlledCamera;
  34536. }
  34537. };
  34538. /**
  34539. * Disposes of the controller
  34540. */
  34541. PoseEnabledController.prototype.dispose = function () {
  34542. if (this._mesh) {
  34543. this._mesh.dispose();
  34544. }
  34545. this._mesh = null;
  34546. _super.prototype.dispose.call(this);
  34547. };
  34548. Object.defineProperty(PoseEnabledController.prototype, "mesh", {
  34549. /**
  34550. * The mesh that is attached to the controller
  34551. */
  34552. get: function () {
  34553. return this._mesh;
  34554. },
  34555. enumerable: true,
  34556. configurable: true
  34557. });
  34558. /**
  34559. * Gets the ray of the controller in the direction the controller is pointing
  34560. * @param length the length the resulting ray should be
  34561. * @returns a ray in the direction the controller is pointing
  34562. */
  34563. PoseEnabledController.prototype.getForwardRay = function (length) {
  34564. if (length === void 0) { length = 100; }
  34565. if (!this.mesh) {
  34566. 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);
  34567. }
  34568. var m = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix();
  34569. var origin = m.getTranslation();
  34570. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, -1);
  34571. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(forward, m);
  34572. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(forwardWorld);
  34573. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](origin, direction, length);
  34574. };
  34575. /**
  34576. * Name of the child mesh that can be used to cast a ray from the controller
  34577. */
  34578. PoseEnabledController.POINTING_POSE = "POINTING_POSE";
  34579. return PoseEnabledController;
  34580. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"]));
  34581. /***/ }),
  34582. /***/ "./Gamepads/Controllers/viveController.ts":
  34583. /*!************************************************!*\
  34584. !*** ./Gamepads/Controllers/viveController.ts ***!
  34585. \************************************************/
  34586. /*! exports provided: ViveController */
  34587. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34588. "use strict";
  34589. __webpack_require__.r(__webpack_exports__);
  34590. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return ViveController; });
  34591. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34592. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34593. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34594. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34595. /**
  34596. * Vive Controller
  34597. */
  34598. var ViveController = /** @class */ (function (_super) {
  34599. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ViveController, _super);
  34600. /**
  34601. * Creates a new ViveController from a gamepad
  34602. * @param vrGamepad the gamepad that the controller should be created from
  34603. */
  34604. function ViveController(vrGamepad) {
  34605. var _this = _super.call(this, vrGamepad) || this;
  34606. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerType"].VIVE;
  34607. _this._invertLeftStickY = true;
  34608. return _this;
  34609. }
  34610. /**
  34611. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34612. * @param scene scene in which to add meshes
  34613. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34614. */
  34615. ViveController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34616. var _this = this;
  34617. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", ViveController.MODEL_BASE_URL, ViveController.MODEL_FILENAME, scene, function (newMeshes) {
  34618. /*
  34619. Parent Mesh name: ViveWand
  34620. - body
  34621. - r_gripper
  34622. - l_gripper
  34623. - menu_button
  34624. - system_button
  34625. - trackpad
  34626. - trigger
  34627. - LED
  34628. */
  34629. _this._defaultModel = newMeshes[1];
  34630. _this.attachToMesh(_this._defaultModel);
  34631. if (meshLoaded) {
  34632. meshLoaded(_this._defaultModel);
  34633. }
  34634. });
  34635. };
  34636. Object.defineProperty(ViveController.prototype, "onLeftButtonStateChangedObservable", {
  34637. /**
  34638. * Fired when the left button on this controller is modified
  34639. */
  34640. get: function () {
  34641. return this.onMainButtonStateChangedObservable;
  34642. },
  34643. enumerable: true,
  34644. configurable: true
  34645. });
  34646. Object.defineProperty(ViveController.prototype, "onRightButtonStateChangedObservable", {
  34647. /**
  34648. * Fired when the right button on this controller is modified
  34649. */
  34650. get: function () {
  34651. return this.onMainButtonStateChangedObservable;
  34652. },
  34653. enumerable: true,
  34654. configurable: true
  34655. });
  34656. Object.defineProperty(ViveController.prototype, "onMenuButtonStateChangedObservable", {
  34657. /**
  34658. * Fired when the menu button on this controller is modified
  34659. */
  34660. get: function () {
  34661. return this.onSecondaryButtonStateChangedObservable;
  34662. },
  34663. enumerable: true,
  34664. configurable: true
  34665. });
  34666. /**
  34667. * Called once for each button that changed state since the last frame
  34668. * Vive mapping:
  34669. * 0: touchpad
  34670. * 1: trigger
  34671. * 2: left AND right buttons
  34672. * 3: menu button
  34673. * @param buttonIdx Which button index changed
  34674. * @param state New state of the button
  34675. * @param changes Which properties on the state changed since last frame
  34676. */
  34677. ViveController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34678. var notifyObject = state; //{ state: state, changes: changes };
  34679. switch (buttonIdx) {
  34680. case 0:
  34681. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  34682. return;
  34683. case 1: // index trigger
  34684. if (this._defaultModel) {
  34685. (this._defaultModel.getChildren()[6]).rotation.x = -notifyObject.value * 0.15;
  34686. }
  34687. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  34688. return;
  34689. case 2: // left AND right button
  34690. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  34691. return;
  34692. case 3:
  34693. if (this._defaultModel) {
  34694. if (notifyObject.pressed) {
  34695. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  34696. }
  34697. else {
  34698. (this._defaultModel.getChildren()[2]).position.y = 0;
  34699. }
  34700. }
  34701. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  34702. return;
  34703. }
  34704. };
  34705. /**
  34706. * Base Url for the controller model.
  34707. */
  34708. ViveController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/vive/';
  34709. /**
  34710. * File name for the controller model.
  34711. */
  34712. ViveController.MODEL_FILENAME = 'wand.babylon';
  34713. return ViveController;
  34714. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  34715. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  34716. canCreate: function (gamepadInfo) {
  34717. return gamepadInfo.id.toLowerCase().indexOf('openvr') !== -1;
  34718. },
  34719. create: function (gamepadInfo) {
  34720. return new ViveController(gamepadInfo);
  34721. }
  34722. });
  34723. /***/ }),
  34724. /***/ "./Gamepads/Controllers/webVRController.ts":
  34725. /*!*************************************************!*\
  34726. !*** ./Gamepads/Controllers/webVRController.ts ***!
  34727. \*************************************************/
  34728. /*! exports provided: WebVRController */
  34729. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34730. "use strict";
  34731. __webpack_require__.r(__webpack_exports__);
  34732. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return WebVRController; });
  34733. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34734. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  34735. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34736. /**
  34737. * Defines the WebVRController object that represents controllers tracked in 3D space
  34738. */
  34739. var WebVRController = /** @class */ (function (_super) {
  34740. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRController, _super);
  34741. /**
  34742. * Creates a new WebVRController from a gamepad
  34743. * @param vrGamepad the gamepad that the WebVRController should be created from
  34744. */
  34745. function WebVRController(vrGamepad) {
  34746. var _this = _super.call(this, vrGamepad) || this;
  34747. // Observables
  34748. /**
  34749. * Fired when the trigger state has changed
  34750. */
  34751. _this.onTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34752. /**
  34753. * Fired when the main button state has changed
  34754. */
  34755. _this.onMainButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34756. /**
  34757. * Fired when the secondary button state has changed
  34758. */
  34759. _this.onSecondaryButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34760. /**
  34761. * Fired when the pad state has changed
  34762. */
  34763. _this.onPadStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34764. /**
  34765. * Fired when controllers stick values have changed
  34766. */
  34767. _this.onPadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34768. /**
  34769. * X and Y axis corrisponding to the controllers joystick
  34770. */
  34771. _this.pad = { x: 0, y: 0 };
  34772. // avoid GC, store state in a tmp object
  34773. _this._changes = {
  34774. pressChanged: false,
  34775. touchChanged: false,
  34776. valueChanged: false,
  34777. changed: false
  34778. };
  34779. _this._buttons = new Array(vrGamepad.buttons.length);
  34780. _this.hand = vrGamepad.hand;
  34781. return _this;
  34782. }
  34783. /**
  34784. * Fired when a controller button's state has changed
  34785. * @param callback the callback containing the button that was modified
  34786. */
  34787. WebVRController.prototype.onButtonStateChange = function (callback) {
  34788. this._onButtonStateChange = callback;
  34789. };
  34790. Object.defineProperty(WebVRController.prototype, "defaultModel", {
  34791. /**
  34792. * The default controller model for the controller
  34793. */
  34794. get: function () {
  34795. return this._defaultModel;
  34796. },
  34797. enumerable: true,
  34798. configurable: true
  34799. });
  34800. /**
  34801. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  34802. */
  34803. WebVRController.prototype.update = function () {
  34804. _super.prototype.update.call(this);
  34805. for (var index = 0; index < this._buttons.length; index++) {
  34806. this._setButtonValue(this.browserGamepad.buttons[index], this._buttons[index], index);
  34807. }
  34808. if (this.leftStick.x !== this.pad.x || this.leftStick.y !== this.pad.y) {
  34809. this.pad.x = this.leftStick.x;
  34810. this.pad.y = this.leftStick.y;
  34811. this.onPadValuesChangedObservable.notifyObservers(this.pad);
  34812. }
  34813. };
  34814. WebVRController.prototype._setButtonValue = function (newState, currentState, buttonIndex) {
  34815. if (!newState) {
  34816. newState = {
  34817. pressed: false,
  34818. touched: false,
  34819. value: 0
  34820. };
  34821. }
  34822. if (!currentState) {
  34823. this._buttons[buttonIndex] = {
  34824. pressed: newState.pressed,
  34825. touched: newState.touched,
  34826. value: newState.value
  34827. };
  34828. return;
  34829. }
  34830. this._checkChanges(newState, currentState);
  34831. if (this._changes.changed) {
  34832. this._onButtonStateChange && this._onButtonStateChange(this.index, buttonIndex, newState);
  34833. this._handleButtonChange(buttonIndex, newState, this._changes);
  34834. }
  34835. this._buttons[buttonIndex].pressed = newState.pressed;
  34836. this._buttons[buttonIndex].touched = newState.touched;
  34837. // oculus triggers are never 0, thou not touched.
  34838. this._buttons[buttonIndex].value = newState.value < 0.00000001 ? 0 : newState.value;
  34839. };
  34840. WebVRController.prototype._checkChanges = function (newState, currentState) {
  34841. this._changes.pressChanged = newState.pressed !== currentState.pressed;
  34842. this._changes.touchChanged = newState.touched !== currentState.touched;
  34843. this._changes.valueChanged = newState.value !== currentState.value;
  34844. this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
  34845. return this._changes;
  34846. };
  34847. /**
  34848. * Disposes of th webVRCOntroller
  34849. */
  34850. WebVRController.prototype.dispose = function () {
  34851. _super.prototype.dispose.call(this);
  34852. this.onTriggerStateChangedObservable.clear();
  34853. this.onMainButtonStateChangedObservable.clear();
  34854. this.onSecondaryButtonStateChangedObservable.clear();
  34855. this.onPadStateChangedObservable.clear();
  34856. this.onPadValuesChangedObservable.clear();
  34857. };
  34858. return WebVRController;
  34859. }(_poseEnabledController__WEBPACK_IMPORTED_MODULE_2__["PoseEnabledController"]));
  34860. /***/ }),
  34861. /***/ "./Gamepads/Controllers/windowsMotionController.ts":
  34862. /*!*********************************************************!*\
  34863. !*** ./Gamepads/Controllers/windowsMotionController.ts ***!
  34864. \*********************************************************/
  34865. /*! exports provided: WindowsMotionController */
  34866. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34867. "use strict";
  34868. __webpack_require__.r(__webpack_exports__);
  34869. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return WindowsMotionController; });
  34870. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34871. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  34872. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  34873. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  34874. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  34875. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  34876. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34877. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34878. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  34879. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34880. /**
  34881. * Defines the LoadedMeshInfo object that describes information about the loaded webVR controller mesh
  34882. */
  34883. var LoadedMeshInfo = /** @class */ (function () {
  34884. function LoadedMeshInfo() {
  34885. /**
  34886. * Map of the button meshes contained in the controller
  34887. */
  34888. this.buttonMeshes = {};
  34889. /**
  34890. * Map of the axis meshes contained in the controller
  34891. */
  34892. this.axisMeshes = {};
  34893. }
  34894. return LoadedMeshInfo;
  34895. }());
  34896. /**
  34897. * Defines the WindowsMotionController object that the state of the windows motion controller
  34898. */
  34899. var WindowsMotionController = /** @class */ (function (_super) {
  34900. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WindowsMotionController, _super);
  34901. /**
  34902. * Creates a new WindowsMotionController from a gamepad
  34903. * @param vrGamepad the gamepad that the controller should be created from
  34904. */
  34905. function WindowsMotionController(vrGamepad) {
  34906. var _this = _super.call(this, vrGamepad) || this;
  34907. _this._mapping = {
  34908. // Semantic button names
  34909. buttons: ['thumbstick', 'trigger', 'grip', 'menu', 'trackpad'],
  34910. // A mapping of the button name to glTF model node name
  34911. // that should be transformed by button value.
  34912. buttonMeshNames: {
  34913. 'trigger': 'SELECT',
  34914. 'menu': 'MENU',
  34915. 'grip': 'GRASP',
  34916. 'thumbstick': 'THUMBSTICK_PRESS',
  34917. 'trackpad': 'TOUCHPAD_PRESS'
  34918. },
  34919. // This mapping is used to translate from the Motion Controller to Babylon semantics
  34920. buttonObservableNames: {
  34921. 'trigger': 'onTriggerStateChangedObservable',
  34922. 'menu': 'onSecondaryButtonStateChangedObservable',
  34923. 'grip': 'onMainButtonStateChangedObservable',
  34924. 'thumbstick': 'onPadStateChangedObservable',
  34925. 'trackpad': 'onTrackpadChangedObservable'
  34926. },
  34927. // A mapping of the axis name to glTF model node name
  34928. // that should be transformed by axis value.
  34929. // This array mirrors the browserGamepad.axes array, such that
  34930. // the mesh corresponding to axis 0 is in this array index 0.
  34931. axisMeshNames: [
  34932. 'THUMBSTICK_X',
  34933. 'THUMBSTICK_Y',
  34934. 'TOUCHPAD_TOUCH_X',
  34935. 'TOUCHPAD_TOUCH_Y'
  34936. ],
  34937. pointingPoseMeshName: _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledController"].POINTING_POSE
  34938. };
  34939. /**
  34940. * Fired when the trackpad on this controller is clicked
  34941. */
  34942. _this.onTrackpadChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  34943. /**
  34944. * Fired when the trackpad on this controller is modified
  34945. */
  34946. _this.onTrackpadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  34947. /**
  34948. * The current x and y values of this controller's trackpad
  34949. */
  34950. _this.trackpad = { x: 0, y: 0 };
  34951. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerType"].WINDOWS;
  34952. _this._loadedMeshInfo = null;
  34953. return _this;
  34954. }
  34955. Object.defineProperty(WindowsMotionController.prototype, "onTriggerButtonStateChangedObservable", {
  34956. /**
  34957. * Fired when the trigger on this controller is modified
  34958. */
  34959. get: function () {
  34960. return this.onTriggerStateChangedObservable;
  34961. },
  34962. enumerable: true,
  34963. configurable: true
  34964. });
  34965. Object.defineProperty(WindowsMotionController.prototype, "onMenuButtonStateChangedObservable", {
  34966. /**
  34967. * Fired when the menu button on this controller is modified
  34968. */
  34969. get: function () {
  34970. return this.onSecondaryButtonStateChangedObservable;
  34971. },
  34972. enumerable: true,
  34973. configurable: true
  34974. });
  34975. Object.defineProperty(WindowsMotionController.prototype, "onGripButtonStateChangedObservable", {
  34976. /**
  34977. * Fired when the grip button on this controller is modified
  34978. */
  34979. get: function () {
  34980. return this.onMainButtonStateChangedObservable;
  34981. },
  34982. enumerable: true,
  34983. configurable: true
  34984. });
  34985. Object.defineProperty(WindowsMotionController.prototype, "onThumbstickButtonStateChangedObservable", {
  34986. /**
  34987. * Fired when the thumbstick button on this controller is modified
  34988. */
  34989. get: function () {
  34990. return this.onPadStateChangedObservable;
  34991. },
  34992. enumerable: true,
  34993. configurable: true
  34994. });
  34995. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadButtonStateChangedObservable", {
  34996. /**
  34997. * Fired when the touchpad button on this controller is modified
  34998. */
  34999. get: function () {
  35000. return this.onTrackpadChangedObservable;
  35001. },
  35002. enumerable: true,
  35003. configurable: true
  35004. });
  35005. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadValuesChangedObservable", {
  35006. /**
  35007. * Fired when the touchpad values on this controller are modified
  35008. */
  35009. get: function () {
  35010. return this.onTrackpadValuesChangedObservable;
  35011. },
  35012. enumerable: true,
  35013. configurable: true
  35014. });
  35015. WindowsMotionController.prototype._updateTrackpad = function () {
  35016. if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.trackpad.x || this.browserGamepad.axes[3] != this.trackpad.y)) {
  35017. this.trackpad.x = this.browserGamepad["axes"][2];
  35018. this.trackpad.y = this.browserGamepad["axes"][3];
  35019. this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad);
  35020. }
  35021. };
  35022. /**
  35023. * Called once per frame by the engine.
  35024. */
  35025. WindowsMotionController.prototype.update = function () {
  35026. _super.prototype.update.call(this);
  35027. if (this.browserGamepad.axes) {
  35028. this._updateTrackpad();
  35029. // Only need to animate axes if there is a loaded mesh
  35030. if (this._loadedMeshInfo) {
  35031. for (var axis = 0; axis < this._mapping.axisMeshNames.length; axis++) {
  35032. this._lerpAxisTransform(axis, this.browserGamepad.axes[axis]);
  35033. }
  35034. }
  35035. }
  35036. };
  35037. /**
  35038. * Called once for each button that changed state since the last frame
  35039. * @param buttonIdx Which button index changed
  35040. * @param state New state of the button
  35041. * @param changes Which properties on the state changed since last frame
  35042. */
  35043. WindowsMotionController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35044. var buttonName = this._mapping.buttons[buttonIdx];
  35045. if (!buttonName) {
  35046. return;
  35047. }
  35048. // Update the trackpad to ensure trackpad.x/y are accurate during button events between frames
  35049. this._updateTrackpad();
  35050. // Only emit events for buttons that we know how to map from index to name
  35051. var observable = this[(this._mapping.buttonObservableNames)[buttonName]];
  35052. if (observable) {
  35053. observable.notifyObservers(state);
  35054. }
  35055. this._lerpButtonTransform(buttonName, state.value);
  35056. };
  35057. /**
  35058. * Moves the buttons on the controller mesh based on their current state
  35059. * @param buttonName the name of the button to move
  35060. * @param buttonValue the value of the button which determines the buttons new position
  35061. */
  35062. WindowsMotionController.prototype._lerpButtonTransform = function (buttonName, buttonValue) {
  35063. // If there is no loaded mesh, there is nothing to transform.
  35064. if (!this._loadedMeshInfo) {
  35065. return;
  35066. }
  35067. var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
  35068. if (!meshInfo.unpressed.rotationQuaternion || !meshInfo.pressed.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  35069. return;
  35070. }
  35071. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
  35072. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
  35073. };
  35074. /**
  35075. * Moves the axis on the controller mesh based on its current state
  35076. * @param axis the index of the axis
  35077. * @param axisValue the value of the axis which determines the meshes new position
  35078. * @hidden
  35079. */
  35080. WindowsMotionController.prototype._lerpAxisTransform = function (axis, axisValue) {
  35081. if (!this._loadedMeshInfo) {
  35082. return;
  35083. }
  35084. var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
  35085. if (!meshInfo) {
  35086. return;
  35087. }
  35088. if (!meshInfo.min.rotationQuaternion || !meshInfo.max.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  35089. return;
  35090. }
  35091. // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
  35092. var lerpValue = axisValue * 0.5 + 0.5;
  35093. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
  35094. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.min.position, meshInfo.max.position, lerpValue, meshInfo.value.position);
  35095. };
  35096. /**
  35097. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35098. * @param scene scene in which to add meshes
  35099. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35100. */
  35101. WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded, forceDefault) {
  35102. var _this = this;
  35103. if (forceDefault === void 0) { forceDefault = false; }
  35104. var path;
  35105. var filename;
  35106. // Checking if GLB loader is present
  35107. if (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].IsPluginForExtensionAvailable(".glb")) {
  35108. // Determine the device specific folder based on the ID suffix
  35109. var device = 'default';
  35110. if (this.id && !forceDefault) {
  35111. var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
  35112. device = ((match && match[0]) || device);
  35113. }
  35114. // Hand
  35115. if (this.hand === 'left') {
  35116. filename = WindowsMotionController.MODEL_LEFT_FILENAME;
  35117. }
  35118. else { // Right is the default if no hand is specified
  35119. filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
  35120. }
  35121. path = WindowsMotionController.MODEL_BASE_URL + device + '/';
  35122. }
  35123. else {
  35124. _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");
  35125. path = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_BASE_URL;
  35126. filename = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_FILENAME;
  35127. }
  35128. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].ImportMesh("", path, filename, scene, function (meshes) {
  35129. // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
  35130. _this._loadedMeshInfo = _this.processModel(scene, meshes);
  35131. if (!_this._loadedMeshInfo) {
  35132. return;
  35133. }
  35134. _this._defaultModel = _this._loadedMeshInfo.rootNode;
  35135. _this.attachToMesh(_this._defaultModel);
  35136. if (meshLoaded) {
  35137. meshLoaded(_this._defaultModel);
  35138. }
  35139. }, null, function (scene, message) {
  35140. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log(message);
  35141. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
  35142. if (!forceDefault) {
  35143. _this.initControllerMesh(scene, meshLoaded, true);
  35144. }
  35145. });
  35146. };
  35147. /**
  35148. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  35149. * can be transformed by button presses and axes values, based on this._mapping.
  35150. *
  35151. * @param scene scene in which the meshes exist
  35152. * @param meshes list of meshes that make up the controller model to process
  35153. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  35154. */
  35155. WindowsMotionController.prototype.processModel = function (scene, meshes) {
  35156. var loadedMeshInfo = null;
  35157. // Create a new mesh to contain the glTF hierarchy
  35158. var parentMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this.id + " " + this.hand, scene);
  35159. // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
  35160. var childMesh = null;
  35161. for (var i = 0; i < meshes.length; i++) {
  35162. var mesh = meshes[i];
  35163. if (!mesh.parent) {
  35164. // Exclude controller meshes from picking results
  35165. mesh.isPickable = false;
  35166. // Handle root node, attach to the new parentMesh
  35167. childMesh = mesh;
  35168. break;
  35169. }
  35170. }
  35171. if (childMesh) {
  35172. childMesh.setParent(parentMesh);
  35173. // Create our mesh info. Note that this method will always return non-null.
  35174. loadedMeshInfo = this.createMeshInfo(parentMesh);
  35175. }
  35176. else {
  35177. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Could not find root node in model file.');
  35178. }
  35179. return loadedMeshInfo;
  35180. };
  35181. WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
  35182. var loadedMeshInfo = new LoadedMeshInfo();
  35183. var i;
  35184. loadedMeshInfo.rootNode = rootNode;
  35185. // Reset the caches
  35186. loadedMeshInfo.buttonMeshes = {};
  35187. loadedMeshInfo.axisMeshes = {};
  35188. // Button Meshes
  35189. for (i = 0; i < this._mapping.buttons.length; i++) {
  35190. var buttonMeshName = this._mapping.buttonMeshNames[this._mapping.buttons[i]];
  35191. if (!buttonMeshName) {
  35192. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown button at index: ' + i + ' with mapped name: ' + this._mapping.buttons[i]);
  35193. continue;
  35194. }
  35195. var buttonMesh = getChildByName(rootNode, buttonMeshName);
  35196. if (!buttonMesh) {
  35197. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button mesh with name: ' + buttonMeshName);
  35198. continue;
  35199. }
  35200. var buttonMeshInfo = {
  35201. index: i,
  35202. value: getImmediateChildByName(buttonMesh, 'VALUE'),
  35203. pressed: getImmediateChildByName(buttonMesh, 'PRESSED'),
  35204. unpressed: getImmediateChildByName(buttonMesh, 'UNPRESSED')
  35205. };
  35206. if (buttonMeshInfo.value && buttonMeshInfo.pressed && buttonMeshInfo.unpressed) {
  35207. loadedMeshInfo.buttonMeshes[this._mapping.buttons[i]] = buttonMeshInfo;
  35208. }
  35209. else {
  35210. // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.
  35211. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button submesh under mesh with name: ' + buttonMeshName +
  35212. '(VALUE: ' + !!buttonMeshInfo.value +
  35213. ', PRESSED: ' + !!buttonMeshInfo.pressed +
  35214. ', UNPRESSED:' + !!buttonMeshInfo.unpressed +
  35215. ')');
  35216. }
  35217. }
  35218. // Axis Meshes
  35219. for (i = 0; i < this._mapping.axisMeshNames.length; i++) {
  35220. var axisMeshName = this._mapping.axisMeshNames[i];
  35221. if (!axisMeshName) {
  35222. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown axis at index: ' + i);
  35223. continue;
  35224. }
  35225. var axisMesh = getChildByName(rootNode, axisMeshName);
  35226. if (!axisMesh) {
  35227. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis mesh with name: ' + axisMeshName);
  35228. continue;
  35229. }
  35230. var axisMeshInfo = {
  35231. index: i,
  35232. value: getImmediateChildByName(axisMesh, 'VALUE'),
  35233. min: getImmediateChildByName(axisMesh, 'MIN'),
  35234. max: getImmediateChildByName(axisMesh, 'MAX')
  35235. };
  35236. if (axisMeshInfo.value && axisMeshInfo.min && axisMeshInfo.max) {
  35237. loadedMeshInfo.axisMeshes[i] = axisMeshInfo;
  35238. }
  35239. else {
  35240. // If we didn't find the mesh, it simply means thit axis won't have transforms applied as mapped axis values change.
  35241. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis submesh under mesh with name: ' + axisMeshName +
  35242. '(VALUE: ' + !!axisMeshInfo.value +
  35243. ', MIN: ' + !!axisMeshInfo.min +
  35244. ', MAX:' + !!axisMeshInfo.max +
  35245. ')');
  35246. }
  35247. }
  35248. // Pointing Ray
  35249. loadedMeshInfo.pointingPoseNode = getChildByName(rootNode, this._mapping.pointingPoseMeshName);
  35250. if (!loadedMeshInfo.pointingPoseNode) {
  35251. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing pointing pose mesh with name: ' + this._mapping.pointingPoseMeshName);
  35252. }
  35253. else {
  35254. this._pointingPoseNode = loadedMeshInfo.pointingPoseNode;
  35255. }
  35256. return loadedMeshInfo;
  35257. // Look through all children recursively. This will return null if no mesh exists with the given name.
  35258. function getChildByName(node, name) {
  35259. return node.getChildren(function (n) { return n.name === name; }, false)[0];
  35260. }
  35261. // Look through only immediate children. This will return null if no mesh exists with the given name.
  35262. function getImmediateChildByName(node, name) {
  35263. return node.getChildren(function (n) { return n.name == name; }, true)[0];
  35264. }
  35265. };
  35266. /**
  35267. * Gets the ray of the controller in the direction the controller is pointing
  35268. * @param length the length the resulting ray should be
  35269. * @returns a ray in the direction the controller is pointing
  35270. */
  35271. WindowsMotionController.prototype.getForwardRay = function (length) {
  35272. if (length === void 0) { length = 100; }
  35273. if (!(this._loadedMeshInfo && this._loadedMeshInfo.pointingPoseNode)) {
  35274. return _super.prototype.getForwardRay.call(this, length);
  35275. }
  35276. var m = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix();
  35277. var origin = m.getTranslation();
  35278. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  35279. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(forward, m);
  35280. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(forwardWorld);
  35281. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, length);
  35282. };
  35283. /**
  35284. * Disposes of the controller
  35285. */
  35286. WindowsMotionController.prototype.dispose = function () {
  35287. _super.prototype.dispose.call(this);
  35288. this.onTrackpadChangedObservable.clear();
  35289. };
  35290. /**
  35291. * The base url used to load the left and right controller models
  35292. */
  35293. WindowsMotionController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/microsoft/';
  35294. /**
  35295. * The name of the left controller model file
  35296. */
  35297. WindowsMotionController.MODEL_LEFT_FILENAME = 'left.glb';
  35298. /**
  35299. * The name of the right controller model file
  35300. */
  35301. WindowsMotionController.MODEL_RIGHT_FILENAME = 'right.glb';
  35302. /**
  35303. * The controller name prefix for this controller type
  35304. */
  35305. WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
  35306. /**
  35307. * The controller id pattern for this controller type
  35308. */
  35309. WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
  35310. return WindowsMotionController;
  35311. }(_webVRController__WEBPACK_IMPORTED_MODULE_7__["WebVRController"]));
  35312. _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35313. canCreate: function (gamepadInfo) {
  35314. return gamepadInfo.id.indexOf(WindowsMotionController.GAMEPAD_ID_PREFIX) === 0;
  35315. },
  35316. create: function (gamepadInfo) {
  35317. return new WindowsMotionController(gamepadInfo);
  35318. }
  35319. });
  35320. /***/ }),
  35321. /***/ "./Gamepads/gamepad.ts":
  35322. /*!*****************************!*\
  35323. !*** ./Gamepads/gamepad.ts ***!
  35324. \*****************************/
  35325. /*! exports provided: StickValues, Gamepad, GenericPad */
  35326. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35327. "use strict";
  35328. __webpack_require__.r(__webpack_exports__);
  35329. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return StickValues; });
  35330. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return Gamepad; });
  35331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return GenericPad; });
  35332. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35333. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  35334. /**
  35335. * Represents a gamepad control stick position
  35336. */
  35337. var StickValues = /** @class */ (function () {
  35338. /**
  35339. * Initializes the gamepad x and y control stick values
  35340. * @param x The x component of the gamepad control stick value
  35341. * @param y The y component of the gamepad control stick value
  35342. */
  35343. function StickValues(
  35344. /**
  35345. * The x component of the control stick
  35346. */
  35347. x,
  35348. /**
  35349. * The y component of the control stick
  35350. */
  35351. y) {
  35352. this.x = x;
  35353. this.y = y;
  35354. }
  35355. return StickValues;
  35356. }());
  35357. /**
  35358. * Represents a gamepad
  35359. */
  35360. var Gamepad = /** @class */ (function () {
  35361. /**
  35362. * Initializes the gamepad
  35363. * @param id The id of the gamepad
  35364. * @param index The index of the gamepad
  35365. * @param browserGamepad The browser gamepad
  35366. * @param leftStickX The x component of the left joystick
  35367. * @param leftStickY The y component of the left joystick
  35368. * @param rightStickX The x component of the right joystick
  35369. * @param rightStickY The y component of the right joystick
  35370. */
  35371. function Gamepad(
  35372. /**
  35373. * The id of the gamepad
  35374. */
  35375. id,
  35376. /**
  35377. * The index of the gamepad
  35378. */
  35379. index,
  35380. /**
  35381. * The browser gamepad
  35382. */
  35383. browserGamepad, leftStickX, leftStickY, rightStickX, rightStickY) {
  35384. if (leftStickX === void 0) { leftStickX = 0; }
  35385. if (leftStickY === void 0) { leftStickY = 1; }
  35386. if (rightStickX === void 0) { rightStickX = 2; }
  35387. if (rightStickY === void 0) { rightStickY = 3; }
  35388. this.id = id;
  35389. this.index = index;
  35390. this.browserGamepad = browserGamepad;
  35391. this._leftStick = { x: 0, y: 0 };
  35392. this._rightStick = { x: 0, y: 0 };
  35393. /** @hidden */
  35394. this._isConnected = true;
  35395. /**
  35396. * Specifies whether the left control stick should be Y-inverted
  35397. */
  35398. this._invertLeftStickY = false;
  35399. this.type = Gamepad.GAMEPAD;
  35400. this._leftStickAxisX = leftStickX;
  35401. this._leftStickAxisY = leftStickY;
  35402. this._rightStickAxisX = rightStickX;
  35403. this._rightStickAxisY = rightStickY;
  35404. if (this.browserGamepad.axes.length >= 2) {
  35405. this._leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  35406. }
  35407. if (this.browserGamepad.axes.length >= 4) {
  35408. this._rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  35409. }
  35410. }
  35411. Object.defineProperty(Gamepad.prototype, "isConnected", {
  35412. /**
  35413. * Specifies if the gamepad has been connected
  35414. */
  35415. get: function () {
  35416. return this._isConnected;
  35417. },
  35418. enumerable: true,
  35419. configurable: true
  35420. });
  35421. /**
  35422. * Callback triggered when the left joystick has changed
  35423. * @param callback
  35424. */
  35425. Gamepad.prototype.onleftstickchanged = function (callback) {
  35426. this._onleftstickchanged = callback;
  35427. };
  35428. /**
  35429. * Callback triggered when the right joystick has changed
  35430. * @param callback
  35431. */
  35432. Gamepad.prototype.onrightstickchanged = function (callback) {
  35433. this._onrightstickchanged = callback;
  35434. };
  35435. Object.defineProperty(Gamepad.prototype, "leftStick", {
  35436. /**
  35437. * Gets the left joystick
  35438. */
  35439. get: function () {
  35440. return this._leftStick;
  35441. },
  35442. /**
  35443. * Sets the left joystick values
  35444. */
  35445. set: function (newValues) {
  35446. if (this._onleftstickchanged && (this._leftStick.x !== newValues.x || this._leftStick.y !== newValues.y)) {
  35447. this._onleftstickchanged(newValues);
  35448. }
  35449. this._leftStick = newValues;
  35450. },
  35451. enumerable: true,
  35452. configurable: true
  35453. });
  35454. Object.defineProperty(Gamepad.prototype, "rightStick", {
  35455. /**
  35456. * Gets the right joystick
  35457. */
  35458. get: function () {
  35459. return this._rightStick;
  35460. },
  35461. /**
  35462. * Sets the right joystick value
  35463. */
  35464. set: function (newValues) {
  35465. if (this._onrightstickchanged && (this._rightStick.x !== newValues.x || this._rightStick.y !== newValues.y)) {
  35466. this._onrightstickchanged(newValues);
  35467. }
  35468. this._rightStick = newValues;
  35469. },
  35470. enumerable: true,
  35471. configurable: true
  35472. });
  35473. /**
  35474. * Updates the gamepad joystick positions
  35475. */
  35476. Gamepad.prototype.update = function () {
  35477. if (this._leftStick) {
  35478. this.leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  35479. if (this._invertLeftStickY) {
  35480. this.leftStick.y *= -1;
  35481. }
  35482. }
  35483. if (this._rightStick) {
  35484. this.rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  35485. }
  35486. };
  35487. /**
  35488. * Disposes the gamepad
  35489. */
  35490. Gamepad.prototype.dispose = function () {
  35491. };
  35492. /**
  35493. * Represents a gamepad controller
  35494. */
  35495. Gamepad.GAMEPAD = 0;
  35496. /**
  35497. * Represents a generic controller
  35498. */
  35499. Gamepad.GENERIC = 1;
  35500. /**
  35501. * Represents an XBox controller
  35502. */
  35503. Gamepad.XBOX = 2;
  35504. /**
  35505. * Represents a pose-enabled controller
  35506. */
  35507. Gamepad.POSE_ENABLED = 3;
  35508. return Gamepad;
  35509. }());
  35510. /**
  35511. * Represents a generic gamepad
  35512. */
  35513. var GenericPad = /** @class */ (function (_super) {
  35514. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericPad, _super);
  35515. /**
  35516. * Initializes the generic gamepad
  35517. * @param id The id of the generic gamepad
  35518. * @param index The index of the generic gamepad
  35519. * @param browserGamepad The browser gamepad
  35520. */
  35521. function GenericPad(id, index, browserGamepad) {
  35522. var _this = _super.call(this, id, index, browserGamepad) || this;
  35523. /**
  35524. * Observable triggered when a button has been pressed
  35525. */
  35526. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35527. /**
  35528. * Observable triggered when a button has been released
  35529. */
  35530. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35531. _this.type = Gamepad.GENERIC;
  35532. _this._buttons = new Array(browserGamepad.buttons.length);
  35533. return _this;
  35534. }
  35535. /**
  35536. * Callback triggered when a button has been pressed
  35537. * @param callback Called when a button has been pressed
  35538. */
  35539. GenericPad.prototype.onbuttondown = function (callback) {
  35540. this._onbuttondown = callback;
  35541. };
  35542. /**
  35543. * Callback triggered when a button has been released
  35544. * @param callback Called when a button has been released
  35545. */
  35546. GenericPad.prototype.onbuttonup = function (callback) {
  35547. this._onbuttonup = callback;
  35548. };
  35549. GenericPad.prototype._setButtonValue = function (newValue, currentValue, buttonIndex) {
  35550. if (newValue !== currentValue) {
  35551. if (newValue === 1) {
  35552. if (this._onbuttondown) {
  35553. this._onbuttondown(buttonIndex);
  35554. }
  35555. this.onButtonDownObservable.notifyObservers(buttonIndex);
  35556. }
  35557. if (newValue === 0) {
  35558. if (this._onbuttonup) {
  35559. this._onbuttonup(buttonIndex);
  35560. }
  35561. this.onButtonUpObservable.notifyObservers(buttonIndex);
  35562. }
  35563. }
  35564. return newValue;
  35565. };
  35566. /**
  35567. * Updates the generic gamepad
  35568. */
  35569. GenericPad.prototype.update = function () {
  35570. _super.prototype.update.call(this);
  35571. for (var index = 0; index < this._buttons.length; index++) {
  35572. this._buttons[index] = this._setButtonValue(this.browserGamepad.buttons[index].value, this._buttons[index], index);
  35573. }
  35574. };
  35575. /**
  35576. * Disposes the generic gamepad
  35577. */
  35578. GenericPad.prototype.dispose = function () {
  35579. _super.prototype.dispose.call(this);
  35580. this.onButtonDownObservable.clear();
  35581. this.onButtonUpObservable.clear();
  35582. };
  35583. return GenericPad;
  35584. }(Gamepad));
  35585. /***/ }),
  35586. /***/ "./Gamepads/gamepadManager.ts":
  35587. /*!************************************!*\
  35588. !*** ./Gamepads/gamepadManager.ts ***!
  35589. \************************************/
  35590. /*! exports provided: GamepadManager */
  35591. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35592. "use strict";
  35593. __webpack_require__.r(__webpack_exports__);
  35594. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return GamepadManager; });
  35595. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  35596. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  35597. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  35598. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35599. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  35600. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  35601. /**
  35602. * Manager for handling gamepads
  35603. */
  35604. var GamepadManager = /** @class */ (function () {
  35605. /**
  35606. * Initializes the gamepad manager
  35607. * @param _scene BabylonJS scene
  35608. */
  35609. function GamepadManager(_scene) {
  35610. var _this = this;
  35611. this._scene = _scene;
  35612. this._babylonGamepads = [];
  35613. this._oneGamepadConnected = false;
  35614. /** @hidden */
  35615. this._isMonitoring = false;
  35616. /**
  35617. * observable to be triggered when the gamepad controller has been disconnected
  35618. */
  35619. this.onGamepadDisconnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35620. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  35621. this._gamepadEventSupported = false;
  35622. }
  35623. else {
  35624. this._gamepadEventSupported = 'GamepadEvent' in window;
  35625. this._gamepadSupport = (navigator.getGamepads ||
  35626. navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
  35627. }
  35628. this.onGamepadConnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"](function (observer) {
  35629. // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
  35630. for (var i in _this._babylonGamepads) {
  35631. var gamepad = _this._babylonGamepads[i];
  35632. if (gamepad && gamepad._isConnected) {
  35633. _this.onGamepadConnectedObservable.notifyObserver(observer, gamepad);
  35634. }
  35635. }
  35636. });
  35637. this._onGamepadConnectedEvent = function (evt) {
  35638. var gamepad = evt.gamepad;
  35639. if (gamepad.index in _this._babylonGamepads) {
  35640. if (_this._babylonGamepads[gamepad.index].isConnected) {
  35641. return;
  35642. }
  35643. }
  35644. var newGamepad;
  35645. if (_this._babylonGamepads[gamepad.index]) {
  35646. newGamepad = _this._babylonGamepads[gamepad.index];
  35647. newGamepad.browserGamepad = gamepad;
  35648. newGamepad._isConnected = true;
  35649. }
  35650. else {
  35651. newGamepad = _this._addNewGamepad(gamepad);
  35652. }
  35653. _this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  35654. _this._startMonitoringGamepads();
  35655. };
  35656. this._onGamepadDisconnectedEvent = function (evt) {
  35657. var gamepad = evt.gamepad;
  35658. // Remove the gamepad from the list of gamepads to monitor.
  35659. for (var i in _this._babylonGamepads) {
  35660. if (_this._babylonGamepads[i].index === gamepad.index) {
  35661. var disconnectedGamepad = _this._babylonGamepads[i];
  35662. disconnectedGamepad._isConnected = false;
  35663. _this.onGamepadDisconnectedObservable.notifyObservers(disconnectedGamepad);
  35664. break;
  35665. }
  35666. }
  35667. };
  35668. if (this._gamepadSupport) {
  35669. //first add already-connected gamepads
  35670. this._updateGamepadObjects();
  35671. if (this._babylonGamepads.length) {
  35672. this._startMonitoringGamepads();
  35673. }
  35674. // Checking if the gamepad connected event is supported (like in Firefox)
  35675. if (this._gamepadEventSupported) {
  35676. window.addEventListener('gamepadconnected', this._onGamepadConnectedEvent, false);
  35677. window.addEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent, false);
  35678. }
  35679. else {
  35680. this._startMonitoringGamepads();
  35681. }
  35682. }
  35683. }
  35684. Object.defineProperty(GamepadManager.prototype, "gamepads", {
  35685. /**
  35686. * The gamepads in the game pad manager
  35687. */
  35688. get: function () {
  35689. return this._babylonGamepads;
  35690. },
  35691. enumerable: true,
  35692. configurable: true
  35693. });
  35694. /**
  35695. * Get the gamepad controllers based on type
  35696. * @param type The type of gamepad controller
  35697. * @returns Nullable gamepad
  35698. */
  35699. GamepadManager.prototype.getGamepadByType = function (type) {
  35700. if (type === void 0) { type = _gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].XBOX; }
  35701. for (var _i = 0, _a = this._babylonGamepads; _i < _a.length; _i++) {
  35702. var gamepad = _a[_i];
  35703. if (gamepad && gamepad.type === type) {
  35704. return gamepad;
  35705. }
  35706. }
  35707. return null;
  35708. };
  35709. /**
  35710. * Disposes the gamepad manager
  35711. */
  35712. GamepadManager.prototype.dispose = function () {
  35713. if (this._gamepadEventSupported) {
  35714. if (this._onGamepadConnectedEvent) {
  35715. window.removeEventListener('gamepadconnected', this._onGamepadConnectedEvent);
  35716. }
  35717. if (this._onGamepadDisconnectedEvent) {
  35718. window.removeEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent);
  35719. }
  35720. this._onGamepadConnectedEvent = null;
  35721. this._onGamepadDisconnectedEvent = null;
  35722. }
  35723. this._babylonGamepads.forEach(function (gamepad) {
  35724. gamepad.dispose();
  35725. });
  35726. this.onGamepadConnectedObservable.clear();
  35727. this.onGamepadDisconnectedObservable.clear();
  35728. this._oneGamepadConnected = false;
  35729. this._stopMonitoringGamepads();
  35730. this._babylonGamepads = [];
  35731. };
  35732. GamepadManager.prototype._addNewGamepad = function (gamepad) {
  35733. if (!this._oneGamepadConnected) {
  35734. this._oneGamepadConnected = true;
  35735. }
  35736. var newGamepad;
  35737. var xboxOne = (gamepad.id.search("Xbox One") !== -1);
  35738. if (xboxOne || gamepad.id.search("Xbox 360") !== -1 || gamepad.id.search("xinput") !== -1) {
  35739. newGamepad = new _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"](gamepad.id, gamepad.index, gamepad, xboxOne);
  35740. }
  35741. // if pose is supported, use the (WebVR) pose enabled controller
  35742. else if (gamepad.pose) {
  35743. newGamepad = _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"].InitiateController(gamepad);
  35744. }
  35745. else {
  35746. newGamepad = new _gamepad__WEBPACK_IMPORTED_MODULE_5__["GenericPad"](gamepad.id, gamepad.index, gamepad);
  35747. }
  35748. this._babylonGamepads[newGamepad.index] = newGamepad;
  35749. return newGamepad;
  35750. };
  35751. GamepadManager.prototype._startMonitoringGamepads = function () {
  35752. if (!this._isMonitoring) {
  35753. this._isMonitoring = true;
  35754. //back-comp
  35755. if (!this._scene) {
  35756. this._checkGamepadsStatus();
  35757. }
  35758. }
  35759. };
  35760. GamepadManager.prototype._stopMonitoringGamepads = function () {
  35761. this._isMonitoring = false;
  35762. };
  35763. /** @hidden */
  35764. GamepadManager.prototype._checkGamepadsStatus = function () {
  35765. var _this = this;
  35766. // Hack to be compatible Chrome
  35767. this._updateGamepadObjects();
  35768. for (var i in this._babylonGamepads) {
  35769. var gamepad = this._babylonGamepads[i];
  35770. if (!gamepad || !gamepad.isConnected) {
  35771. continue;
  35772. }
  35773. gamepad.update();
  35774. }
  35775. if (this._isMonitoring && !this._scene) {
  35776. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].QueueNewFrame(function () { _this._checkGamepadsStatus(); });
  35777. }
  35778. };
  35779. // This function is called only on Chrome, which does not properly support
  35780. // connection/disconnection events and forces you to recopy again the gamepad object
  35781. GamepadManager.prototype._updateGamepadObjects = function () {
  35782. var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
  35783. for (var i = 0; i < gamepads.length; i++) {
  35784. var gamepad = gamepads[i];
  35785. if (gamepad) {
  35786. if (!this._babylonGamepads[gamepad.index]) {
  35787. var newGamepad = this._addNewGamepad(gamepad);
  35788. this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  35789. }
  35790. else {
  35791. // Forced to copy again this object for Chrome for unknown reason
  35792. this._babylonGamepads[i].browserGamepad = gamepad;
  35793. if (!this._babylonGamepads[i].isConnected) {
  35794. this._babylonGamepads[i]._isConnected = true;
  35795. this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[i]);
  35796. }
  35797. }
  35798. }
  35799. }
  35800. };
  35801. return GamepadManager;
  35802. }());
  35803. /***/ }),
  35804. /***/ "./Gamepads/gamepadSceneComponent.ts":
  35805. /*!*******************************************!*\
  35806. !*** ./Gamepads/gamepadSceneComponent.ts ***!
  35807. \*******************************************/
  35808. /*! exports provided: GamepadSystemSceneComponent */
  35809. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35810. "use strict";
  35811. __webpack_require__.r(__webpack_exports__);
  35812. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return GamepadSystemSceneComponent; });
  35813. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  35814. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  35815. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  35816. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  35817. /* harmony import */ var _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  35818. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  35819. /* harmony import */ var _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  35820. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "gamepadManager", {
  35821. get: function () {
  35822. if (!this._gamepadManager) {
  35823. this._gamepadManager = new _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"](this);
  35824. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD);
  35825. if (!component) {
  35826. component = new GamepadSystemSceneComponent(this);
  35827. this._addComponent(component);
  35828. }
  35829. }
  35830. return this._gamepadManager;
  35831. },
  35832. enumerable: true,
  35833. configurable: true
  35834. });
  35835. /**
  35836. * Adds a gamepad to the free camera inputs manager
  35837. */
  35838. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addGamepad = function () {
  35839. this.add(new _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraGamepadInput"]());
  35840. return this;
  35841. };
  35842. /**
  35843. * Adds a gamepad to the arc rotate camera inputs manager
  35844. */
  35845. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["ArcRotateCameraInputsManager"].prototype.addGamepad = function () {
  35846. this.add(new _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__["ArcRotateCameraGamepadInput"]());
  35847. return this;
  35848. };
  35849. /**
  35850. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  35851. */
  35852. var GamepadSystemSceneComponent = /** @class */ (function () {
  35853. /**
  35854. * Creates a new instance of the component for the given scene
  35855. * @param scene Defines the scene to register the component in
  35856. */
  35857. function GamepadSystemSceneComponent(scene) {
  35858. /**
  35859. * The component name helpfull to identify the component in the list of scene components.
  35860. */
  35861. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD;
  35862. this.scene = scene;
  35863. }
  35864. /**
  35865. * Registers the component in a given scene
  35866. */
  35867. GamepadSystemSceneComponent.prototype.register = function () {
  35868. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate);
  35869. };
  35870. /**
  35871. * Rebuilds the elements related to this component in case of
  35872. * context lost for instance.
  35873. */
  35874. GamepadSystemSceneComponent.prototype.rebuild = function () {
  35875. // Nothing to do for gamepads
  35876. };
  35877. /**
  35878. * Disposes the component and the associated ressources
  35879. */
  35880. GamepadSystemSceneComponent.prototype.dispose = function () {
  35881. var gamepadManager = this.scene._gamepadManager;
  35882. if (gamepadManager) {
  35883. gamepadManager.dispose();
  35884. this.scene._gamepadManager = null;
  35885. }
  35886. };
  35887. GamepadSystemSceneComponent.prototype._beforeCameraUpdate = function () {
  35888. var gamepadManager = this.scene._gamepadManager;
  35889. if (gamepadManager && gamepadManager._isMonitoring) {
  35890. gamepadManager._checkGamepadsStatus();
  35891. }
  35892. };
  35893. return GamepadSystemSceneComponent;
  35894. }());
  35895. /***/ }),
  35896. /***/ "./Gamepads/index.ts":
  35897. /*!***************************!*\
  35898. !*** ./Gamepads/index.ts ***!
  35899. \***************************/
  35900. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad */
  35901. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35902. "use strict";
  35903. __webpack_require__.r(__webpack_exports__);
  35904. /* harmony import */ var _Controllers_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Controllers/index */ "./Gamepads/Controllers/index.ts");
  35905. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  35906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  35907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  35908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  35909. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  35910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  35911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  35912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  35913. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  35914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  35915. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  35916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["StickValues"]; });
  35917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["Gamepad"]; });
  35918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["GenericPad"]; });
  35919. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  35920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"]; });
  35921. /* harmony import */ var _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  35922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__["GamepadSystemSceneComponent"]; });
  35923. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  35924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Button"]; });
  35925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Dpad"]; });
  35926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"]; });
  35927. /***/ }),
  35928. /***/ "./Gamepads/xboxGamepad.ts":
  35929. /*!*********************************!*\
  35930. !*** ./Gamepads/xboxGamepad.ts ***!
  35931. \*********************************/
  35932. /*! exports provided: Xbox360Button, Xbox360Dpad, Xbox360Pad */
  35933. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35934. "use strict";
  35935. __webpack_require__.r(__webpack_exports__);
  35936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return Xbox360Button; });
  35937. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return Xbox360Dpad; });
  35938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return Xbox360Pad; });
  35939. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35940. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  35941. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  35942. /**
  35943. * Defines supported buttons for XBox360 compatible gamepads
  35944. */
  35945. var Xbox360Button;
  35946. (function (Xbox360Button) {
  35947. /** A */
  35948. Xbox360Button[Xbox360Button["A"] = 0] = "A";
  35949. /** B */
  35950. Xbox360Button[Xbox360Button["B"] = 1] = "B";
  35951. /** X */
  35952. Xbox360Button[Xbox360Button["X"] = 2] = "X";
  35953. /** Y */
  35954. Xbox360Button[Xbox360Button["Y"] = 3] = "Y";
  35955. /** Start */
  35956. Xbox360Button[Xbox360Button["Start"] = 4] = "Start";
  35957. /** Back */
  35958. Xbox360Button[Xbox360Button["Back"] = 5] = "Back";
  35959. /** Left button */
  35960. Xbox360Button[Xbox360Button["LB"] = 6] = "LB";
  35961. /** Right button */
  35962. Xbox360Button[Xbox360Button["RB"] = 7] = "RB";
  35963. /** Left stick */
  35964. Xbox360Button[Xbox360Button["LeftStick"] = 8] = "LeftStick";
  35965. /** Right stick */
  35966. Xbox360Button[Xbox360Button["RightStick"] = 9] = "RightStick";
  35967. })(Xbox360Button || (Xbox360Button = {}));
  35968. /** Defines values for XBox360 DPad */
  35969. var Xbox360Dpad;
  35970. (function (Xbox360Dpad) {
  35971. /** Up */
  35972. Xbox360Dpad[Xbox360Dpad["Up"] = 0] = "Up";
  35973. /** Down */
  35974. Xbox360Dpad[Xbox360Dpad["Down"] = 1] = "Down";
  35975. /** Left */
  35976. Xbox360Dpad[Xbox360Dpad["Left"] = 2] = "Left";
  35977. /** Right */
  35978. Xbox360Dpad[Xbox360Dpad["Right"] = 3] = "Right";
  35979. })(Xbox360Dpad || (Xbox360Dpad = {}));
  35980. /**
  35981. * Defines a XBox360 gamepad
  35982. */
  35983. var Xbox360Pad = /** @class */ (function (_super) {
  35984. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Xbox360Pad, _super);
  35985. /**
  35986. * Creates a new XBox360 gamepad object
  35987. * @param id defines the id of this gamepad
  35988. * @param index defines its index
  35989. * @param gamepad defines the internal HTML gamepad object
  35990. * @param xboxOne defines if it is a XBox One gamepad
  35991. */
  35992. function Xbox360Pad(id, index, gamepad, xboxOne) {
  35993. if (xboxOne === void 0) { xboxOne = false; }
  35994. var _this = _super.call(this, id, index, gamepad, 0, 1, 2, 3) || this;
  35995. _this._leftTrigger = 0;
  35996. _this._rightTrigger = 0;
  35997. /** Observable raised when a button is pressed */
  35998. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35999. /** Observable raised when a button is released */
  36000. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36001. /** Observable raised when a pad is pressed */
  36002. _this.onPadDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36003. /** Observable raised when a pad is released */
  36004. _this.onPadUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36005. _this._buttonA = 0;
  36006. _this._buttonB = 0;
  36007. _this._buttonX = 0;
  36008. _this._buttonY = 0;
  36009. _this._buttonBack = 0;
  36010. _this._buttonStart = 0;
  36011. _this._buttonLB = 0;
  36012. _this._buttonRB = 0;
  36013. _this._buttonLeftStick = 0;
  36014. _this._buttonRightStick = 0;
  36015. _this._dPadUp = 0;
  36016. _this._dPadDown = 0;
  36017. _this._dPadLeft = 0;
  36018. _this._dPadRight = 0;
  36019. _this._isXboxOnePad = false;
  36020. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"].XBOX;
  36021. _this._isXboxOnePad = xboxOne;
  36022. return _this;
  36023. }
  36024. /**
  36025. * Defines the callback to call when left trigger is pressed
  36026. * @param callback defines the callback to use
  36027. */
  36028. Xbox360Pad.prototype.onlefttriggerchanged = function (callback) {
  36029. this._onlefttriggerchanged = callback;
  36030. };
  36031. /**
  36032. * Defines the callback to call when right trigger is pressed
  36033. * @param callback defines the callback to use
  36034. */
  36035. Xbox360Pad.prototype.onrighttriggerchanged = function (callback) {
  36036. this._onrighttriggerchanged = callback;
  36037. };
  36038. Object.defineProperty(Xbox360Pad.prototype, "leftTrigger", {
  36039. /**
  36040. * Gets the left trigger value
  36041. */
  36042. get: function () {
  36043. return this._leftTrigger;
  36044. },
  36045. /**
  36046. * Sets the left trigger value
  36047. */
  36048. set: function (newValue) {
  36049. if (this._onlefttriggerchanged && this._leftTrigger !== newValue) {
  36050. this._onlefttriggerchanged(newValue);
  36051. }
  36052. this._leftTrigger = newValue;
  36053. },
  36054. enumerable: true,
  36055. configurable: true
  36056. });
  36057. Object.defineProperty(Xbox360Pad.prototype, "rightTrigger", {
  36058. /**
  36059. * Gets the right trigger value
  36060. */
  36061. get: function () {
  36062. return this._rightTrigger;
  36063. },
  36064. /**
  36065. * Sets the right trigger value
  36066. */
  36067. set: function (newValue) {
  36068. if (this._onrighttriggerchanged && this._rightTrigger !== newValue) {
  36069. this._onrighttriggerchanged(newValue);
  36070. }
  36071. this._rightTrigger = newValue;
  36072. },
  36073. enumerable: true,
  36074. configurable: true
  36075. });
  36076. /**
  36077. * Defines the callback to call when a button is pressed
  36078. * @param callback defines the callback to use
  36079. */
  36080. Xbox360Pad.prototype.onbuttondown = function (callback) {
  36081. this._onbuttondown = callback;
  36082. };
  36083. /**
  36084. * Defines the callback to call when a button is released
  36085. * @param callback defines the callback to use
  36086. */
  36087. Xbox360Pad.prototype.onbuttonup = function (callback) {
  36088. this._onbuttonup = callback;
  36089. };
  36090. /**
  36091. * Defines the callback to call when a pad is pressed
  36092. * @param callback defines the callback to use
  36093. */
  36094. Xbox360Pad.prototype.ondpaddown = function (callback) {
  36095. this._ondpaddown = callback;
  36096. };
  36097. /**
  36098. * Defines the callback to call when a pad is released
  36099. * @param callback defines the callback to use
  36100. */
  36101. Xbox360Pad.prototype.ondpadup = function (callback) {
  36102. this._ondpadup = callback;
  36103. };
  36104. Xbox360Pad.prototype._setButtonValue = function (newValue, currentValue, buttonType) {
  36105. if (newValue !== currentValue) {
  36106. if (newValue === 1) {
  36107. if (this._onbuttondown) {
  36108. this._onbuttondown(buttonType);
  36109. }
  36110. this.onButtonDownObservable.notifyObservers(buttonType);
  36111. }
  36112. if (newValue === 0) {
  36113. if (this._onbuttonup) {
  36114. this._onbuttonup(buttonType);
  36115. }
  36116. this.onButtonUpObservable.notifyObservers(buttonType);
  36117. }
  36118. }
  36119. return newValue;
  36120. };
  36121. Xbox360Pad.prototype._setDPadValue = function (newValue, currentValue, buttonType) {
  36122. if (newValue !== currentValue) {
  36123. if (newValue === 1) {
  36124. if (this._ondpaddown) {
  36125. this._ondpaddown(buttonType);
  36126. }
  36127. this.onPadDownObservable.notifyObservers(buttonType);
  36128. }
  36129. if (newValue === 0) {
  36130. if (this._ondpadup) {
  36131. this._ondpadup(buttonType);
  36132. }
  36133. this.onPadUpObservable.notifyObservers(buttonType);
  36134. }
  36135. }
  36136. return newValue;
  36137. };
  36138. Object.defineProperty(Xbox360Pad.prototype, "buttonA", {
  36139. /**
  36140. * Gets the value of the `A` button
  36141. */
  36142. get: function () {
  36143. return this._buttonA;
  36144. },
  36145. /**
  36146. * Sets the value of the `A` button
  36147. */
  36148. set: function (value) {
  36149. this._buttonA = this._setButtonValue(value, this._buttonA, Xbox360Button.A);
  36150. },
  36151. enumerable: true,
  36152. configurable: true
  36153. });
  36154. Object.defineProperty(Xbox360Pad.prototype, "buttonB", {
  36155. /**
  36156. * Gets the value of the `B` button
  36157. */
  36158. get: function () {
  36159. return this._buttonB;
  36160. },
  36161. /**
  36162. * Sets the value of the `B` button
  36163. */
  36164. set: function (value) {
  36165. this._buttonB = this._setButtonValue(value, this._buttonB, Xbox360Button.B);
  36166. },
  36167. enumerable: true,
  36168. configurable: true
  36169. });
  36170. Object.defineProperty(Xbox360Pad.prototype, "buttonX", {
  36171. /**
  36172. * Gets the value of the `X` button
  36173. */
  36174. get: function () {
  36175. return this._buttonX;
  36176. },
  36177. /**
  36178. * Sets the value of the `X` button
  36179. */
  36180. set: function (value) {
  36181. this._buttonX = this._setButtonValue(value, this._buttonX, Xbox360Button.X);
  36182. },
  36183. enumerable: true,
  36184. configurable: true
  36185. });
  36186. Object.defineProperty(Xbox360Pad.prototype, "buttonY", {
  36187. /**
  36188. * Gets the value of the `Y` button
  36189. */
  36190. get: function () {
  36191. return this._buttonY;
  36192. },
  36193. /**
  36194. * Sets the value of the `Y` button
  36195. */
  36196. set: function (value) {
  36197. this._buttonY = this._setButtonValue(value, this._buttonY, Xbox360Button.Y);
  36198. },
  36199. enumerable: true,
  36200. configurable: true
  36201. });
  36202. Object.defineProperty(Xbox360Pad.prototype, "buttonStart", {
  36203. /**
  36204. * Gets the value of the `Start` button
  36205. */
  36206. get: function () {
  36207. return this._buttonStart;
  36208. },
  36209. /**
  36210. * Sets the value of the `Start` button
  36211. */
  36212. set: function (value) {
  36213. this._buttonStart = this._setButtonValue(value, this._buttonStart, Xbox360Button.Start);
  36214. },
  36215. enumerable: true,
  36216. configurable: true
  36217. });
  36218. Object.defineProperty(Xbox360Pad.prototype, "buttonBack", {
  36219. /**
  36220. * Gets the value of the `Back` button
  36221. */
  36222. get: function () {
  36223. return this._buttonBack;
  36224. },
  36225. /**
  36226. * Sets the value of the `Back` button
  36227. */
  36228. set: function (value) {
  36229. this._buttonBack = this._setButtonValue(value, this._buttonBack, Xbox360Button.Back);
  36230. },
  36231. enumerable: true,
  36232. configurable: true
  36233. });
  36234. Object.defineProperty(Xbox360Pad.prototype, "buttonLB", {
  36235. /**
  36236. * Gets the value of the `Left` button
  36237. */
  36238. get: function () {
  36239. return this._buttonLB;
  36240. },
  36241. /**
  36242. * Sets the value of the `Left` button
  36243. */
  36244. set: function (value) {
  36245. this._buttonLB = this._setButtonValue(value, this._buttonLB, Xbox360Button.LB);
  36246. },
  36247. enumerable: true,
  36248. configurable: true
  36249. });
  36250. Object.defineProperty(Xbox360Pad.prototype, "buttonRB", {
  36251. /**
  36252. * Gets the value of the `Right` button
  36253. */
  36254. get: function () {
  36255. return this._buttonRB;
  36256. },
  36257. /**
  36258. * Sets the value of the `Right` button
  36259. */
  36260. set: function (value) {
  36261. this._buttonRB = this._setButtonValue(value, this._buttonRB, Xbox360Button.RB);
  36262. },
  36263. enumerable: true,
  36264. configurable: true
  36265. });
  36266. Object.defineProperty(Xbox360Pad.prototype, "buttonLeftStick", {
  36267. /**
  36268. * Gets the value of the Left joystick
  36269. */
  36270. get: function () {
  36271. return this._buttonLeftStick;
  36272. },
  36273. /**
  36274. * Sets the value of the Left joystick
  36275. */
  36276. set: function (value) {
  36277. this._buttonLeftStick = this._setButtonValue(value, this._buttonLeftStick, Xbox360Button.LeftStick);
  36278. },
  36279. enumerable: true,
  36280. configurable: true
  36281. });
  36282. Object.defineProperty(Xbox360Pad.prototype, "buttonRightStick", {
  36283. /**
  36284. * Gets the value of the Right joystick
  36285. */
  36286. get: function () {
  36287. return this._buttonRightStick;
  36288. },
  36289. /**
  36290. * Sets the value of the Right joystick
  36291. */
  36292. set: function (value) {
  36293. this._buttonRightStick = this._setButtonValue(value, this._buttonRightStick, Xbox360Button.RightStick);
  36294. },
  36295. enumerable: true,
  36296. configurable: true
  36297. });
  36298. Object.defineProperty(Xbox360Pad.prototype, "dPadUp", {
  36299. /**
  36300. * Gets the value of D-pad up
  36301. */
  36302. get: function () {
  36303. return this._dPadUp;
  36304. },
  36305. /**
  36306. * Sets the value of D-pad up
  36307. */
  36308. set: function (value) {
  36309. this._dPadUp = this._setDPadValue(value, this._dPadUp, Xbox360Dpad.Up);
  36310. },
  36311. enumerable: true,
  36312. configurable: true
  36313. });
  36314. Object.defineProperty(Xbox360Pad.prototype, "dPadDown", {
  36315. /**
  36316. * Gets the value of D-pad down
  36317. */
  36318. get: function () {
  36319. return this._dPadDown;
  36320. },
  36321. /**
  36322. * Sets the value of D-pad down
  36323. */
  36324. set: function (value) {
  36325. this._dPadDown = this._setDPadValue(value, this._dPadDown, Xbox360Dpad.Down);
  36326. },
  36327. enumerable: true,
  36328. configurable: true
  36329. });
  36330. Object.defineProperty(Xbox360Pad.prototype, "dPadLeft", {
  36331. /**
  36332. * Gets the value of D-pad left
  36333. */
  36334. get: function () {
  36335. return this._dPadLeft;
  36336. },
  36337. /**
  36338. * Sets the value of D-pad left
  36339. */
  36340. set: function (value) {
  36341. this._dPadLeft = this._setDPadValue(value, this._dPadLeft, Xbox360Dpad.Left);
  36342. },
  36343. enumerable: true,
  36344. configurable: true
  36345. });
  36346. Object.defineProperty(Xbox360Pad.prototype, "dPadRight", {
  36347. /**
  36348. * Gets the value of D-pad right
  36349. */
  36350. get: function () {
  36351. return this._dPadRight;
  36352. },
  36353. /**
  36354. * Sets the value of D-pad right
  36355. */
  36356. set: function (value) {
  36357. this._dPadRight = this._setDPadValue(value, this._dPadRight, Xbox360Dpad.Right);
  36358. },
  36359. enumerable: true,
  36360. configurable: true
  36361. });
  36362. /**
  36363. * Force the gamepad to synchronize with device values
  36364. */
  36365. Xbox360Pad.prototype.update = function () {
  36366. _super.prototype.update.call(this);
  36367. if (this._isXboxOnePad) {
  36368. this.buttonA = this.browserGamepad.buttons[0].value;
  36369. this.buttonB = this.browserGamepad.buttons[1].value;
  36370. this.buttonX = this.browserGamepad.buttons[2].value;
  36371. this.buttonY = this.browserGamepad.buttons[3].value;
  36372. this.buttonLB = this.browserGamepad.buttons[4].value;
  36373. this.buttonRB = this.browserGamepad.buttons[5].value;
  36374. this.leftTrigger = this.browserGamepad.axes[2];
  36375. this.rightTrigger = this.browserGamepad.axes[5];
  36376. this.buttonBack = this.browserGamepad.buttons[9].value;
  36377. this.buttonStart = this.browserGamepad.buttons[8].value;
  36378. this.buttonLeftStick = this.browserGamepad.buttons[6].value;
  36379. this.buttonRightStick = this.browserGamepad.buttons[7].value;
  36380. this.dPadUp = this.browserGamepad.buttons[11].value;
  36381. this.dPadDown = this.browserGamepad.buttons[12].value;
  36382. this.dPadLeft = this.browserGamepad.buttons[13].value;
  36383. this.dPadRight = this.browserGamepad.buttons[14].value;
  36384. }
  36385. else {
  36386. this.buttonA = this.browserGamepad.buttons[0].value;
  36387. this.buttonB = this.browserGamepad.buttons[1].value;
  36388. this.buttonX = this.browserGamepad.buttons[2].value;
  36389. this.buttonY = this.browserGamepad.buttons[3].value;
  36390. this.buttonLB = this.browserGamepad.buttons[4].value;
  36391. this.buttonRB = this.browserGamepad.buttons[5].value;
  36392. this.leftTrigger = this.browserGamepad.buttons[6].value;
  36393. this.rightTrigger = this.browserGamepad.buttons[7].value;
  36394. this.buttonBack = this.browserGamepad.buttons[8].value;
  36395. this.buttonStart = this.browserGamepad.buttons[9].value;
  36396. this.buttonLeftStick = this.browserGamepad.buttons[10].value;
  36397. this.buttonRightStick = this.browserGamepad.buttons[11].value;
  36398. this.dPadUp = this.browserGamepad.buttons[12].value;
  36399. this.dPadDown = this.browserGamepad.buttons[13].value;
  36400. this.dPadLeft = this.browserGamepad.buttons[14].value;
  36401. this.dPadRight = this.browserGamepad.buttons[15].value;
  36402. }
  36403. };
  36404. /**
  36405. * Disposes the gamepad
  36406. */
  36407. Xbox360Pad.prototype.dispose = function () {
  36408. _super.prototype.dispose.call(this);
  36409. this.onButtonDownObservable.clear();
  36410. this.onButtonUpObservable.clear();
  36411. this.onPadDownObservable.clear();
  36412. this.onPadUpObservable.clear();
  36413. };
  36414. return Xbox360Pad;
  36415. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"]));
  36416. /***/ }),
  36417. /***/ "./Gizmos/axisDragGizmo.ts":
  36418. /*!*********************************!*\
  36419. !*** ./Gizmos/axisDragGizmo.ts ***!
  36420. \*********************************/
  36421. /*! exports provided: AxisDragGizmo */
  36422. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36423. "use strict";
  36424. __webpack_require__.r(__webpack_exports__);
  36425. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return AxisDragGizmo; });
  36426. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36427. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36428. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  36429. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  36430. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  36431. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  36432. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  36433. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  36434. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  36435. /**
  36436. * Single axis drag gizmo
  36437. */
  36438. var AxisDragGizmo = /** @class */ (function (_super) {
  36439. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisDragGizmo, _super);
  36440. /**
  36441. * Creates an AxisDragGizmo
  36442. * @param gizmoLayer The utility layer the gizmo will be added to
  36443. * @param dragAxis The axis which the gizmo will be able to drag on
  36444. * @param color The color of the gizmo
  36445. */
  36446. function AxisDragGizmo(dragAxis, color, gizmoLayer) {
  36447. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  36448. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  36449. var _this = _super.call(this, gizmoLayer) || this;
  36450. _this._pointerObserver = null;
  36451. /**
  36452. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  36453. */
  36454. _this.snapDistance = 0;
  36455. /**
  36456. * Event that fires each time the gizmo snaps to a new location.
  36457. * * snapDistance is the the change in distance
  36458. */
  36459. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36460. // Create Material
  36461. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  36462. coloredMaterial.disableLighting = true;
  36463. coloredMaterial.emissiveColor = color;
  36464. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  36465. hoverMaterial.disableLighting = true;
  36466. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  36467. // Build mesh on root node
  36468. var arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, coloredMaterial);
  36469. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  36470. arrow.scaling.scaleInPlace(1 / 3);
  36471. arrow.parent = _this._rootMesh;
  36472. var currentSnapDragDistance = 0;
  36473. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  36474. var tmpSnapEvent = { snapDistance: 0 };
  36475. // Add drag behavior to handle events when the gizmo is dragged
  36476. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragAxis: dragAxis });
  36477. _this.dragBehavior.moveAttached = false;
  36478. _this._rootMesh.addBehavior(_this.dragBehavior);
  36479. var localDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  36480. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  36481. _this.dragBehavior.onDragObservable.add(function (event) {
  36482. if (_this.attachedMesh) {
  36483. // Convert delta to local translation if it has a parent
  36484. if (_this.attachedMesh.parent) {
  36485. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  36486. tmpMatrix.setTranslationFromFloats(0, 0, 0);
  36487. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(event.delta, tmpMatrix, localDelta);
  36488. }
  36489. else {
  36490. localDelta.copyFrom(event.delta);
  36491. }
  36492. // Snapping logic
  36493. if (_this.snapDistance == 0) {
  36494. _this.attachedMesh.position.addInPlace(localDelta);
  36495. }
  36496. else {
  36497. currentSnapDragDistance += event.dragDistance;
  36498. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  36499. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  36500. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  36501. localDelta.normalizeToRef(tmpVector);
  36502. tmpVector.scaleInPlace(_this.snapDistance * dragSteps);
  36503. _this.attachedMesh.position.addInPlace(tmpVector);
  36504. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  36505. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  36506. }
  36507. }
  36508. }
  36509. });
  36510. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  36511. if (_this._customMeshSet) {
  36512. return;
  36513. }
  36514. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  36515. var material = isHovered ? hoverMaterial : coloredMaterial;
  36516. _this._rootMesh.getChildMeshes().forEach(function (m) {
  36517. m.material = material;
  36518. if (m.color) {
  36519. m.color = material.emissiveColor;
  36520. }
  36521. });
  36522. });
  36523. return _this;
  36524. }
  36525. /** @hidden */
  36526. AxisDragGizmo._CreateArrow = function (scene, material) {
  36527. var arrow = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  36528. var cylinder = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_4__["MeshBuilder"].CreateCylinder("cylinder", { diameterTop: 0, height: 1.5, diameterBottom: 0.75, tessellation: 96 }, scene);
  36529. var line = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_4__["MeshBuilder"].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);
  36530. line.color = material.emissiveColor;
  36531. cylinder.parent = arrow;
  36532. line.parent = arrow;
  36533. // Position arrow pointing in its drag axis
  36534. cylinder.scaling.scaleInPlace(0.05);
  36535. cylinder.material = material;
  36536. cylinder.rotation.x = Math.PI / 2;
  36537. cylinder.position.z += 0.3;
  36538. line.scaling.scaleInPlace(0.26);
  36539. line.rotation.x = Math.PI / 2;
  36540. line.material = material;
  36541. return arrow;
  36542. };
  36543. /** @hidden */
  36544. AxisDragGizmo._CreateArrowInstance = function (scene, arrow) {
  36545. var instance = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  36546. for (var _i = 0, _a = arrow.getChildMeshes(); _i < _a.length; _i++) {
  36547. var mesh = _a[_i];
  36548. var childInstance = mesh.createInstance(mesh.name);
  36549. childInstance.parent = instance;
  36550. }
  36551. return instance;
  36552. };
  36553. AxisDragGizmo.prototype._attachedMeshChanged = function (value) {
  36554. if (this.dragBehavior) {
  36555. this.dragBehavior.enabled = value ? true : false;
  36556. }
  36557. };
  36558. /**
  36559. * Disposes of the gizmo
  36560. */
  36561. AxisDragGizmo.prototype.dispose = function () {
  36562. this.onSnapObservable.clear();
  36563. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  36564. this.dragBehavior.detach();
  36565. _super.prototype.dispose.call(this);
  36566. };
  36567. return AxisDragGizmo;
  36568. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  36569. /***/ }),
  36570. /***/ "./Gizmos/axisScaleGizmo.ts":
  36571. /*!**********************************!*\
  36572. !*** ./Gizmos/axisScaleGizmo.ts ***!
  36573. \**********************************/
  36574. /*! exports provided: AxisScaleGizmo */
  36575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36576. "use strict";
  36577. __webpack_require__.r(__webpack_exports__);
  36578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return AxisScaleGizmo; });
  36579. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36580. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36581. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  36582. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  36583. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  36584. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  36585. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  36586. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  36587. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  36588. /**
  36589. * Single axis scale gizmo
  36590. */
  36591. var AxisScaleGizmo = /** @class */ (function (_super) {
  36592. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisScaleGizmo, _super);
  36593. /**
  36594. * Creates an AxisScaleGizmo
  36595. * @param gizmoLayer The utility layer the gizmo will be added to
  36596. * @param dragAxis The axis which the gizmo will be able to scale on
  36597. * @param color The color of the gizmo
  36598. */
  36599. function AxisScaleGizmo(dragAxis, color, gizmoLayer) {
  36600. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  36601. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  36602. var _this = _super.call(this, gizmoLayer) || this;
  36603. _this._pointerObserver = null;
  36604. /**
  36605. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  36606. */
  36607. _this.snapDistance = 0;
  36608. /**
  36609. * Event that fires each time the gizmo snaps to a new location.
  36610. * * snapDistance is the the change in distance
  36611. */
  36612. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36613. /**
  36614. * If the scaling operation should be done on all axis (default: false)
  36615. */
  36616. _this.uniformScaling = false;
  36617. // Create Material
  36618. _this._coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  36619. _this._coloredMaterial.disableLighting = true;
  36620. _this._coloredMaterial.emissiveColor = color;
  36621. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  36622. hoverMaterial.disableLighting = true;
  36623. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  36624. // Build mesh on root node
  36625. var arrow = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  36626. var arrowMesh = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_4__["MeshBuilder"].CreateBox("yPosMesh", { size: 0.4 }, gizmoLayer.utilityLayerScene);
  36627. var arrowTail = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_4__["MeshBuilder"].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);
  36628. arrowTail.color = _this._coloredMaterial.emissiveColor;
  36629. arrow.addChild(arrowMesh);
  36630. arrow.addChild(arrowTail);
  36631. // Position arrow pointing in its drag axis
  36632. arrowMesh.scaling.scaleInPlace(0.1);
  36633. arrowMesh.material = _this._coloredMaterial;
  36634. arrowMesh.rotation.x = Math.PI / 2;
  36635. arrowMesh.position.z += 0.3;
  36636. arrowTail.scaling.scaleInPlace(0.26);
  36637. arrowTail.rotation.x = Math.PI / 2;
  36638. arrowTail.material = _this._coloredMaterial;
  36639. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  36640. _this._rootMesh.addChild(arrow);
  36641. arrow.scaling.scaleInPlace(1 / 3);
  36642. // Add drag behavior to handle events when the gizmo is dragged
  36643. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__["PointerDragBehavior"]({ dragAxis: dragAxis });
  36644. _this.dragBehavior.moveAttached = false;
  36645. _this._rootMesh.addBehavior(_this.dragBehavior);
  36646. var currentSnapDragDistance = 0;
  36647. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  36648. var tmpSnapEvent = { snapDistance: 0 };
  36649. _this.dragBehavior.onDragObservable.add(function (event) {
  36650. if (_this.attachedMesh) {
  36651. // Snapping logic
  36652. var snapped = false;
  36653. var dragSteps = 0;
  36654. if (_this.uniformScaling) {
  36655. _this.attachedMesh.scaling.normalizeToRef(tmpVector);
  36656. if (tmpVector.y < 0) {
  36657. tmpVector.scaleInPlace(-1);
  36658. }
  36659. }
  36660. else {
  36661. tmpVector.copyFrom(dragAxis);
  36662. }
  36663. if (_this.snapDistance == 0) {
  36664. tmpVector.scaleToRef(event.dragDistance, tmpVector);
  36665. }
  36666. else {
  36667. currentSnapDragDistance += event.dragDistance;
  36668. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  36669. dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  36670. if (currentSnapDragDistance < 0) {
  36671. dragSteps *= -1;
  36672. }
  36673. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  36674. tmpVector.scaleToRef(_this.snapDistance * dragSteps, tmpVector);
  36675. snapped = true;
  36676. }
  36677. else {
  36678. tmpVector.scaleInPlace(0);
  36679. }
  36680. }
  36681. _this.attachedMesh.scaling.addInPlace(tmpVector);
  36682. if (snapped) {
  36683. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  36684. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  36685. }
  36686. }
  36687. });
  36688. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  36689. if (_this._customMeshSet) {
  36690. return;
  36691. }
  36692. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  36693. var material = isHovered ? hoverMaterial : _this._coloredMaterial;
  36694. _this._rootMesh.getChildMeshes().forEach(function (m) {
  36695. m.material = material;
  36696. if (m.color) {
  36697. m.color = material.emissiveColor;
  36698. }
  36699. });
  36700. });
  36701. return _this;
  36702. }
  36703. AxisScaleGizmo.prototype._attachedMeshChanged = function (value) {
  36704. if (this.dragBehavior) {
  36705. this.dragBehavior.enabled = value ? true : false;
  36706. }
  36707. };
  36708. /**
  36709. * Disposes of the gizmo
  36710. */
  36711. AxisScaleGizmo.prototype.dispose = function () {
  36712. this.onSnapObservable.clear();
  36713. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  36714. this.dragBehavior.detach();
  36715. _super.prototype.dispose.call(this);
  36716. };
  36717. /**
  36718. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  36719. * @param mesh The mesh to replace the default mesh of the gizmo
  36720. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  36721. */
  36722. AxisScaleGizmo.prototype.setCustomMesh = function (mesh, useGizmoMaterial) {
  36723. var _this = this;
  36724. if (useGizmoMaterial === void 0) { useGizmoMaterial = false; }
  36725. _super.prototype.setCustomMesh.call(this, mesh);
  36726. if (useGizmoMaterial) {
  36727. this._rootMesh.getChildMeshes().forEach(function (m) {
  36728. m.material = _this._coloredMaterial;
  36729. if (m.color) {
  36730. m.color = _this._coloredMaterial.emissiveColor;
  36731. }
  36732. });
  36733. this._customMeshSet = false;
  36734. }
  36735. };
  36736. return AxisScaleGizmo;
  36737. }(_gizmo__WEBPACK_IMPORTED_MODULE_7__["Gizmo"]));
  36738. /***/ }),
  36739. /***/ "./Gizmos/boundingBoxGizmo.ts":
  36740. /*!************************************!*\
  36741. !*** ./Gizmos/boundingBoxGizmo.ts ***!
  36742. \************************************/
  36743. /*! exports provided: BoundingBoxGizmo */
  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__, "BoundingBoxGizmo", function() { return BoundingBoxGizmo; });
  36748. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36749. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36750. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  36751. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  36752. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  36753. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  36754. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  36755. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  36756. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  36757. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  36758. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  36759. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Misc/pivotTools */ "./Misc/pivotTools.ts");
  36760. /**
  36761. * Bounding box gizmo
  36762. */
  36763. var BoundingBoxGizmo = /** @class */ (function (_super) {
  36764. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoundingBoxGizmo, _super);
  36765. /**
  36766. * Creates an BoundingBoxGizmo
  36767. * @param gizmoLayer The utility layer the gizmo will be added to
  36768. * @param color The color of the gizmo
  36769. */
  36770. function BoundingBoxGizmo(color, gizmoLayer) {
  36771. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Gray(); }
  36772. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"].DefaultKeepDepthUtilityLayer; }
  36773. var _this = _super.call(this, gizmoLayer) || this;
  36774. _this._boundingDimensions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 1);
  36775. _this._renderObserver = null;
  36776. _this._pointerObserver = null;
  36777. _this._scaleDragSpeed = 0.2;
  36778. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  36779. _this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  36780. _this._tmpRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  36781. /**
  36782. * 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)
  36783. */
  36784. _this.ignoreChildren = false;
  36785. /**
  36786. * 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)
  36787. */
  36788. _this.includeChildPredicate = null;
  36789. /**
  36790. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  36791. */
  36792. _this.rotationSphereSize = 0.1;
  36793. /**
  36794. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  36795. */
  36796. _this.scaleBoxSize = 0.1;
  36797. /**
  36798. * 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)
  36799. */
  36800. _this.fixedDragMeshScreenSize = false;
  36801. /**
  36802. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  36803. */
  36804. _this.fixedDragMeshScreenSizeDistanceFactor = 10;
  36805. /**
  36806. * Fired when a rotation sphere or scale box is dragged
  36807. */
  36808. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36809. /**
  36810. * Fired when a scale box is dragged
  36811. */
  36812. _this.onScaleBoxDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36813. /**
  36814. * Fired when a scale box drag is ended
  36815. */
  36816. _this.onScaleBoxDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36817. /**
  36818. * Fired when a rotation sphere is dragged
  36819. */
  36820. _this.onRotationSphereDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36821. /**
  36822. * Fired when a rotation sphere drag is ended
  36823. */
  36824. _this.onRotationSphereDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36825. /**
  36826. * 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)
  36827. */
  36828. _this.scalePivot = null;
  36829. _this._existingMeshScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  36830. // Dragging
  36831. _this._dragMesh = null;
  36832. _this.pointerDragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]();
  36833. // Do not update the gizmo's scale so it has a fixed size to the object its attached to
  36834. _this._updateScale = false;
  36835. _this._anchorMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("anchor", gizmoLayer.utilityLayerScene);
  36836. // Create Materials
  36837. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_10__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  36838. coloredMaterial.disableLighting = true;
  36839. coloredMaterial.emissiveColor = color;
  36840. var hoverColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_10__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  36841. hoverColoredMaterial.disableLighting = true;
  36842. hoverColoredMaterial.emissiveColor = color.clone().add(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.3, 0.3, 0.3));
  36843. // Build bounding box out of lines
  36844. _this._lineBoundingBox = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  36845. _this._lineBoundingBox.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  36846. var lines = [];
  36847. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].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));
  36848. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].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));
  36849. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].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));
  36850. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].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));
  36851. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].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));
  36852. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].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));
  36853. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].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));
  36854. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].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));
  36855. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].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));
  36856. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].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));
  36857. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].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));
  36858. lines.push(_Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].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));
  36859. lines.forEach(function (l) {
  36860. l.color = color;
  36861. l.position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-_this._boundingDimensions.x / 2, -_this._boundingDimensions.y / 2, -_this._boundingDimensions.z / 2));
  36862. l.isPickable = false;
  36863. _this._lineBoundingBox.addChild(l);
  36864. });
  36865. _this._rootMesh.addChild(_this._lineBoundingBox);
  36866. // Create rotation spheres
  36867. _this._rotateSpheresParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  36868. _this._rotateSpheresParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  36869. var _loop_1 = function (i_1) {
  36870. var sphere = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].CreateSphere("", { diameter: 1 }, gizmoLayer.utilityLayerScene);
  36871. sphere.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  36872. sphere.material = coloredMaterial;
  36873. // Drag behavior
  36874. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]({});
  36875. _dragBehavior.moveAttached = false;
  36876. _dragBehavior.updateDragPlane = false;
  36877. sphere.addBehavior(_dragBehavior);
  36878. var startingTurnDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  36879. var totalTurnAmountOfDrag = 0;
  36880. _dragBehavior.onDragStartObservable.add(function () {
  36881. startingTurnDirection.copyFrom(sphere.forward);
  36882. totalTurnAmountOfDrag = 0;
  36883. });
  36884. _dragBehavior.onDragObservable.add(function (event) {
  36885. _this.onRotationSphereDragObservable.notifyObservers({});
  36886. if (_this.attachedMesh) {
  36887. var originalParent = _this.attachedMesh.parent;
  36888. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  36889. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  36890. return;
  36891. }
  36892. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  36893. var worldDragDirection = startingTurnDirection;
  36894. // Project the world right on to the drag plane
  36895. var toSub = event.dragPlaneNormal.scale(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(event.dragPlaneNormal, worldDragDirection));
  36896. var dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();
  36897. // project drag delta on to the resulting drag axis and rotate based on that
  36898. var projectDist = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());
  36899. // Make rotation relative to size of mesh.
  36900. projectDist = (projectDist / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  36901. // Rotate based on axis
  36902. if (!_this.attachedMesh.rotationQuaternion) {
  36903. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  36904. }
  36905. if (!_this._anchorMesh.rotationQuaternion) {
  36906. _this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this._anchorMesh.rotation.y, _this._anchorMesh.rotation.x, _this._anchorMesh.rotation.z);
  36907. }
  36908. // Do not allow the object to turn more than a full circle
  36909. totalTurnAmountOfDrag += projectDist;
  36910. if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {
  36911. if (i_1 >= 8) {
  36912. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, 0, projectDist, _this._tmpQuaternion);
  36913. }
  36914. else if (i_1 >= 4) {
  36915. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(projectDist, 0, 0, _this._tmpQuaternion);
  36916. }
  36917. else {
  36918. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, projectDist, 0, _this._tmpQuaternion);
  36919. }
  36920. // Rotate around center of bounding box
  36921. _this._anchorMesh.addChild(_this.attachedMesh);
  36922. _this._anchorMesh.rotationQuaternion.multiplyToRef(_this._tmpQuaternion, _this._anchorMesh.rotationQuaternion);
  36923. _this._anchorMesh.removeChild(_this.attachedMesh);
  36924. _this.attachedMesh.setParent(originalParent);
  36925. }
  36926. _this.updateBoundingBox();
  36927. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  36928. }
  36929. _this._updateDummy();
  36930. });
  36931. // Selection/deselection
  36932. _dragBehavior.onDragStartObservable.add(function () {
  36933. _this.onDragStartObservable.notifyObservers({});
  36934. _this._selectNode(sphere);
  36935. });
  36936. _dragBehavior.onDragEndObservable.add(function () {
  36937. _this.onRotationSphereDragEndObservable.notifyObservers({});
  36938. _this._selectNode(null);
  36939. _this._updateDummy();
  36940. });
  36941. this_1._rotateSpheresParent.addChild(sphere);
  36942. };
  36943. var this_1 = this, _dragBehavior;
  36944. for (var i_1 = 0; i_1 < 12; i_1++) {
  36945. _loop_1(i_1);
  36946. }
  36947. _this._rootMesh.addChild(_this._rotateSpheresParent);
  36948. // Create scale cubes
  36949. _this._scaleBoxesParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  36950. _this._scaleBoxesParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  36951. for (var i = 0; i < 2; i++) {
  36952. for (var j = 0; j < 2; j++) {
  36953. var _loop_2 = function () {
  36954. var box = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].CreateBox("", { size: 1 }, gizmoLayer.utilityLayerScene);
  36955. box.material = coloredMaterial;
  36956. // Dragging logic
  36957. var dragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](i == 0 ? -1 : 1, j == 0 ? -1 : 1, k == 0 ? -1 : 1);
  36958. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]({ dragAxis: dragAxis });
  36959. _dragBehavior.moveAttached = false;
  36960. box.addBehavior(_dragBehavior);
  36961. _dragBehavior.onDragObservable.add(function (event) {
  36962. _this.onScaleBoxDragObservable.notifyObservers({});
  36963. if (_this.attachedMesh) {
  36964. var originalParent = _this.attachedMesh.parent;
  36965. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  36966. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  36967. return;
  36968. }
  36969. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  36970. var relativeDragDistance = (event.dragDistance / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  36971. var deltaScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](relativeDragDistance, relativeDragDistance, relativeDragDistance);
  36972. deltaScale.scaleInPlace(_this._scaleDragSpeed);
  36973. _this.updateBoundingBox();
  36974. if (_this.scalePivot) {
  36975. _this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(_this._tmpRotationMatrix);
  36976. // Move anchor to desired pivot point (Bottom left corner + dimension/2)
  36977. _this._boundingDimensions.scaleToRef(0.5, _this._tmpVector);
  36978. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  36979. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  36980. _this._boundingDimensions.multiplyToRef(_this.scalePivot, _this._tmpVector);
  36981. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  36982. _this._anchorMesh.position.addInPlace(_this._tmpVector);
  36983. }
  36984. else {
  36985. // Scale from the position of the opposite corner
  36986. box.absolutePosition.subtractToRef(_this._anchorMesh.position, _this._tmpVector);
  36987. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  36988. }
  36989. _this._anchorMesh.addChild(_this.attachedMesh);
  36990. _this._anchorMesh.scaling.addInPlace(deltaScale);
  36991. if (_this._anchorMesh.scaling.x < 0 || _this._anchorMesh.scaling.y < 0 || _this._anchorMesh.scaling.z < 0) {
  36992. _this._anchorMesh.scaling.subtractInPlace(deltaScale);
  36993. }
  36994. _this._anchorMesh.removeChild(_this.attachedMesh);
  36995. _this.attachedMesh.setParent(originalParent);
  36996. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  36997. }
  36998. _this._updateDummy();
  36999. });
  37000. // Selection/deselection
  37001. _dragBehavior.onDragStartObservable.add(function () {
  37002. _this.onDragStartObservable.notifyObservers({});
  37003. _this._selectNode(box);
  37004. });
  37005. _dragBehavior.onDragEndObservable.add(function () {
  37006. _this.onScaleBoxDragEndObservable.notifyObservers({});
  37007. _this._selectNode(null);
  37008. _this._updateDummy();
  37009. });
  37010. this_2._scaleBoxesParent.addChild(box);
  37011. };
  37012. var this_2 = this, _dragBehavior;
  37013. for (var k = 0; k < 2; k++) {
  37014. _loop_2();
  37015. }
  37016. }
  37017. }
  37018. _this._rootMesh.addChild(_this._scaleBoxesParent);
  37019. // Hover color change
  37020. var pointerIds = new Array();
  37021. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37022. if (!pointerIds[pointerInfo.event.pointerId]) {
  37023. _this._rotateSpheresParent.getChildMeshes().concat(_this._scaleBoxesParent.getChildMeshes()).forEach(function (mesh) {
  37024. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {
  37025. pointerIds[pointerInfo.event.pointerId] = mesh;
  37026. mesh.material = hoverColoredMaterial;
  37027. }
  37028. });
  37029. }
  37030. else {
  37031. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[pointerInfo.event.pointerId]) {
  37032. pointerIds[pointerInfo.event.pointerId].material = coloredMaterial;
  37033. delete pointerIds[pointerInfo.event.pointerId];
  37034. }
  37035. }
  37036. });
  37037. // Update bounding box positions
  37038. _this._renderObserver = _this.gizmoLayer.originalScene.onBeforeRenderObservable.add(function () {
  37039. // Only update the bouding box if scaling has changed
  37040. if (_this.attachedMesh && !_this._existingMeshScale.equals(_this.attachedMesh.scaling)) {
  37041. _this.updateBoundingBox();
  37042. }
  37043. else if (_this.fixedDragMeshScreenSize) {
  37044. _this._updateRotationSpheres();
  37045. _this._updateScaleBoxes();
  37046. }
  37047. // If dragg mesh is enabled and dragging, update the attached mesh pose to match the drag mesh
  37048. if (_this._dragMesh && _this.attachedMesh && _this.pointerDragBehavior.dragging) {
  37049. _this._lineBoundingBox.position.rotateByQuaternionToRef(_this._rootMesh.rotationQuaternion, _this._tmpVector);
  37050. _this.attachedMesh.setAbsolutePosition(_this._dragMesh.position.add(_this._tmpVector.scale(-1)));
  37051. }
  37052. });
  37053. _this.updateBoundingBox();
  37054. return _this;
  37055. }
  37056. BoundingBoxGizmo.prototype._attachedMeshChanged = function (value) {
  37057. var _this = this;
  37058. if (value) {
  37059. // Reset anchor mesh to match attached mesh's scale
  37060. // This is needed to avoid invalid box/sphere position on first drag
  37061. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RemoveAndStorePivotPoint(value);
  37062. var originalParent = value.parent;
  37063. this._anchorMesh.addChild(value);
  37064. this._anchorMesh.removeChild(value);
  37065. value.setParent(originalParent);
  37066. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RestorePivotPoint(value);
  37067. this.updateBoundingBox();
  37068. value.getChildMeshes(false).forEach(function (m) {
  37069. m.markAsDirty("scaling");
  37070. });
  37071. this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function () {
  37072. _this._updateDummy();
  37073. });
  37074. }
  37075. };
  37076. BoundingBoxGizmo.prototype._selectNode = function (selectedMesh) {
  37077. this._rotateSpheresParent.getChildMeshes()
  37078. .concat(this._scaleBoxesParent.getChildMeshes()).forEach(function (m) {
  37079. m.isVisible = (!selectedMesh || m == selectedMesh);
  37080. });
  37081. };
  37082. /**
  37083. * Updates the bounding box information for the Gizmo
  37084. */
  37085. BoundingBoxGizmo.prototype.updateBoundingBox = function () {
  37086. if (this.attachedMesh) {
  37087. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RemoveAndStorePivotPoint(this.attachedMesh);
  37088. var originalParent = this.attachedMesh.parent;
  37089. this.attachedMesh.setParent(null);
  37090. this._update();
  37091. // Rotate based on axis
  37092. if (!this.attachedMesh.rotationQuaternion) {
  37093. this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
  37094. }
  37095. if (!this._anchorMesh.rotationQuaternion) {
  37096. this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);
  37097. }
  37098. this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  37099. // Store original position and reset mesh to origin before computing the bounding box
  37100. this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  37101. this._tmpVector.copyFrom(this.attachedMesh.position);
  37102. this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);
  37103. this.attachedMesh.position.set(0, 0, 0);
  37104. // Update bounding dimensions/positions
  37105. var boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
  37106. boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);
  37107. // Update gizmo to match bounding box scaling and rotation
  37108. this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);
  37109. 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);
  37110. this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position);
  37111. this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);
  37112. this._lineBoundingBox.computeWorldMatrix();
  37113. this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);
  37114. // restore position/rotation values
  37115. this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);
  37116. this.attachedMesh.position.copyFrom(this._tmpVector);
  37117. this.attachedMesh.setParent(originalParent);
  37118. }
  37119. this._updateRotationSpheres();
  37120. this._updateScaleBoxes();
  37121. if (this.attachedMesh) {
  37122. this._existingMeshScale.copyFrom(this.attachedMesh.scaling);
  37123. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_11__["PivotTools"]._RestorePivotPoint(this.attachedMesh);
  37124. }
  37125. };
  37126. BoundingBoxGizmo.prototype._updateRotationSpheres = function () {
  37127. var rotateSpheres = this._rotateSpheresParent.getChildMeshes();
  37128. for (var i = 0; i < 3; i++) {
  37129. for (var j = 0; j < 2; j++) {
  37130. for (var k = 0; k < 2; k++) {
  37131. var index = ((i * 4) + (j * 2)) + k;
  37132. if (i == 0) {
  37133. rotateSpheres[index].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  37134. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37135. 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));
  37136. }
  37137. if (i == 1) {
  37138. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y / 2, this._boundingDimensions.z * k);
  37139. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37140. 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));
  37141. }
  37142. if (i == 2) {
  37143. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y * k, this._boundingDimensions.z / 2);
  37144. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37145. 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));
  37146. }
  37147. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  37148. rotateSpheres[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  37149. var distanceFromCamera = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  37150. rotateSpheres[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  37151. }
  37152. else {
  37153. rotateSpheres[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);
  37154. }
  37155. }
  37156. }
  37157. }
  37158. };
  37159. BoundingBoxGizmo.prototype._updateScaleBoxes = function () {
  37160. var scaleBoxes = this._scaleBoxesParent.getChildMeshes();
  37161. for (var i = 0; i < 2; i++) {
  37162. for (var j = 0; j < 2; j++) {
  37163. for (var k = 0; k < 2; k++) {
  37164. var index = ((i * 4) + (j * 2)) + k;
  37165. if (scaleBoxes[index]) {
  37166. scaleBoxes[index].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  37167. scaleBoxes[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37168. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  37169. scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  37170. var distanceFromCamera = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  37171. scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  37172. }
  37173. else {
  37174. scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
  37175. }
  37176. }
  37177. }
  37178. }
  37179. }
  37180. };
  37181. /**
  37182. * Enables rotation on the specified axis and disables rotation on the others
  37183. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  37184. */
  37185. BoundingBoxGizmo.prototype.setEnabledRotationAxis = function (axis) {
  37186. this._rotateSpheresParent.getChildMeshes().forEach(function (m, i) {
  37187. if (i < 4) {
  37188. m.setEnabled(axis.indexOf("x") != -1);
  37189. }
  37190. else if (i < 8) {
  37191. m.setEnabled(axis.indexOf("y") != -1);
  37192. }
  37193. else {
  37194. m.setEnabled(axis.indexOf("z") != -1);
  37195. }
  37196. });
  37197. };
  37198. /**
  37199. * Enables/disables scaling
  37200. * @param enable if scaling should be enabled
  37201. */
  37202. BoundingBoxGizmo.prototype.setEnabledScaling = function (enable) {
  37203. this._scaleBoxesParent.getChildMeshes().forEach(function (m, i) {
  37204. m.setEnabled(enable);
  37205. });
  37206. };
  37207. BoundingBoxGizmo.prototype._updateDummy = function () {
  37208. if (this._dragMesh) {
  37209. this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());
  37210. this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);
  37211. this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion);
  37212. }
  37213. };
  37214. /**
  37215. * Enables a pointer drag behavior on the bounding box of the gizmo
  37216. */
  37217. BoundingBoxGizmo.prototype.enableDragBehavior = function () {
  37218. this._dragMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreateBox("dummy", 1, this.gizmoLayer.utilityLayerScene);
  37219. this._dragMesh.visibility = 0;
  37220. this._dragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37221. this.pointerDragBehavior.useObjectOrienationForDragging = false;
  37222. this._dragMesh.addBehavior(this.pointerDragBehavior);
  37223. };
  37224. /**
  37225. * Disposes of the gizmo
  37226. */
  37227. BoundingBoxGizmo.prototype.dispose = function () {
  37228. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  37229. this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);
  37230. this._lineBoundingBox.dispose();
  37231. this._rotateSpheresParent.dispose();
  37232. this._scaleBoxesParent.dispose();
  37233. if (this._dragMesh) {
  37234. this._dragMesh.dispose();
  37235. }
  37236. _super.prototype.dispose.call(this);
  37237. };
  37238. /**
  37239. * 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)
  37240. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  37241. * @returns the bounding box mesh with the passed in mesh as a child
  37242. */
  37243. BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox = function (mesh) {
  37244. var makeNotPickable = function (root) {
  37245. root.isPickable = false;
  37246. root.getChildMeshes().forEach(function (c) {
  37247. makeNotPickable(c);
  37248. });
  37249. };
  37250. makeNotPickable(mesh);
  37251. // Reset position to get boudning box from origin with no rotation
  37252. if (!mesh.rotationQuaternion) {
  37253. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
  37254. }
  37255. var oldPos = mesh.position.clone();
  37256. var oldRot = mesh.rotationQuaternion.clone();
  37257. mesh.rotationQuaternion.set(0, 0, 0, 1);
  37258. mesh.position.set(0, 0, 0);
  37259. // Update bounding dimensions/positions
  37260. var box = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__["MeshBuilder"].CreateBox("box", { size: 1 }, mesh.getScene());
  37261. var boundingMinMax = mesh.getHierarchyBoundingVectors();
  37262. boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);
  37263. // Adjust scale to avoid undefined behavior when adding child
  37264. if (box.scaling.y === 0) {
  37265. box.scaling.y = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  37266. }
  37267. if (box.scaling.x === 0) {
  37268. box.scaling.x = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  37269. }
  37270. if (box.scaling.z === 0) {
  37271. box.scaling.z = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  37272. }
  37273. box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);
  37274. // Restore original positions
  37275. mesh.addChild(box);
  37276. mesh.rotationQuaternion.copyFrom(oldRot);
  37277. mesh.position.copyFrom(oldPos);
  37278. // Reverse parenting
  37279. mesh.removeChild(box);
  37280. box.addChild(mesh);
  37281. box.visibility = 0;
  37282. return box;
  37283. };
  37284. /**
  37285. * CustomMeshes are not supported by this gizmo
  37286. * @param mesh The mesh to replace the default mesh of the gizmo
  37287. */
  37288. BoundingBoxGizmo.prototype.setCustomMesh = function (mesh) {
  37289. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("Custom meshes are not supported on this gizmo");
  37290. };
  37291. return BoundingBoxGizmo;
  37292. }(_gizmo__WEBPACK_IMPORTED_MODULE_8__["Gizmo"]));
  37293. /***/ }),
  37294. /***/ "./Gizmos/gizmo.ts":
  37295. /*!*************************!*\
  37296. !*** ./Gizmos/gizmo.ts ***!
  37297. \*************************/
  37298. /*! exports provided: Gizmo */
  37299. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37300. "use strict";
  37301. __webpack_require__.r(__webpack_exports__);
  37302. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return Gizmo; });
  37303. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37304. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  37305. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37306. /**
  37307. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  37308. */
  37309. var Gizmo = /** @class */ (function () {
  37310. /**
  37311. * Creates a gizmo
  37312. * @param gizmoLayer The utility layer the gizmo will be added to
  37313. */
  37314. function Gizmo(
  37315. /** The utility layer the gizmo will be added to */
  37316. gizmoLayer) {
  37317. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37318. var _this = this;
  37319. this.gizmoLayer = gizmoLayer;
  37320. /**
  37321. * Ratio for the scale of the gizmo (Default: 1)
  37322. */
  37323. this.scaleRatio = 1;
  37324. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  37325. /**
  37326. * If a custom mesh has been set (Default: false)
  37327. */
  37328. this._customMeshSet = false;
  37329. /**
  37330. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  37331. */
  37332. this.updateGizmoRotationToMatchAttachedMesh = true;
  37333. /**
  37334. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  37335. */
  37336. this.updateGizmoPositionToMatchAttachedMesh = true;
  37337. /**
  37338. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  37339. */
  37340. this._updateScale = true;
  37341. this._interactionsEnabled = true;
  37342. this._tempVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  37343. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]("gizmoRootNode", gizmoLayer.utilityLayerScene);
  37344. this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function () {
  37345. _this._update();
  37346. });
  37347. this.attachedMesh = null;
  37348. }
  37349. Object.defineProperty(Gizmo.prototype, "attachedMesh", {
  37350. /**
  37351. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  37352. * * When set, interactions will be enabled
  37353. */
  37354. get: function () {
  37355. return this._attachedMesh;
  37356. },
  37357. set: function (value) {
  37358. this._attachedMesh = value;
  37359. this._rootMesh.setEnabled(value ? true : false);
  37360. this._attachedMeshChanged(value);
  37361. },
  37362. enumerable: true,
  37363. configurable: true
  37364. });
  37365. /**
  37366. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  37367. * @param mesh The mesh to replace the default mesh of the gizmo
  37368. */
  37369. Gizmo.prototype.setCustomMesh = function (mesh) {
  37370. if (mesh.getScene() != this.gizmoLayer.utilityLayerScene) {
  37371. throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
  37372. }
  37373. this._rootMesh.getChildMeshes().forEach(function (c) {
  37374. c.dispose();
  37375. });
  37376. mesh.parent = this._rootMesh;
  37377. this._customMeshSet = true;
  37378. };
  37379. Gizmo.prototype._attachedMeshChanged = function (value) {
  37380. };
  37381. /**
  37382. * @hidden
  37383. * Updates the gizmo to match the attached mesh's position/rotation
  37384. */
  37385. Gizmo.prototype._update = function () {
  37386. if (this.attachedMesh) {
  37387. if (this.updateGizmoRotationToMatchAttachedMesh) {
  37388. if (!this._rootMesh.rotationQuaternion) {
  37389. this._rootMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(this._rootMesh.rotation.y, this._rootMesh.rotation.x, this._rootMesh.rotation.z);
  37390. }
  37391. // Remove scaling before getting rotation matrix to get rotation matrix unmodified by scale
  37392. this._tempVector.copyFrom(this.attachedMesh.scaling);
  37393. if (this.attachedMesh.scaling.x < 0) {
  37394. this.attachedMesh.scaling.x *= -1;
  37395. }
  37396. if (this.attachedMesh.scaling.y < 0) {
  37397. this.attachedMesh.scaling.y *= -1;
  37398. }
  37399. if (this.attachedMesh.scaling.z < 0) {
  37400. this.attachedMesh.scaling.z *= -1;
  37401. }
  37402. this.attachedMesh.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix);
  37403. this.attachedMesh.scaling.copyFrom(this._tempVector);
  37404. this.attachedMesh.computeWorldMatrix();
  37405. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._tmpMatrix, this._rootMesh.rotationQuaternion);
  37406. }
  37407. else if (this._rootMesh.rotationQuaternion) {
  37408. this._rootMesh.rotationQuaternion.set(0, 0, 0, 1);
  37409. }
  37410. if (this.updateGizmoPositionToMatchAttachedMesh) {
  37411. this._rootMesh.position.copyFrom(this.attachedMesh.absolutePosition);
  37412. }
  37413. if (this._updateScale && this.gizmoLayer.utilityLayerScene.activeCamera && this.attachedMesh) {
  37414. var cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition;
  37415. if (this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition) {
  37416. cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition;
  37417. }
  37418. this._rootMesh.position.subtractToRef(cameraPosition, this._tempVector);
  37419. var dist = this._tempVector.length() * this.scaleRatio;
  37420. this._rootMesh.scaling.set(dist, dist, dist);
  37421. }
  37422. }
  37423. };
  37424. /**
  37425. * Disposes of the gizmo
  37426. */
  37427. Gizmo.prototype.dispose = function () {
  37428. this._rootMesh.dispose();
  37429. if (this._beforeRenderObserver) {
  37430. this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  37431. }
  37432. };
  37433. return Gizmo;
  37434. }());
  37435. /***/ }),
  37436. /***/ "./Gizmos/gizmoManager.ts":
  37437. /*!********************************!*\
  37438. !*** ./Gizmos/gizmoManager.ts ***!
  37439. \********************************/
  37440. /*! exports provided: GizmoManager */
  37441. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37442. "use strict";
  37443. __webpack_require__.r(__webpack_exports__);
  37444. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return GizmoManager; });
  37445. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37446. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  37447. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  37448. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37449. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37450. /* harmony import */ var _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  37451. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  37452. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  37453. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  37454. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  37455. /**
  37456. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  37457. */
  37458. var GizmoManager = /** @class */ (function () {
  37459. /**
  37460. * Instatiates a gizmo manager
  37461. * @param scene the scene to overlay the gizmos on top of
  37462. */
  37463. function GizmoManager(scene) {
  37464. var _this = this;
  37465. this.scene = scene;
  37466. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  37467. this.clearGizmoOnEmptyPointerEvent = false;
  37468. /** Fires an event when the manager is attached to a mesh */
  37469. this.onAttachedToMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  37470. this._gizmosEnabled = { positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false };
  37471. this._pointerObserver = null;
  37472. this._attachedMesh = null;
  37473. this._boundingBoxColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromHexString("#0984e3");
  37474. /**
  37475. * When bounding box gizmo is enabled, this can be used to track drag/end events
  37476. */
  37477. this.boundingBoxDragBehavior = new _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]();
  37478. /**
  37479. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  37480. */
  37481. this.attachableMeshes = null;
  37482. /**
  37483. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  37484. */
  37485. this.usePointerToAttachGizmos = true;
  37486. this._defaultKeepDepthUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  37487. this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  37488. this._defaultUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  37489. this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
  37490. // Instatiate/dispose gizmos based on pointer actions
  37491. this._pointerObserver = scene.onPointerObservable.add(function (pointerInfo) {
  37492. if (!_this.usePointerToAttachGizmos) {
  37493. return;
  37494. }
  37495. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  37496. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh) {
  37497. var node = pointerInfo.pickInfo.pickedMesh;
  37498. if (_this.attachableMeshes == null) {
  37499. // Attach to the most parent node
  37500. while (node && node.parent != null) {
  37501. node = node.parent;
  37502. }
  37503. }
  37504. else {
  37505. // Attach to the parent node that is an attachableMesh
  37506. var found = false;
  37507. _this.attachableMeshes.forEach(function (mesh) {
  37508. if (node && (node == mesh || node.isDescendantOf(mesh))) {
  37509. node = mesh;
  37510. found = true;
  37511. }
  37512. });
  37513. if (!found) {
  37514. node = null;
  37515. }
  37516. }
  37517. if (node instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]) {
  37518. if (_this._attachedMesh != node) {
  37519. _this.attachToMesh(node);
  37520. }
  37521. }
  37522. else {
  37523. if (_this.clearGizmoOnEmptyPointerEvent) {
  37524. _this.attachToMesh(null);
  37525. }
  37526. }
  37527. }
  37528. else {
  37529. if (_this.clearGizmoOnEmptyPointerEvent) {
  37530. _this.attachToMesh(null);
  37531. }
  37532. }
  37533. }
  37534. });
  37535. }
  37536. /**
  37537. * Attaches a set of gizmos to the specified mesh
  37538. * @param mesh The mesh the gizmo's should be attached to
  37539. */
  37540. GizmoManager.prototype.attachToMesh = function (mesh) {
  37541. if (this._attachedMesh) {
  37542. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  37543. }
  37544. this._attachedMesh = mesh;
  37545. for (var key in this.gizmos) {
  37546. var gizmo = (this.gizmos[key]);
  37547. if (gizmo && this._gizmosEnabled[key]) {
  37548. gizmo.attachedMesh = mesh;
  37549. }
  37550. }
  37551. if (this.boundingBoxGizmoEnabled && this._attachedMesh) {
  37552. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  37553. }
  37554. this.onAttachedToMeshObservable.notifyObservers(mesh);
  37555. };
  37556. Object.defineProperty(GizmoManager.prototype, "positionGizmoEnabled", {
  37557. get: function () {
  37558. return this._gizmosEnabled.positionGizmo;
  37559. },
  37560. /**
  37561. * If the position gizmo is enabled
  37562. */
  37563. set: function (value) {
  37564. if (value) {
  37565. if (!this.gizmos.positionGizmo) {
  37566. this.gizmos.positionGizmo = new _positionGizmo__WEBPACK_IMPORTED_MODULE_7__["PositionGizmo"](this._defaultUtilityLayer);
  37567. }
  37568. this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
  37569. }
  37570. else if (this.gizmos.positionGizmo) {
  37571. this.gizmos.positionGizmo.attachedMesh = null;
  37572. }
  37573. this._gizmosEnabled.positionGizmo = value;
  37574. },
  37575. enumerable: true,
  37576. configurable: true
  37577. });
  37578. Object.defineProperty(GizmoManager.prototype, "rotationGizmoEnabled", {
  37579. get: function () {
  37580. return this._gizmosEnabled.rotationGizmo;
  37581. },
  37582. /**
  37583. * If the rotation gizmo is enabled
  37584. */
  37585. set: function (value) {
  37586. if (value) {
  37587. if (!this.gizmos.rotationGizmo) {
  37588. this.gizmos.rotationGizmo = new _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__["RotationGizmo"](this._defaultUtilityLayer);
  37589. }
  37590. this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
  37591. }
  37592. else if (this.gizmos.rotationGizmo) {
  37593. this.gizmos.rotationGizmo.attachedMesh = null;
  37594. }
  37595. this._gizmosEnabled.rotationGizmo = value;
  37596. },
  37597. enumerable: true,
  37598. configurable: true
  37599. });
  37600. Object.defineProperty(GizmoManager.prototype, "scaleGizmoEnabled", {
  37601. get: function () {
  37602. return this._gizmosEnabled.scaleGizmo;
  37603. },
  37604. /**
  37605. * If the scale gizmo is enabled
  37606. */
  37607. set: function (value) {
  37608. if (value) {
  37609. this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"](this._defaultUtilityLayer);
  37610. this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;
  37611. }
  37612. else if (this.gizmos.scaleGizmo) {
  37613. this.gizmos.scaleGizmo.attachedMesh = null;
  37614. }
  37615. this._gizmosEnabled.scaleGizmo = value;
  37616. },
  37617. enumerable: true,
  37618. configurable: true
  37619. });
  37620. Object.defineProperty(GizmoManager.prototype, "boundingBoxGizmoEnabled", {
  37621. get: function () {
  37622. return this._gizmosEnabled.boundingBoxGizmo;
  37623. },
  37624. /**
  37625. * If the boundingBox gizmo is enabled
  37626. */
  37627. set: function (value) {
  37628. if (value) {
  37629. this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__["BoundingBoxGizmo"](this._boundingBoxColor, this._defaultKeepDepthUtilityLayer);
  37630. this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;
  37631. if (this._attachedMesh) {
  37632. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  37633. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  37634. }
  37635. }
  37636. else if (this.gizmos.boundingBoxGizmo) {
  37637. this.gizmos.boundingBoxGizmo.attachedMesh = null;
  37638. }
  37639. this._gizmosEnabled.boundingBoxGizmo = value;
  37640. },
  37641. enumerable: true,
  37642. configurable: true
  37643. });
  37644. /**
  37645. * Disposes of the gizmo manager
  37646. */
  37647. GizmoManager.prototype.dispose = function () {
  37648. this.scene.onPointerObservable.remove(this._pointerObserver);
  37649. for (var key in this.gizmos) {
  37650. var gizmo = (this.gizmos[key]);
  37651. if (gizmo) {
  37652. gizmo.dispose();
  37653. }
  37654. }
  37655. this._defaultKeepDepthUtilityLayer.dispose();
  37656. this._defaultUtilityLayer.dispose();
  37657. this.boundingBoxDragBehavior.detach();
  37658. this.onAttachedToMeshObservable.clear();
  37659. };
  37660. return GizmoManager;
  37661. }());
  37662. /***/ }),
  37663. /***/ "./Gizmos/index.ts":
  37664. /*!*************************!*\
  37665. !*** ./Gizmos/index.ts ***!
  37666. \*************************/
  37667. /*! exports provided: AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo */
  37668. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37669. "use strict";
  37670. __webpack_require__.r(__webpack_exports__);
  37671. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  37672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  37673. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  37674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__["AxisScaleGizmo"]; });
  37675. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  37676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__["BoundingBoxGizmo"]; });
  37677. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _gizmo__WEBPACK_IMPORTED_MODULE_3__["Gizmo"]; });
  37679. /* harmony import */ var _gizmoManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmoManager */ "./Gizmos/gizmoManager.ts");
  37680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _gizmoManager__WEBPACK_IMPORTED_MODULE_4__["GizmoManager"]; });
  37681. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  37682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"]; });
  37683. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  37684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _positionGizmo__WEBPACK_IMPORTED_MODULE_6__["PositionGizmo"]; });
  37685. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  37686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__["RotationGizmo"]; });
  37687. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  37688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"]; });
  37689. /***/ }),
  37690. /***/ "./Gizmos/planeRotationGizmo.ts":
  37691. /*!**************************************!*\
  37692. !*** ./Gizmos/planeRotationGizmo.ts ***!
  37693. \**************************************/
  37694. /*! exports provided: PlaneRotationGizmo */
  37695. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37696. "use strict";
  37697. __webpack_require__.r(__webpack_exports__);
  37698. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return PlaneRotationGizmo; });
  37699. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37700. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37701. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37702. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  37703. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  37704. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37705. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37706. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37707. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37708. /**
  37709. * Single plane rotation gizmo
  37710. */
  37711. var PlaneRotationGizmo = /** @class */ (function (_super) {
  37712. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneRotationGizmo, _super);
  37713. /**
  37714. * Creates a PlaneRotationGizmo
  37715. * @param gizmoLayer The utility layer the gizmo will be added to
  37716. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  37717. * @param color The color of the gizmo
  37718. * @param tessellation Amount of tessellation to be used when creating rotation circles
  37719. */
  37720. function PlaneRotationGizmo(planeNormal, color, gizmoLayer, tessellation) {
  37721. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  37722. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37723. if (tessellation === void 0) { tessellation = 32; }
  37724. var _this = _super.call(this, gizmoLayer) || this;
  37725. _this._pointerObserver = null;
  37726. /**
  37727. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  37728. */
  37729. _this.snapDistance = 0;
  37730. /**
  37731. * Event that fires each time the gizmo snaps to a new location.
  37732. * * snapDistance is the the change in distance
  37733. */
  37734. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37735. // Create Material
  37736. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37737. coloredMaterial.disableLighting = true;
  37738. coloredMaterial.emissiveColor = color;
  37739. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37740. hoverMaterial.disableLighting = true;
  37741. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  37742. // Build mesh on root node
  37743. var parentMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37744. // Create circle out of lines
  37745. var radius = 0.8;
  37746. var points = new Array();
  37747. for (var i = 0; i < tessellation; i++) {
  37748. var radian = (2 * Math.PI) * (i / (tessellation - 1));
  37749. points.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](radius * Math.sin(radian), 0, radius * Math.cos(radian)));
  37750. }
  37751. var rotationMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateLines("", points, gizmoLayer.utilityLayerScene);
  37752. rotationMesh.color = coloredMaterial.emissiveColor;
  37753. // Position arrow pointing in its drag axis
  37754. rotationMesh.scaling.scaleInPlace(0.26);
  37755. rotationMesh.material = coloredMaterial;
  37756. rotationMesh.rotation.x = Math.PI / 2;
  37757. parentMesh.addChild(rotationMesh);
  37758. parentMesh.lookAt(_this._rootMesh.position.add(planeNormal));
  37759. _this._rootMesh.addChild(parentMesh);
  37760. parentMesh.scaling.scaleInPlace(1 / 3);
  37761. // Add drag behavior to handle events when the gizmo is dragged
  37762. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragPlaneNormal: planeNormal });
  37763. _this.dragBehavior.moveAttached = false;
  37764. _this.dragBehavior.maxDragAngle = Math.PI * 9 / 20;
  37765. _this.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = true;
  37766. _this._rootMesh.addBehavior(_this.dragBehavior);
  37767. var lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37768. _this.dragBehavior.onDragStartObservable.add(function (e) {
  37769. if (_this.attachedMesh) {
  37770. lastDragPosition.copyFrom(e.dragPlanePoint);
  37771. }
  37772. });
  37773. var rotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  37774. var planeNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37775. var localPlaneNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37776. var tmpSnapEvent = { snapDistance: 0 };
  37777. var currentSnapDragDistance = 0;
  37778. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  37779. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37780. var amountToRotate = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  37781. _this.dragBehavior.onDragObservable.add(function (event) {
  37782. if (_this.attachedMesh) {
  37783. if (!_this.attachedMesh.rotationQuaternion) {
  37784. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  37785. }
  37786. // Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)
  37787. var newVector = event.dragPlanePoint.subtract(_this.attachedMesh.absolutePosition).normalize();
  37788. var originalVector = lastDragPosition.subtract(_this.attachedMesh.absolutePosition).normalize();
  37789. var cross = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(newVector, originalVector);
  37790. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(newVector, originalVector);
  37791. var angle = Math.atan2(cross.length(), dot);
  37792. planeNormalTowardsCamera.copyFrom(planeNormal);
  37793. localPlaneNormalTowardsCamera.copyFrom(planeNormal);
  37794. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  37795. _this.attachedMesh.rotationQuaternion.toRotationMatrix(rotationMatrix);
  37796. localPlaneNormalTowardsCamera = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(planeNormalTowardsCamera, rotationMatrix);
  37797. }
  37798. // Flip up vector depending on which side the camera is on
  37799. if (gizmoLayer.utilityLayerScene.activeCamera) {
  37800. var camVec = gizmoLayer.utilityLayerScene.activeCamera.position.subtract(_this.attachedMesh.position);
  37801. if (_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(camVec, localPlaneNormalTowardsCamera) > 0) {
  37802. planeNormalTowardsCamera.scaleInPlace(-1);
  37803. localPlaneNormalTowardsCamera.scaleInPlace(-1);
  37804. }
  37805. }
  37806. var halfCircleSide = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(localPlaneNormalTowardsCamera, cross) > 0.0;
  37807. if (halfCircleSide) {
  37808. angle = -angle;
  37809. }
  37810. // Snapping logic
  37811. var snapped = false;
  37812. if (_this.snapDistance != 0) {
  37813. currentSnapDragDistance += angle;
  37814. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  37815. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  37816. if (currentSnapDragDistance < 0) {
  37817. dragSteps *= -1;
  37818. }
  37819. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  37820. angle = _this.snapDistance * dragSteps;
  37821. snapped = true;
  37822. }
  37823. else {
  37824. angle = 0;
  37825. }
  37826. }
  37827. // If the mesh has a parent, convert needed world rotation to local rotation
  37828. tmpMatrix.reset();
  37829. if (_this.attachedMesh.parent) {
  37830. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  37831. tmpMatrix.getRotationMatrixToRef(tmpMatrix);
  37832. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(planeNormalTowardsCamera, tmpMatrix, planeNormalTowardsCamera);
  37833. }
  37834. // Convert angle and axis to quaternion (http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm)
  37835. var quaternionCoefficient = Math.sin(angle / 2);
  37836. amountToRotate.set(planeNormalTowardsCamera.x * quaternionCoefficient, planeNormalTowardsCamera.y * quaternionCoefficient, planeNormalTowardsCamera.z * quaternionCoefficient, Math.cos(angle / 2));
  37837. // 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
  37838. if (tmpMatrix.determinant() > 0) {
  37839. amountToRotate.toEulerAnglesToRef(tmpVector);
  37840. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(tmpVector.y, -tmpVector.x, -tmpVector.z, amountToRotate);
  37841. }
  37842. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  37843. // Rotate selected mesh quaternion over fixed axis
  37844. _this.attachedMesh.rotationQuaternion.multiplyToRef(amountToRotate, _this.attachedMesh.rotationQuaternion);
  37845. }
  37846. else {
  37847. // Rotate selected mesh quaternion over rotated axis
  37848. amountToRotate.multiplyToRef(_this.attachedMesh.rotationQuaternion, _this.attachedMesh.rotationQuaternion);
  37849. }
  37850. lastDragPosition.copyFrom(event.dragPlanePoint);
  37851. if (snapped) {
  37852. tmpSnapEvent.snapDistance = angle;
  37853. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  37854. }
  37855. }
  37856. });
  37857. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37858. if (_this._customMeshSet) {
  37859. return;
  37860. }
  37861. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  37862. var material = isHovered ? hoverMaterial : coloredMaterial;
  37863. _this._rootMesh.getChildMeshes().forEach(function (m) {
  37864. m.material = material;
  37865. if (m.color) {
  37866. m.color = material.emissiveColor;
  37867. }
  37868. });
  37869. });
  37870. return _this;
  37871. }
  37872. PlaneRotationGizmo.prototype._attachedMeshChanged = function (value) {
  37873. if (this.dragBehavior) {
  37874. this.dragBehavior.enabled = value ? true : false;
  37875. }
  37876. };
  37877. /**
  37878. * Disposes of the gizmo
  37879. */
  37880. PlaneRotationGizmo.prototype.dispose = function () {
  37881. this.onSnapObservable.clear();
  37882. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  37883. this.dragBehavior.detach();
  37884. _super.prototype.dispose.call(this);
  37885. };
  37886. return PlaneRotationGizmo;
  37887. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  37888. /***/ }),
  37889. /***/ "./Gizmos/positionGizmo.ts":
  37890. /*!*********************************!*\
  37891. !*** ./Gizmos/positionGizmo.ts ***!
  37892. \*********************************/
  37893. /*! exports provided: PositionGizmo */
  37894. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37895. "use strict";
  37896. __webpack_require__.r(__webpack_exports__);
  37897. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return PositionGizmo; });
  37898. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37899. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  37900. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37901. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37902. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37903. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  37904. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37905. /**
  37906. * Gizmo that enables dragging a mesh along 3 axis
  37907. */
  37908. var PositionGizmo = /** @class */ (function (_super) {
  37909. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PositionGizmo, _super);
  37910. /**
  37911. * Creates a PositionGizmo
  37912. * @param gizmoLayer The utility layer the gizmo will be added to
  37913. */
  37914. function PositionGizmo(gizmoLayer) {
  37915. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37916. var _this = _super.call(this, gizmoLayer) || this;
  37917. /** Fires an event when any of it's sub gizmos are dragged */
  37918. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  37919. /** Fires an event when any of it's sub gizmos are released from dragging */
  37920. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  37921. _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);
  37922. _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);
  37923. _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);
  37924. // Relay drag events
  37925. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  37926. gizmo.dragBehavior.onDragStartObservable.add(function () {
  37927. _this.onDragStartObservable.notifyObservers({});
  37928. });
  37929. gizmo.dragBehavior.onDragEndObservable.add(function () {
  37930. _this.onDragEndObservable.notifyObservers({});
  37931. });
  37932. });
  37933. _this.attachedMesh = null;
  37934. return _this;
  37935. }
  37936. Object.defineProperty(PositionGizmo.prototype, "attachedMesh", {
  37937. set: function (mesh) {
  37938. if (this.xGizmo) {
  37939. this.xGizmo.attachedMesh = mesh;
  37940. this.yGizmo.attachedMesh = mesh;
  37941. this.zGizmo.attachedMesh = mesh;
  37942. }
  37943. },
  37944. enumerable: true,
  37945. configurable: true
  37946. });
  37947. Object.defineProperty(PositionGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  37948. get: function () {
  37949. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  37950. },
  37951. set: function (value) {
  37952. if (this.xGizmo) {
  37953. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  37954. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  37955. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  37956. }
  37957. },
  37958. enumerable: true,
  37959. configurable: true
  37960. });
  37961. Object.defineProperty(PositionGizmo.prototype, "snapDistance", {
  37962. get: function () {
  37963. return this.xGizmo.snapDistance;
  37964. },
  37965. /**
  37966. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  37967. */
  37968. set: function (value) {
  37969. if (this.xGizmo) {
  37970. this.xGizmo.snapDistance = value;
  37971. this.yGizmo.snapDistance = value;
  37972. this.zGizmo.snapDistance = value;
  37973. }
  37974. },
  37975. enumerable: true,
  37976. configurable: true
  37977. });
  37978. Object.defineProperty(PositionGizmo.prototype, "scaleRatio", {
  37979. get: function () {
  37980. return this.xGizmo.scaleRatio;
  37981. },
  37982. /**
  37983. * Ratio for the scale of the gizmo (Default: 1)
  37984. */
  37985. set: function (value) {
  37986. if (this.xGizmo) {
  37987. this.xGizmo.scaleRatio = value;
  37988. this.yGizmo.scaleRatio = value;
  37989. this.zGizmo.scaleRatio = value;
  37990. }
  37991. },
  37992. enumerable: true,
  37993. configurable: true
  37994. });
  37995. /**
  37996. * Disposes of the gizmo
  37997. */
  37998. PositionGizmo.prototype.dispose = function () {
  37999. this.xGizmo.dispose();
  38000. this.yGizmo.dispose();
  38001. this.zGizmo.dispose();
  38002. this.onDragStartObservable.clear();
  38003. this.onDragEndObservable.clear();
  38004. };
  38005. /**
  38006. * CustomMeshes are not supported by this gizmo
  38007. * @param mesh The mesh to replace the default mesh of the gizmo
  38008. */
  38009. PositionGizmo.prototype.setCustomMesh = function (mesh) {
  38010. _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)");
  38011. };
  38012. return PositionGizmo;
  38013. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  38014. /***/ }),
  38015. /***/ "./Gizmos/rotationGizmo.ts":
  38016. /*!*********************************!*\
  38017. !*** ./Gizmos/rotationGizmo.ts ***!
  38018. \*********************************/
  38019. /*! exports provided: RotationGizmo */
  38020. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38021. "use strict";
  38022. __webpack_require__.r(__webpack_exports__);
  38023. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return RotationGizmo; });
  38024. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38025. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38026. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38027. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38028. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38029. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  38030. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38031. /**
  38032. * Gizmo that enables rotating a mesh along 3 axis
  38033. */
  38034. var RotationGizmo = /** @class */ (function (_super) {
  38035. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RotationGizmo, _super);
  38036. /**
  38037. * Creates a RotationGizmo
  38038. * @param gizmoLayer The utility layer the gizmo will be added to
  38039. * @param tessellation Amount of tessellation to be used when creating rotation circles
  38040. */
  38041. function RotationGizmo(gizmoLayer, tessellation) {
  38042. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38043. if (tessellation === void 0) { tessellation = 32; }
  38044. var _this = _super.call(this, gizmoLayer) || this;
  38045. /** Fires an event when any of it's sub gizmos are dragged */
  38046. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38047. /** Fires an event when any of it's sub gizmos are released from dragging */
  38048. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38049. _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);
  38050. _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);
  38051. _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);
  38052. // Relay drag events
  38053. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  38054. gizmo.dragBehavior.onDragStartObservable.add(function () {
  38055. _this.onDragStartObservable.notifyObservers({});
  38056. });
  38057. gizmo.dragBehavior.onDragEndObservable.add(function () {
  38058. _this.onDragEndObservable.notifyObservers({});
  38059. });
  38060. });
  38061. _this.attachedMesh = null;
  38062. return _this;
  38063. }
  38064. Object.defineProperty(RotationGizmo.prototype, "attachedMesh", {
  38065. set: function (mesh) {
  38066. if (this.xGizmo) {
  38067. this.xGizmo.attachedMesh = mesh;
  38068. this.yGizmo.attachedMesh = mesh;
  38069. this.zGizmo.attachedMesh = mesh;
  38070. }
  38071. },
  38072. enumerable: true,
  38073. configurable: true
  38074. });
  38075. Object.defineProperty(RotationGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  38076. get: function () {
  38077. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  38078. },
  38079. set: function (value) {
  38080. if (this.xGizmo) {
  38081. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38082. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38083. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38084. }
  38085. },
  38086. enumerable: true,
  38087. configurable: true
  38088. });
  38089. Object.defineProperty(RotationGizmo.prototype, "snapDistance", {
  38090. get: function () {
  38091. return this.xGizmo.snapDistance;
  38092. },
  38093. /**
  38094. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38095. */
  38096. set: function (value) {
  38097. if (this.xGizmo) {
  38098. this.xGizmo.snapDistance = value;
  38099. this.yGizmo.snapDistance = value;
  38100. this.zGizmo.snapDistance = value;
  38101. }
  38102. },
  38103. enumerable: true,
  38104. configurable: true
  38105. });
  38106. Object.defineProperty(RotationGizmo.prototype, "scaleRatio", {
  38107. get: function () {
  38108. return this.xGizmo.scaleRatio;
  38109. },
  38110. /**
  38111. * Ratio for the scale of the gizmo (Default: 1)
  38112. */
  38113. set: function (value) {
  38114. if (this.xGizmo) {
  38115. this.xGizmo.scaleRatio = value;
  38116. this.yGizmo.scaleRatio = value;
  38117. this.zGizmo.scaleRatio = value;
  38118. }
  38119. },
  38120. enumerable: true,
  38121. configurable: true
  38122. });
  38123. /**
  38124. * Disposes of the gizmo
  38125. */
  38126. RotationGizmo.prototype.dispose = function () {
  38127. this.xGizmo.dispose();
  38128. this.yGizmo.dispose();
  38129. this.zGizmo.dispose();
  38130. this.onDragStartObservable.clear();
  38131. this.onDragEndObservable.clear();
  38132. };
  38133. /**
  38134. * CustomMeshes are not supported by this gizmo
  38135. * @param mesh The mesh to replace the default mesh of the gizmo
  38136. */
  38137. RotationGizmo.prototype.setCustomMesh = function (mesh) {
  38138. _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)");
  38139. };
  38140. return RotationGizmo;
  38141. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  38142. /***/ }),
  38143. /***/ "./Gizmos/scaleGizmo.ts":
  38144. /*!******************************!*\
  38145. !*** ./Gizmos/scaleGizmo.ts ***!
  38146. \******************************/
  38147. /*! exports provided: ScaleGizmo */
  38148. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38149. "use strict";
  38150. __webpack_require__.r(__webpack_exports__);
  38151. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return ScaleGizmo; });
  38152. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38153. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38154. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38155. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38156. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38157. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38158. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  38159. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38160. /**
  38161. * Gizmo that enables scaling a mesh along 3 axis
  38162. */
  38163. var ScaleGizmo = /** @class */ (function (_super) {
  38164. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScaleGizmo, _super);
  38165. /**
  38166. * Creates a ScaleGizmo
  38167. * @param gizmoLayer The utility layer the gizmo will be added to
  38168. */
  38169. function ScaleGizmo(gizmoLayer) {
  38170. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38171. var _this = _super.call(this, gizmoLayer) || this;
  38172. /** Fires an event when any of it's sub gizmos are dragged */
  38173. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38174. /** Fires an event when any of it's sub gizmos are released from dragging */
  38175. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38176. _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);
  38177. _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);
  38178. _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);
  38179. // Create uniform scale gizmo
  38180. _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);
  38181. _this.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh = false;
  38182. _this.uniformScaleGizmo.uniformScaling = true;
  38183. var uniformScalingMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  38184. uniformScalingMesh.scaling.scaleInPlace(0.02);
  38185. uniformScalingMesh.visibility = 0;
  38186. var octahedron = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  38187. octahedron.scaling.scaleInPlace(0.007);
  38188. uniformScalingMesh.addChild(octahedron);
  38189. _this.uniformScaleGizmo.setCustomMesh(uniformScalingMesh, true);
  38190. // Relay drag events
  38191. [_this.xGizmo, _this.yGizmo, _this.zGizmo, _this.uniformScaleGizmo].forEach(function (gizmo) {
  38192. gizmo.dragBehavior.onDragStartObservable.add(function () {
  38193. _this.onDragStartObservable.notifyObservers({});
  38194. });
  38195. gizmo.dragBehavior.onDragEndObservable.add(function () {
  38196. _this.onDragEndObservable.notifyObservers({});
  38197. });
  38198. });
  38199. _this.attachedMesh = null;
  38200. return _this;
  38201. }
  38202. Object.defineProperty(ScaleGizmo.prototype, "attachedMesh", {
  38203. set: function (mesh) {
  38204. if (this.xGizmo) {
  38205. this.xGizmo.attachedMesh = mesh;
  38206. this.yGizmo.attachedMesh = mesh;
  38207. this.zGizmo.attachedMesh = mesh;
  38208. this.uniformScaleGizmo.attachedMesh = mesh;
  38209. }
  38210. },
  38211. enumerable: true,
  38212. configurable: true
  38213. });
  38214. Object.defineProperty(ScaleGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  38215. get: function () {
  38216. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  38217. },
  38218. set: function (value) {
  38219. if (!value) {
  38220. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
  38221. }
  38222. if (this.xGizmo) {
  38223. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38224. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38225. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38226. }
  38227. },
  38228. enumerable: true,
  38229. configurable: true
  38230. });
  38231. Object.defineProperty(ScaleGizmo.prototype, "snapDistance", {
  38232. get: function () {
  38233. return this.xGizmo.snapDistance;
  38234. },
  38235. /**
  38236. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38237. */
  38238. set: function (value) {
  38239. if (this.xGizmo) {
  38240. this.xGizmo.snapDistance = value;
  38241. this.yGizmo.snapDistance = value;
  38242. this.zGizmo.snapDistance = value;
  38243. this.uniformScaleGizmo.snapDistance = value;
  38244. }
  38245. },
  38246. enumerable: true,
  38247. configurable: true
  38248. });
  38249. Object.defineProperty(ScaleGizmo.prototype, "scaleRatio", {
  38250. get: function () {
  38251. return this.xGizmo.scaleRatio;
  38252. },
  38253. /**
  38254. * Ratio for the scale of the gizmo (Default: 1)
  38255. */
  38256. set: function (value) {
  38257. if (this.xGizmo) {
  38258. this.xGizmo.scaleRatio = value;
  38259. this.yGizmo.scaleRatio = value;
  38260. this.zGizmo.scaleRatio = value;
  38261. this.uniformScaleGizmo.scaleRatio = value;
  38262. }
  38263. },
  38264. enumerable: true,
  38265. configurable: true
  38266. });
  38267. /**
  38268. * Disposes of the gizmo
  38269. */
  38270. ScaleGizmo.prototype.dispose = function () {
  38271. this.xGizmo.dispose();
  38272. this.yGizmo.dispose();
  38273. this.zGizmo.dispose();
  38274. this.uniformScaleGizmo.dispose();
  38275. this.onDragStartObservable.clear();
  38276. this.onDragEndObservable.clear();
  38277. };
  38278. return ScaleGizmo;
  38279. }(_gizmo__WEBPACK_IMPORTED_MODULE_5__["Gizmo"]));
  38280. /***/ }),
  38281. /***/ "./Helpers/environmentHelper.ts":
  38282. /*!**************************************!*\
  38283. !*** ./Helpers/environmentHelper.ts ***!
  38284. \**************************************/
  38285. /*! exports provided: EnvironmentHelper */
  38286. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38287. "use strict";
  38288. __webpack_require__.r(__webpack_exports__);
  38289. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return EnvironmentHelper; });
  38290. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38291. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38292. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  38293. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38294. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38295. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  38296. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  38297. /* harmony import */ var _Materials_Textures_mirrorTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  38298. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  38299. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  38300. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  38301. /**
  38302. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  38303. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  38304. * It also helps with the default setup of your imageProcessing configuration.
  38305. */
  38306. var EnvironmentHelper = /** @class */ (function () {
  38307. /**
  38308. * constructor
  38309. * @param options
  38310. * @param scene The scene to add the material to
  38311. */
  38312. function EnvironmentHelper(options, scene) {
  38313. var _this = this;
  38314. this._errorHandler = function (message, exception) {
  38315. _this.onErrorObservable.notifyObservers({ message: message, exception: exception });
  38316. };
  38317. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, EnvironmentHelper._getDefaultOptions(), options);
  38318. this._scene = scene;
  38319. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38320. this._setupBackground();
  38321. this._setupImageProcessing();
  38322. }
  38323. /**
  38324. * Creates the default options for the helper.
  38325. */
  38326. EnvironmentHelper._getDefaultOptions = function () {
  38327. return {
  38328. createGround: true,
  38329. groundSize: 15,
  38330. groundTexture: this._groundTextureCDNUrl,
  38331. groundColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  38332. groundOpacity: 0.9,
  38333. enableGroundShadow: true,
  38334. groundShadowLevel: 0.5,
  38335. enableGroundMirror: false,
  38336. groundMirrorSizeRatio: 0.3,
  38337. groundMirrorBlurKernel: 64,
  38338. groundMirrorAmount: 1,
  38339. groundMirrorFresnelWeight: 1,
  38340. groundMirrorFallOffDistance: 0,
  38341. groundMirrorTextureType: _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT,
  38342. groundYBias: 0.00001,
  38343. createSkybox: true,
  38344. skyboxSize: 20,
  38345. skyboxTexture: this._skyboxTextureCDNUrl,
  38346. skyboxColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  38347. backgroundYRotation: 0,
  38348. sizeAuto: true,
  38349. rootPosition: _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(),
  38350. setupImageProcessing: true,
  38351. environmentTexture: this._environmentTextureCDNUrl,
  38352. cameraExposure: 0.8,
  38353. cameraContrast: 1.2,
  38354. toneMappingEnabled: true,
  38355. };
  38356. };
  38357. Object.defineProperty(EnvironmentHelper.prototype, "rootMesh", {
  38358. /**
  38359. * Gets the root mesh created by the helper.
  38360. */
  38361. get: function () {
  38362. return this._rootMesh;
  38363. },
  38364. enumerable: true,
  38365. configurable: true
  38366. });
  38367. Object.defineProperty(EnvironmentHelper.prototype, "skybox", {
  38368. /**
  38369. * Gets the skybox created by the helper.
  38370. */
  38371. get: function () {
  38372. return this._skybox;
  38373. },
  38374. enumerable: true,
  38375. configurable: true
  38376. });
  38377. Object.defineProperty(EnvironmentHelper.prototype, "skyboxTexture", {
  38378. /**
  38379. * Gets the skybox texture created by the helper.
  38380. */
  38381. get: function () {
  38382. return this._skyboxTexture;
  38383. },
  38384. enumerable: true,
  38385. configurable: true
  38386. });
  38387. Object.defineProperty(EnvironmentHelper.prototype, "skyboxMaterial", {
  38388. /**
  38389. * Gets the skybox material created by the helper.
  38390. */
  38391. get: function () {
  38392. return this._skyboxMaterial;
  38393. },
  38394. enumerable: true,
  38395. configurable: true
  38396. });
  38397. Object.defineProperty(EnvironmentHelper.prototype, "ground", {
  38398. /**
  38399. * Gets the ground mesh created by the helper.
  38400. */
  38401. get: function () {
  38402. return this._ground;
  38403. },
  38404. enumerable: true,
  38405. configurable: true
  38406. });
  38407. Object.defineProperty(EnvironmentHelper.prototype, "groundTexture", {
  38408. /**
  38409. * Gets the ground texture created by the helper.
  38410. */
  38411. get: function () {
  38412. return this._groundTexture;
  38413. },
  38414. enumerable: true,
  38415. configurable: true
  38416. });
  38417. Object.defineProperty(EnvironmentHelper.prototype, "groundMirror", {
  38418. /**
  38419. * Gets the ground mirror created by the helper.
  38420. */
  38421. get: function () {
  38422. return this._groundMirror;
  38423. },
  38424. enumerable: true,
  38425. configurable: true
  38426. });
  38427. Object.defineProperty(EnvironmentHelper.prototype, "groundMirrorRenderList", {
  38428. /**
  38429. * Gets the ground mirror render list to helps pushing the meshes
  38430. * you wish in the ground reflection.
  38431. */
  38432. get: function () {
  38433. if (this._groundMirror) {
  38434. return this._groundMirror.renderList;
  38435. }
  38436. return null;
  38437. },
  38438. enumerable: true,
  38439. configurable: true
  38440. });
  38441. Object.defineProperty(EnvironmentHelper.prototype, "groundMaterial", {
  38442. /**
  38443. * Gets the ground material created by the helper.
  38444. */
  38445. get: function () {
  38446. return this._groundMaterial;
  38447. },
  38448. enumerable: true,
  38449. configurable: true
  38450. });
  38451. /**
  38452. * Updates the background according to the new options
  38453. * @param options
  38454. */
  38455. EnvironmentHelper.prototype.updateOptions = function (options) {
  38456. var newOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, this._options, options);
  38457. if (this._ground && !newOptions.createGround) {
  38458. this._ground.dispose();
  38459. this._ground = null;
  38460. }
  38461. if (this._groundMaterial && !newOptions.createGround) {
  38462. this._groundMaterial.dispose();
  38463. this._groundMaterial = null;
  38464. }
  38465. if (this._groundTexture) {
  38466. if (this._options.groundTexture != newOptions.groundTexture) {
  38467. this._groundTexture.dispose();
  38468. this._groundTexture = null;
  38469. }
  38470. }
  38471. if (this._skybox && !newOptions.createSkybox) {
  38472. this._skybox.dispose();
  38473. this._skybox = null;
  38474. }
  38475. if (this._skyboxMaterial && !newOptions.createSkybox) {
  38476. this._skyboxMaterial.dispose();
  38477. this._skyboxMaterial = null;
  38478. }
  38479. if (this._skyboxTexture) {
  38480. if (this._options.skyboxTexture != newOptions.skyboxTexture) {
  38481. this._skyboxTexture.dispose();
  38482. this._skyboxTexture = null;
  38483. }
  38484. }
  38485. if (this._groundMirror && !newOptions.enableGroundMirror) {
  38486. this._groundMirror.dispose();
  38487. this._groundMirror = null;
  38488. }
  38489. if (this._scene.environmentTexture) {
  38490. if (this._options.environmentTexture != newOptions.environmentTexture) {
  38491. this._scene.environmentTexture.dispose();
  38492. }
  38493. }
  38494. this._options = newOptions;
  38495. this._setupBackground();
  38496. this._setupImageProcessing();
  38497. };
  38498. /**
  38499. * Sets the primary color of all the available elements.
  38500. * @param color the main color to affect to the ground and the background
  38501. */
  38502. EnvironmentHelper.prototype.setMainColor = function (color) {
  38503. if (this.groundMaterial) {
  38504. this.groundMaterial.primaryColor = color;
  38505. }
  38506. if (this.skyboxMaterial) {
  38507. this.skyboxMaterial.primaryColor = color;
  38508. }
  38509. if (this.groundMirror) {
  38510. this.groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](color.r, color.g, color.b, 1.0);
  38511. }
  38512. };
  38513. /**
  38514. * Setup the image processing according to the specified options.
  38515. */
  38516. EnvironmentHelper.prototype._setupImageProcessing = function () {
  38517. if (this._options.setupImageProcessing) {
  38518. this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast;
  38519. this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure;
  38520. this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled;
  38521. this._setupEnvironmentTexture();
  38522. }
  38523. };
  38524. /**
  38525. * Setup the environment texture according to the specified options.
  38526. */
  38527. EnvironmentHelper.prototype._setupEnvironmentTexture = function () {
  38528. if (this._scene.environmentTexture) {
  38529. return;
  38530. }
  38531. if (this._options.environmentTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  38532. this._scene.environmentTexture = this._options.environmentTexture;
  38533. return;
  38534. }
  38535. var environmentTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
  38536. this._scene.environmentTexture = environmentTexture;
  38537. };
  38538. /**
  38539. * Setup the background according to the specified options.
  38540. */
  38541. EnvironmentHelper.prototype._setupBackground = function () {
  38542. if (!this._rootMesh) {
  38543. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("BackgroundHelper", this._scene);
  38544. }
  38545. this._rootMesh.rotation.y = this._options.backgroundYRotation;
  38546. var sceneSize = this._getSceneSize();
  38547. if (this._options.createGround) {
  38548. this._setupGround(sceneSize);
  38549. this._setupGroundMaterial();
  38550. this._setupGroundDiffuseTexture();
  38551. if (this._options.enableGroundMirror) {
  38552. this._setupGroundMirrorTexture(sceneSize);
  38553. }
  38554. this._setupMirrorInGroundMaterial();
  38555. }
  38556. if (this._options.createSkybox) {
  38557. this._setupSkybox(sceneSize);
  38558. this._setupSkyboxMaterial();
  38559. this._setupSkyboxReflectionTexture();
  38560. }
  38561. this._rootMesh.position.x = sceneSize.rootPosition.x;
  38562. this._rootMesh.position.z = sceneSize.rootPosition.z;
  38563. this._rootMesh.position.y = sceneSize.rootPosition.y;
  38564. };
  38565. /**
  38566. * Get the scene sizes according to the setup.
  38567. */
  38568. EnvironmentHelper.prototype._getSceneSize = function () {
  38569. var _this = this;
  38570. var groundSize = this._options.groundSize;
  38571. var skyboxSize = this._options.skyboxSize;
  38572. var rootPosition = this._options.rootPosition;
  38573. if (!this._scene.meshes || this._scene.meshes.length === 1) { // 1 only means the root of the helper.
  38574. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  38575. }
  38576. var sceneExtends = this._scene.getWorldExtends(function (mesh) {
  38577. return (mesh !== _this._ground && mesh !== _this._rootMesh && mesh !== _this._skybox);
  38578. });
  38579. var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
  38580. if (this._options.sizeAuto) {
  38581. if (this._scene.activeCamera instanceof _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"] &&
  38582. this._scene.activeCamera.upperRadiusLimit) {
  38583. groundSize = this._scene.activeCamera.upperRadiusLimit * 2;
  38584. skyboxSize = groundSize;
  38585. }
  38586. var sceneDiagonalLenght = sceneDiagonal.length();
  38587. if (sceneDiagonalLenght > groundSize) {
  38588. groundSize = sceneDiagonalLenght * 2;
  38589. skyboxSize = groundSize;
  38590. }
  38591. // 10 % bigger.
  38592. groundSize *= 1.1;
  38593. skyboxSize *= 1.5;
  38594. rootPosition = sceneExtends.min.add(sceneDiagonal.scale(0.5));
  38595. rootPosition.y = sceneExtends.min.y - this._options.groundYBias;
  38596. }
  38597. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  38598. };
  38599. /**
  38600. * Setup the ground according to the specified options.
  38601. */
  38602. EnvironmentHelper.prototype._setupGround = function (sceneSize) {
  38603. var _this = this;
  38604. if (!this._ground || this._ground.isDisposed()) {
  38605. this._ground = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePlane("BackgroundPlane", sceneSize.groundSize, this._scene);
  38606. this._ground.rotation.x = Math.PI / 2; // Face up by default.
  38607. this._ground.parent = this._rootMesh;
  38608. this._ground.onDisposeObservable.add(function () { _this._ground = null; });
  38609. }
  38610. this._ground.receiveShadows = this._options.enableGroundShadow;
  38611. };
  38612. /**
  38613. * Setup the ground material according to the specified options.
  38614. */
  38615. EnvironmentHelper.prototype._setupGroundMaterial = function () {
  38616. if (!this._groundMaterial) {
  38617. this._groundMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundPlaneMaterial", this._scene);
  38618. }
  38619. this._groundMaterial.alpha = this._options.groundOpacity;
  38620. this._groundMaterial.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  38621. this._groundMaterial.shadowLevel = this._options.groundShadowLevel;
  38622. this._groundMaterial.primaryColor = this._options.groundColor;
  38623. this._groundMaterial.useRGBColor = false;
  38624. this._groundMaterial.enableNoise = true;
  38625. if (this._ground) {
  38626. this._ground.material = this._groundMaterial;
  38627. }
  38628. };
  38629. /**
  38630. * Setup the ground diffuse texture according to the specified options.
  38631. */
  38632. EnvironmentHelper.prototype._setupGroundDiffuseTexture = function () {
  38633. if (!this._groundMaterial) {
  38634. return;
  38635. }
  38636. if (this._groundTexture) {
  38637. return;
  38638. }
  38639. if (this._options.groundTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  38640. this._groundMaterial.diffuseTexture = this._options.groundTexture;
  38641. return;
  38642. }
  38643. var diffuseTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](this._options.groundTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  38644. diffuseTexture.gammaSpace = false;
  38645. diffuseTexture.hasAlpha = true;
  38646. this._groundMaterial.diffuseTexture = diffuseTexture;
  38647. };
  38648. /**
  38649. * Setup the ground mirror texture according to the specified options.
  38650. */
  38651. EnvironmentHelper.prototype._setupGroundMirrorTexture = function (sceneSize) {
  38652. var wrapping = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  38653. if (!this._groundMirror) {
  38654. 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);
  38655. this._groundMirror.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Plane"](0, -1, 0, sceneSize.rootPosition.y);
  38656. this._groundMirror.anisotropicFilteringLevel = 1;
  38657. this._groundMirror.wrapU = wrapping;
  38658. this._groundMirror.wrapV = wrapping;
  38659. this._groundMirror.gammaSpace = false;
  38660. if (this._groundMirror.renderList) {
  38661. for (var i = 0; i < this._scene.meshes.length; i++) {
  38662. var mesh = this._scene.meshes[i];
  38663. if (mesh !== this._ground &&
  38664. mesh !== this._skybox &&
  38665. mesh !== this._rootMesh) {
  38666. this._groundMirror.renderList.push(mesh);
  38667. }
  38668. }
  38669. }
  38670. }
  38671. this._groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](this._options.groundColor.r, this._options.groundColor.g, this._options.groundColor.b, 1);
  38672. this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel;
  38673. };
  38674. /**
  38675. * Setup the ground to receive the mirror texture.
  38676. */
  38677. EnvironmentHelper.prototype._setupMirrorInGroundMaterial = function () {
  38678. if (this._groundMaterial) {
  38679. this._groundMaterial.reflectionTexture = this._groundMirror;
  38680. this._groundMaterial.reflectionFresnel = true;
  38681. this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount;
  38682. this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight;
  38683. this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance;
  38684. }
  38685. };
  38686. /**
  38687. * Setup the skybox according to the specified options.
  38688. */
  38689. EnvironmentHelper.prototype._setupSkybox = function (sceneSize) {
  38690. var _this = this;
  38691. if (!this._skybox || this._skybox.isDisposed()) {
  38692. this._skybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateBox("BackgroundSkybox", sceneSize.skyboxSize, this._scene, undefined, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].BACKSIDE);
  38693. this._skybox.onDisposeObservable.add(function () { _this._skybox = null; });
  38694. }
  38695. this._skybox.parent = this._rootMesh;
  38696. };
  38697. /**
  38698. * Setup the skybox material according to the specified options.
  38699. */
  38700. EnvironmentHelper.prototype._setupSkyboxMaterial = function () {
  38701. if (!this._skybox) {
  38702. return;
  38703. }
  38704. if (!this._skyboxMaterial) {
  38705. this._skyboxMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundSkyboxMaterial", this._scene);
  38706. }
  38707. this._skyboxMaterial.useRGBColor = false;
  38708. this._skyboxMaterial.primaryColor = this._options.skyboxColor;
  38709. this._skyboxMaterial.enableNoise = true;
  38710. this._skybox.material = this._skyboxMaterial;
  38711. };
  38712. /**
  38713. * Setup the skybox reflection texture according to the specified options.
  38714. */
  38715. EnvironmentHelper.prototype._setupSkyboxReflectionTexture = function () {
  38716. if (!this._skyboxMaterial) {
  38717. return;
  38718. }
  38719. if (this._skyboxTexture) {
  38720. return;
  38721. }
  38722. if (this._options.skyboxTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  38723. this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture;
  38724. return;
  38725. }
  38726. this._skyboxTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](this._options.skyboxTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  38727. this._skyboxTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].SKYBOX_MODE;
  38728. this._skyboxTexture.gammaSpace = false;
  38729. this._skyboxMaterial.reflectionTexture = this._skyboxTexture;
  38730. };
  38731. /**
  38732. * Dispose all the elements created by the Helper.
  38733. */
  38734. EnvironmentHelper.prototype.dispose = function () {
  38735. if (this._groundMaterial) {
  38736. this._groundMaterial.dispose(true, true);
  38737. }
  38738. if (this._skyboxMaterial) {
  38739. this._skyboxMaterial.dispose(true, true);
  38740. }
  38741. this._rootMesh.dispose(false);
  38742. };
  38743. /**
  38744. * Default ground texture URL.
  38745. */
  38746. EnvironmentHelper._groundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png";
  38747. /**
  38748. * Default skybox texture URL.
  38749. */
  38750. EnvironmentHelper._skyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds";
  38751. /**
  38752. * Default environment texture URL.
  38753. */
  38754. EnvironmentHelper._environmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env";
  38755. return EnvironmentHelper;
  38756. }());
  38757. /***/ }),
  38758. /***/ "./Helpers/index.ts":
  38759. /*!**************************!*\
  38760. !*** ./Helpers/index.ts ***!
  38761. \**************************/
  38762. /*! exports provided: EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome */
  38763. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38764. "use strict";
  38765. __webpack_require__.r(__webpack_exports__);
  38766. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  38767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _environmentHelper__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  38768. /* harmony import */ var _photoDome__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./photoDome */ "./Helpers/photoDome.ts");
  38769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _photoDome__WEBPACK_IMPORTED_MODULE_1__["PhotoDome"]; });
  38770. /* harmony import */ var _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneHelpers */ "./Helpers/sceneHelpers.ts");
  38771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__["_forceSceneHelpersToBundle"]; });
  38772. /* harmony import */ var _videoDome__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./videoDome */ "./Helpers/videoDome.ts");
  38773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _videoDome__WEBPACK_IMPORTED_MODULE_3__["VideoDome"]; });
  38774. /***/ }),
  38775. /***/ "./Helpers/photoDome.ts":
  38776. /*!******************************!*\
  38777. !*** ./Helpers/photoDome.ts ***!
  38778. \******************************/
  38779. /*! exports provided: PhotoDome */
  38780. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38781. "use strict";
  38782. __webpack_require__.r(__webpack_exports__);
  38783. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return PhotoDome; });
  38784. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38785. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38786. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  38787. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38788. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  38789. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  38790. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  38791. /**
  38792. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  38793. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  38794. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  38795. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  38796. */
  38797. var PhotoDome = /** @class */ (function (_super) {
  38798. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PhotoDome, _super);
  38799. /**
  38800. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  38801. * @param name Element's name, child elements will append suffixes for their own names.
  38802. * @param urlsOfPhoto defines the url of the photo to display
  38803. * @param options defines an object containing optional or exposed sub element properties
  38804. * @param onError defines a callback called when an error occured while loading the texture
  38805. */
  38806. function PhotoDome(name, urlOfPhoto, options, scene, onError) {
  38807. if (onError === void 0) { onError = null; }
  38808. var _this = _super.call(this, name, scene) || this;
  38809. _this._useDirectMapping = false;
  38810. /**
  38811. * Observable raised when an error occured while loading the 360 image
  38812. */
  38813. _this.onLoadErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38814. // set defaults and manage values
  38815. name = name || "photoDome";
  38816. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  38817. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  38818. if (options.useDirectMapping === undefined) {
  38819. _this._useDirectMapping = true;
  38820. }
  38821. else {
  38822. _this._useDirectMapping = options.useDirectMapping;
  38823. }
  38824. _this._setReady(false);
  38825. // create
  38826. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  38827. _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);
  38828. // configure material
  38829. material.opacityFresnel = false;
  38830. material.useEquirectangularFOV = true;
  38831. material.fovMultiplier = 1.0;
  38832. _this.photoTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](urlOfPhoto, scene, true, !_this._useDirectMapping, undefined, undefined, function (message, exception) {
  38833. _this.onLoadErrorObservable.notifyObservers(message || "Unknown error occured");
  38834. if (onError) {
  38835. onError(message, exception);
  38836. }
  38837. });
  38838. _this.photoTexture.onLoadObservable.addOnce(function () {
  38839. _this._setReady(true);
  38840. });
  38841. // configure mesh
  38842. _this._mesh.material = material;
  38843. _this._mesh.parent = _this;
  38844. return _this;
  38845. }
  38846. Object.defineProperty(PhotoDome.prototype, "photoTexture", {
  38847. /**
  38848. * Gets or sets the texture being displayed on the sphere
  38849. */
  38850. get: function () {
  38851. return this._photoTexture;
  38852. },
  38853. set: function (value) {
  38854. if (this._photoTexture === value) {
  38855. return;
  38856. }
  38857. this._photoTexture = value;
  38858. if (this._useDirectMapping) {
  38859. this._photoTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  38860. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  38861. this._material.diffuseTexture = this._photoTexture;
  38862. }
  38863. else {
  38864. this._photoTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  38865. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  38866. this._material.reflectionTexture = this._photoTexture;
  38867. }
  38868. },
  38869. enumerable: true,
  38870. configurable: true
  38871. });
  38872. Object.defineProperty(PhotoDome.prototype, "fovMultiplier", {
  38873. /**
  38874. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  38875. * Also see the options.resolution property.
  38876. */
  38877. get: function () {
  38878. return this._material.fovMultiplier;
  38879. },
  38880. set: function (value) {
  38881. this._material.fovMultiplier = value;
  38882. },
  38883. enumerable: true,
  38884. configurable: true
  38885. });
  38886. /**
  38887. * Releases resources associated with this node.
  38888. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38889. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38890. */
  38891. PhotoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  38892. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  38893. this._photoTexture.dispose();
  38894. this._mesh.dispose();
  38895. this._material.dispose();
  38896. this.onLoadErrorObservable.clear();
  38897. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  38898. };
  38899. return PhotoDome;
  38900. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__["TransformNode"]));
  38901. /***/ }),
  38902. /***/ "./Helpers/sceneHelpers.ts":
  38903. /*!*********************************!*\
  38904. !*** ./Helpers/sceneHelpers.ts ***!
  38905. \*********************************/
  38906. /*! exports provided: _forceSceneHelpersToBundle */
  38907. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38908. "use strict";
  38909. __webpack_require__.r(__webpack_exports__);
  38910. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _forceSceneHelpersToBundle; });
  38911. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38912. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  38913. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38914. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38915. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  38916. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38917. /* harmony import */ var _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/PBR/pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  38918. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  38919. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  38920. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  38921. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  38922. /* harmony import */ var _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/XR/webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  38923. /* harmony import */ var _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Cameras/XR/webXRInput */ "./Cameras/XR/webXRInput.ts");
  38924. /* harmony import */ var _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Cameras/XR/webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  38925. /* harmony import */ var _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Cameras/XR/webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  38926. /* harmony import */ var _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Cameras/VR/vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  38927. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  38928. /** @hidden */
  38929. var _forceSceneHelpersToBundle = true;
  38930. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultLight = function (replace) {
  38931. if (replace === void 0) { replace = false; }
  38932. // Dispose existing light in replace mode.
  38933. if (replace) {
  38934. if (this.lights) {
  38935. for (var i = 0; i < this.lights.length; i++) {
  38936. this.lights[i].dispose();
  38937. }
  38938. }
  38939. }
  38940. // Light
  38941. if (this.lights.length === 0) {
  38942. new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__["HemisphericLight"]("default light", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up(), this);
  38943. }
  38944. };
  38945. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCamera = function (createArcRotateCamera, replace, attachCameraControls) {
  38946. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  38947. if (replace === void 0) { replace = false; }
  38948. if (attachCameraControls === void 0) { attachCameraControls = false; }
  38949. // Dispose existing camera in replace mode.
  38950. if (replace) {
  38951. if (this.activeCamera) {
  38952. this.activeCamera.dispose();
  38953. this.activeCamera = null;
  38954. }
  38955. }
  38956. // Camera
  38957. if (!this.activeCamera) {
  38958. var worldExtends = this.getWorldExtends();
  38959. var worldSize = worldExtends.max.subtract(worldExtends.min);
  38960. var worldCenter = worldExtends.min.add(worldSize.scale(0.5));
  38961. var camera;
  38962. var radius = worldSize.length() * 1.5;
  38963. // empty scene scenario!
  38964. if (!isFinite(radius)) {
  38965. radius = 1;
  38966. worldCenter.copyFromFloats(0, 0, 0);
  38967. }
  38968. if (createArcRotateCamera) {
  38969. var arcRotateCamera = new _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__["ArcRotateCamera"]("default camera", -(Math.PI / 2), Math.PI / 2, radius, worldCenter, this);
  38970. arcRotateCamera.lowerRadiusLimit = radius * 0.01;
  38971. arcRotateCamera.wheelPrecision = 100 / radius;
  38972. camera = arcRotateCamera;
  38973. }
  38974. else {
  38975. 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);
  38976. freeCamera.setTarget(worldCenter);
  38977. camera = freeCamera;
  38978. }
  38979. camera.minZ = radius * 0.01;
  38980. camera.maxZ = radius * 1000;
  38981. camera.speed = radius * 0.2;
  38982. this.activeCamera = camera;
  38983. var canvas = this.getEngine().getRenderingCanvas();
  38984. if (attachCameraControls && canvas) {
  38985. camera.attachControl(canvas);
  38986. }
  38987. }
  38988. };
  38989. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCameraOrLight = function (createArcRotateCamera, replace, attachCameraControls) {
  38990. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  38991. if (replace === void 0) { replace = false; }
  38992. if (attachCameraControls === void 0) { attachCameraControls = false; }
  38993. this.createDefaultLight(replace);
  38994. this.createDefaultCamera(createArcRotateCamera, replace, attachCameraControls);
  38995. };
  38996. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultSkybox = function (environmentTexture, pbr, scale, blur, setGlobalEnvTexture) {
  38997. if (pbr === void 0) { pbr = false; }
  38998. if (scale === void 0) { scale = 1000; }
  38999. if (blur === void 0) { blur = 0; }
  39000. if (setGlobalEnvTexture === void 0) { setGlobalEnvTexture = true; }
  39001. if (!environmentTexture) {
  39002. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Can not create default skybox without environment texture.");
  39003. return null;
  39004. }
  39005. if (setGlobalEnvTexture) {
  39006. if (environmentTexture) {
  39007. this.environmentTexture = environmentTexture;
  39008. }
  39009. }
  39010. // Skybox
  39011. var hdrSkybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateBox("hdrSkyBox", scale, this);
  39012. if (pbr) {
  39013. var hdrSkyboxMaterial = new _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__["PBRMaterial"]("skyBox", this);
  39014. hdrSkyboxMaterial.backFaceCulling = false;
  39015. hdrSkyboxMaterial.reflectionTexture = environmentTexture.clone();
  39016. if (hdrSkyboxMaterial.reflectionTexture) {
  39017. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  39018. }
  39019. hdrSkyboxMaterial.microSurface = 1.0 - blur;
  39020. hdrSkyboxMaterial.disableLighting = true;
  39021. hdrSkyboxMaterial.twoSidedLighting = true;
  39022. hdrSkybox.infiniteDistance = true;
  39023. hdrSkybox.material = hdrSkyboxMaterial;
  39024. }
  39025. else {
  39026. var skyboxMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("skyBox", this);
  39027. skyboxMaterial.backFaceCulling = false;
  39028. skyboxMaterial.reflectionTexture = environmentTexture.clone();
  39029. if (skyboxMaterial.reflectionTexture) {
  39030. skyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  39031. }
  39032. skyboxMaterial.disableLighting = true;
  39033. hdrSkybox.infiniteDistance = true;
  39034. hdrSkybox.material = skyboxMaterial;
  39035. }
  39036. hdrSkybox.isPickable = false;
  39037. return hdrSkybox;
  39038. };
  39039. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultEnvironment = function (options) {
  39040. if (_environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"]) {
  39041. return new _environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"](options, this);
  39042. }
  39043. return null;
  39044. };
  39045. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultVRExperience = function (webVROptions) {
  39046. if (webVROptions === void 0) { webVROptions = {}; }
  39047. return new _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__["VRExperienceHelper"](this, webVROptions);
  39048. };
  39049. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultXRExperienceAsync = function () {
  39050. var _this = this;
  39051. return _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__["WebXRExperienceHelper"].CreateAsync(this).then(function (helper) {
  39052. var outputCanvas = new _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__["WebXRManagedOutputCanvas"](helper);
  39053. return _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__["WebXREnterExitUI"].CreateAsync(_this, helper, { outputCanvasContext: outputCanvas.canvasContext })
  39054. .then(function (ui) {
  39055. new _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__["WebXRInput"](helper);
  39056. return helper;
  39057. });
  39058. });
  39059. };
  39060. /***/ }),
  39061. /***/ "./Helpers/videoDome.ts":
  39062. /*!******************************!*\
  39063. !*** ./Helpers/videoDome.ts ***!
  39064. \******************************/
  39065. /*! exports provided: VideoDome */
  39066. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39067. "use strict";
  39068. __webpack_require__.r(__webpack_exports__);
  39069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return VideoDome; });
  39070. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39071. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  39072. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39073. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39074. /* harmony import */ var _Materials_Textures_videoTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/videoTexture */ "./Materials/Textures/videoTexture.ts");
  39075. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  39076. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  39077. /**
  39078. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  39079. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  39080. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  39081. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  39082. */
  39083. var VideoDome = /** @class */ (function (_super) {
  39084. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoDome, _super);
  39085. /**
  39086. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  39087. * @param name Element's name, child elements will append suffixes for their own names.
  39088. * @param urlsOrVideo defines the url(s) or the video element to use
  39089. * @param options An object containing optional or exposed sub element properties
  39090. */
  39091. function VideoDome(name, urlsOrVideo, options, scene) {
  39092. var _this = _super.call(this, name, scene) || this;
  39093. _this._useDirectMapping = false;
  39094. // set defaults and manage values
  39095. name = name || "videoDome";
  39096. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  39097. options.clickToPlay = Boolean(options.clickToPlay);
  39098. options.autoPlay = options.autoPlay === undefined ? true : Boolean(options.autoPlay);
  39099. options.loop = options.loop === undefined ? true : Boolean(options.loop);
  39100. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  39101. if (options.useDirectMapping === undefined) {
  39102. _this._useDirectMapping = true;
  39103. }
  39104. else {
  39105. _this._useDirectMapping = options.useDirectMapping;
  39106. }
  39107. _this._setReady(false);
  39108. // create
  39109. var tempOptions = { loop: options.loop, autoPlay: options.autoPlay, autoUpdateTexture: true, poster: options.poster };
  39110. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  39111. 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);
  39112. _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);
  39113. texture.onLoadObservable.addOnce(function () {
  39114. _this._setReady(true);
  39115. });
  39116. // configure material
  39117. material.useEquirectangularFOV = true;
  39118. material.fovMultiplier = 1.0;
  39119. material.opacityFresnel = false;
  39120. if (_this._useDirectMapping) {
  39121. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  39122. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  39123. material.diffuseTexture = texture;
  39124. }
  39125. else {
  39126. texture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  39127. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  39128. material.reflectionTexture = texture;
  39129. }
  39130. // configure mesh
  39131. _this._mesh.material = material;
  39132. _this._mesh.parent = _this;
  39133. // optional configuration
  39134. if (options.clickToPlay) {
  39135. scene.onPointerUp = function () {
  39136. _this._videoTexture.video.play();
  39137. };
  39138. }
  39139. return _this;
  39140. }
  39141. Object.defineProperty(VideoDome.prototype, "videoTexture", {
  39142. /**
  39143. * Gets the video texture being displayed on the sphere
  39144. */
  39145. get: function () {
  39146. return this._videoTexture;
  39147. },
  39148. enumerable: true,
  39149. configurable: true
  39150. });
  39151. Object.defineProperty(VideoDome.prototype, "fovMultiplier", {
  39152. /**
  39153. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  39154. * Also see the options.resolution property.
  39155. */
  39156. get: function () {
  39157. return this._material.fovMultiplier;
  39158. },
  39159. set: function (value) {
  39160. this._material.fovMultiplier = value;
  39161. },
  39162. enumerable: true,
  39163. configurable: true
  39164. });
  39165. /**
  39166. * Releases resources associated with this node.
  39167. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  39168. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  39169. */
  39170. VideoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  39171. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  39172. this._videoTexture.dispose();
  39173. this._mesh.dispose();
  39174. this._material.dispose();
  39175. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  39176. };
  39177. return VideoDome;
  39178. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]));
  39179. /***/ }),
  39180. /***/ "./Instrumentation/engineInstrumentation.ts":
  39181. /*!**************************************************!*\
  39182. !*** ./Instrumentation/engineInstrumentation.ts ***!
  39183. \**************************************************/
  39184. /*! exports provided: EngineInstrumentation */
  39185. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39186. "use strict";
  39187. __webpack_require__.r(__webpack_exports__);
  39188. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return EngineInstrumentation; });
  39189. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  39190. /**
  39191. * This class can be used to get instrumentation data from a Babylon engine
  39192. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39193. */
  39194. var EngineInstrumentation = /** @class */ (function () {
  39195. /**
  39196. * Instantiates a new engine instrumentation.
  39197. * This class can be used to get instrumentation data from a Babylon engine
  39198. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39199. * @param engine Defines the engine to instrument
  39200. */
  39201. function EngineInstrumentation(
  39202. /**
  39203. * Define the instrumented engine.
  39204. */
  39205. engine) {
  39206. this.engine = engine;
  39207. this._captureGPUFrameTime = false;
  39208. this._gpuFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39209. this._captureShaderCompilationTime = false;
  39210. this._shaderCompilationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39211. // Observers
  39212. this._onBeginFrameObserver = null;
  39213. this._onEndFrameObserver = null;
  39214. this._onBeforeShaderCompilationObserver = null;
  39215. this._onAfterShaderCompilationObserver = null;
  39216. }
  39217. Object.defineProperty(EngineInstrumentation.prototype, "gpuFrameTimeCounter", {
  39218. // Properties
  39219. /**
  39220. * Gets the perf counter used for GPU frame time
  39221. */
  39222. get: function () {
  39223. return this._gpuFrameTime;
  39224. },
  39225. enumerable: true,
  39226. configurable: true
  39227. });
  39228. Object.defineProperty(EngineInstrumentation.prototype, "captureGPUFrameTime", {
  39229. /**
  39230. * Gets the GPU frame time capture status
  39231. */
  39232. get: function () {
  39233. return this._captureGPUFrameTime;
  39234. },
  39235. /**
  39236. * Enable or disable the GPU frame time capture
  39237. */
  39238. set: function (value) {
  39239. var _this = this;
  39240. if (value === this._captureGPUFrameTime) {
  39241. return;
  39242. }
  39243. this._captureGPUFrameTime = value;
  39244. if (value) {
  39245. this._onBeginFrameObserver = this.engine.onBeginFrameObservable.add(function () {
  39246. if (!_this._gpuFrameTimeToken) {
  39247. _this._gpuFrameTimeToken = _this.engine.startTimeQuery();
  39248. }
  39249. });
  39250. this._onEndFrameObserver = this.engine.onEndFrameObservable.add(function () {
  39251. if (!_this._gpuFrameTimeToken) {
  39252. return;
  39253. }
  39254. var time = _this.engine.endTimeQuery(_this._gpuFrameTimeToken);
  39255. if (time > -1) {
  39256. _this._gpuFrameTimeToken = null;
  39257. _this._gpuFrameTime.fetchNewFrame();
  39258. _this._gpuFrameTime.addCount(time, true);
  39259. }
  39260. });
  39261. }
  39262. else {
  39263. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  39264. this._onBeginFrameObserver = null;
  39265. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  39266. this._onEndFrameObserver = null;
  39267. }
  39268. },
  39269. enumerable: true,
  39270. configurable: true
  39271. });
  39272. Object.defineProperty(EngineInstrumentation.prototype, "shaderCompilationTimeCounter", {
  39273. /**
  39274. * Gets the perf counter used for shader compilation time
  39275. */
  39276. get: function () {
  39277. return this._shaderCompilationTime;
  39278. },
  39279. enumerable: true,
  39280. configurable: true
  39281. });
  39282. Object.defineProperty(EngineInstrumentation.prototype, "captureShaderCompilationTime", {
  39283. /**
  39284. * Gets the shader compilation time capture status
  39285. */
  39286. get: function () {
  39287. return this._captureShaderCompilationTime;
  39288. },
  39289. /**
  39290. * Enable or disable the shader compilation time capture
  39291. */
  39292. set: function (value) {
  39293. var _this = this;
  39294. if (value === this._captureShaderCompilationTime) {
  39295. return;
  39296. }
  39297. this._captureShaderCompilationTime = value;
  39298. if (value) {
  39299. this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function () {
  39300. _this._shaderCompilationTime.fetchNewFrame();
  39301. _this._shaderCompilationTime.beginMonitoring();
  39302. });
  39303. this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function () {
  39304. _this._shaderCompilationTime.endMonitoring();
  39305. });
  39306. }
  39307. else {
  39308. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  39309. this._onBeforeShaderCompilationObserver = null;
  39310. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  39311. this._onAfterShaderCompilationObserver = null;
  39312. }
  39313. },
  39314. enumerable: true,
  39315. configurable: true
  39316. });
  39317. /**
  39318. * Dispose and release associated resources.
  39319. */
  39320. EngineInstrumentation.prototype.dispose = function () {
  39321. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  39322. this._onBeginFrameObserver = null;
  39323. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  39324. this._onEndFrameObserver = null;
  39325. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  39326. this._onBeforeShaderCompilationObserver = null;
  39327. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  39328. this._onAfterShaderCompilationObserver = null;
  39329. this.engine = null;
  39330. };
  39331. return EngineInstrumentation;
  39332. }());
  39333. /***/ }),
  39334. /***/ "./Instrumentation/index.ts":
  39335. /*!**********************************!*\
  39336. !*** ./Instrumentation/index.ts ***!
  39337. \**********************************/
  39338. /*! exports provided: EngineInstrumentation, SceneInstrumentation, _TimeToken */
  39339. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39340. "use strict";
  39341. __webpack_require__.r(__webpack_exports__);
  39342. /* harmony import */ var _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engineInstrumentation */ "./Instrumentation/engineInstrumentation.ts");
  39343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  39344. /* harmony import */ var _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sceneInstrumentation */ "./Instrumentation/sceneInstrumentation.ts");
  39345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__["SceneInstrumentation"]; });
  39346. /* harmony import */ var _timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./timeToken */ "./Instrumentation/timeToken.ts");
  39347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]; });
  39348. /***/ }),
  39349. /***/ "./Instrumentation/sceneInstrumentation.ts":
  39350. /*!*************************************************!*\
  39351. !*** ./Instrumentation/sceneInstrumentation.ts ***!
  39352. \*************************************************/
  39353. /*! exports provided: SceneInstrumentation */
  39354. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39355. "use strict";
  39356. __webpack_require__.r(__webpack_exports__);
  39357. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return SceneInstrumentation; });
  39358. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  39359. /**
  39360. * This class can be used to get instrumentation data from a Babylon engine
  39361. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  39362. */
  39363. var SceneInstrumentation = /** @class */ (function () {
  39364. /**
  39365. * Instantiates a new scene instrumentation.
  39366. * This class can be used to get instrumentation data from a Babylon engine
  39367. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  39368. * @param scene Defines the scene to instrument
  39369. */
  39370. function SceneInstrumentation(
  39371. /**
  39372. * Defines the scene to instrument
  39373. */
  39374. scene) {
  39375. var _this = this;
  39376. this.scene = scene;
  39377. this._captureActiveMeshesEvaluationTime = false;
  39378. this._activeMeshesEvaluationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39379. this._captureRenderTargetsRenderTime = false;
  39380. this._renderTargetsRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39381. this._captureFrameTime = false;
  39382. this._frameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39383. this._captureRenderTime = false;
  39384. this._renderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39385. this._captureInterFrameTime = false;
  39386. this._interFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39387. this._captureParticlesRenderTime = false;
  39388. this._particlesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39389. this._captureSpritesRenderTime = false;
  39390. this._spritesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39391. this._capturePhysicsTime = false;
  39392. this._physicsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39393. this._captureAnimationsTime = false;
  39394. this._animationsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39395. this._captureCameraRenderTime = false;
  39396. this._cameraRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  39397. // Observers
  39398. this._onBeforeActiveMeshesEvaluationObserver = null;
  39399. this._onAfterActiveMeshesEvaluationObserver = null;
  39400. this._onBeforeRenderTargetsRenderObserver = null;
  39401. this._onAfterRenderTargetsRenderObserver = null;
  39402. this._onAfterRenderObserver = null;
  39403. this._onBeforeDrawPhaseObserver = null;
  39404. this._onAfterDrawPhaseObserver = null;
  39405. this._onBeforeAnimationsObserver = null;
  39406. this._onBeforeParticlesRenderingObserver = null;
  39407. this._onAfterParticlesRenderingObserver = null;
  39408. this._onBeforeSpritesRenderingObserver = null;
  39409. this._onAfterSpritesRenderingObserver = null;
  39410. this._onBeforePhysicsObserver = null;
  39411. this._onAfterPhysicsObserver = null;
  39412. this._onAfterAnimationsObserver = null;
  39413. this._onBeforeCameraRenderObserver = null;
  39414. this._onAfterCameraRenderObserver = null;
  39415. // Before render
  39416. this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
  39417. if (_this._captureActiveMeshesEvaluationTime) {
  39418. _this._activeMeshesEvaluationTime.fetchNewFrame();
  39419. }
  39420. if (_this._captureRenderTargetsRenderTime) {
  39421. _this._renderTargetsRenderTime.fetchNewFrame();
  39422. }
  39423. if (_this._captureFrameTime) {
  39424. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Scene rendering");
  39425. _this._frameTime.beginMonitoring();
  39426. }
  39427. if (_this._captureInterFrameTime) {
  39428. _this._interFrameTime.endMonitoring();
  39429. }
  39430. if (_this._captureParticlesRenderTime) {
  39431. _this._particlesRenderTime.fetchNewFrame();
  39432. }
  39433. if (_this._captureSpritesRenderTime) {
  39434. _this._spritesRenderTime.fetchNewFrame();
  39435. }
  39436. if (_this._captureAnimationsTime) {
  39437. _this._animationsTime.beginMonitoring();
  39438. }
  39439. _this.scene.getEngine()._drawCalls.fetchNewFrame();
  39440. _this.scene.getEngine()._textureCollisions.fetchNewFrame();
  39441. });
  39442. // After render
  39443. this._onAfterRenderObserver = scene.onAfterRenderObservable.add(function () {
  39444. if (_this._captureFrameTime) {
  39445. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Scene rendering");
  39446. _this._frameTime.endMonitoring();
  39447. }
  39448. if (_this._captureRenderTime) {
  39449. _this._renderTime.endMonitoring(false);
  39450. }
  39451. if (_this._captureInterFrameTime) {
  39452. _this._interFrameTime.beginMonitoring();
  39453. }
  39454. });
  39455. }
  39456. Object.defineProperty(SceneInstrumentation.prototype, "activeMeshesEvaluationTimeCounter", {
  39457. // Properties
  39458. /**
  39459. * Gets the perf counter used for active meshes evaluation time
  39460. */
  39461. get: function () {
  39462. return this._activeMeshesEvaluationTime;
  39463. },
  39464. enumerable: true,
  39465. configurable: true
  39466. });
  39467. Object.defineProperty(SceneInstrumentation.prototype, "captureActiveMeshesEvaluationTime", {
  39468. /**
  39469. * Gets the active meshes evaluation time capture status
  39470. */
  39471. get: function () {
  39472. return this._captureActiveMeshesEvaluationTime;
  39473. },
  39474. /**
  39475. * Enable or disable the active meshes evaluation time capture
  39476. */
  39477. set: function (value) {
  39478. var _this = this;
  39479. if (value === this._captureActiveMeshesEvaluationTime) {
  39480. return;
  39481. }
  39482. this._captureActiveMeshesEvaluationTime = value;
  39483. if (value) {
  39484. this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function () {
  39485. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Active meshes evaluation");
  39486. _this._activeMeshesEvaluationTime.beginMonitoring();
  39487. });
  39488. this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function () {
  39489. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Active meshes evaluation");
  39490. _this._activeMeshesEvaluationTime.endMonitoring();
  39491. });
  39492. }
  39493. else {
  39494. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  39495. this._onBeforeActiveMeshesEvaluationObserver = null;
  39496. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  39497. this._onAfterActiveMeshesEvaluationObserver = null;
  39498. }
  39499. },
  39500. enumerable: true,
  39501. configurable: true
  39502. });
  39503. Object.defineProperty(SceneInstrumentation.prototype, "renderTargetsRenderTimeCounter", {
  39504. /**
  39505. * Gets the perf counter used for render targets render time
  39506. */
  39507. get: function () {
  39508. return this._renderTargetsRenderTime;
  39509. },
  39510. enumerable: true,
  39511. configurable: true
  39512. });
  39513. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTargetsRenderTime", {
  39514. /**
  39515. * Gets the render targets render time capture status
  39516. */
  39517. get: function () {
  39518. return this._captureRenderTargetsRenderTime;
  39519. },
  39520. /**
  39521. * Enable or disable the render targets render time capture
  39522. */
  39523. set: function (value) {
  39524. var _this = this;
  39525. if (value === this._captureRenderTargetsRenderTime) {
  39526. return;
  39527. }
  39528. this._captureRenderTargetsRenderTime = value;
  39529. if (value) {
  39530. this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function () {
  39531. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Render targets rendering");
  39532. _this._renderTargetsRenderTime.beginMonitoring();
  39533. });
  39534. this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function () {
  39535. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Render targets rendering");
  39536. _this._renderTargetsRenderTime.endMonitoring(false);
  39537. });
  39538. }
  39539. else {
  39540. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  39541. this._onBeforeRenderTargetsRenderObserver = null;
  39542. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  39543. this._onAfterRenderTargetsRenderObserver = null;
  39544. }
  39545. },
  39546. enumerable: true,
  39547. configurable: true
  39548. });
  39549. Object.defineProperty(SceneInstrumentation.prototype, "particlesRenderTimeCounter", {
  39550. /**
  39551. * Gets the perf counter used for particles render time
  39552. */
  39553. get: function () {
  39554. return this._particlesRenderTime;
  39555. },
  39556. enumerable: true,
  39557. configurable: true
  39558. });
  39559. Object.defineProperty(SceneInstrumentation.prototype, "captureParticlesRenderTime", {
  39560. /**
  39561. * Gets the particles render time capture status
  39562. */
  39563. get: function () {
  39564. return this._captureParticlesRenderTime;
  39565. },
  39566. /**
  39567. * Enable or disable the particles render time capture
  39568. */
  39569. set: function (value) {
  39570. var _this = this;
  39571. if (value === this._captureParticlesRenderTime) {
  39572. return;
  39573. }
  39574. this._captureParticlesRenderTime = value;
  39575. if (value) {
  39576. this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function () {
  39577. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Particles");
  39578. _this._particlesRenderTime.beginMonitoring();
  39579. });
  39580. this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function () {
  39581. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Particles");
  39582. _this._particlesRenderTime.endMonitoring(false);
  39583. });
  39584. }
  39585. else {
  39586. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  39587. this._onBeforeParticlesRenderingObserver = null;
  39588. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  39589. this._onAfterParticlesRenderingObserver = null;
  39590. }
  39591. },
  39592. enumerable: true,
  39593. configurable: true
  39594. });
  39595. Object.defineProperty(SceneInstrumentation.prototype, "spritesRenderTimeCounter", {
  39596. /**
  39597. * Gets the perf counter used for sprites render time
  39598. */
  39599. get: function () {
  39600. return this._spritesRenderTime;
  39601. },
  39602. enumerable: true,
  39603. configurable: true
  39604. });
  39605. Object.defineProperty(SceneInstrumentation.prototype, "captureSpritesRenderTime", {
  39606. /**
  39607. * Gets the sprites render time capture status
  39608. */
  39609. get: function () {
  39610. return this._captureSpritesRenderTime;
  39611. },
  39612. /**
  39613. * Enable or disable the sprites render time capture
  39614. */
  39615. set: function (value) {
  39616. var _this = this;
  39617. if (value === this._captureSpritesRenderTime) {
  39618. return;
  39619. }
  39620. this._captureSpritesRenderTime = value;
  39621. if (!this.scene.spriteManagers) {
  39622. return;
  39623. }
  39624. if (value) {
  39625. this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function () {
  39626. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Sprites");
  39627. _this._spritesRenderTime.beginMonitoring();
  39628. });
  39629. this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function () {
  39630. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Sprites");
  39631. _this._spritesRenderTime.endMonitoring(false);
  39632. });
  39633. }
  39634. else {
  39635. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  39636. this._onBeforeSpritesRenderingObserver = null;
  39637. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  39638. this._onAfterSpritesRenderingObserver = null;
  39639. }
  39640. },
  39641. enumerable: true,
  39642. configurable: true
  39643. });
  39644. Object.defineProperty(SceneInstrumentation.prototype, "physicsTimeCounter", {
  39645. /**
  39646. * Gets the perf counter used for physics time
  39647. */
  39648. get: function () {
  39649. return this._physicsTime;
  39650. },
  39651. enumerable: true,
  39652. configurable: true
  39653. });
  39654. Object.defineProperty(SceneInstrumentation.prototype, "capturePhysicsTime", {
  39655. /**
  39656. * Gets the physics time capture status
  39657. */
  39658. get: function () {
  39659. return this._capturePhysicsTime;
  39660. },
  39661. /**
  39662. * Enable or disable the physics time capture
  39663. */
  39664. set: function (value) {
  39665. var _this = this;
  39666. if (value === this._capturePhysicsTime) {
  39667. return;
  39668. }
  39669. if (!this.scene.onBeforePhysicsObservable) {
  39670. return;
  39671. }
  39672. this._capturePhysicsTime = value;
  39673. if (value) {
  39674. this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function () {
  39675. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Physics");
  39676. _this._physicsTime.beginMonitoring();
  39677. });
  39678. this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function () {
  39679. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Physics");
  39680. _this._physicsTime.endMonitoring();
  39681. });
  39682. }
  39683. else {
  39684. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  39685. this._onBeforePhysicsObserver = null;
  39686. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  39687. this._onAfterPhysicsObserver = null;
  39688. }
  39689. },
  39690. enumerable: true,
  39691. configurable: true
  39692. });
  39693. Object.defineProperty(SceneInstrumentation.prototype, "animationsTimeCounter", {
  39694. /**
  39695. * Gets the perf counter used for animations time
  39696. */
  39697. get: function () {
  39698. return this._animationsTime;
  39699. },
  39700. enumerable: true,
  39701. configurable: true
  39702. });
  39703. Object.defineProperty(SceneInstrumentation.prototype, "captureAnimationsTime", {
  39704. /**
  39705. * Gets the animations time capture status
  39706. */
  39707. get: function () {
  39708. return this._captureAnimationsTime;
  39709. },
  39710. /**
  39711. * Enable or disable the animations time capture
  39712. */
  39713. set: function (value) {
  39714. var _this = this;
  39715. if (value === this._captureAnimationsTime) {
  39716. return;
  39717. }
  39718. this._captureAnimationsTime = value;
  39719. if (value) {
  39720. this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function () {
  39721. _this._animationsTime.endMonitoring();
  39722. });
  39723. }
  39724. else {
  39725. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  39726. this._onAfterAnimationsObserver = null;
  39727. }
  39728. },
  39729. enumerable: true,
  39730. configurable: true
  39731. });
  39732. Object.defineProperty(SceneInstrumentation.prototype, "frameTimeCounter", {
  39733. /**
  39734. * Gets the perf counter used for frame time capture
  39735. */
  39736. get: function () {
  39737. return this._frameTime;
  39738. },
  39739. enumerable: true,
  39740. configurable: true
  39741. });
  39742. Object.defineProperty(SceneInstrumentation.prototype, "captureFrameTime", {
  39743. /**
  39744. * Gets the frame time capture status
  39745. */
  39746. get: function () {
  39747. return this._captureFrameTime;
  39748. },
  39749. /**
  39750. * Enable or disable the frame time capture
  39751. */
  39752. set: function (value) {
  39753. this._captureFrameTime = value;
  39754. },
  39755. enumerable: true,
  39756. configurable: true
  39757. });
  39758. Object.defineProperty(SceneInstrumentation.prototype, "interFrameTimeCounter", {
  39759. /**
  39760. * Gets the perf counter used for inter-frames time capture
  39761. */
  39762. get: function () {
  39763. return this._interFrameTime;
  39764. },
  39765. enumerable: true,
  39766. configurable: true
  39767. });
  39768. Object.defineProperty(SceneInstrumentation.prototype, "captureInterFrameTime", {
  39769. /**
  39770. * Gets the inter-frames time capture status
  39771. */
  39772. get: function () {
  39773. return this._captureInterFrameTime;
  39774. },
  39775. /**
  39776. * Enable or disable the inter-frames time capture
  39777. */
  39778. set: function (value) {
  39779. this._captureInterFrameTime = value;
  39780. },
  39781. enumerable: true,
  39782. configurable: true
  39783. });
  39784. Object.defineProperty(SceneInstrumentation.prototype, "renderTimeCounter", {
  39785. /**
  39786. * Gets the perf counter used for render time capture
  39787. */
  39788. get: function () {
  39789. return this._renderTime;
  39790. },
  39791. enumerable: true,
  39792. configurable: true
  39793. });
  39794. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTime", {
  39795. /**
  39796. * Gets the render time capture status
  39797. */
  39798. get: function () {
  39799. return this._captureRenderTime;
  39800. },
  39801. /**
  39802. * Enable or disable the render time capture
  39803. */
  39804. set: function (value) {
  39805. var _this = this;
  39806. if (value === this._captureRenderTime) {
  39807. return;
  39808. }
  39809. this._captureRenderTime = value;
  39810. if (value) {
  39811. this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function () {
  39812. _this._renderTime.beginMonitoring();
  39813. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Main render");
  39814. });
  39815. this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function () {
  39816. _this._renderTime.endMonitoring(false);
  39817. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Main render");
  39818. });
  39819. }
  39820. else {
  39821. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  39822. this._onBeforeDrawPhaseObserver = null;
  39823. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  39824. this._onAfterDrawPhaseObserver = null;
  39825. }
  39826. },
  39827. enumerable: true,
  39828. configurable: true
  39829. });
  39830. Object.defineProperty(SceneInstrumentation.prototype, "cameraRenderTimeCounter", {
  39831. /**
  39832. * Gets the perf counter used for camera render time capture
  39833. */
  39834. get: function () {
  39835. return this._cameraRenderTime;
  39836. },
  39837. enumerable: true,
  39838. configurable: true
  39839. });
  39840. Object.defineProperty(SceneInstrumentation.prototype, "captureCameraRenderTime", {
  39841. /**
  39842. * Gets the camera render time capture status
  39843. */
  39844. get: function () {
  39845. return this._captureCameraRenderTime;
  39846. },
  39847. /**
  39848. * Enable or disable the camera render time capture
  39849. */
  39850. set: function (value) {
  39851. var _this = this;
  39852. if (value === this._captureCameraRenderTime) {
  39853. return;
  39854. }
  39855. this._captureCameraRenderTime = value;
  39856. if (value) {
  39857. this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function (camera) {
  39858. _this._cameraRenderTime.beginMonitoring();
  39859. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Rendering camera " + camera.name);
  39860. });
  39861. this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function (camera) {
  39862. _this._cameraRenderTime.endMonitoring(false);
  39863. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Rendering camera " + camera.name);
  39864. });
  39865. }
  39866. else {
  39867. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  39868. this._onBeforeCameraRenderObserver = null;
  39869. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  39870. this._onAfterCameraRenderObserver = null;
  39871. }
  39872. },
  39873. enumerable: true,
  39874. configurable: true
  39875. });
  39876. Object.defineProperty(SceneInstrumentation.prototype, "drawCallsCounter", {
  39877. /**
  39878. * Gets the perf counter used for draw calls
  39879. */
  39880. get: function () {
  39881. return this.scene.getEngine()._drawCalls;
  39882. },
  39883. enumerable: true,
  39884. configurable: true
  39885. });
  39886. Object.defineProperty(SceneInstrumentation.prototype, "textureCollisionsCounter", {
  39887. /**
  39888. * Gets the perf counter used for texture collisions
  39889. */
  39890. get: function () {
  39891. return this.scene.getEngine()._textureCollisions;
  39892. },
  39893. enumerable: true,
  39894. configurable: true
  39895. });
  39896. /**
  39897. * Dispose and release associated resources.
  39898. */
  39899. SceneInstrumentation.prototype.dispose = function () {
  39900. this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  39901. this._onAfterRenderObserver = null;
  39902. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  39903. this._onBeforeActiveMeshesEvaluationObserver = null;
  39904. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  39905. this._onAfterActiveMeshesEvaluationObserver = null;
  39906. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  39907. this._onBeforeRenderTargetsRenderObserver = null;
  39908. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  39909. this._onAfterRenderTargetsRenderObserver = null;
  39910. this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);
  39911. this._onBeforeAnimationsObserver = null;
  39912. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  39913. this._onBeforeParticlesRenderingObserver = null;
  39914. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  39915. this._onAfterParticlesRenderingObserver = null;
  39916. if (this._onBeforeSpritesRenderingObserver) {
  39917. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  39918. this._onBeforeSpritesRenderingObserver = null;
  39919. }
  39920. if (this._onAfterSpritesRenderingObserver) {
  39921. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  39922. this._onAfterSpritesRenderingObserver = null;
  39923. }
  39924. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  39925. this._onBeforeDrawPhaseObserver = null;
  39926. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  39927. this._onAfterDrawPhaseObserver = null;
  39928. if (this._onBeforePhysicsObserver) {
  39929. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  39930. this._onBeforePhysicsObserver = null;
  39931. }
  39932. if (this._onAfterPhysicsObserver) {
  39933. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  39934. this._onAfterPhysicsObserver = null;
  39935. }
  39936. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  39937. this._onAfterAnimationsObserver = null;
  39938. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  39939. this._onBeforeCameraRenderObserver = null;
  39940. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  39941. this._onAfterCameraRenderObserver = null;
  39942. this.scene = null;
  39943. };
  39944. return SceneInstrumentation;
  39945. }());
  39946. /***/ }),
  39947. /***/ "./Instrumentation/timeToken.ts":
  39948. /*!**************************************!*\
  39949. !*** ./Instrumentation/timeToken.ts ***!
  39950. \**************************************/
  39951. /*! exports provided: _TimeToken */
  39952. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39953. "use strict";
  39954. __webpack_require__.r(__webpack_exports__);
  39955. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _TimeToken; });
  39956. /**
  39957. * @hidden
  39958. **/
  39959. var _TimeToken = /** @class */ (function () {
  39960. function _TimeToken() {
  39961. this._timeElapsedQueryEnded = false;
  39962. }
  39963. return _TimeToken;
  39964. }());
  39965. /***/ }),
  39966. /***/ "./Layers/effectLayer.ts":
  39967. /*!*******************************!*\
  39968. !*** ./Layers/effectLayer.ts ***!
  39969. \*******************************/
  39970. /*! exports provided: EffectLayer */
  39971. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39972. "use strict";
  39973. __webpack_require__.r(__webpack_exports__);
  39974. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return EffectLayer; });
  39975. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39976. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  39977. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  39978. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39979. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39980. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  39981. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  39982. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39983. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  39984. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  39985. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  39986. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  39987. /* harmony import */ var _Shaders_glowMapGeneration_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.fragment */ "./Shaders/glowMapGeneration.fragment.ts");
  39988. /* harmony import */ var _Shaders_glowMapGeneration_vertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.vertex */ "./Shaders/glowMapGeneration.vertex.ts");
  39989. /**
  39990. * The effect layer Helps adding post process effect blended with the main pass.
  39991. *
  39992. * This can be for instance use to generate glow or higlight effects on the scene.
  39993. *
  39994. * The effect layer class can not be used directly and is intented to inherited from to be
  39995. * customized per effects.
  39996. */
  39997. var EffectLayer = /** @class */ (function () {
  39998. /**
  39999. * Instantiates a new effect Layer and references it in the scene.
  40000. * @param name The name of the layer
  40001. * @param scene The scene to use the layer in
  40002. */
  40003. function EffectLayer(
  40004. /** The Friendly of the effect in the scene */
  40005. name, scene) {
  40006. this._vertexBuffers = {};
  40007. this._maxSize = 0;
  40008. this._mainTextureDesiredSize = { width: 0, height: 0 };
  40009. this._shouldRender = true;
  40010. this._postProcesses = [];
  40011. this._textures = [];
  40012. this._emissiveTextureAndColor = { texture: null, color: new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]() };
  40013. /**
  40014. * The clear color of the texture used to generate the glow map.
  40015. */
  40016. this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]();
  40017. /**
  40018. * Specifies wether the highlight layer is enabled or not.
  40019. */
  40020. this.isEnabled = true;
  40021. /**
  40022. * An event triggered when the effect layer has been disposed.
  40023. */
  40024. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40025. /**
  40026. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  40027. */
  40028. this.onBeforeRenderMainTextureObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40029. /**
  40030. * An event triggered when the generated texture is being merged in the scene.
  40031. */
  40032. this.onBeforeComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40033. /**
  40034. * An event triggered when the generated texture has been merged in the scene.
  40035. */
  40036. this.onAfterComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40037. /**
  40038. * An event triggered when the efffect layer changes its size.
  40039. */
  40040. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40041. this.name = name;
  40042. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  40043. EffectLayer._SceneComponentInitialization(this._scene);
  40044. this._engine = this._scene.getEngine();
  40045. this._maxSize = this._engine.getCaps().maxTextureSize;
  40046. this._scene.effectLayers.push(this);
  40047. // Generate Buffers
  40048. this._generateIndexBuffer();
  40049. this._genrateVertexBuffer();
  40050. }
  40051. Object.defineProperty(EffectLayer.prototype, "camera", {
  40052. /**
  40053. * Gets the camera attached to the layer.
  40054. */
  40055. get: function () {
  40056. return this._effectLayerOptions.camera;
  40057. },
  40058. enumerable: true,
  40059. configurable: true
  40060. });
  40061. Object.defineProperty(EffectLayer.prototype, "renderingGroupId", {
  40062. /**
  40063. * Gets the rendering group id the layer should render in.
  40064. */
  40065. get: function () {
  40066. return this._effectLayerOptions.renderingGroupId;
  40067. },
  40068. enumerable: true,
  40069. configurable: true
  40070. });
  40071. /**
  40072. * Initializes the effect layer with the required options.
  40073. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  40074. */
  40075. EffectLayer.prototype._init = function (options) {
  40076. // Adapt options
  40077. 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);
  40078. this._setMainTextureSize();
  40079. this._createMainTexture();
  40080. this._createTextureAndPostProcesses();
  40081. this._mergeEffect = this._createMergeEffect();
  40082. };
  40083. /**
  40084. * Generates the index buffer of the full screen quad blending to the main canvas.
  40085. */
  40086. EffectLayer.prototype._generateIndexBuffer = function () {
  40087. // Indices
  40088. var indices = [];
  40089. indices.push(0);
  40090. indices.push(1);
  40091. indices.push(2);
  40092. indices.push(0);
  40093. indices.push(2);
  40094. indices.push(3);
  40095. this._indexBuffer = this._engine.createIndexBuffer(indices);
  40096. };
  40097. /**
  40098. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  40099. */
  40100. EffectLayer.prototype._genrateVertexBuffer = function () {
  40101. // VBO
  40102. var vertices = [];
  40103. vertices.push(1, 1);
  40104. vertices.push(-1, 1);
  40105. vertices.push(-1, -1);
  40106. vertices.push(1, -1);
  40107. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"](this._engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind, false, false, 2);
  40108. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = vertexBuffer;
  40109. };
  40110. /**
  40111. * Sets the main texture desired size which is the closest power of two
  40112. * of the engine canvas size.
  40113. */
  40114. EffectLayer.prototype._setMainTextureSize = function () {
  40115. if (this._effectLayerOptions.mainTextureFixedSize) {
  40116. this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize;
  40117. this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize;
  40118. }
  40119. else {
  40120. this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio;
  40121. this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio;
  40122. this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width;
  40123. this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height;
  40124. }
  40125. this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width);
  40126. this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height);
  40127. };
  40128. /**
  40129. * Creates the main texture for the effect layer.
  40130. */
  40131. EffectLayer.prototype._createMainTexture = function () {
  40132. var _this = this;
  40133. this._mainTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerMainRTT", {
  40134. width: this._mainTextureDesiredSize.width,
  40135. height: this._mainTextureDesiredSize.height
  40136. }, this._scene, false, true, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  40137. this._mainTexture.activeCamera = this._effectLayerOptions.camera;
  40138. this._mainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  40139. this._mainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  40140. this._mainTexture.anisotropicFilteringLevel = 1;
  40141. this._mainTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE);
  40142. this._mainTexture.renderParticles = false;
  40143. this._mainTexture.renderList = null;
  40144. this._mainTexture.ignoreCameraViewport = true;
  40145. // Custom render function
  40146. this._mainTexture.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  40147. _this.onBeforeRenderMainTextureObservable.notifyObservers(_this);
  40148. var index;
  40149. var engine = _this._scene.getEngine();
  40150. if (depthOnlySubMeshes.length) {
  40151. engine.setColorWrite(false);
  40152. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  40153. _this._renderSubMesh(depthOnlySubMeshes.data[index]);
  40154. }
  40155. engine.setColorWrite(true);
  40156. }
  40157. for (index = 0; index < opaqueSubMeshes.length; index++) {
  40158. _this._renderSubMesh(opaqueSubMeshes.data[index]);
  40159. }
  40160. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  40161. _this._renderSubMesh(alphaTestSubMeshes.data[index]);
  40162. }
  40163. for (index = 0; index < transparentSubMeshes.length; index++) {
  40164. _this._renderSubMesh(transparentSubMeshes.data[index]);
  40165. }
  40166. };
  40167. this._mainTexture.onClearObservable.add(function (engine) {
  40168. engine.clear(_this.neutralColor, true, true, true);
  40169. });
  40170. };
  40171. /**
  40172. * Adds specific effects defines.
  40173. * @param defines The defines to add specifics to.
  40174. */
  40175. EffectLayer.prototype._addCustomEffectDefines = function (defines) {
  40176. // Nothing to add by default.
  40177. };
  40178. /**
  40179. * Checks for the readiness of the element composing the layer.
  40180. * @param subMesh the mesh to check for
  40181. * @param useInstances specify wether or not to use instances to render the mesh
  40182. * @param emissiveTexture the associated emissive texture used to generate the glow
  40183. * @return true if ready otherwise, false
  40184. */
  40185. EffectLayer.prototype._isReady = function (subMesh, useInstances, emissiveTexture) {
  40186. var material = subMesh.getMaterial();
  40187. if (!material) {
  40188. return false;
  40189. }
  40190. if (!material.isReadyForSubMesh(subMesh.getMesh(), subMesh, useInstances)) {
  40191. return false;
  40192. }
  40193. var defines = [];
  40194. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  40195. var mesh = subMesh.getMesh();
  40196. var uv1 = false;
  40197. var uv2 = false;
  40198. // Diffuse
  40199. if (material) {
  40200. var needAlphaTest = material.needAlphaTesting();
  40201. var diffuseTexture = material.getAlphaTestTexture();
  40202. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  40203. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  40204. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  40205. defines.push("#define DIFFUSE");
  40206. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  40207. diffuseTexture.coordinatesIndex === 1) {
  40208. defines.push("#define DIFFUSEUV2");
  40209. uv2 = true;
  40210. }
  40211. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  40212. defines.push("#define DIFFUSEUV1");
  40213. uv1 = true;
  40214. }
  40215. if (needAlphaTest) {
  40216. defines.push("#define ALPHATEST");
  40217. defines.push("#define ALPHATESTVALUE 0.4");
  40218. }
  40219. }
  40220. var opacityTexture = material.opacityTexture;
  40221. if (opacityTexture) {
  40222. defines.push("#define OPACITY");
  40223. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  40224. opacityTexture.coordinatesIndex === 1) {
  40225. defines.push("#define OPACITYUV2");
  40226. uv2 = true;
  40227. }
  40228. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  40229. defines.push("#define OPACITYUV1");
  40230. uv1 = true;
  40231. }
  40232. }
  40233. }
  40234. // Emissive
  40235. if (emissiveTexture) {
  40236. defines.push("#define EMISSIVE");
  40237. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  40238. emissiveTexture.coordinatesIndex === 1) {
  40239. defines.push("#define EMISSIVEUV2");
  40240. uv2 = true;
  40241. }
  40242. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  40243. defines.push("#define EMISSIVEUV1");
  40244. uv1 = true;
  40245. }
  40246. }
  40247. // Vertex
  40248. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind) && mesh.hasVertexAlpha) {
  40249. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind);
  40250. defines.push("#define VERTEXALPHA");
  40251. }
  40252. if (uv1) {
  40253. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind);
  40254. defines.push("#define UV1");
  40255. }
  40256. if (uv2) {
  40257. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind);
  40258. defines.push("#define UV2");
  40259. }
  40260. // Bones
  40261. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  40262. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesKind);
  40263. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsKind);
  40264. if (mesh.numBoneInfluencers > 4) {
  40265. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesExtraKind);
  40266. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsExtraKind);
  40267. }
  40268. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  40269. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  40270. }
  40271. else {
  40272. defines.push("#define NUM_BONE_INFLUENCERS 0");
  40273. }
  40274. // Morph targets
  40275. var manager = mesh.morphTargetManager;
  40276. var morphInfluencers = 0;
  40277. if (manager) {
  40278. if (manager.numInfluencers > 0) {
  40279. defines.push("#define MORPHTARGETS");
  40280. morphInfluencers = manager.numInfluencers;
  40281. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  40282. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  40283. }
  40284. }
  40285. // Instances
  40286. if (useInstances) {
  40287. defines.push("#define INSTANCES");
  40288. attribs.push("world0");
  40289. attribs.push("world1");
  40290. attribs.push("world2");
  40291. attribs.push("world3");
  40292. }
  40293. this._addCustomEffectDefines(defines);
  40294. // Get correct effect
  40295. var join = defines.join("\n");
  40296. if (this._cachedDefines !== join) {
  40297. this._cachedDefines = join;
  40298. this._effectLayerMapGenerationEffect = this._scene.getEngine().createEffect("glowMapGeneration", attribs, ["world", "mBones", "viewProjection",
  40299. "color", "morphTargetInfluences",
  40300. "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity"], ["diffuseSampler", "emissiveSampler", "opacitySampler"], join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  40301. }
  40302. return this._effectLayerMapGenerationEffect.isReady();
  40303. };
  40304. /**
  40305. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  40306. */
  40307. EffectLayer.prototype.render = function () {
  40308. var currentEffect = this._mergeEffect;
  40309. // Check
  40310. if (!currentEffect.isReady()) {
  40311. return;
  40312. }
  40313. for (var i = 0; i < this._postProcesses.length; i++) {
  40314. if (!this._postProcesses[i].isReady()) {
  40315. return;
  40316. }
  40317. }
  40318. var engine = this._scene.getEngine();
  40319. this.onBeforeComposeObservable.notifyObservers(this);
  40320. // Render
  40321. engine.enableEffect(currentEffect);
  40322. engine.setState(false);
  40323. // VBOs
  40324. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  40325. // Cache
  40326. var previousAlphaMode = engine.getAlphaMode();
  40327. // Go Blend.
  40328. engine.setAlphaMode(this._effectLayerOptions.alphaBlendingMode);
  40329. // Blends the map on the main canvas.
  40330. this._internalRender(currentEffect);
  40331. // Restore Alpha
  40332. engine.setAlphaMode(previousAlphaMode);
  40333. this.onAfterComposeObservable.notifyObservers(this);
  40334. // Handle size changes.
  40335. var size = this._mainTexture.getSize();
  40336. this._setMainTextureSize();
  40337. if (size.width !== this._mainTextureDesiredSize.width || size.height !== this._mainTextureDesiredSize.height) {
  40338. // Recreate RTT and post processes on size change.
  40339. this.onSizeChangedObservable.notifyObservers(this);
  40340. this._disposeTextureAndPostProcesses();
  40341. this._createMainTexture();
  40342. this._createTextureAndPostProcesses();
  40343. }
  40344. };
  40345. /**
  40346. * Determine if a given mesh will be used in the current effect.
  40347. * @param mesh mesh to test
  40348. * @returns true if the mesh will be used
  40349. */
  40350. EffectLayer.prototype.hasMesh = function (mesh) {
  40351. if (this.renderingGroupId === -1 || mesh.renderingGroupId === this.renderingGroupId) {
  40352. return true;
  40353. }
  40354. return false;
  40355. };
  40356. /**
  40357. * Returns true if the layer contains information to display, otherwise false.
  40358. * @returns true if the glow layer should be rendered
  40359. */
  40360. EffectLayer.prototype.shouldRender = function () {
  40361. return this.isEnabled && this._shouldRender;
  40362. };
  40363. /**
  40364. * Returns true if the mesh should render, otherwise false.
  40365. * @param mesh The mesh to render
  40366. * @returns true if it should render otherwise false
  40367. */
  40368. EffectLayer.prototype._shouldRenderMesh = function (mesh) {
  40369. return true;
  40370. };
  40371. /**
  40372. * Returns true if the mesh can be rendered, otherwise false.
  40373. * @param mesh The mesh to render
  40374. * @param material The material used on the mesh
  40375. * @returns true if it can be rendered otherwise false
  40376. */
  40377. EffectLayer.prototype._canRenderMesh = function (mesh, material) {
  40378. return !material.needAlphaBlendingForMesh(mesh);
  40379. };
  40380. /**
  40381. * Returns true if the mesh should render, otherwise false.
  40382. * @param mesh The mesh to render
  40383. * @returns true if it should render otherwise false
  40384. */
  40385. EffectLayer.prototype._shouldRenderEmissiveTextureForMesh = function () {
  40386. return true;
  40387. };
  40388. /**
  40389. * Renders the submesh passed in parameter to the generation map.
  40390. */
  40391. EffectLayer.prototype._renderSubMesh = function (subMesh) {
  40392. var _this = this;
  40393. if (!this.shouldRender()) {
  40394. return;
  40395. }
  40396. var material = subMesh.getMaterial();
  40397. var mesh = subMesh.getRenderingMesh();
  40398. var scene = this._scene;
  40399. var engine = scene.getEngine();
  40400. if (!material) {
  40401. return;
  40402. }
  40403. // Do not block in blend mode.
  40404. if (!this._canRenderMesh(mesh, material)) {
  40405. return;
  40406. }
  40407. // Culling
  40408. engine.setState(material.backFaceCulling);
  40409. // Managing instances
  40410. var batch = mesh._getInstancesRenderList(subMesh._id);
  40411. if (batch.mustReturn) {
  40412. return;
  40413. }
  40414. // Early Exit per mesh
  40415. if (!this._shouldRenderMesh(mesh)) {
  40416. return;
  40417. }
  40418. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  40419. this._setEmissiveTextureAndColor(mesh, subMesh, material);
  40420. if (this._isReady(subMesh, hardwareInstancedRendering, this._emissiveTextureAndColor.texture)) {
  40421. engine.enableEffect(this._effectLayerMapGenerationEffect);
  40422. mesh._bind(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode);
  40423. this._effectLayerMapGenerationEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  40424. this._effectLayerMapGenerationEffect.setFloat4("color", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a);
  40425. var needAlphaTest = material.needAlphaTesting();
  40426. var diffuseTexture = material.getAlphaTestTexture();
  40427. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  40428. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  40429. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  40430. this._effectLayerMapGenerationEffect.setTexture("diffuseSampler", diffuseTexture);
  40431. var textureMatrix = diffuseTexture.getTextureMatrix();
  40432. if (textureMatrix) {
  40433. this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix", textureMatrix);
  40434. }
  40435. }
  40436. var opacityTexture = material.opacityTexture;
  40437. if (opacityTexture) {
  40438. this._effectLayerMapGenerationEffect.setTexture("opacitySampler", opacityTexture);
  40439. this._effectLayerMapGenerationEffect.setFloat("opacityIntensity", opacityTexture.level);
  40440. var textureMatrix = opacityTexture.getTextureMatrix();
  40441. if (textureMatrix) {
  40442. this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix", textureMatrix);
  40443. }
  40444. }
  40445. // Glow emissive only
  40446. if (this._emissiveTextureAndColor.texture) {
  40447. this._effectLayerMapGenerationEffect.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture);
  40448. this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix());
  40449. }
  40450. // Bones
  40451. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  40452. this._effectLayerMapGenerationEffect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  40453. }
  40454. // Morph targets
  40455. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effectLayerMapGenerationEffect);
  40456. // Draw
  40457. mesh._processRendering(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effectLayerMapGenerationEffect.setMatrix("world", world); });
  40458. }
  40459. else {
  40460. // Need to reset refresh rate of the main map
  40461. this._mainTexture.resetRefreshCounter();
  40462. }
  40463. };
  40464. /**
  40465. * Rebuild the required buffers.
  40466. * @hidden Internal use only.
  40467. */
  40468. EffectLayer.prototype._rebuild = function () {
  40469. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  40470. if (vb) {
  40471. vb._rebuild();
  40472. }
  40473. this._generateIndexBuffer();
  40474. };
  40475. /**
  40476. * Dispose only the render target textures and post process.
  40477. */
  40478. EffectLayer.prototype._disposeTextureAndPostProcesses = function () {
  40479. this._mainTexture.dispose();
  40480. for (var i = 0; i < this._postProcesses.length; i++) {
  40481. if (this._postProcesses[i]) {
  40482. this._postProcesses[i].dispose();
  40483. }
  40484. }
  40485. this._postProcesses = [];
  40486. for (var i = 0; i < this._textures.length; i++) {
  40487. if (this._textures[i]) {
  40488. this._textures[i].dispose();
  40489. }
  40490. }
  40491. this._textures = [];
  40492. };
  40493. /**
  40494. * Dispose the highlight layer and free resources.
  40495. */
  40496. EffectLayer.prototype.dispose = function () {
  40497. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  40498. if (vertexBuffer) {
  40499. vertexBuffer.dispose();
  40500. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = null;
  40501. }
  40502. if (this._indexBuffer) {
  40503. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  40504. this._indexBuffer = null;
  40505. }
  40506. // Clean textures and post processes
  40507. this._disposeTextureAndPostProcesses();
  40508. // Remove from scene
  40509. var index = this._scene.effectLayers.indexOf(this, 0);
  40510. if (index > -1) {
  40511. this._scene.effectLayers.splice(index, 1);
  40512. }
  40513. // Callback
  40514. this.onDisposeObservable.notifyObservers(this);
  40515. this.onDisposeObservable.clear();
  40516. this.onBeforeRenderMainTextureObservable.clear();
  40517. this.onBeforeComposeObservable.clear();
  40518. this.onAfterComposeObservable.clear();
  40519. this.onSizeChangedObservable.clear();
  40520. };
  40521. /**
  40522. * Gets the class name of the effect layer
  40523. * @returns the string with the class name of the effect layer
  40524. */
  40525. EffectLayer.prototype.getClassName = function () {
  40526. return "EffectLayer";
  40527. };
  40528. /**
  40529. * Creates an effect layer from parsed effect layer data
  40530. * @param parsedEffectLayer defines effect layer data
  40531. * @param scene defines the current scene
  40532. * @param rootUrl defines the root URL containing the effect layer information
  40533. * @returns a parsed effect Layer
  40534. */
  40535. EffectLayer.Parse = function (parsedEffectLayer, scene, rootUrl) {
  40536. var effectLayerType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedEffectLayer.customType);
  40537. return effectLayerType.Parse(parsedEffectLayer, scene, rootUrl);
  40538. };
  40539. /** @hidden */
  40540. EffectLayer._SceneComponentInitialization = function (_) {
  40541. throw "Import EffectLayerSceneComponent before creating EffectLayer.";
  40542. };
  40543. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  40544. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  40545. ], EffectLayer.prototype, "name", void 0);
  40546. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  40547. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  40548. ], EffectLayer.prototype, "neutralColor", void 0);
  40549. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  40550. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  40551. ], EffectLayer.prototype, "isEnabled", void 0);
  40552. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  40553. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsCameraReference"])()
  40554. ], EffectLayer.prototype, "camera", null);
  40555. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  40556. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  40557. ], EffectLayer.prototype, "renderingGroupId", null);
  40558. return EffectLayer;
  40559. }());
  40560. /***/ }),
  40561. /***/ "./Layers/effectLayerSceneComponent.ts":
  40562. /*!*********************************************!*\
  40563. !*** ./Layers/effectLayerSceneComponent.ts ***!
  40564. \*********************************************/
  40565. /*! exports provided: EffectLayerSceneComponent */
  40566. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40567. "use strict";
  40568. __webpack_require__.r(__webpack_exports__);
  40569. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return EffectLayerSceneComponent; });
  40570. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  40571. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  40572. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  40573. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  40574. // Adds the parser to the scene parsers.
  40575. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER, function (parsedData, scene, container, rootUrl) {
  40576. if (parsedData.effectLayers) {
  40577. if (!container.effectLayers) {
  40578. container.effectLayers = new Array();
  40579. }
  40580. for (var index = 0; index < parsedData.effectLayers.length; index++) {
  40581. var effectLayer = _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"].Parse(parsedData.effectLayers[index], scene, rootUrl);
  40582. container.effectLayers.push(effectLayer);
  40583. }
  40584. }
  40585. });
  40586. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.removeEffectLayer = function (toRemove) {
  40587. var index = this.effectLayers.indexOf(toRemove);
  40588. if (index !== -1) {
  40589. this.effectLayers.splice(index, 1);
  40590. }
  40591. return index;
  40592. };
  40593. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.addEffectLayer = function (newEffectLayer) {
  40594. this.effectLayers.push(newEffectLayer);
  40595. };
  40596. /**
  40597. * Defines the layer scene component responsible to manage any effect layers
  40598. * in a given scene.
  40599. */
  40600. var EffectLayerSceneComponent = /** @class */ (function () {
  40601. /**
  40602. * Creates a new instance of the component for the given scene
  40603. * @param scene Defines the scene to register the component in
  40604. */
  40605. function EffectLayerSceneComponent(scene) {
  40606. /**
  40607. * The component name helpfull to identify the component in the list of scene components.
  40608. */
  40609. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER;
  40610. this._renderEffects = false;
  40611. this._needStencil = false;
  40612. this._previousStencilState = false;
  40613. this.scene = scene;
  40614. this._engine = scene.getEngine();
  40615. scene.effectLayers = new Array();
  40616. }
  40617. /**
  40618. * Registers the component in a given scene
  40619. */
  40620. EffectLayerSceneComponent.prototype.register = function () {
  40621. this.scene._isReadyForMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh);
  40622. this.scene._cameraDrawRenderTargetStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture);
  40623. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil);
  40624. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup);
  40625. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack);
  40626. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera);
  40627. };
  40628. /**
  40629. * Rebuilds the elements related to this component in case of
  40630. * context lost for instance.
  40631. */
  40632. EffectLayerSceneComponent.prototype.rebuild = function () {
  40633. var layers = this.scene.effectLayers;
  40634. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  40635. var effectLayer = layers_1[_i];
  40636. effectLayer._rebuild();
  40637. }
  40638. };
  40639. /**
  40640. * Serializes the component data to the specified json object
  40641. * @param serializationObject The object to serialize to
  40642. */
  40643. EffectLayerSceneComponent.prototype.serialize = function (serializationObject) {
  40644. // Effect layers
  40645. serializationObject.effectLayers = [];
  40646. var layers = this.scene.effectLayers;
  40647. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  40648. var effectLayer = layers_2[_i];
  40649. if (effectLayer.serialize) {
  40650. serializationObject.effectLayers.push(effectLayer.serialize());
  40651. }
  40652. }
  40653. };
  40654. /**
  40655. * Adds all the element from the container to the scene
  40656. * @param container the container holding the elements
  40657. */
  40658. EffectLayerSceneComponent.prototype.addFromContainer = function (container) {
  40659. var _this = this;
  40660. if (!container.effectLayers) {
  40661. return;
  40662. }
  40663. container.effectLayers.forEach(function (o) {
  40664. _this.scene.addEffectLayer(o);
  40665. });
  40666. };
  40667. /**
  40668. * Removes all the elements in the container from the scene
  40669. * @param container contains the elements to remove
  40670. */
  40671. EffectLayerSceneComponent.prototype.removeFromContainer = function (container) {
  40672. var _this = this;
  40673. if (!container.effectLayers) {
  40674. return;
  40675. }
  40676. container.effectLayers.forEach(function (o) {
  40677. _this.scene.removeEffectLayer(o);
  40678. });
  40679. };
  40680. /**
  40681. * Disposes the component and the associated ressources.
  40682. */
  40683. EffectLayerSceneComponent.prototype.dispose = function () {
  40684. var layers = this.scene.effectLayers;
  40685. while (layers.length) {
  40686. layers[0].dispose();
  40687. }
  40688. };
  40689. EffectLayerSceneComponent.prototype._isReadyForMesh = function (mesh, hardwareInstancedRendering) {
  40690. var layers = this.scene.effectLayers;
  40691. for (var _i = 0, layers_3 = layers; _i < layers_3.length; _i++) {
  40692. var layer = layers_3[_i];
  40693. if (!layer.hasMesh(mesh)) {
  40694. continue;
  40695. }
  40696. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  40697. var subMesh = _b[_a];
  40698. if (!layer.isReady(subMesh, hardwareInstancedRendering)) {
  40699. return false;
  40700. }
  40701. }
  40702. }
  40703. return true;
  40704. };
  40705. EffectLayerSceneComponent.prototype._renderMainTexture = function (camera) {
  40706. this._renderEffects = false;
  40707. this._needStencil = false;
  40708. var layers = this.scene.effectLayers;
  40709. if (layers && layers.length > 0) {
  40710. this._previousStencilState = this._engine.getStencilBuffer();
  40711. for (var _i = 0, layers_4 = layers; _i < layers_4.length; _i++) {
  40712. var effectLayer = layers_4[_i];
  40713. if (effectLayer.shouldRender() &&
  40714. (!effectLayer.camera ||
  40715. (effectLayer.camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && camera === effectLayer.camera) ||
  40716. (effectLayer.camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && effectLayer.camera._rigCameras.indexOf(camera) > -1))) {
  40717. this._renderEffects = true;
  40718. this._needStencil = this._needStencil || effectLayer.needStencil();
  40719. var renderTarget = effectLayer._mainTexture;
  40720. if (renderTarget._shouldRender()) {
  40721. this.scene.incrementRenderId();
  40722. renderTarget.render(false, false);
  40723. }
  40724. }
  40725. }
  40726. this.scene.incrementRenderId();
  40727. }
  40728. };
  40729. EffectLayerSceneComponent.prototype._setStencil = function () {
  40730. // Activate effect Layer stencil
  40731. if (this._needStencil) {
  40732. this._engine.setStencilBuffer(true);
  40733. }
  40734. };
  40735. EffectLayerSceneComponent.prototype._setStencilBack = function () {
  40736. // Restore effect Layer stencil
  40737. if (this._needStencil) {
  40738. this._engine.setStencilBuffer(this._previousStencilState);
  40739. }
  40740. };
  40741. EffectLayerSceneComponent.prototype._draw = function (renderingGroupId) {
  40742. if (this._renderEffects) {
  40743. this._engine.setDepthBuffer(false);
  40744. var layers = this.scene.effectLayers;
  40745. for (var i = 0; i < layers.length; i++) {
  40746. var effectLayer = layers[i];
  40747. if (effectLayer.renderingGroupId === renderingGroupId) {
  40748. if (effectLayer.shouldRender()) {
  40749. effectLayer.render();
  40750. }
  40751. }
  40752. }
  40753. this._engine.setDepthBuffer(true);
  40754. }
  40755. };
  40756. EffectLayerSceneComponent.prototype._drawCamera = function () {
  40757. if (this._renderEffects) {
  40758. this._draw(-1);
  40759. }
  40760. };
  40761. EffectLayerSceneComponent.prototype._drawRenderingGroup = function (index) {
  40762. if (!this.scene._isInIntermediateRendering() && this._renderEffects) {
  40763. this._draw(index);
  40764. }
  40765. };
  40766. return EffectLayerSceneComponent;
  40767. }());
  40768. _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"]._SceneComponentInitialization = function (scene) {
  40769. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER);
  40770. if (!component) {
  40771. component = new EffectLayerSceneComponent(scene);
  40772. scene._addComponent(component);
  40773. }
  40774. };
  40775. /***/ }),
  40776. /***/ "./Layers/glowLayer.ts":
  40777. /*!*****************************!*\
  40778. !*** ./Layers/glowLayer.ts ***!
  40779. \*****************************/
  40780. /*! exports provided: GlowLayer */
  40781. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40782. "use strict";
  40783. __webpack_require__.r(__webpack_exports__);
  40784. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return GlowLayer; });
  40785. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40786. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  40787. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40788. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40789. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  40790. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40791. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  40792. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  40793. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  40794. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  40795. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  40796. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  40797. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  40798. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  40799. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  40800. _abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"].prototype.getGlowLayerByName = function (name) {
  40801. for (var index = 0; index < this.effectLayers.length; index++) {
  40802. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === GlowLayer.EffectName) {
  40803. return this.effectLayers[index];
  40804. }
  40805. }
  40806. return null;
  40807. };
  40808. /**
  40809. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  40810. *
  40811. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  40812. * glowy meshes to your scene.
  40813. *
  40814. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  40815. */
  40816. var GlowLayer = /** @class */ (function (_super) {
  40817. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowLayer, _super);
  40818. /**
  40819. * Instantiates a new glow Layer and references it to the scene.
  40820. * @param name The name of the layer
  40821. * @param scene The scene to use the layer in
  40822. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  40823. */
  40824. function GlowLayer(name, scene, options) {
  40825. var _this = _super.call(this, name, scene) || this;
  40826. _this._intensity = 1.0;
  40827. _this._includedOnlyMeshes = [];
  40828. _this._excludedMeshes = [];
  40829. _this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 1);
  40830. // Adapt options
  40831. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: GlowLayer.DefaultTextureRatio, blurKernelSize: 32, mainTextureFixedSize: undefined, camera: null, mainTextureSamples: 1, renderingGroupId: -1 }, options);
  40832. // Initialize the layer
  40833. _this._init({
  40834. alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ALPHA_ADD,
  40835. camera: _this._options.camera,
  40836. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  40837. mainTextureRatio: _this._options.mainTextureRatio,
  40838. renderingGroupId: _this._options.renderingGroupId
  40839. });
  40840. return _this;
  40841. }
  40842. Object.defineProperty(GlowLayer.prototype, "blurKernelSize", {
  40843. /**
  40844. * Gets the kernel size of the blur.
  40845. */
  40846. get: function () {
  40847. return this._horizontalBlurPostprocess1.kernel;
  40848. },
  40849. /**
  40850. * Sets the kernel size of the blur.
  40851. */
  40852. set: function (value) {
  40853. this._horizontalBlurPostprocess1.kernel = value;
  40854. this._verticalBlurPostprocess1.kernel = value;
  40855. this._horizontalBlurPostprocess2.kernel = value;
  40856. this._verticalBlurPostprocess2.kernel = value;
  40857. },
  40858. enumerable: true,
  40859. configurable: true
  40860. });
  40861. Object.defineProperty(GlowLayer.prototype, "intensity", {
  40862. /**
  40863. * Gets the glow intensity.
  40864. */
  40865. get: function () {
  40866. return this._intensity;
  40867. },
  40868. /**
  40869. * Sets the glow intensity.
  40870. */
  40871. set: function (value) {
  40872. this._intensity = value;
  40873. },
  40874. enumerable: true,
  40875. configurable: true
  40876. });
  40877. /**
  40878. * Get the effect name of the layer.
  40879. * @return The effect name
  40880. */
  40881. GlowLayer.prototype.getEffectName = function () {
  40882. return GlowLayer.EffectName;
  40883. };
  40884. /**
  40885. * Create the merge effect. This is the shader use to blit the information back
  40886. * to the main canvas at the end of the scene rendering.
  40887. */
  40888. GlowLayer.prototype._createMergeEffect = function () {
  40889. // Effect
  40890. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler", "textureSampler2"], "#define EMISSIVE \n");
  40891. };
  40892. /**
  40893. * Creates the render target textures and post processes used in the glow layer.
  40894. */
  40895. GlowLayer.prototype._createTextureAndPostProcesses = function () {
  40896. var _this = this;
  40897. var blurTextureWidth = this._mainTextureDesiredSize.width;
  40898. var blurTextureHeight = this._mainTextureDesiredSize.height;
  40899. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  40900. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  40901. var textureType = 0;
  40902. if (this._engine.getCaps().textureHalfFloatRender) {
  40903. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_HALF_FLOAT;
  40904. }
  40905. else {
  40906. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  40907. }
  40908. this._blurTexture1 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT", {
  40909. width: blurTextureWidth,
  40910. height: blurTextureHeight
  40911. }, this._scene, false, true, textureType);
  40912. this._blurTexture1.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  40913. this._blurTexture1.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  40914. this._blurTexture1.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  40915. this._blurTexture1.renderParticles = false;
  40916. this._blurTexture1.ignoreCameraViewport = true;
  40917. var blurTextureWidth2 = Math.floor(blurTextureWidth / 2);
  40918. var blurTextureHeight2 = Math.floor(blurTextureHeight / 2);
  40919. this._blurTexture2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT2", {
  40920. width: blurTextureWidth2,
  40921. height: blurTextureHeight2
  40922. }, this._scene, false, true, textureType);
  40923. this._blurTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  40924. this._blurTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  40925. this._blurTexture2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  40926. this._blurTexture2.renderParticles = false;
  40927. this._blurTexture2.ignoreCameraViewport = true;
  40928. this._textures = [this._blurTexture1, this._blurTexture2];
  40929. 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, {
  40930. width: blurTextureWidth,
  40931. height: blurTextureHeight
  40932. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  40933. this._horizontalBlurPostprocess1.width = blurTextureWidth;
  40934. this._horizontalBlurPostprocess1.height = blurTextureHeight;
  40935. this._horizontalBlurPostprocess1.onApplyObservable.add(function (effect) {
  40936. effect.setTexture("textureSampler", _this._mainTexture);
  40937. });
  40938. 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, {
  40939. width: blurTextureWidth,
  40940. height: blurTextureHeight
  40941. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  40942. 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, {
  40943. width: blurTextureWidth2,
  40944. height: blurTextureHeight2
  40945. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  40946. this._horizontalBlurPostprocess2.width = blurTextureWidth2;
  40947. this._horizontalBlurPostprocess2.height = blurTextureHeight2;
  40948. this._horizontalBlurPostprocess2.onApplyObservable.add(function (effect) {
  40949. effect.setTexture("textureSampler", _this._blurTexture1);
  40950. });
  40951. 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, {
  40952. width: blurTextureWidth2,
  40953. height: blurTextureHeight2
  40954. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  40955. this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  40956. this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1];
  40957. this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  40958. this._mainTexture.samples = this._options.mainTextureSamples;
  40959. this._mainTexture.onAfterUnbindObservable.add(function () {
  40960. var internalTexture = _this._blurTexture1.getInternalTexture();
  40961. if (internalTexture) {
  40962. _this._scene.postProcessManager.directRender(_this._postProcesses1, internalTexture, true);
  40963. internalTexture = _this._blurTexture2.getInternalTexture();
  40964. if (internalTexture) {
  40965. _this._scene.postProcessManager.directRender(_this._postProcesses2, internalTexture, true);
  40966. }
  40967. }
  40968. });
  40969. // Prevent autoClear.
  40970. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  40971. };
  40972. /**
  40973. * Checks for the readiness of the element composing the layer.
  40974. * @param subMesh the mesh to check for
  40975. * @param useInstances specify wether or not to use instances to render the mesh
  40976. * @param emissiveTexture the associated emissive texture used to generate the glow
  40977. * @return true if ready otherwise, false
  40978. */
  40979. GlowLayer.prototype.isReady = function (subMesh, useInstances) {
  40980. var material = subMesh.getMaterial();
  40981. var mesh = subMesh.getRenderingMesh();
  40982. if (!material || !mesh) {
  40983. return false;
  40984. }
  40985. var emissiveTexture = material.emissiveTexture;
  40986. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  40987. };
  40988. /**
  40989. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  40990. */
  40991. GlowLayer.prototype.needStencil = function () {
  40992. return false;
  40993. };
  40994. /**
  40995. * Returns true if the mesh can be rendered, otherwise false.
  40996. * @param mesh The mesh to render
  40997. * @param material The material used on the mesh
  40998. * @returns true if it can be rendered otherwise false
  40999. */
  41000. GlowLayer.prototype._canRenderMesh = function (mesh, material) {
  41001. return true;
  41002. };
  41003. /**
  41004. * Implementation specific of rendering the generating effect on the main canvas.
  41005. * @param effect The effect used to render through
  41006. */
  41007. GlowLayer.prototype._internalRender = function (effect) {
  41008. // Texture
  41009. effect.setTexture("textureSampler", this._blurTexture1);
  41010. effect.setTexture("textureSampler2", this._blurTexture2);
  41011. effect.setFloat("offset", this._intensity);
  41012. // Cache
  41013. var engine = this._engine;
  41014. var previousStencilBuffer = engine.getStencilBuffer();
  41015. // Draw order
  41016. engine.setStencilBuffer(false);
  41017. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, 6);
  41018. // Draw order
  41019. engine.setStencilBuffer(previousStencilBuffer);
  41020. };
  41021. /**
  41022. * Sets the required values for both the emissive texture and and the main color.
  41023. */
  41024. GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  41025. var textureLevel = 1.0;
  41026. if (this.customEmissiveTextureSelector) {
  41027. this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
  41028. }
  41029. else {
  41030. if (material) {
  41031. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  41032. if (this._emissiveTextureAndColor.texture) {
  41033. textureLevel = this._emissiveTextureAndColor.texture.level;
  41034. }
  41035. }
  41036. else {
  41037. this._emissiveTextureAndColor.texture = null;
  41038. }
  41039. }
  41040. if (this.customEmissiveColorSelector) {
  41041. this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
  41042. }
  41043. else {
  41044. if (material.emissiveColor) {
  41045. this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, material.alpha);
  41046. }
  41047. else {
  41048. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  41049. }
  41050. }
  41051. };
  41052. /**
  41053. * Returns true if the mesh should render, otherwise false.
  41054. * @param mesh The mesh to render
  41055. * @returns true if it should render otherwise false
  41056. */
  41057. GlowLayer.prototype._shouldRenderMesh = function (mesh) {
  41058. return this.hasMesh(mesh);
  41059. };
  41060. /**
  41061. * Adds specific effects defines.
  41062. * @param defines The defines to add specifics to.
  41063. */
  41064. GlowLayer.prototype._addCustomEffectDefines = function (defines) {
  41065. defines.push("#define GLOW");
  41066. };
  41067. /**
  41068. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  41069. * @param mesh The mesh to exclude from the glow layer
  41070. */
  41071. GlowLayer.prototype.addExcludedMesh = function (mesh) {
  41072. if (this._excludedMeshes.indexOf(mesh.uniqueId) === -1) {
  41073. this._excludedMeshes.push(mesh.uniqueId);
  41074. }
  41075. };
  41076. /**
  41077. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  41078. * @param mesh The mesh to remove
  41079. */
  41080. GlowLayer.prototype.removeExcludedMesh = function (mesh) {
  41081. var index = this._excludedMeshes.indexOf(mesh.uniqueId);
  41082. if (index !== -1) {
  41083. this._excludedMeshes.splice(index, 1);
  41084. }
  41085. };
  41086. /**
  41087. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  41088. * @param mesh The mesh to include in the glow layer
  41089. */
  41090. GlowLayer.prototype.addIncludedOnlyMesh = function (mesh) {
  41091. if (this._includedOnlyMeshes.indexOf(mesh.uniqueId) === -1) {
  41092. this._includedOnlyMeshes.push(mesh.uniqueId);
  41093. }
  41094. };
  41095. /**
  41096. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  41097. * @param mesh The mesh to remove
  41098. */
  41099. GlowLayer.prototype.removeIncludedOnlyMesh = function (mesh) {
  41100. var index = this._includedOnlyMeshes.indexOf(mesh.uniqueId);
  41101. if (index !== -1) {
  41102. this._includedOnlyMeshes.splice(index, 1);
  41103. }
  41104. };
  41105. /**
  41106. * Determine if a given mesh will be used in the glow layer
  41107. * @param mesh The mesh to test
  41108. * @returns true if the mesh will be highlighted by the current glow layer
  41109. */
  41110. GlowLayer.prototype.hasMesh = function (mesh) {
  41111. if (!_super.prototype.hasMesh.call(this, mesh)) {
  41112. return false;
  41113. }
  41114. // Included Mesh
  41115. if (this._includedOnlyMeshes.length) {
  41116. return this._includedOnlyMeshes.indexOf(mesh.uniqueId) !== -1;
  41117. }
  41118. // Excluded Mesh
  41119. if (this._excludedMeshes.length) {
  41120. return this._excludedMeshes.indexOf(mesh.uniqueId) === -1;
  41121. }
  41122. return true;
  41123. };
  41124. /**
  41125. * Free any resources and references associated to a mesh.
  41126. * Internal use
  41127. * @param mesh The mesh to free.
  41128. * @hidden
  41129. */
  41130. GlowLayer.prototype._disposeMesh = function (mesh) {
  41131. this.removeIncludedOnlyMesh(mesh);
  41132. this.removeExcludedMesh(mesh);
  41133. };
  41134. /**
  41135. * Gets the class name of the effect layer
  41136. * @returns the string with the class name of the effect layer
  41137. */
  41138. GlowLayer.prototype.getClassName = function () {
  41139. return "GlowLayer";
  41140. };
  41141. /**
  41142. * Serializes this glow layer
  41143. * @returns a serialized glow layer object
  41144. */
  41145. GlowLayer.prototype.serialize = function () {
  41146. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  41147. serializationObject.customType = "BABYLON.GlowLayer";
  41148. var index;
  41149. // Included meshes
  41150. serializationObject.includedMeshes = [];
  41151. if (this._includedOnlyMeshes.length) {
  41152. for (index = 0; index < this._includedOnlyMeshes.length; index++) {
  41153. var mesh = this._scene.getMeshByUniqueID(this._includedOnlyMeshes[index]);
  41154. if (mesh) {
  41155. serializationObject.includedMeshes.push(mesh.id);
  41156. }
  41157. }
  41158. }
  41159. // Excluded meshes
  41160. serializationObject.excludedMeshes = [];
  41161. if (this._excludedMeshes.length) {
  41162. for (index = 0; index < this._excludedMeshes.length; index++) {
  41163. var mesh = this._scene.getMeshByUniqueID(this._excludedMeshes[index]);
  41164. if (mesh) {
  41165. serializationObject.excludedMeshes.push(mesh.id);
  41166. }
  41167. }
  41168. }
  41169. return serializationObject;
  41170. };
  41171. /**
  41172. * Creates a Glow Layer from parsed glow layer data
  41173. * @param parsedGlowLayer defines glow layer data
  41174. * @param scene defines the current scene
  41175. * @param rootUrl defines the root URL containing the glow layer information
  41176. * @returns a parsed Glow Layer
  41177. */
  41178. GlowLayer.Parse = function (parsedGlowLayer, scene, rootUrl) {
  41179. var gl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new GlowLayer(parsedGlowLayer.name, scene, parsedGlowLayer.options); }, parsedGlowLayer, scene, rootUrl);
  41180. var index;
  41181. // Excluded meshes
  41182. for (index = 0; index < parsedGlowLayer.excludedMeshes.length; index++) {
  41183. var mesh = scene.getMeshByID(parsedGlowLayer.excludedMeshes[index]);
  41184. if (mesh) {
  41185. gl.addExcludedMesh(mesh);
  41186. }
  41187. }
  41188. // Included meshes
  41189. for (index = 0; index < parsedGlowLayer.includedMeshes.length; index++) {
  41190. var mesh = scene.getMeshByID(parsedGlowLayer.includedMeshes[index]);
  41191. if (mesh) {
  41192. gl.addIncludedOnlyMesh(mesh);
  41193. }
  41194. }
  41195. return gl;
  41196. };
  41197. /**
  41198. * Effect Name of the layer.
  41199. */
  41200. GlowLayer.EffectName = "GlowLayer";
  41201. /**
  41202. * The default blur kernel size used for the glow.
  41203. */
  41204. GlowLayer.DefaultBlurKernelSize = 32;
  41205. /**
  41206. * The default texture size ratio used for the glow.
  41207. */
  41208. GlowLayer.DefaultTextureRatio = 0.5;
  41209. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41210. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41211. ], GlowLayer.prototype, "blurKernelSize", null);
  41212. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41213. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41214. ], GlowLayer.prototype, "intensity", null);
  41215. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41216. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  41217. ], GlowLayer.prototype, "_options", void 0);
  41218. return GlowLayer;
  41219. }(_effectLayer__WEBPACK_IMPORTED_MODULE_9__["EffectLayer"]));
  41220. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.GlowLayer"] = GlowLayer;
  41221. /***/ }),
  41222. /***/ "./Layers/highlightLayer.ts":
  41223. /*!**********************************!*\
  41224. !*** ./Layers/highlightLayer.ts ***!
  41225. \**********************************/
  41226. /*! exports provided: HighlightLayer */
  41227. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41228. "use strict";
  41229. __webpack_require__.r(__webpack_exports__);
  41230. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return HighlightLayer; });
  41231. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  41232. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  41233. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  41234. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41235. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41236. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  41237. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  41238. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41239. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  41240. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  41241. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  41242. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  41243. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  41244. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  41245. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  41246. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  41247. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  41248. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  41249. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  41250. /* harmony import */ var _Shaders_glowBlurPostProcess_fragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/glowBlurPostProcess.fragment */ "./Shaders/glowBlurPostProcess.fragment.ts");
  41251. _abstractScene__WEBPACK_IMPORTED_MODULE_13__["AbstractScene"].prototype.getHighlightLayerByName = function (name) {
  41252. for (var index = 0; index < this.effectLayers.length; index++) {
  41253. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === HighlightLayer.EffectName) {
  41254. return this.effectLayers[index];
  41255. }
  41256. }
  41257. return null;
  41258. };
  41259. /**
  41260. * Special Glow Blur post process only blurring the alpha channel
  41261. * It enforces keeping the most luminous color in the color channel.
  41262. */
  41263. var GlowBlurPostProcess = /** @class */ (function (_super) {
  41264. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowBlurPostProcess, _super);
  41265. function GlowBlurPostProcess(name, direction, kernel, options, camera, samplingMode, engine, reusable) {
  41266. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE; }
  41267. var _this = _super.call(this, name, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, options, camera, samplingMode, engine, reusable) || this;
  41268. _this.direction = direction;
  41269. _this.kernel = kernel;
  41270. _this.onApplyObservable.add(function (effect) {
  41271. effect.setFloat2("screenSize", _this.width, _this.height);
  41272. effect.setVector2("direction", _this.direction);
  41273. effect.setFloat("blurWidth", _this.kernel);
  41274. });
  41275. return _this;
  41276. }
  41277. return GlowBlurPostProcess;
  41278. }(_PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__["PostProcess"]));
  41279. /**
  41280. * The highlight layer Helps adding a glow effect around a mesh.
  41281. *
  41282. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  41283. * glowy meshes to your scene.
  41284. *
  41285. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  41286. */
  41287. var HighlightLayer = /** @class */ (function (_super) {
  41288. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightLayer, _super);
  41289. /**
  41290. * Instantiates a new highlight Layer and references it to the scene..
  41291. * @param name The name of the layer
  41292. * @param scene The scene to use the layer in
  41293. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  41294. */
  41295. function HighlightLayer(name, scene, options) {
  41296. var _this = _super.call(this, name, scene) || this;
  41297. _this.name = name;
  41298. /**
  41299. * Specifies whether or not the inner glow is ACTIVE in the layer.
  41300. */
  41301. _this.innerGlow = true;
  41302. /**
  41303. * Specifies whether or not the outer glow is ACTIVE in the layer.
  41304. */
  41305. _this.outerGlow = true;
  41306. /**
  41307. * An event triggered when the highlight layer is being blurred.
  41308. */
  41309. _this.onBeforeBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  41310. /**
  41311. * An event triggered when the highlight layer has been blurred.
  41312. */
  41313. _this.onAfterBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  41314. _this._instanceGlowingMeshStencilReference = HighlightLayer.GlowingMeshStencilReference++;
  41315. _this._meshes = {};
  41316. _this._excludedMeshes = {};
  41317. _this.neutralColor = HighlightLayer.NeutralColor;
  41318. // Warn on stencil
  41319. if (!_this._engine.isStencilEnable) {
  41320. _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 }");
  41321. }
  41322. // Adapt options
  41323. _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);
  41324. // Initialize the layer
  41325. _this._init({
  41326. alphaBlendingMode: _this._options.alphaBlendingMode,
  41327. camera: _this._options.camera,
  41328. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  41329. mainTextureRatio: _this._options.mainTextureRatio,
  41330. renderingGroupId: _this._options.renderingGroupId
  41331. });
  41332. // Do not render as long as no meshes have been added
  41333. _this._shouldRender = false;
  41334. return _this;
  41335. }
  41336. Object.defineProperty(HighlightLayer.prototype, "blurHorizontalSize", {
  41337. /**
  41338. * Gets the horizontal size of the blur.
  41339. */
  41340. get: function () {
  41341. return this._horizontalBlurPostprocess.kernel;
  41342. },
  41343. /**
  41344. * Specifies the horizontal size of the blur.
  41345. */
  41346. set: function (value) {
  41347. this._horizontalBlurPostprocess.kernel = value;
  41348. },
  41349. enumerable: true,
  41350. configurable: true
  41351. });
  41352. Object.defineProperty(HighlightLayer.prototype, "blurVerticalSize", {
  41353. /**
  41354. * Gets the vertical size of the blur.
  41355. */
  41356. get: function () {
  41357. return this._verticalBlurPostprocess.kernel;
  41358. },
  41359. /**
  41360. * Specifies the vertical size of the blur.
  41361. */
  41362. set: function (value) {
  41363. this._verticalBlurPostprocess.kernel = value;
  41364. },
  41365. enumerable: true,
  41366. configurable: true
  41367. });
  41368. /**
  41369. * Get the effect name of the layer.
  41370. * @return The effect name
  41371. */
  41372. HighlightLayer.prototype.getEffectName = function () {
  41373. return HighlightLayer.EffectName;
  41374. };
  41375. /**
  41376. * Create the merge effect. This is the shader use to blit the information back
  41377. * to the main canvas at the end of the scene rendering.
  41378. */
  41379. HighlightLayer.prototype._createMergeEffect = function () {
  41380. // Effect
  41381. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : undefined);
  41382. };
  41383. /**
  41384. * Creates the render target textures and post processes used in the highlight layer.
  41385. */
  41386. HighlightLayer.prototype._createTextureAndPostProcesses = function () {
  41387. var _this = this;
  41388. var blurTextureWidth = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio;
  41389. var blurTextureHeight = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
  41390. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  41391. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  41392. var textureType = 0;
  41393. if (this._engine.getCaps().textureHalfFloatRender) {
  41394. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_HALF_FLOAT;
  41395. }
  41396. else {
  41397. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  41398. }
  41399. this._blurTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerBlurRTT", {
  41400. width: blurTextureWidth,
  41401. height: blurTextureHeight
  41402. }, this._scene, false, true, textureType);
  41403. this._blurTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  41404. this._blurTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  41405. this._blurTexture.anisotropicFilteringLevel = 16;
  41406. this._blurTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].TRILINEAR_SAMPLINGMODE);
  41407. this._blurTexture.renderParticles = false;
  41408. this._blurTexture.ignoreCameraViewport = true;
  41409. this._textures = [this._blurTexture];
  41410. if (this._options.alphaBlendingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].ALPHA_COMBINE) {
  41411. 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());
  41412. this._downSamplePostprocess.onApplyObservable.add(function (effect) {
  41413. effect.setTexture("textureSampler", _this._mainTexture);
  41414. });
  41415. 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());
  41416. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  41417. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  41418. });
  41419. 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());
  41420. this._verticalBlurPostprocess.onApplyObservable.add(function (effect) {
  41421. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  41422. });
  41423. this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  41424. }
  41425. else {
  41426. 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, {
  41427. width: blurTextureWidth,
  41428. height: blurTextureHeight
  41429. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41430. this._horizontalBlurPostprocess.width = blurTextureWidth;
  41431. this._horizontalBlurPostprocess.height = blurTextureHeight;
  41432. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  41433. effect.setTexture("textureSampler", _this._mainTexture);
  41434. });
  41435. 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, {
  41436. width: blurTextureWidth,
  41437. height: blurTextureHeight
  41438. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41439. this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  41440. }
  41441. this._mainTexture.onAfterUnbindObservable.add(function () {
  41442. _this.onBeforeBlurObservable.notifyObservers(_this);
  41443. var internalTexture = _this._blurTexture.getInternalTexture();
  41444. if (internalTexture) {
  41445. _this._scene.postProcessManager.directRender(_this._postProcesses, internalTexture, true);
  41446. }
  41447. _this.onAfterBlurObservable.notifyObservers(_this);
  41448. });
  41449. // Prevent autoClear.
  41450. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  41451. };
  41452. /**
  41453. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  41454. */
  41455. HighlightLayer.prototype.needStencil = function () {
  41456. return true;
  41457. };
  41458. /**
  41459. * Checks for the readiness of the element composing the layer.
  41460. * @param subMesh the mesh to check for
  41461. * @param useInstances specify wether or not to use instances to render the mesh
  41462. * @param emissiveTexture the associated emissive texture used to generate the glow
  41463. * @return true if ready otherwise, false
  41464. */
  41465. HighlightLayer.prototype.isReady = function (subMesh, useInstances) {
  41466. var material = subMesh.getMaterial();
  41467. var mesh = subMesh.getRenderingMesh();
  41468. if (!material || !mesh || !this._meshes) {
  41469. return false;
  41470. }
  41471. var emissiveTexture = null;
  41472. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  41473. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  41474. emissiveTexture = material.emissiveTexture;
  41475. }
  41476. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  41477. };
  41478. /**
  41479. * Implementation specific of rendering the generating effect on the main canvas.
  41480. * @param effect The effect used to render through
  41481. */
  41482. HighlightLayer.prototype._internalRender = function (effect) {
  41483. // Texture
  41484. effect.setTexture("textureSampler", this._blurTexture);
  41485. // Cache
  41486. var engine = this._engine;
  41487. var previousStencilBuffer = engine.getStencilBuffer();
  41488. var previousStencilFunction = engine.getStencilFunction();
  41489. var previousStencilMask = engine.getStencilMask();
  41490. var previousStencilOperationPass = engine.getStencilOperationPass();
  41491. var previousStencilOperationFail = engine.getStencilOperationFail();
  41492. var previousStencilOperationDepthFail = engine.getStencilOperationDepthFail();
  41493. var previousStencilReference = engine.getStencilFunctionReference();
  41494. // Stencil operations
  41495. engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].REPLACE);
  41496. engine.setStencilOperationFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  41497. engine.setStencilOperationDepthFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  41498. // Draw order
  41499. engine.setStencilMask(0x00);
  41500. engine.setStencilBuffer(true);
  41501. engine.setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
  41502. // 2 passes inner outer
  41503. if (this.outerGlow) {
  41504. effect.setFloat("offset", 0);
  41505. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].NOTEQUAL);
  41506. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  41507. }
  41508. if (this.innerGlow) {
  41509. effect.setFloat("offset", 1);
  41510. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].EQUAL);
  41511. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  41512. }
  41513. // Restore Cache
  41514. engine.setStencilFunction(previousStencilFunction);
  41515. engine.setStencilMask(previousStencilMask);
  41516. engine.setStencilBuffer(previousStencilBuffer);
  41517. engine.setStencilOperationPass(previousStencilOperationPass);
  41518. engine.setStencilOperationFail(previousStencilOperationFail);
  41519. engine.setStencilOperationDepthFail(previousStencilOperationDepthFail);
  41520. engine.setStencilFunctionReference(previousStencilReference);
  41521. };
  41522. /**
  41523. * Returns true if the layer contains information to display, otherwise false.
  41524. */
  41525. HighlightLayer.prototype.shouldRender = function () {
  41526. if (_super.prototype.shouldRender.call(this)) {
  41527. return this._meshes ? true : false;
  41528. }
  41529. return false;
  41530. };
  41531. /**
  41532. * Returns true if the mesh should render, otherwise false.
  41533. * @param mesh The mesh to render
  41534. * @returns true if it should render otherwise false
  41535. */
  41536. HighlightLayer.prototype._shouldRenderMesh = function (mesh) {
  41537. // Excluded Mesh
  41538. if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
  41539. return false;
  41540. }
  41541. if (!_super.prototype.hasMesh.call(this, mesh)) {
  41542. return false;
  41543. }
  41544. return true;
  41545. };
  41546. /**
  41547. * Sets the required values for both the emissive texture and and the main color.
  41548. */
  41549. HighlightLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  41550. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  41551. if (highlightLayerMesh) {
  41552. this._emissiveTextureAndColor.color.set(highlightLayerMesh.color.r, highlightLayerMesh.color.g, highlightLayerMesh.color.b, 1.0);
  41553. }
  41554. else {
  41555. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  41556. }
  41557. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  41558. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  41559. this._emissiveTextureAndColor.color.set(1.0, 1.0, 1.0, 1.0);
  41560. }
  41561. else {
  41562. this._emissiveTextureAndColor.texture = null;
  41563. }
  41564. };
  41565. /**
  41566. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  41567. * @param mesh The mesh to exclude from the highlight layer
  41568. */
  41569. HighlightLayer.prototype.addExcludedMesh = function (mesh) {
  41570. if (!this._excludedMeshes) {
  41571. return;
  41572. }
  41573. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  41574. if (!meshExcluded) {
  41575. this._excludedMeshes[mesh.uniqueId] = {
  41576. mesh: mesh,
  41577. beforeRender: mesh.onBeforeRenderObservable.add(function (mesh) {
  41578. mesh.getEngine().setStencilBuffer(false);
  41579. }),
  41580. afterRender: mesh.onAfterRenderObservable.add(function (mesh) {
  41581. mesh.getEngine().setStencilBuffer(true);
  41582. }),
  41583. };
  41584. }
  41585. };
  41586. /**
  41587. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  41588. * @param mesh The mesh to highlight
  41589. */
  41590. HighlightLayer.prototype.removeExcludedMesh = function (mesh) {
  41591. if (!this._excludedMeshes) {
  41592. return;
  41593. }
  41594. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  41595. if (meshExcluded) {
  41596. if (meshExcluded.beforeRender) {
  41597. mesh.onBeforeRenderObservable.remove(meshExcluded.beforeRender);
  41598. }
  41599. if (meshExcluded.afterRender) {
  41600. mesh.onAfterRenderObservable.remove(meshExcluded.afterRender);
  41601. }
  41602. }
  41603. this._excludedMeshes[mesh.uniqueId] = null;
  41604. };
  41605. /**
  41606. * Determine if a given mesh will be highlighted by the current HighlightLayer
  41607. * @param mesh mesh to test
  41608. * @returns true if the mesh will be highlighted by the current HighlightLayer
  41609. */
  41610. HighlightLayer.prototype.hasMesh = function (mesh) {
  41611. if (!this._meshes) {
  41612. return false;
  41613. }
  41614. if (!_super.prototype.hasMesh.call(this, mesh)) {
  41615. return false;
  41616. }
  41617. return this._meshes[mesh.uniqueId] !== undefined && this._meshes[mesh.uniqueId] !== null;
  41618. };
  41619. /**
  41620. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  41621. * @param mesh The mesh to highlight
  41622. * @param color The color of the highlight
  41623. * @param glowEmissiveOnly Extract the glow from the emissive texture
  41624. */
  41625. HighlightLayer.prototype.addMesh = function (mesh, color, glowEmissiveOnly) {
  41626. var _this = this;
  41627. if (glowEmissiveOnly === void 0) { glowEmissiveOnly = false; }
  41628. if (!this._meshes) {
  41629. return;
  41630. }
  41631. var meshHighlight = this._meshes[mesh.uniqueId];
  41632. if (meshHighlight) {
  41633. meshHighlight.color = color;
  41634. }
  41635. else {
  41636. this._meshes[mesh.uniqueId] = {
  41637. mesh: mesh,
  41638. color: color,
  41639. // Lambda required for capture due to Observable this context
  41640. observerHighlight: mesh.onBeforeRenderObservable.add(function (mesh) {
  41641. if (_this._excludedMeshes && _this._excludedMeshes[mesh.uniqueId]) {
  41642. _this._defaultStencilReference(mesh);
  41643. }
  41644. else {
  41645. mesh.getScene().getEngine().setStencilFunctionReference(_this._instanceGlowingMeshStencilReference);
  41646. }
  41647. }),
  41648. observerDefault: mesh.onAfterRenderObservable.add(this._defaultStencilReference),
  41649. glowEmissiveOnly: glowEmissiveOnly
  41650. };
  41651. mesh.onDisposeObservable.add(function () {
  41652. _this._disposeMesh(mesh);
  41653. });
  41654. }
  41655. this._shouldRender = true;
  41656. };
  41657. /**
  41658. * Remove a mesh from the highlight layer in order to make it stop glowing.
  41659. * @param mesh The mesh to highlight
  41660. */
  41661. HighlightLayer.prototype.removeMesh = function (mesh) {
  41662. if (!this._meshes) {
  41663. return;
  41664. }
  41665. var meshHighlight = this._meshes[mesh.uniqueId];
  41666. if (meshHighlight) {
  41667. if (meshHighlight.observerHighlight) {
  41668. mesh.onBeforeRenderObservable.remove(meshHighlight.observerHighlight);
  41669. }
  41670. if (meshHighlight.observerDefault) {
  41671. mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  41672. }
  41673. delete this._meshes[mesh.uniqueId];
  41674. }
  41675. this._shouldRender = false;
  41676. for (var meshHighlightToCheck in this._meshes) {
  41677. if (this._meshes[meshHighlightToCheck]) {
  41678. this._shouldRender = true;
  41679. break;
  41680. }
  41681. }
  41682. };
  41683. /**
  41684. * Force the stencil to the normal expected value for none glowing parts
  41685. */
  41686. HighlightLayer.prototype._defaultStencilReference = function (mesh) {
  41687. mesh.getScene().getEngine().setStencilFunctionReference(HighlightLayer.NormalMeshStencilReference);
  41688. };
  41689. /**
  41690. * Free any resources and references associated to a mesh.
  41691. * Internal use
  41692. * @param mesh The mesh to free.
  41693. * @hidden
  41694. */
  41695. HighlightLayer.prototype._disposeMesh = function (mesh) {
  41696. this.removeMesh(mesh);
  41697. this.removeExcludedMesh(mesh);
  41698. };
  41699. /**
  41700. * Dispose the highlight layer and free resources.
  41701. */
  41702. HighlightLayer.prototype.dispose = function () {
  41703. if (this._meshes) {
  41704. // Clean mesh references
  41705. for (var id in this._meshes) {
  41706. var meshHighlight = this._meshes[id];
  41707. if (meshHighlight && meshHighlight.mesh) {
  41708. if (meshHighlight.observerHighlight) {
  41709. meshHighlight.mesh.onBeforeRenderObservable.remove(meshHighlight.observerHighlight);
  41710. }
  41711. if (meshHighlight.observerDefault) {
  41712. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  41713. }
  41714. }
  41715. }
  41716. this._meshes = null;
  41717. }
  41718. if (this._excludedMeshes) {
  41719. for (var id in this._excludedMeshes) {
  41720. var meshHighlight = this._excludedMeshes[id];
  41721. if (meshHighlight) {
  41722. if (meshHighlight.beforeRender) {
  41723. meshHighlight.mesh.onBeforeRenderObservable.remove(meshHighlight.beforeRender);
  41724. }
  41725. if (meshHighlight.afterRender) {
  41726. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.afterRender);
  41727. }
  41728. }
  41729. }
  41730. this._excludedMeshes = null;
  41731. }
  41732. _super.prototype.dispose.call(this);
  41733. };
  41734. /**
  41735. * Gets the class name of the effect layer
  41736. * @returns the string with the class name of the effect layer
  41737. */
  41738. HighlightLayer.prototype.getClassName = function () {
  41739. return "HighlightLayer";
  41740. };
  41741. /**
  41742. * Serializes this Highlight layer
  41743. * @returns a serialized Highlight layer object
  41744. */
  41745. HighlightLayer.prototype.serialize = function () {
  41746. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  41747. serializationObject.customType = "BABYLON.HighlightLayer";
  41748. // Highlighted meshes
  41749. serializationObject.meshes = [];
  41750. if (this._meshes) {
  41751. for (var m in this._meshes) {
  41752. var mesh = this._meshes[m];
  41753. if (mesh) {
  41754. serializationObject.meshes.push({
  41755. glowEmissiveOnly: mesh.glowEmissiveOnly,
  41756. color: mesh.color.asArray(),
  41757. meshId: mesh.mesh.id
  41758. });
  41759. }
  41760. }
  41761. }
  41762. // Excluded meshes
  41763. serializationObject.excludedMeshes = [];
  41764. if (this._excludedMeshes) {
  41765. for (var e in this._excludedMeshes) {
  41766. var excludedMesh = this._excludedMeshes[e];
  41767. if (excludedMesh) {
  41768. serializationObject.excludedMeshes.push(excludedMesh.mesh.id);
  41769. }
  41770. }
  41771. }
  41772. return serializationObject;
  41773. };
  41774. /**
  41775. * Creates a Highlight layer from parsed Highlight layer data
  41776. * @param parsedHightlightLayer defines the Highlight layer data
  41777. * @param scene defines the current scene
  41778. * @param rootUrl defines the root URL containing the Highlight layer information
  41779. * @returns a parsed Highlight layer
  41780. */
  41781. HighlightLayer.Parse = function (parsedHightlightLayer, scene, rootUrl) {
  41782. var hl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new HighlightLayer(parsedHightlightLayer.name, scene, parsedHightlightLayer.options); }, parsedHightlightLayer, scene, rootUrl);
  41783. var index;
  41784. // Excluded meshes
  41785. for (index = 0; index < parsedHightlightLayer.excludedMeshes.length; index++) {
  41786. var mesh = scene.getMeshByID(parsedHightlightLayer.excludedMeshes[index]);
  41787. if (mesh) {
  41788. hl.addExcludedMesh(mesh);
  41789. }
  41790. }
  41791. // Included meshes
  41792. for (index = 0; index < parsedHightlightLayer.meshes.length; index++) {
  41793. var highlightedMesh = parsedHightlightLayer.meshes[index];
  41794. var mesh = scene.getMeshByID(highlightedMesh.meshId);
  41795. if (mesh) {
  41796. hl.addMesh(mesh, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromArray(highlightedMesh.color), highlightedMesh.glowEmissiveOnly);
  41797. }
  41798. }
  41799. return hl;
  41800. };
  41801. /**
  41802. * Effect Name of the highlight layer.
  41803. */
  41804. HighlightLayer.EffectName = "HighlightLayer";
  41805. /**
  41806. * The neutral color used during the preparation of the glow effect.
  41807. * This is black by default as the blend operation is a blend operation.
  41808. */
  41809. HighlightLayer.NeutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  41810. /**
  41811. * Stencil value used for glowing meshes.
  41812. */
  41813. HighlightLayer.GlowingMeshStencilReference = 0x02;
  41814. /**
  41815. * Stencil value used for the other meshes in the scene.
  41816. */
  41817. HighlightLayer.NormalMeshStencilReference = 0x01;
  41818. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41819. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41820. ], HighlightLayer.prototype, "innerGlow", void 0);
  41821. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41822. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41823. ], HighlightLayer.prototype, "outerGlow", void 0);
  41824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41826. ], HighlightLayer.prototype, "blurHorizontalSize", null);
  41827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41828. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41829. ], HighlightLayer.prototype, "blurVerticalSize", null);
  41830. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41831. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  41832. ], HighlightLayer.prototype, "_options", void 0);
  41833. return HighlightLayer;
  41834. }(_effectLayer__WEBPACK_IMPORTED_MODULE_12__["EffectLayer"]));
  41835. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__["_TypeStore"].RegisteredTypes["BABYLON.HighlightLayer"] = HighlightLayer;
  41836. /***/ }),
  41837. /***/ "./Layers/index.ts":
  41838. /*!*************************!*\
  41839. !*** ./Layers/index.ts ***!
  41840. \*************************/
  41841. /*! exports provided: EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent */
  41842. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41843. "use strict";
  41844. __webpack_require__.r(__webpack_exports__);
  41845. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  41846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _effectLayer__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  41847. /* harmony import */ var _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  41848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__["EffectLayerSceneComponent"]; });
  41849. /* harmony import */ var _glowLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glowLayer */ "./Layers/glowLayer.ts");
  41850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _glowLayer__WEBPACK_IMPORTED_MODULE_2__["GlowLayer"]; });
  41851. /* harmony import */ var _highlightLayer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./highlightLayer */ "./Layers/highlightLayer.ts");
  41852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _highlightLayer__WEBPACK_IMPORTED_MODULE_3__["HighlightLayer"]; });
  41853. /* harmony import */ var _layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./layer */ "./Layers/layer.ts");
  41854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _layer__WEBPACK_IMPORTED_MODULE_4__["Layer"]; });
  41855. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  41856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__["LayerSceneComponent"]; });
  41857. /***/ }),
  41858. /***/ "./Layers/layer.ts":
  41859. /*!*************************!*\
  41860. !*** ./Layers/layer.ts ***!
  41861. \*************************/
  41862. /*! exports provided: Layer */
  41863. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41864. "use strict";
  41865. __webpack_require__.r(__webpack_exports__);
  41866. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return Layer; });
  41867. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  41868. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41869. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  41870. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  41871. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  41872. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41873. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  41874. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  41875. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  41876. /* harmony import */ var _Shaders_layer_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/layer.fragment */ "./Shaders/layer.fragment.ts");
  41877. /* harmony import */ var _Shaders_layer_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/layer.vertex */ "./Shaders/layer.vertex.ts");
  41878. /**
  41879. * This represents a full screen 2d layer.
  41880. * This can be useful to display a picture in the background of your scene for instance.
  41881. * @see https://www.babylonjs-playground.com/#08A2BS#1
  41882. */
  41883. var Layer = /** @class */ (function () {
  41884. /**
  41885. * Instantiates a new layer.
  41886. * This represents a full screen 2d layer.
  41887. * This can be useful to display a picture in the background of your scene for instance.
  41888. * @see https://www.babylonjs-playground.com/#08A2BS#1
  41889. * @param name Define the name of the layer in the scene
  41890. * @param imgUrl Define the url of the texture to display in the layer
  41891. * @param scene Define the scene the layer belongs to
  41892. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  41893. * @param color Defines a color for the layer
  41894. */
  41895. function Layer(
  41896. /**
  41897. * Define the name of the layer.
  41898. */
  41899. name, imgUrl, scene, isBackground, color) {
  41900. this.name = name;
  41901. /**
  41902. * Define the scale of the layer in order to zoom in out of the texture.
  41903. */
  41904. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 1);
  41905. /**
  41906. * Define an offset for the layer in order to shift the texture.
  41907. */
  41908. this.offset = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 0);
  41909. /**
  41910. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  41911. */
  41912. this.alphaBlendingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  41913. /**
  41914. * Define a mask to restrict the layer to only some of the scene cameras.
  41915. */
  41916. this.layerMask = 0x0FFFFFFF;
  41917. /**
  41918. * Define the list of render target the layer is visible into.
  41919. */
  41920. this.renderTargetTextures = [];
  41921. /**
  41922. * Define if the layer is only used in renderTarget or if it also
  41923. * renders in the main frame buffer of the canvas.
  41924. */
  41925. this.renderOnlyInRenderTargetTextures = false;
  41926. this._vertexBuffers = {};
  41927. /**
  41928. * An event triggered when the layer is disposed.
  41929. */
  41930. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  41931. /**
  41932. * An event triggered before rendering the scene
  41933. */
  41934. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  41935. /**
  41936. * An event triggered after rendering the scene
  41937. */
  41938. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  41939. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"](imgUrl, scene, true) : null;
  41940. this.isBackground = isBackground === undefined ? true : isBackground;
  41941. this.color = color === undefined ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1) : color;
  41942. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene);
  41943. var layerComponent = this._scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_LAYER);
  41944. if (!layerComponent) {
  41945. layerComponent = new _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__["LayerSceneComponent"](this._scene);
  41946. this._scene._addComponent(layerComponent);
  41947. }
  41948. this._scene.layers.push(this);
  41949. var engine = this._scene.getEngine();
  41950. // VBO
  41951. var vertices = [];
  41952. vertices.push(1, 1);
  41953. vertices.push(-1, 1);
  41954. vertices.push(-1, -1);
  41955. vertices.push(1, -1);
  41956. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false, false, 2);
  41957. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = vertexBuffer;
  41958. this._createIndexBuffer();
  41959. // Effects
  41960. this._effect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "");
  41961. this._alphaTestEffect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "#define ALPHATEST");
  41962. }
  41963. Object.defineProperty(Layer.prototype, "onDispose", {
  41964. /**
  41965. * Back compatibility with callback before the onDisposeObservable existed.
  41966. * The set callback will be triggered when the layer has been disposed.
  41967. */
  41968. set: function (callback) {
  41969. if (this._onDisposeObserver) {
  41970. this.onDisposeObservable.remove(this._onDisposeObserver);
  41971. }
  41972. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  41973. },
  41974. enumerable: true,
  41975. configurable: true
  41976. });
  41977. Object.defineProperty(Layer.prototype, "onBeforeRender", {
  41978. /**
  41979. * Back compatibility with callback before the onBeforeRenderObservable existed.
  41980. * The set callback will be triggered just before rendering the layer.
  41981. */
  41982. set: function (callback) {
  41983. if (this._onBeforeRenderObserver) {
  41984. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  41985. }
  41986. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  41987. },
  41988. enumerable: true,
  41989. configurable: true
  41990. });
  41991. Object.defineProperty(Layer.prototype, "onAfterRender", {
  41992. /**
  41993. * Back compatibility with callback before the onAfterRenderObservable existed.
  41994. * The set callback will be triggered just after rendering the layer.
  41995. */
  41996. set: function (callback) {
  41997. if (this._onAfterRenderObserver) {
  41998. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  41999. }
  42000. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  42001. },
  42002. enumerable: true,
  42003. configurable: true
  42004. });
  42005. Layer.prototype._createIndexBuffer = function () {
  42006. var engine = this._scene.getEngine();
  42007. // Indices
  42008. var indices = [];
  42009. indices.push(0);
  42010. indices.push(1);
  42011. indices.push(2);
  42012. indices.push(0);
  42013. indices.push(2);
  42014. indices.push(3);
  42015. this._indexBuffer = engine.createIndexBuffer(indices);
  42016. };
  42017. /** @hidden */
  42018. Layer.prototype._rebuild = function () {
  42019. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  42020. if (vb) {
  42021. vb._rebuild();
  42022. }
  42023. this._createIndexBuffer();
  42024. };
  42025. /**
  42026. * Renders the layer in the scene.
  42027. */
  42028. Layer.prototype.render = function () {
  42029. var currentEffect = this.alphaTest ? this._alphaTestEffect : this._effect;
  42030. // Check
  42031. if (!currentEffect.isReady() || !this.texture || !this.texture.isReady()) {
  42032. return;
  42033. }
  42034. var engine = this._scene.getEngine();
  42035. this.onBeforeRenderObservable.notifyObservers(this);
  42036. // Render
  42037. engine.enableEffect(currentEffect);
  42038. engine.setState(false);
  42039. // Texture
  42040. currentEffect.setTexture("textureSampler", this.texture);
  42041. currentEffect.setMatrix("textureMatrix", this.texture.getTextureMatrix());
  42042. // Color
  42043. currentEffect.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a);
  42044. // Scale / offset
  42045. currentEffect.setVector2("offset", this.offset);
  42046. currentEffect.setVector2("scale", this.scale);
  42047. // VBOs
  42048. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  42049. // Draw order
  42050. if (!this.alphaTest) {
  42051. engine.setAlphaMode(this.alphaBlendingMode);
  42052. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  42053. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  42054. }
  42055. else {
  42056. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  42057. }
  42058. this.onAfterRenderObservable.notifyObservers(this);
  42059. };
  42060. /**
  42061. * Disposes and releases the associated ressources.
  42062. */
  42063. Layer.prototype.dispose = function () {
  42064. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  42065. if (vertexBuffer) {
  42066. vertexBuffer.dispose();
  42067. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  42068. }
  42069. if (this._indexBuffer) {
  42070. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  42071. this._indexBuffer = null;
  42072. }
  42073. if (this.texture) {
  42074. this.texture.dispose();
  42075. this.texture = null;
  42076. }
  42077. // Clean RTT list
  42078. this.renderTargetTextures = [];
  42079. // Remove from scene
  42080. var index = this._scene.layers.indexOf(this);
  42081. this._scene.layers.splice(index, 1);
  42082. // Callback
  42083. this.onDisposeObservable.notifyObservers(this);
  42084. this.onDisposeObservable.clear();
  42085. this.onAfterRenderObservable.clear();
  42086. this.onBeforeRenderObservable.clear();
  42087. };
  42088. return Layer;
  42089. }());
  42090. /***/ }),
  42091. /***/ "./Layers/layerSceneComponent.ts":
  42092. /*!***************************************!*\
  42093. !*** ./Layers/layerSceneComponent.ts ***!
  42094. \***************************************/
  42095. /*! exports provided: LayerSceneComponent */
  42096. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42097. "use strict";
  42098. __webpack_require__.r(__webpack_exports__);
  42099. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return LayerSceneComponent; });
  42100. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  42101. /**
  42102. * Defines the layer scene component responsible to manage any layers
  42103. * in a given scene.
  42104. */
  42105. var LayerSceneComponent = /** @class */ (function () {
  42106. /**
  42107. * Creates a new instance of the component for the given scene
  42108. * @param scene Defines the scene to register the component in
  42109. */
  42110. function LayerSceneComponent(scene) {
  42111. /**
  42112. * The component name helpfull to identify the component in the list of scene components.
  42113. */
  42114. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_LAYER;
  42115. this.scene = scene;
  42116. this._engine = scene.getEngine();
  42117. scene.layers = new Array();
  42118. }
  42119. /**
  42120. * Registers the component in a given scene
  42121. */
  42122. LayerSceneComponent.prototype.register = function () {
  42123. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground);
  42124. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground);
  42125. this.scene._beforeRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground);
  42126. this.scene._afterRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground);
  42127. };
  42128. /**
  42129. * Rebuilds the elements related to this component in case of
  42130. * context lost for instance.
  42131. */
  42132. LayerSceneComponent.prototype.rebuild = function () {
  42133. var layers = this.scene.layers;
  42134. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  42135. var layer = layers_1[_i];
  42136. layer._rebuild();
  42137. }
  42138. };
  42139. /**
  42140. * Disposes the component and the associated ressources.
  42141. */
  42142. LayerSceneComponent.prototype.dispose = function () {
  42143. var layers = this.scene.layers;
  42144. while (layers.length) {
  42145. layers[0].dispose();
  42146. }
  42147. };
  42148. LayerSceneComponent.prototype._draw = function (predicate) {
  42149. var layers = this.scene.layers;
  42150. if (layers.length) {
  42151. this._engine.setDepthBuffer(false);
  42152. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  42153. var layer = layers_2[_i];
  42154. if (predicate(layer)) {
  42155. layer.render();
  42156. }
  42157. }
  42158. this._engine.setDepthBuffer(true);
  42159. }
  42160. };
  42161. LayerSceneComponent.prototype._drawCameraPredicate = function (layer, isBackground, cameraLayerMask) {
  42162. return !layer.renderOnlyInRenderTargetTextures &&
  42163. layer.isBackground === isBackground &&
  42164. ((layer.layerMask & cameraLayerMask) !== 0);
  42165. };
  42166. LayerSceneComponent.prototype._drawCameraBackground = function (camera) {
  42167. var _this = this;
  42168. this._draw(function (layer) {
  42169. return _this._drawCameraPredicate(layer, true, camera.layerMask);
  42170. });
  42171. };
  42172. LayerSceneComponent.prototype._drawCameraForeground = function (camera) {
  42173. var _this = this;
  42174. this._draw(function (layer) {
  42175. return _this._drawCameraPredicate(layer, false, camera.layerMask);
  42176. });
  42177. };
  42178. LayerSceneComponent.prototype._drawRenderTargetPredicate = function (layer, isBackground, cameraLayerMask, renderTargetTexture) {
  42179. return (layer.renderTargetTextures.length > 0) &&
  42180. layer.isBackground === isBackground &&
  42181. (layer.renderTargetTextures.indexOf(renderTargetTexture) > -1) &&
  42182. ((layer.layerMask & cameraLayerMask) !== 0);
  42183. };
  42184. LayerSceneComponent.prototype._drawRenderTargetBackground = function (renderTarget) {
  42185. var _this = this;
  42186. this._draw(function (layer) {
  42187. return _this._drawRenderTargetPredicate(layer, true, _this.scene.activeCamera.layerMask, renderTarget);
  42188. });
  42189. };
  42190. LayerSceneComponent.prototype._drawRenderTargetForeground = function (renderTarget) {
  42191. var _this = this;
  42192. this._draw(function (layer) {
  42193. return _this._drawRenderTargetPredicate(layer, false, _this.scene.activeCamera.layerMask, renderTarget);
  42194. });
  42195. };
  42196. return LayerSceneComponent;
  42197. }());
  42198. /***/ }),
  42199. /***/ "./Legacy/legacy.ts":
  42200. /*!**************************!*\
  42201. !*** ./Legacy/legacy.ts ***!
  42202. \**************************/
  42203. /*! 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, AnimationRange, AnimationEvent, PathCursor, AnimationKeyInterpolation, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, 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, CollisionCoordinatorLegacy, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, _PrimitiveGeometry, RibbonGeometry, BoxGeometry, SphereGeometry, DiscGeometry, CylinderGeometry, TorusGeometry, GroundGeometry, TiledGroundGeometry, PlaneGeometry, TorusKnotGeometry, GroundMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, 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, 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 */
  42204. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42205. "use strict";
  42206. __webpack_require__.r(__webpack_exports__);
  42207. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  42208. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/index */ "./Debug/index.ts");
  42209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  42210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeepAssets"]; });
  42211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetContainer"]; });
  42212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Node"]; });
  42213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scene"]; });
  42214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"]; });
  42215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Stage"]; });
  42216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  42217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionEvent"]; });
  42218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionManager"]; });
  42219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Condition"]; });
  42220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueCondition"]; });
  42221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PredicateCondition"]; });
  42222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StateCondition"]; });
  42223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SwitchBooleanAction"]; });
  42224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetStateAction"]; });
  42225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetValueAction"]; });
  42226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IncrementValueAction"]; });
  42227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlayAnimationAction"]; });
  42228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopAnimationAction"]; });
  42229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DoNothingAction"]; });
  42230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CombineAction"]; });
  42231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExecuteCodeAction"]; });
  42232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetParentAction"]; });
  42233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaySoundAction"]; });
  42234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopSoundAction"]; });
  42235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InterpolateValueAction"]; });
  42236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  42237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationRange"]; });
  42238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationEvent"]; });
  42239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PathCursor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PathCursor"]; });
  42240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationKeyInterpolation"]; });
  42241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animation"]; });
  42242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetedAnimation"]; });
  42243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationGroup"]; });
  42244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationPropertiesOverride"]; });
  42245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"]; });
  42246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleEase"]; });
  42247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackEase"]; });
  42248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BounceEase"]; });
  42249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubicEase"]; });
  42250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ElasticEase"]; });
  42251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]; });
  42252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PowerEase"]; });
  42253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuadraticEase"]; });
  42254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuarticEase"]; });
  42255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuinticEase"]; });
  42256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SineEase"]; });
  42257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurveEase"]; });
  42258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RuntimeAnimation"]; });
  42259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  42260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioEngine"]; });
  42261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioSceneComponent"]; });
  42262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sound"]; });
  42263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SoundTrack"]; });
  42264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WeightedSound"]; });
  42265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  42266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneIKController"]; });
  42267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneLookController"]; });
  42268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Skeleton"]; });
  42269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]; });
  42270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputsManager"]; });
  42271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Camera"]; });
  42272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetCamera"]; });
  42273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCamera"]; });
  42274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraInputsManager"]; });
  42275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TouchCamera"]; });
  42276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCamera"]; });
  42277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraInputsManager"]; });
  42278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeviceOrientationCamera"]; });
  42279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCamera"]; });
  42280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraInputsManager"]; });
  42281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCamera"]; });
  42282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcFollowCamera"]; });
  42283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadCamera"]; });
  42284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniversalCamera"]; });
  42285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoysticksCamera"]; });
  42286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  42287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CollisionCoordinatorLegacy", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CollisionCoordinatorLegacy"]; });
  42288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PickingInfo"]; });
  42289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IntersectionInfo"]; });
  42290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  42291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingInfo"]; });
  42292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingSphere"]; });
  42293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ray"]; });
  42294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  42295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneAxesViewer"]; });
  42296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DebugLayer"]; });
  42297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsViewer"]; });
  42298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RayHelper"]; });
  42299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SkeletonViewer"]; });
  42300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  42301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancingAttributeInfo"]; });
  42302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthTextureCreationOptions"]; });
  42303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineCapabilities"]; });
  42304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Engine"]; });
  42305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineStore"]; });
  42306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngineOptions"]; });
  42307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngine"]; });
  42308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  42309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  42310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  42311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"]; });
  42312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoBase"]; });
  42313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoPre"]; });
  42314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"]; });
  42315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardEventTypes"]; });
  42316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardInfo"]; });
  42317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  42318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  42319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  42320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  42321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  42322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  42323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  42324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  42325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  42326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  42327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StickValues"]; });
  42328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gamepad"]; });
  42329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericPad"]; });
  42330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadManager"]; });
  42331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadSystemSceneComponent"]; });
  42332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Button"]; });
  42333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Dpad"]; });
  42334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Pad"]; });
  42335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  42336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisScaleGizmo"]; });
  42337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxGizmo"]; });
  42338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gizmo"]; });
  42339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GizmoManager"]; });
  42340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneRotationGizmo"]; });
  42341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionGizmo"]; });
  42342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RotationGizmo"]; });
  42343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScaleGizmo"]; });
  42344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  42345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhotoDome"]; });
  42346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceSceneHelpersToBundle"]; });
  42347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoDome"]; });
  42348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  42349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneInstrumentation"]; });
  42350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TimeToken"]; });
  42351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  42352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayerSceneComponent"]; });
  42353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GlowLayer"]; });
  42354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightLayer"]; });
  42355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Layer"]; });
  42356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LayerSceneComponent"]; });
  42357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  42358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystem"]; });
  42359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystemSceneComponent"]; });
  42360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  42361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowLight"]; });
  42362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DirectionalLight"]; });
  42363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]; });
  42364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointLight"]; });
  42365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpotLight"]; });
  42366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  42367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderProgressEvent"]; });
  42368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"]; });
  42369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderFlags"]; });
  42370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCurves"]; });
  42371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectFallbacks"]; });
  42372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectCreationOptions"]; });
  42373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Effect"]; });
  42374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FresnelParameters"]; });
  42375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfigurationDefines"]; });
  42376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfiguration"]; });
  42377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Material"]; });
  42378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialDefines"]; });
  42379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialHelper"]; });
  42380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiMaterial"]; });
  42381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PushMaterial"]; });
  42382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShaderMaterial"]; });
  42383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterialDefines"]; });
  42384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterial"]; });
  42385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  42386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTexture"]; });
  42387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTexture"]; });
  42388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InternalTexture"]; });
  42389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DummyInternalTextureTracker"]; });
  42390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MirrorTexture"]; });
  42391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiRenderTarget"]; });
  42392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture"]; });
  42393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetTexture"]; });
  42394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Texture"]; });
  42395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniformBuffer"]; });
  42396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialFlags"]; });
  42397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  42398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToGammaSpace"]; });
  42399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]; });
  42400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; });
  42401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3"]; });
  42402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color4"]; });
  42403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2"]; });
  42404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3"]; });
  42405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector4"]; });
  42406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Size"]; });
  42407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]; });
  42408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix"]; });
  42409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Plane"]; });
  42410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Viewport"]; });
  42411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Frustum"]; });
  42412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Space"]; });
  42413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Axis"]; });
  42414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurve"]; });
  42415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Orientation"]; });
  42416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Angle"]; });
  42417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Arc2"]; });
  42418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path2"]; });
  42419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path3D"]; });
  42420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Curve3"]; });
  42421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]; });
  42422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalTextureVertex"]; });
  42423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tmp"]; });
  42424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]; });
  42425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalHarmonics"]; });
  42426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  42427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Buffer"]; });
  42428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"]; });
  42429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CSG"]; });
  42430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Geometry"]; });
  42431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_PrimitiveGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_PrimitiveGeometry"]; });
  42432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RibbonGeometry"]; });
  42433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxGeometry"]; });
  42434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereGeometry"]; });
  42435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DiscGeometry"]; });
  42436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderGeometry"]; });
  42437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusGeometry"]; });
  42438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundGeometry"]; });
  42439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TiledGroundGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TiledGroundGeometry"]; });
  42440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneGeometry"]; });
  42441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotGeometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusKnotGeometry"]; });
  42442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundMesh"]; });
  42443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedMesh"]; });
  42444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesMesh"]; });
  42445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedLinesMesh"]; });
  42446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshLODLevel"]; });
  42447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_CreationDataStorage"]; });
  42448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_InstancesBatch"]; });
  42449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Mesh"]; });
  42450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexData"]; });
  42451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"]; });
  42452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationSettings"]; });
  42453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationQueue"]; });
  42454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationType"]; });
  42455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplicationQueueSceneComponent"]; });
  42456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Polygon"]; });
  42457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonMeshBuilder"]; });
  42458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSubMesh"]; });
  42459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubMesh"]; });
  42460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TransformNode"]; });
  42461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  42462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTargetManager"]; });
  42463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  42464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  42465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GPUParticleSystem"]; });
  42466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Particle"]; });
  42467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleHelper"]; });
  42468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystem"]; });
  42469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IDoNeedToBeInTheBuild"]; });
  42470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystemSet"]; });
  42471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticle"]; });
  42472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ModelShape"]; });
  42473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthSortedParticle"]; });
  42474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticleSystem"]; });
  42475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitterType"]; });
  42476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitter"]; });
  42477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  42478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngineSceneComponent"]; });
  42479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsHelper"]; });
  42480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialExplosionEvent"]; });
  42481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsGravitationalFieldEvent"]; });
  42482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftEvent"]; });
  42483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsVortexEvent"]; });
  42484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialImpulseFalloff"]; });
  42485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftMode"]; });
  42486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"]; });
  42487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsJoint"]; });
  42488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DistanceJoint"]; });
  42489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotorEnabledJoint"]; });
  42490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HingeJoint"]; });
  42491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Hinge2Joint"]; });
  42492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  42493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlackAndWhitePostProcess"]; });
  42494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomEffect"]; });
  42495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomMergePostProcess"]; });
  42496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlurPostProcess"]; });
  42497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ChromaticAberrationPostProcess"]; });
  42498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleOfConfusionPostProcess"]; });
  42499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCorrectionPostProcess"]; });
  42500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConvolutionPostProcess"]; });
  42501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldBlurPostProcess"]; });
  42502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffectBlurLevel"]; });
  42503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffect"]; });
  42504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcessOptions"]; });
  42505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcess"]; });
  42506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayPassPostProcess"]; });
  42507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExtractHighlightsPostProcess"]; });
  42508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilterPostProcess"]; });
  42509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FxaaPostProcess"]; });
  42510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GrainPostProcess"]; });
  42511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightsPostProcess"]; });
  42512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingPostProcess"]; });
  42513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotionBlurPostProcess"]; });
  42514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassPostProcess"]; });
  42515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassCubePostProcess"]; });
  42516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcess"]; });
  42517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessManager"]; });
  42518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionPostProcess"]; });
  42519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SharpenPostProcess"]; });
  42520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicInterlacePostProcess"]; });
  42521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemappingOperator"]; });
  42522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemapPostProcess"]; });
  42523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumetricLightScatteringPostProcess"]; });
  42524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDistortionCorrectionPostProcess"]; });
  42525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  42526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  42527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRenderer"]; });
  42528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRendererSceneComponent"]; });
  42529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EdgesRenderer"]; });
  42530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LineEdgesRenderer"]; });
  42531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRenderer"]; });
  42532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRendererSceneComponent"]; });
  42533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OutlineRenderer"]; });
  42534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"]; });
  42535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroupInfo"]; });
  42536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingManager"]; });
  42537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"]; });
  42538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  42539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteManager"]; });
  42540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteSceneComponent"]; });
  42541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  42542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DepthCullingState"]; });
  42543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_StencilState"]; });
  42544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  42545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetTaskState"]; });
  42546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractAssetTask"]; });
  42547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsProgressEvent"]; });
  42548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshAssetTask"]; });
  42549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextFileAssetTask"]; });
  42550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BinaryFileAssetTask"]; });
  42551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageAssetTask"]; });
  42552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureAssetTask"]; });
  42553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTextureAssetTask"]; });
  42554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTextureAssetTask"]; });
  42555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsManager"]; });
  42556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DDSTools"]; });
  42557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["expandToProperty"]; });
  42558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serialize"]; });
  42559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsTexture"]; });
  42560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor3"]; });
  42561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsFresnelParameters"]; });
  42562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector2"]; });
  42563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector3"]; });
  42564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMeshReference"]; });
  42565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColorCurves"]; });
  42566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor4"]; });
  42567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsImageProcessingConfiguration"]; });
  42568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsQuaternion"]; });
  42569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsCameraReference"]; });
  42570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SerializationHelper"]; });
  42571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Deferred"]; });
  42572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"]; });
  42573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInput"]; });
  42574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"]; });
  42575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EventState"]; });
  42576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observer"]; });
  42577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiObserver"]; });
  42578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observable"]; });
  42579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerformanceMonitor"]; });
  42580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RollingAverage"]; });
  42581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PromisePolyfill"]; });
  42582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimization"]; });
  42583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureOptimization"]; });
  42584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HardwareScalingOptimization"]; });
  42585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowsOptimization"]; });
  42586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessesOptimization"]; });
  42587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlaresOptimization"]; });
  42588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomOptimization"]; });
  42589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticlesOptimization"]; });
  42590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetsOptimization"]; });
  42591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MergeMeshesOptimization"]; });
  42592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizerOptions"]; });
  42593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizer"]; });
  42594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneSerializer"]; });
  42595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArray"]; });
  42596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"]; });
  42597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StringDictionary"]; });
  42598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tags"]; });
  42599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureTools"]; });
  42600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TGATools"]; });
  42601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradient"]; });
  42602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3Gradient"]; });
  42603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FactorGradient"]; });
  42604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LoadFileError"]; });
  42605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RetryStrategy"]; });
  42606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tools"]; });
  42607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]; });
  42608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["className"]; });
  42609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AsyncLoop"]; });
  42610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoRecorder"]; });
  42611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"]; });
  42612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"]; });
  42613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WorkerPool"]; });
  42614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Logger"]; });
  42615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"]; });
  42616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInputStore"]; });
  42617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"]; });
  42618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PivotTools"]; });
  42619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"]; });
  42620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScreenshotTools"]; });
  42621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  42622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  42623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  42624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  42625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FadeInOutBehavior"]; });
  42626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiPointerScaleBehavior"]; });
  42627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]; });
  42628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SixDofDragBehavior"]; });
  42629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  42630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  42631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  42632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  42633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  42634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  42635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  42636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  42637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  42638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  42639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  42640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  42641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  42642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  42643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphFreeCamera"]; });
  42644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphGamepadCamera"]; });
  42645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphUniversalCamera"]; });
  42646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicArcRotateCamera"]; });
  42647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicFreeCamera"]; });
  42648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicGamepadCamera"]; });
  42649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicUniversalCamera"]; });
  42650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  42651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationArcRotateCamera"]; });
  42652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationFreeCamera"]; });
  42653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationGamepadCamera"]; });
  42654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRExperienceHelper"]; });
  42655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRFreeCamera"]; });
  42656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  42657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIButton"]; });
  42658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIOptions"]; });
  42659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUI"]; });
  42660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRState"]; });
  42661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRExperienceHelper"]; });
  42662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRController"]; });
  42663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRInput"]; });
  42664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRManagedOutputCanvas"]; });
  42665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRSessionManager"]; });
  42666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  42667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeBlock"]; });
  42668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeSceneComponent"]; });
  42669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  42670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceTransformFeedbackToBundle"]; });
  42671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  42672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGeneratorSceneComponent"]; });
  42673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  42674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  42675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  42676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseSimpleMaterial"]; });
  42677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"]; });
  42678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMetallicRoughnessMaterial"]; });
  42679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRSpecularGlossinessMaterial"]; });
  42680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradingTexture"]; });
  42681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DynamicTexture"]; });
  42682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTexture"]; });
  42683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawCubeTexture"]; });
  42684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture3D"]; });
  42685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionTexture"]; });
  42686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoTexture"]; });
  42687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  42688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  42689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConeParticleEmitter"]; });
  42690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderParticleEmitter"]; });
  42691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderDirectedParticleEmitter"]; });
  42692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericParticleEmitter"]; });
  42693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointParticleEmitter"]; });
  42694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereParticleEmitter"]; });
  42695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereDirectedParticleEmitter"]; });
  42696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  42697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AmmoJSPlugin"]; });
  42698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OimoJSPlugin"]; });
  42699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderEffect"]; });
  42700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipeline"]; });
  42701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManager"]; });
  42702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManagerSceneComponent"]; });
  42703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  42704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRTools"]; });
  42705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"]; });
  42706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  42707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_ENVTextureLoader"]; });
  42708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_KTXTextureLoader"]; });
  42709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TGATextureLoader"]; });
  42710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  42711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NoiseProceduralTexture"]; });
  42712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTextureSceneComponent"]; });
  42713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  42714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  42715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  42716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  42717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  42718. /**
  42719. * Legacy support, defining window.BABYLON (global variable).
  42720. *
  42721. * This is the entry point for the UMD module.
  42722. * The entry point for a future ESM package should be index.ts
  42723. */
  42724. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  42725. if (typeof globalObject !== "undefined") {
  42726. globalObject.BABYLON = BABYLON;
  42727. globalObject.BABYLON = globalObject.BABYLON || {};
  42728. var BABYLON = globalObject.BABYLON;
  42729. BABYLON.Debug = BABYLON.Debug || {};
  42730. var keys = [];
  42731. for (var key in _Debug_index__WEBPACK_IMPORTED_MODULE_1__) {
  42732. BABYLON.Debug[key] = _Debug_index__WEBPACK_IMPORTED_MODULE_1__[key];
  42733. keys.push(key);
  42734. }
  42735. for (var key in _index__WEBPACK_IMPORTED_MODULE_0__) {
  42736. // Prevent Reassignment.
  42737. if (keys.indexOf(key) > -1) {
  42738. continue;
  42739. }
  42740. BABYLON[key] = _index__WEBPACK_IMPORTED_MODULE_0__[key];
  42741. }
  42742. }
  42743. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  42744. /***/ }),
  42745. /***/ "./LensFlares/index.ts":
  42746. /*!*****************************!*\
  42747. !*** ./LensFlares/index.ts ***!
  42748. \*****************************/
  42749. /*! exports provided: LensFlare, LensFlareSystem, LensFlareSystemSceneComponent */
  42750. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42751. "use strict";
  42752. __webpack_require__.r(__webpack_exports__);
  42753. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  42754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _lensFlare__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  42755. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  42756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__["LensFlareSystem"]; });
  42757. /* harmony import */ var _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lensFlareSystemSceneComponent */ "./LensFlares/lensFlareSystemSceneComponent.ts");
  42758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__["LensFlareSystemSceneComponent"]; });
  42759. /***/ }),
  42760. /***/ "./LensFlares/lensFlare.ts":
  42761. /*!*********************************!*\
  42762. !*** ./LensFlares/lensFlare.ts ***!
  42763. \*********************************/
  42764. /*! exports provided: LensFlare */
  42765. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42766. "use strict";
  42767. __webpack_require__.r(__webpack_exports__);
  42768. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return LensFlare; });
  42769. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42770. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42771. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42772. /**
  42773. * This represents one of the lens effect in a `lensFlareSystem`.
  42774. * It controls one of the indiviual texture used in the effect.
  42775. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  42776. */
  42777. var LensFlare = /** @class */ (function () {
  42778. /**
  42779. * Instantiates a new Lens Flare.
  42780. * This represents one of the lens effect in a `lensFlareSystem`.
  42781. * It controls one of the indiviual texture used in the effect.
  42782. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  42783. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  42784. * @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.
  42785. * @param color Define the lens color
  42786. * @param imgUrl Define the lens texture url
  42787. * @param system Define the `lensFlareSystem` this flare is part of
  42788. */
  42789. function LensFlare(
  42790. /**
  42791. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  42792. */
  42793. size,
  42794. /**
  42795. * 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.
  42796. */
  42797. position, color, imgUrl, system) {
  42798. this.size = size;
  42799. this.position = position;
  42800. /**
  42801. * Define the alpha mode to render this particular lens.
  42802. */
  42803. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_ONEONE;
  42804. this.color = color || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](1, 1, 1);
  42805. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](imgUrl, system.getScene(), true) : null;
  42806. this._system = system;
  42807. system.lensFlares.push(this);
  42808. }
  42809. /**
  42810. * Creates a new Lens Flare.
  42811. * This represents one of the lens effect in a `lensFlareSystem`.
  42812. * It controls one of the indiviual texture used in the effect.
  42813. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  42814. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  42815. * @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.
  42816. * @param color Define the lens color
  42817. * @param imgUrl Define the lens texture url
  42818. * @param system Define the `lensFlareSystem` this flare is part of
  42819. * @returns The newly created Lens Flare
  42820. */
  42821. LensFlare.AddFlare = function (size, position, color, imgUrl, system) {
  42822. return new LensFlare(size, position, color, imgUrl, system);
  42823. };
  42824. /**
  42825. * Dispose and release the lens flare with its associated resources.
  42826. */
  42827. LensFlare.prototype.dispose = function () {
  42828. if (this.texture) {
  42829. this.texture.dispose();
  42830. }
  42831. // Remove from scene
  42832. var index = this._system.lensFlares.indexOf(this);
  42833. this._system.lensFlares.splice(index, 1);
  42834. };
  42835. return LensFlare;
  42836. }());
  42837. /***/ }),
  42838. /***/ "./LensFlares/lensFlareSystem.ts":
  42839. /*!***************************************!*\
  42840. !*** ./LensFlares/lensFlareSystem.ts ***!
  42841. \***************************************/
  42842. /*! exports provided: LensFlareSystem */
  42843. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42844. "use strict";
  42845. __webpack_require__.r(__webpack_exports__);
  42846. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return LensFlareSystem; });
  42847. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42848. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42849. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  42850. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  42851. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42852. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  42853. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42854. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  42855. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42856. /* harmony import */ var _Shaders_lensFlare_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/lensFlare.fragment */ "./Shaders/lensFlare.fragment.ts");
  42857. /* harmony import */ var _Shaders_lensFlare_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/lensFlare.vertex */ "./Shaders/lensFlare.vertex.ts");
  42858. /**
  42859. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  42860. * It is usually composed of several `lensFlare`.
  42861. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  42862. */
  42863. var LensFlareSystem = /** @class */ (function () {
  42864. /**
  42865. * Instantiates a lens flare system.
  42866. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  42867. * It is usually composed of several `lensFlare`.
  42868. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  42869. * @param name Define the name of the lens flare system in the scene
  42870. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  42871. * @param scene Define the scene the lens flare system belongs to
  42872. */
  42873. function LensFlareSystem(
  42874. /**
  42875. * Define the name of the lens flare system
  42876. */
  42877. name, emitter, scene) {
  42878. this.name = name;
  42879. /**
  42880. * List of lens flares used in this system.
  42881. */
  42882. this.lensFlares = new Array();
  42883. /**
  42884. * Define a limit from the border the lens flare can be visible.
  42885. */
  42886. this.borderLimit = 300;
  42887. /**
  42888. * Define a viewport border we do not want to see the lens flare in.
  42889. */
  42890. this.viewportBorder = 0;
  42891. /**
  42892. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  42893. */
  42894. this.layerMask = 0x0FFFFFFF;
  42895. this._vertexBuffers = {};
  42896. this._isEnabled = true;
  42897. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  42898. LensFlareSystem._SceneComponentInitialization(this._scene);
  42899. this._emitter = emitter;
  42900. this.id = name;
  42901. scene.lensFlareSystems.push(this);
  42902. this.meshesSelectionPredicate = function (m) { return (scene.activeCamera && m.material && m.isVisible && m.isEnabled() && m.isBlocker && ((m.layerMask & scene.activeCamera.layerMask) != 0)); };
  42903. var engine = scene.getEngine();
  42904. // VBO
  42905. var vertices = [];
  42906. vertices.push(1, 1);
  42907. vertices.push(-1, 1);
  42908. vertices.push(-1, -1);
  42909. vertices.push(1, -1);
  42910. 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);
  42911. // Indices
  42912. var indices = [];
  42913. indices.push(0);
  42914. indices.push(1);
  42915. indices.push(2);
  42916. indices.push(0);
  42917. indices.push(2);
  42918. indices.push(3);
  42919. this._indexBuffer = engine.createIndexBuffer(indices);
  42920. // Effects
  42921. this._effect = engine.createEffect("lensFlare", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["color", "viewportMatrix"], ["textureSampler"], "");
  42922. }
  42923. Object.defineProperty(LensFlareSystem.prototype, "isEnabled", {
  42924. /**
  42925. * Define if the lens flare system is enabled.
  42926. */
  42927. get: function () {
  42928. return this._isEnabled;
  42929. },
  42930. set: function (value) {
  42931. this._isEnabled = value;
  42932. },
  42933. enumerable: true,
  42934. configurable: true
  42935. });
  42936. /**
  42937. * Get the scene the effects belongs to.
  42938. * @returns the scene holding the lens flare system
  42939. */
  42940. LensFlareSystem.prototype.getScene = function () {
  42941. return this._scene;
  42942. };
  42943. /**
  42944. * Get the emitter of the lens flare system.
  42945. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  42946. * @returns the emitter of the lens flare system
  42947. */
  42948. LensFlareSystem.prototype.getEmitter = function () {
  42949. return this._emitter;
  42950. };
  42951. /**
  42952. * Set the emitter of the lens flare system.
  42953. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  42954. * @param newEmitter Define the new emitter of the system
  42955. */
  42956. LensFlareSystem.prototype.setEmitter = function (newEmitter) {
  42957. this._emitter = newEmitter;
  42958. };
  42959. /**
  42960. * Get the lens flare system emitter position.
  42961. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  42962. * @returns the position
  42963. */
  42964. LensFlareSystem.prototype.getEmitterPosition = function () {
  42965. return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position;
  42966. };
  42967. /**
  42968. * @hidden
  42969. */
  42970. LensFlareSystem.prototype.computeEffectivePosition = function (globalViewport) {
  42971. var position = this.getEmitterPosition();
  42972. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), this._scene.getTransformMatrix(), globalViewport);
  42973. this._positionX = position.x;
  42974. this._positionY = position.y;
  42975. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix());
  42976. if (this.viewportBorder > 0) {
  42977. globalViewport.x -= this.viewportBorder;
  42978. globalViewport.y -= this.viewportBorder;
  42979. globalViewport.width += this.viewportBorder * 2;
  42980. globalViewport.height += this.viewportBorder * 2;
  42981. position.x += this.viewportBorder;
  42982. position.y += this.viewportBorder;
  42983. this._positionX += this.viewportBorder;
  42984. this._positionY += this.viewportBorder;
  42985. }
  42986. if (position.z > 0) {
  42987. if ((this._positionX > globalViewport.x) && (this._positionX < globalViewport.x + globalViewport.width)) {
  42988. if ((this._positionY > globalViewport.y) && (this._positionY < globalViewport.y + globalViewport.height)) {
  42989. return true;
  42990. }
  42991. }
  42992. return true;
  42993. }
  42994. return false;
  42995. };
  42996. /** @hidden */
  42997. LensFlareSystem.prototype._isVisible = function () {
  42998. if (!this._isEnabled || !this._scene.activeCamera) {
  42999. return false;
  43000. }
  43001. var emitterPosition = this.getEmitterPosition();
  43002. var direction = emitterPosition.subtract(this._scene.activeCamera.globalPosition);
  43003. var distance = direction.length();
  43004. direction.normalize();
  43005. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](this._scene.activeCamera.globalPosition, direction);
  43006. var pickInfo = this._scene.pickWithRay(ray, this.meshesSelectionPredicate, true);
  43007. return !pickInfo || !pickInfo.hit || pickInfo.distance > distance;
  43008. };
  43009. /**
  43010. * @hidden
  43011. */
  43012. LensFlareSystem.prototype.render = function () {
  43013. if (!this._effect.isReady() || !this._scene.activeCamera) {
  43014. return false;
  43015. }
  43016. var engine = this._scene.getEngine();
  43017. var viewport = this._scene.activeCamera.viewport;
  43018. var globalViewport = viewport.toGlobal(engine.getRenderWidth(true), engine.getRenderHeight(true));
  43019. // Position
  43020. if (!this.computeEffectivePosition(globalViewport)) {
  43021. return false;
  43022. }
  43023. // Visibility
  43024. if (!this._isVisible()) {
  43025. return false;
  43026. }
  43027. // Intensity
  43028. var awayX;
  43029. var awayY;
  43030. if (this._positionX < this.borderLimit + globalViewport.x) {
  43031. awayX = this.borderLimit + globalViewport.x - this._positionX;
  43032. }
  43033. else if (this._positionX > globalViewport.x + globalViewport.width - this.borderLimit) {
  43034. awayX = this._positionX - globalViewport.x - globalViewport.width + this.borderLimit;
  43035. }
  43036. else {
  43037. awayX = 0;
  43038. }
  43039. if (this._positionY < this.borderLimit + globalViewport.y) {
  43040. awayY = this.borderLimit + globalViewport.y - this._positionY;
  43041. }
  43042. else if (this._positionY > globalViewport.y + globalViewport.height - this.borderLimit) {
  43043. awayY = this._positionY - globalViewport.y - globalViewport.height + this.borderLimit;
  43044. }
  43045. else {
  43046. awayY = 0;
  43047. }
  43048. var away = (awayX > awayY) ? awayX : awayY;
  43049. away -= this.viewportBorder;
  43050. if (away > this.borderLimit) {
  43051. away = this.borderLimit;
  43052. }
  43053. var intensity = 1.0 - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Clamp(away / this.borderLimit, 0, 1);
  43054. if (intensity < 0) {
  43055. return false;
  43056. }
  43057. if (intensity > 1.0) {
  43058. intensity = 1.0;
  43059. }
  43060. if (this.viewportBorder > 0) {
  43061. globalViewport.x += this.viewportBorder;
  43062. globalViewport.y += this.viewportBorder;
  43063. globalViewport.width -= this.viewportBorder * 2;
  43064. globalViewport.height -= this.viewportBorder * 2;
  43065. this._positionX -= this.viewportBorder;
  43066. this._positionY -= this.viewportBorder;
  43067. }
  43068. // Position
  43069. var centerX = globalViewport.x + globalViewport.width / 2;
  43070. var centerY = globalViewport.y + globalViewport.height / 2;
  43071. var distX = centerX - this._positionX;
  43072. var distY = centerY - this._positionY;
  43073. // Effects
  43074. engine.enableEffect(this._effect);
  43075. engine.setState(false);
  43076. engine.setDepthBuffer(false);
  43077. // VBOs
  43078. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  43079. // Flares
  43080. for (var index = 0; index < this.lensFlares.length; index++) {
  43081. var flare = this.lensFlares[index];
  43082. engine.setAlphaMode(flare.alphaMode);
  43083. var x = centerX - (distX * flare.position);
  43084. var y = centerY - (distY * flare.position);
  43085. var cw = flare.size;
  43086. var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera, true);
  43087. var cx = 2 * (x / (globalViewport.width + globalViewport.x * 2)) - 1.0;
  43088. var cy = 1.0 - 2 * (y / (globalViewport.height + globalViewport.y * 2));
  43089. 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);
  43090. this._effect.setMatrix("viewportMatrix", viewportMatrix);
  43091. // Texture
  43092. this._effect.setTexture("textureSampler", flare.texture);
  43093. // Color
  43094. this._effect.setFloat4("color", flare.color.r * intensity, flare.color.g * intensity, flare.color.b * intensity, 1.0);
  43095. // Draw order
  43096. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  43097. }
  43098. engine.setDepthBuffer(true);
  43099. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  43100. return true;
  43101. };
  43102. /**
  43103. * Dispose and release the lens flare with its associated resources.
  43104. */
  43105. LensFlareSystem.prototype.dispose = function () {
  43106. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  43107. if (vertexBuffer) {
  43108. vertexBuffer.dispose();
  43109. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = null;
  43110. }
  43111. if (this._indexBuffer) {
  43112. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  43113. this._indexBuffer = null;
  43114. }
  43115. while (this.lensFlares.length) {
  43116. this.lensFlares[0].dispose();
  43117. }
  43118. // Remove from scene
  43119. var index = this._scene.lensFlareSystems.indexOf(this);
  43120. this._scene.lensFlareSystems.splice(index, 1);
  43121. };
  43122. /**
  43123. * Parse a lens flare system from a JSON repressentation
  43124. * @param parsedLensFlareSystem Define the JSON to parse
  43125. * @param scene Define the scene the parsed system should be instantiated in
  43126. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  43127. * @returns the parsed system
  43128. */
  43129. LensFlareSystem.Parse = function (parsedLensFlareSystem, scene, rootUrl) {
  43130. var emitter = scene.getLastEntryByID(parsedLensFlareSystem.emitterId);
  43131. var name = parsedLensFlareSystem.name || "lensFlareSystem#" + parsedLensFlareSystem.emitterId;
  43132. var lensFlareSystem = new LensFlareSystem(name, emitter, scene);
  43133. lensFlareSystem.id = parsedLensFlareSystem.id || name;
  43134. lensFlareSystem.borderLimit = parsedLensFlareSystem.borderLimit;
  43135. for (var index = 0; index < parsedLensFlareSystem.flares.length; index++) {
  43136. var parsedFlare = parsedLensFlareSystem.flares[index];
  43137. _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);
  43138. }
  43139. return lensFlareSystem;
  43140. };
  43141. /**
  43142. * Serialize the current Lens Flare System into a JSON representation.
  43143. * @returns the serialized JSON
  43144. */
  43145. LensFlareSystem.prototype.serialize = function () {
  43146. var serializationObject = {};
  43147. serializationObject.id = this.id;
  43148. serializationObject.name = this.name;
  43149. serializationObject.emitterId = this.getEmitter().id;
  43150. serializationObject.borderLimit = this.borderLimit;
  43151. serializationObject.flares = [];
  43152. for (var index = 0; index < this.lensFlares.length; index++) {
  43153. var flare = this.lensFlares[index];
  43154. serializationObject.flares.push({
  43155. size: flare.size,
  43156. position: flare.position,
  43157. color: flare.color.asArray(),
  43158. textureName: _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(flare.texture ? flare.texture.name : "")
  43159. });
  43160. }
  43161. return serializationObject;
  43162. };
  43163. /** @hidden */
  43164. LensFlareSystem._SceneComponentInitialization = function (_) {
  43165. throw "Import LensFlareSystemSceneComponent before creating LensFlareSystem.";
  43166. };
  43167. return LensFlareSystem;
  43168. }());
  43169. /***/ }),
  43170. /***/ "./LensFlares/lensFlareSystemSceneComponent.ts":
  43171. /*!*****************************************************!*\
  43172. !*** ./LensFlares/lensFlareSystemSceneComponent.ts ***!
  43173. \*****************************************************/
  43174. /*! exports provided: LensFlareSystemSceneComponent */
  43175. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43176. "use strict";
  43177. __webpack_require__.r(__webpack_exports__);
  43178. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return LensFlareSystemSceneComponent; });
  43179. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  43180. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  43181. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  43182. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  43183. // Adds the parser to the scene parsers.
  43184. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM, function (parsedData, scene, container, rootUrl) {
  43185. // Lens flares
  43186. if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {
  43187. if (!container.lensFlareSystems) {
  43188. container.lensFlareSystems = new Array();
  43189. }
  43190. for (var index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {
  43191. var parsedLensFlareSystem = parsedData.lensFlareSystems[index];
  43192. var lf = _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"].Parse(parsedLensFlareSystem, scene, rootUrl);
  43193. container.lensFlareSystems.push(lf);
  43194. }
  43195. }
  43196. });
  43197. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByName = function (name) {
  43198. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  43199. if (this.lensFlareSystems[index].name === name) {
  43200. return this.lensFlareSystems[index];
  43201. }
  43202. }
  43203. return null;
  43204. };
  43205. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByID = function (id) {
  43206. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  43207. if (this.lensFlareSystems[index].id === id) {
  43208. return this.lensFlareSystems[index];
  43209. }
  43210. }
  43211. return null;
  43212. };
  43213. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.removeLensFlareSystem = function (toRemove) {
  43214. var index = this.lensFlareSystems.indexOf(toRemove);
  43215. if (index !== -1) {
  43216. this.lensFlareSystems.splice(index, 1);
  43217. }
  43218. return index;
  43219. };
  43220. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.addLensFlareSystem = function (newLensFlareSystem) {
  43221. this.lensFlareSystems.push(newLensFlareSystem);
  43222. };
  43223. /**
  43224. * Defines the lens flare scene component responsible to manage any lens flares
  43225. * in a given scene.
  43226. */
  43227. var LensFlareSystemSceneComponent = /** @class */ (function () {
  43228. /**
  43229. * Creates a new instance of the component for the given scene
  43230. * @param scene Defines the scene to register the component in
  43231. */
  43232. function LensFlareSystemSceneComponent(scene) {
  43233. /**
  43234. * The component name helpfull to identify the component in the list of scene components.
  43235. */
  43236. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM;
  43237. this.scene = scene;
  43238. scene.lensFlareSystems = new Array();
  43239. }
  43240. /**
  43241. * Registers the component in a given scene
  43242. */
  43243. LensFlareSystemSceneComponent.prototype.register = function () {
  43244. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);
  43245. };
  43246. /**
  43247. * Rebuilds the elements related to this component in case of
  43248. * context lost for instance.
  43249. */
  43250. LensFlareSystemSceneComponent.prototype.rebuild = function () {
  43251. // Nothing to do for lens flare
  43252. };
  43253. /**
  43254. * Adds all the element from the container to the scene
  43255. * @param container the container holding the elements
  43256. */
  43257. LensFlareSystemSceneComponent.prototype.addFromContainer = function (container) {
  43258. var _this = this;
  43259. if (!container.lensFlareSystems) {
  43260. return;
  43261. }
  43262. container.lensFlareSystems.forEach(function (o) {
  43263. _this.scene.addLensFlareSystem(o);
  43264. });
  43265. };
  43266. /**
  43267. * Removes all the elements in the container from the scene
  43268. * @param container contains the elements to remove
  43269. */
  43270. LensFlareSystemSceneComponent.prototype.removeFromContainer = function (container) {
  43271. var _this = this;
  43272. if (!container.lensFlareSystems) {
  43273. return;
  43274. }
  43275. container.lensFlareSystems.forEach(function (o) {
  43276. _this.scene.removeLensFlareSystem(o);
  43277. });
  43278. };
  43279. /**
  43280. * Serializes the component data to the specified json object
  43281. * @param serializationObject The object to serialize to
  43282. */
  43283. LensFlareSystemSceneComponent.prototype.serialize = function (serializationObject) {
  43284. // Lens flares
  43285. serializationObject.lensFlareSystems = [];
  43286. var lensFlareSystems = this.scene.lensFlareSystems;
  43287. for (var _i = 0, lensFlareSystems_1 = lensFlareSystems; _i < lensFlareSystems_1.length; _i++) {
  43288. var lensFlareSystem = lensFlareSystems_1[_i];
  43289. serializationObject.lensFlareSystems.push(lensFlareSystem.serialize());
  43290. }
  43291. };
  43292. /**
  43293. * Disposes the component and the associated ressources.
  43294. */
  43295. LensFlareSystemSceneComponent.prototype.dispose = function () {
  43296. var lensFlareSystems = this.scene.lensFlareSystems;
  43297. while (lensFlareSystems.length) {
  43298. lensFlareSystems[0].dispose();
  43299. }
  43300. };
  43301. LensFlareSystemSceneComponent.prototype._draw = function (camera) {
  43302. // Lens flares
  43303. if (this.scene.lensFlaresEnabled) {
  43304. var lensFlareSystems = this.scene.lensFlareSystems;
  43305. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  43306. for (var _i = 0, lensFlareSystems_2 = lensFlareSystems; _i < lensFlareSystems_2.length; _i++) {
  43307. var lensFlareSystem = lensFlareSystems_2[_i];
  43308. if ((camera.layerMask & lensFlareSystem.layerMask) !== 0) {
  43309. lensFlareSystem.render();
  43310. }
  43311. }
  43312. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  43313. }
  43314. };
  43315. return LensFlareSystemSceneComponent;
  43316. }());
  43317. _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"]._SceneComponentInitialization = function (scene) {
  43318. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM);
  43319. if (!component) {
  43320. component = new LensFlareSystemSceneComponent(scene);
  43321. scene._addComponent(component);
  43322. }
  43323. };
  43324. /***/ }),
  43325. /***/ "./Lights/Shadows/index.ts":
  43326. /*!*********************************!*\
  43327. !*** ./Lights/Shadows/index.ts ***!
  43328. \*********************************/
  43329. /*! exports provided: ShadowGenerator, ShadowGeneratorSceneComponent */
  43330. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43331. "use strict";
  43332. __webpack_require__.r(__webpack_exports__);
  43333. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  43334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  43335. /* harmony import */ var _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowGeneratorSceneComponent */ "./Lights/Shadows/shadowGeneratorSceneComponent.ts");
  43336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__["ShadowGeneratorSceneComponent"]; });
  43337. /***/ }),
  43338. /***/ "./Lights/Shadows/shadowGenerator.ts":
  43339. /*!*******************************************!*\
  43340. !*** ./Lights/Shadows/shadowGenerator.ts ***!
  43341. \*******************************************/
  43342. /*! exports provided: ShadowGenerator */
  43343. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43344. "use strict";
  43345. __webpack_require__.r(__webpack_exports__);
  43346. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return ShadowGenerator; });
  43347. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  43348. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  43349. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  43350. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  43351. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  43352. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  43353. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43354. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  43355. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  43356. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  43357. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  43358. /* harmony import */ var _Shaders_shadowMap_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Shaders/shadowMap.fragment */ "./Shaders/shadowMap.fragment.ts");
  43359. /* harmony import */ var _Shaders_shadowMap_vertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Shaders/shadowMap.vertex */ "./Shaders/shadowMap.vertex.ts");
  43360. /* harmony import */ var _Shaders_depthBoxBlur_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Shaders/depthBoxBlur.fragment */ "./Shaders/depthBoxBlur.fragment.ts");
  43361. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  43362. /**
  43363. * Default implementation IShadowGenerator.
  43364. * This is the main object responsible of generating shadows in the framework.
  43365. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  43366. */
  43367. var ShadowGenerator = /** @class */ (function () {
  43368. /**
  43369. * Creates a ShadowGenerator object.
  43370. * A ShadowGenerator is the required tool to use the shadows.
  43371. * Each light casting shadows needs to use its own ShadowGenerator.
  43372. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  43373. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  43374. * @param light The light object generating the shadows.
  43375. * @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.
  43376. */
  43377. function ShadowGenerator(mapSize, light, usefulFloatFirst) {
  43378. /**
  43379. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  43380. */
  43381. this.onBeforeShadowMapRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  43382. this._bias = 0.00005;
  43383. this._normalBias = 0;
  43384. this._blurBoxOffset = 1;
  43385. this._blurScale = 2;
  43386. this._blurKernel = 1;
  43387. this._useKernelBlur = false;
  43388. this._filter = ShadowGenerator.FILTER_NONE;
  43389. this._filteringQuality = ShadowGenerator.QUALITY_HIGH;
  43390. this._contactHardeningLightSizeUVRatio = 0.1;
  43391. this._darkness = 0;
  43392. this._transparencyShadow = false;
  43393. /**
  43394. * Controls the extent to which the shadows fade out at the edge of the frustum
  43395. * Used only by directionals and spots
  43396. */
  43397. this.frustumEdgeFalloff = 0;
  43398. /**
  43399. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  43400. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  43401. * It might on the other hand introduce peter panning.
  43402. */
  43403. this.forceBackFacesOnly = false;
  43404. this._lightDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  43405. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  43406. this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  43407. this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  43408. this._cachedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  43409. this._cachedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  43410. this._currentFaceIndex = 0;
  43411. this._currentFaceIndexCache = 0;
  43412. this._defaultTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  43413. this._mapSize = mapSize;
  43414. this._light = light;
  43415. this._scene = light.getScene();
  43416. light._shadowGenerator = this;
  43417. ShadowGenerator._SceneComponentInitialization(this._scene);
  43418. // Texture type fallback from float to int if not supported.
  43419. var caps = this._scene.getEngine().getCaps();
  43420. if (!usefulFloatFirst) {
  43421. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  43422. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  43423. }
  43424. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  43425. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  43426. }
  43427. else {
  43428. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  43429. }
  43430. }
  43431. else {
  43432. if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  43433. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  43434. }
  43435. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  43436. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  43437. }
  43438. else {
  43439. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  43440. }
  43441. }
  43442. this._initializeGenerator();
  43443. this._applyFilterValues();
  43444. }
  43445. Object.defineProperty(ShadowGenerator.prototype, "bias", {
  43446. /**
  43447. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  43448. */
  43449. get: function () {
  43450. return this._bias;
  43451. },
  43452. /**
  43453. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  43454. */
  43455. set: function (bias) {
  43456. this._bias = bias;
  43457. },
  43458. enumerable: true,
  43459. configurable: true
  43460. });
  43461. Object.defineProperty(ShadowGenerator.prototype, "normalBias", {
  43462. /**
  43463. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  43464. */
  43465. get: function () {
  43466. return this._normalBias;
  43467. },
  43468. /**
  43469. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  43470. */
  43471. set: function (normalBias) {
  43472. this._normalBias = normalBias;
  43473. },
  43474. enumerable: true,
  43475. configurable: true
  43476. });
  43477. Object.defineProperty(ShadowGenerator.prototype, "blurBoxOffset", {
  43478. /**
  43479. * Gets the blur box offset: offset applied during the blur pass.
  43480. * Only useful if useKernelBlur = false
  43481. */
  43482. get: function () {
  43483. return this._blurBoxOffset;
  43484. },
  43485. /**
  43486. * Sets the blur box offset: offset applied during the blur pass.
  43487. * Only useful if useKernelBlur = false
  43488. */
  43489. set: function (value) {
  43490. if (this._blurBoxOffset === value) {
  43491. return;
  43492. }
  43493. this._blurBoxOffset = value;
  43494. this._disposeBlurPostProcesses();
  43495. },
  43496. enumerable: true,
  43497. configurable: true
  43498. });
  43499. Object.defineProperty(ShadowGenerator.prototype, "blurScale", {
  43500. /**
  43501. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  43502. * 2 means half of the size.
  43503. */
  43504. get: function () {
  43505. return this._blurScale;
  43506. },
  43507. /**
  43508. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  43509. * 2 means half of the size.
  43510. */
  43511. set: function (value) {
  43512. if (this._blurScale === value) {
  43513. return;
  43514. }
  43515. this._blurScale = value;
  43516. this._disposeBlurPostProcesses();
  43517. },
  43518. enumerable: true,
  43519. configurable: true
  43520. });
  43521. Object.defineProperty(ShadowGenerator.prototype, "blurKernel", {
  43522. /**
  43523. * Gets the blur kernel: kernel size of the blur pass.
  43524. * Only useful if useKernelBlur = true
  43525. */
  43526. get: function () {
  43527. return this._blurKernel;
  43528. },
  43529. /**
  43530. * Sets the blur kernel: kernel size of the blur pass.
  43531. * Only useful if useKernelBlur = true
  43532. */
  43533. set: function (value) {
  43534. if (this._blurKernel === value) {
  43535. return;
  43536. }
  43537. this._blurKernel = value;
  43538. this._disposeBlurPostProcesses();
  43539. },
  43540. enumerable: true,
  43541. configurable: true
  43542. });
  43543. Object.defineProperty(ShadowGenerator.prototype, "useKernelBlur", {
  43544. /**
  43545. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  43546. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  43547. */
  43548. get: function () {
  43549. return this._useKernelBlur;
  43550. },
  43551. /**
  43552. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  43553. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  43554. */
  43555. set: function (value) {
  43556. if (this._useKernelBlur === value) {
  43557. return;
  43558. }
  43559. this._useKernelBlur = value;
  43560. this._disposeBlurPostProcesses();
  43561. },
  43562. enumerable: true,
  43563. configurable: true
  43564. });
  43565. Object.defineProperty(ShadowGenerator.prototype, "depthScale", {
  43566. /**
  43567. * Gets the depth scale used in ESM mode.
  43568. */
  43569. get: function () {
  43570. return this._depthScale !== undefined ? this._depthScale : this._light.getDepthScale();
  43571. },
  43572. /**
  43573. * Sets the depth scale used in ESM mode.
  43574. * This can override the scale stored on the light.
  43575. */
  43576. set: function (value) {
  43577. this._depthScale = value;
  43578. },
  43579. enumerable: true,
  43580. configurable: true
  43581. });
  43582. Object.defineProperty(ShadowGenerator.prototype, "filter", {
  43583. /**
  43584. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  43585. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  43586. */
  43587. get: function () {
  43588. return this._filter;
  43589. },
  43590. /**
  43591. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  43592. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  43593. */
  43594. set: function (value) {
  43595. // Blurring the cubemap is going to be too expensive. Reverting to unblurred version
  43596. if (this._light.needCube()) {
  43597. if (value === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  43598. this.useExponentialShadowMap = true;
  43599. return;
  43600. }
  43601. else if (value === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  43602. this.useCloseExponentialShadowMap = true;
  43603. return;
  43604. }
  43605. // PCF on cubemap would also be expensive
  43606. else if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  43607. this.usePoissonSampling = true;
  43608. return;
  43609. }
  43610. }
  43611. // Weblg1 fallback for PCF.
  43612. if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  43613. if (this._scene.getEngine().webGLVersion === 1) {
  43614. this.usePoissonSampling = true;
  43615. return;
  43616. }
  43617. }
  43618. if (this._filter === value) {
  43619. return;
  43620. }
  43621. this._filter = value;
  43622. this._disposeBlurPostProcesses();
  43623. this._applyFilterValues();
  43624. this._light._markMeshesAsLightDirty();
  43625. },
  43626. enumerable: true,
  43627. configurable: true
  43628. });
  43629. Object.defineProperty(ShadowGenerator.prototype, "usePoissonSampling", {
  43630. /**
  43631. * Gets if the current filter is set to Poisson Sampling.
  43632. */
  43633. get: function () {
  43634. return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
  43635. },
  43636. /**
  43637. * Sets the current filter to Poisson Sampling.
  43638. */
  43639. set: function (value) {
  43640. if (!value && this.filter !== ShadowGenerator.FILTER_POISSONSAMPLING) {
  43641. return;
  43642. }
  43643. this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE);
  43644. },
  43645. enumerable: true,
  43646. configurable: true
  43647. });
  43648. Object.defineProperty(ShadowGenerator.prototype, "useExponentialShadowMap", {
  43649. /**
  43650. * Gets if the current filter is set to ESM.
  43651. */
  43652. get: function () {
  43653. return this.filter === ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP;
  43654. },
  43655. /**
  43656. * Sets the current filter is to ESM.
  43657. */
  43658. set: function (value) {
  43659. if (!value && this.filter !== ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP) {
  43660. return;
  43661. }
  43662. this.filter = (value ? ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  43663. },
  43664. enumerable: true,
  43665. configurable: true
  43666. });
  43667. Object.defineProperty(ShadowGenerator.prototype, "useBlurExponentialShadowMap", {
  43668. /**
  43669. * Gets if the current filter is set to filtered ESM.
  43670. */
  43671. get: function () {
  43672. return this.filter === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP;
  43673. },
  43674. /**
  43675. * Gets if the current filter is set to filtered ESM.
  43676. */
  43677. set: function (value) {
  43678. if (!value && this.filter !== ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  43679. return;
  43680. }
  43681. this.filter = (value ? ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  43682. },
  43683. enumerable: true,
  43684. configurable: true
  43685. });
  43686. Object.defineProperty(ShadowGenerator.prototype, "useCloseExponentialShadowMap", {
  43687. /**
  43688. * Gets if the current filter is set to "close ESM" (using the inverse of the
  43689. * exponential to prevent steep falloff artifacts).
  43690. */
  43691. get: function () {
  43692. return this.filter === ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP;
  43693. },
  43694. /**
  43695. * Sets the current filter to "close ESM" (using the inverse of the
  43696. * exponential to prevent steep falloff artifacts).
  43697. */
  43698. set: function (value) {
  43699. if (!value && this.filter !== ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP) {
  43700. return;
  43701. }
  43702. this.filter = (value ? ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  43703. },
  43704. enumerable: true,
  43705. configurable: true
  43706. });
  43707. Object.defineProperty(ShadowGenerator.prototype, "useBlurCloseExponentialShadowMap", {
  43708. /**
  43709. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  43710. * exponential to prevent steep falloff artifacts).
  43711. */
  43712. get: function () {
  43713. return this.filter === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  43714. },
  43715. /**
  43716. * Sets the current filter to filtered "close ESM" (using the inverse of the
  43717. * exponential to prevent steep falloff artifacts).
  43718. */
  43719. set: function (value) {
  43720. if (!value && this.filter !== ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  43721. return;
  43722. }
  43723. this.filter = (value ? ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  43724. },
  43725. enumerable: true,
  43726. configurable: true
  43727. });
  43728. Object.defineProperty(ShadowGenerator.prototype, "usePercentageCloserFiltering", {
  43729. /**
  43730. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  43731. */
  43732. get: function () {
  43733. return this.filter === ShadowGenerator.FILTER_PCF;
  43734. },
  43735. /**
  43736. * Sets the current filter to "PCF" (percentage closer filtering).
  43737. */
  43738. set: function (value) {
  43739. if (!value && this.filter !== ShadowGenerator.FILTER_PCF) {
  43740. return;
  43741. }
  43742. this.filter = (value ? ShadowGenerator.FILTER_PCF : ShadowGenerator.FILTER_NONE);
  43743. },
  43744. enumerable: true,
  43745. configurable: true
  43746. });
  43747. Object.defineProperty(ShadowGenerator.prototype, "filteringQuality", {
  43748. /**
  43749. * Gets the PCF or PCSS Quality.
  43750. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  43751. */
  43752. get: function () {
  43753. return this._filteringQuality;
  43754. },
  43755. /**
  43756. * Sets the PCF or PCSS Quality.
  43757. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  43758. */
  43759. set: function (filteringQuality) {
  43760. this._filteringQuality = filteringQuality;
  43761. },
  43762. enumerable: true,
  43763. configurable: true
  43764. });
  43765. Object.defineProperty(ShadowGenerator.prototype, "useContactHardeningShadow", {
  43766. /**
  43767. * Gets if the current filter is set to "PCSS" (contact hardening).
  43768. */
  43769. get: function () {
  43770. return this.filter === ShadowGenerator.FILTER_PCSS;
  43771. },
  43772. /**
  43773. * Sets the current filter to "PCSS" (contact hardening).
  43774. */
  43775. set: function (value) {
  43776. if (!value && this.filter !== ShadowGenerator.FILTER_PCSS) {
  43777. return;
  43778. }
  43779. this.filter = (value ? ShadowGenerator.FILTER_PCSS : ShadowGenerator.FILTER_NONE);
  43780. },
  43781. enumerable: true,
  43782. configurable: true
  43783. });
  43784. Object.defineProperty(ShadowGenerator.prototype, "contactHardeningLightSizeUVRatio", {
  43785. /**
  43786. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  43787. * Using a ratio helps keeping shape stability independently of the map size.
  43788. *
  43789. * It does not account for the light projection as it was having too much
  43790. * instability during the light setup or during light position changes.
  43791. *
  43792. * Only valid if useContactHardeningShadow is true.
  43793. */
  43794. get: function () {
  43795. return this._contactHardeningLightSizeUVRatio;
  43796. },
  43797. /**
  43798. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  43799. * Using a ratio helps keeping shape stability independently of the map size.
  43800. *
  43801. * It does not account for the light projection as it was having too much
  43802. * instability during the light setup or during light position changes.
  43803. *
  43804. * Only valid if useContactHardeningShadow is true.
  43805. */
  43806. set: function (contactHardeningLightSizeUVRatio) {
  43807. this._contactHardeningLightSizeUVRatio = contactHardeningLightSizeUVRatio;
  43808. },
  43809. enumerable: true,
  43810. configurable: true
  43811. });
  43812. /**
  43813. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  43814. * 0 means strongest and 1 would means no shadow.
  43815. * @returns the darkness.
  43816. */
  43817. ShadowGenerator.prototype.getDarkness = function () {
  43818. return this._darkness;
  43819. };
  43820. /**
  43821. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  43822. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  43823. * @returns the shadow generator allowing fluent coding.
  43824. */
  43825. ShadowGenerator.prototype.setDarkness = function (darkness) {
  43826. if (darkness >= 1.0) {
  43827. this._darkness = 1.0;
  43828. }
  43829. else if (darkness <= 0.0) {
  43830. this._darkness = 0.0;
  43831. }
  43832. else {
  43833. this._darkness = darkness;
  43834. }
  43835. return this;
  43836. };
  43837. /**
  43838. * Sets the ability to have transparent shadow (boolean).
  43839. * @param transparent True if transparent else False
  43840. * @returns the shadow generator allowing fluent coding
  43841. */
  43842. ShadowGenerator.prototype.setTransparencyShadow = function (transparent) {
  43843. this._transparencyShadow = transparent;
  43844. return this;
  43845. };
  43846. /**
  43847. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  43848. * @returns The render target texture if present otherwise, null
  43849. */
  43850. ShadowGenerator.prototype.getShadowMap = function () {
  43851. return this._shadowMap;
  43852. };
  43853. /**
  43854. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  43855. * @returns The render target texture if the shadow map is present otherwise, null
  43856. */
  43857. ShadowGenerator.prototype.getShadowMapForRendering = function () {
  43858. if (this._shadowMap2) {
  43859. return this._shadowMap2;
  43860. }
  43861. return this._shadowMap;
  43862. };
  43863. /**
  43864. * Helper function to add a mesh and its descendants to the list of shadow casters.
  43865. * @param mesh Mesh to add
  43866. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  43867. * @returns the Shadow Generator itself
  43868. */
  43869. ShadowGenerator.prototype.addShadowCaster = function (mesh, includeDescendants) {
  43870. if (includeDescendants === void 0) { includeDescendants = true; }
  43871. var _a;
  43872. if (!this._shadowMap) {
  43873. return this;
  43874. }
  43875. if (!this._shadowMap.renderList) {
  43876. this._shadowMap.renderList = [];
  43877. }
  43878. this._shadowMap.renderList.push(mesh);
  43879. if (includeDescendants) {
  43880. (_a = this._shadowMap.renderList).push.apply(_a, mesh.getChildMeshes());
  43881. }
  43882. return this;
  43883. };
  43884. /**
  43885. * Helper function to remove a mesh and its descendants from the list of shadow casters
  43886. * @param mesh Mesh to remove
  43887. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  43888. * @returns the Shadow Generator itself
  43889. */
  43890. ShadowGenerator.prototype.removeShadowCaster = function (mesh, includeDescendants) {
  43891. if (includeDescendants === void 0) { includeDescendants = true; }
  43892. if (!this._shadowMap || !this._shadowMap.renderList) {
  43893. return this;
  43894. }
  43895. var index = this._shadowMap.renderList.indexOf(mesh);
  43896. if (index !== -1) {
  43897. this._shadowMap.renderList.splice(index, 1);
  43898. }
  43899. if (includeDescendants) {
  43900. for (var _i = 0, _a = mesh.getChildren(); _i < _a.length; _i++) {
  43901. var child = _a[_i];
  43902. this.removeShadowCaster(child);
  43903. }
  43904. }
  43905. return this;
  43906. };
  43907. /**
  43908. * Returns the associated light object.
  43909. * @returns the light generating the shadow
  43910. */
  43911. ShadowGenerator.prototype.getLight = function () {
  43912. return this._light;
  43913. };
  43914. ShadowGenerator.prototype._initializeGenerator = function () {
  43915. this._light._markMeshesAsLightDirty();
  43916. this._initializeShadowMap();
  43917. };
  43918. ShadowGenerator.prototype._initializeShadowMap = function () {
  43919. var _this = this;
  43920. // Render target
  43921. var engine = this._scene.getEngine();
  43922. if (engine.webGLVersion > 1) {
  43923. 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);
  43924. this._shadowMap.createDepthStencilTexture(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].LESS, true);
  43925. }
  43926. else {
  43927. 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());
  43928. }
  43929. this._shadowMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  43930. this._shadowMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  43931. this._shadowMap.anisotropicFilteringLevel = 1;
  43932. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  43933. this._shadowMap.renderParticles = false;
  43934. this._shadowMap.ignoreCameraViewport = true;
  43935. // Record Face Index before render.
  43936. this._shadowMap.onBeforeRenderObservable.add(function (faceIndex) {
  43937. _this._currentFaceIndex = faceIndex;
  43938. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  43939. engine.setColorWrite(false);
  43940. }
  43941. });
  43942. // Custom render function.
  43943. this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this);
  43944. // Blur if required afer render.
  43945. this._shadowMap.onAfterUnbindObservable.add(function () {
  43946. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  43947. engine.setColorWrite(true);
  43948. }
  43949. if (!_this.useBlurExponentialShadowMap && !_this.useBlurCloseExponentialShadowMap) {
  43950. return;
  43951. }
  43952. var shadowMap = _this.getShadowMapForRendering();
  43953. if (shadowMap) {
  43954. _this._scene.postProcessManager.directRender(_this._blurPostProcesses, shadowMap.getInternalTexture(), true);
  43955. }
  43956. });
  43957. // Clear according to the chosen filter.
  43958. var clearZero = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  43959. var clearOne = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  43960. this._shadowMap.onClearObservable.add(function (engine) {
  43961. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  43962. engine.clear(clearOne, false, true, false);
  43963. }
  43964. else if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
  43965. engine.clear(clearZero, true, true, false);
  43966. }
  43967. else {
  43968. engine.clear(clearOne, true, true, false);
  43969. }
  43970. });
  43971. };
  43972. ShadowGenerator.prototype._initializeBlurRTTAndPostProcesses = function () {
  43973. var _this = this;
  43974. var engine = this._scene.getEngine();
  43975. var targetSize = this._mapSize / this.blurScale;
  43976. if (!this.useKernelBlur || this.blurScale !== 1.0) {
  43977. this._shadowMap2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap2", targetSize, this._scene, false, true, this._textureType);
  43978. this._shadowMap2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  43979. this._shadowMap2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  43980. this._shadowMap2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  43981. }
  43982. if (this.useKernelBlur) {
  43983. 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);
  43984. this._kernelBlurXPostprocess.width = targetSize;
  43985. this._kernelBlurXPostprocess.height = targetSize;
  43986. this._kernelBlurXPostprocess.onApplyObservable.add(function (effect) {
  43987. effect.setTexture("textureSampler", _this._shadowMap);
  43988. });
  43989. 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);
  43990. this._kernelBlurXPostprocess.autoClear = false;
  43991. this._kernelBlurYPostprocess.autoClear = false;
  43992. if (this._textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  43993. this._kernelBlurXPostprocess.packedFloat = true;
  43994. this._kernelBlurYPostprocess.packedFloat = true;
  43995. }
  43996. this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess];
  43997. }
  43998. else {
  43999. 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);
  44000. this._boxBlurPostprocess.onApplyObservable.add(function (effect) {
  44001. effect.setFloat2("screenSize", targetSize, targetSize);
  44002. effect.setTexture("textureSampler", _this._shadowMap);
  44003. });
  44004. this._boxBlurPostprocess.autoClear = false;
  44005. this._blurPostProcesses = [this._boxBlurPostprocess];
  44006. }
  44007. };
  44008. ShadowGenerator.prototype._renderForShadowMap = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  44009. var index;
  44010. var engine = this._scene.getEngine();
  44011. if (depthOnlySubMeshes.length) {
  44012. engine.setColorWrite(false);
  44013. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  44014. this._renderSubMeshForShadowMap(depthOnlySubMeshes.data[index]);
  44015. }
  44016. engine.setColorWrite(true);
  44017. }
  44018. for (index = 0; index < opaqueSubMeshes.length; index++) {
  44019. this._renderSubMeshForShadowMap(opaqueSubMeshes.data[index]);
  44020. }
  44021. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  44022. this._renderSubMeshForShadowMap(alphaTestSubMeshes.data[index]);
  44023. }
  44024. if (this._transparencyShadow) {
  44025. for (index = 0; index < transparentSubMeshes.length; index++) {
  44026. this._renderSubMeshForShadowMap(transparentSubMeshes.data[index]);
  44027. }
  44028. }
  44029. };
  44030. ShadowGenerator.prototype._renderSubMeshForShadowMap = function (subMesh) {
  44031. var _this = this;
  44032. var mesh = subMesh.getRenderingMesh();
  44033. var scene = this._scene;
  44034. var engine = scene.getEngine();
  44035. var material = subMesh.getMaterial();
  44036. if (!material || subMesh.verticesCount === 0) {
  44037. return;
  44038. }
  44039. // Culling
  44040. engine.setState(material.backFaceCulling);
  44041. // Managing instances
  44042. var batch = mesh._getInstancesRenderList(subMesh._id);
  44043. if (batch.mustReturn) {
  44044. return;
  44045. }
  44046. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  44047. if (this.isReady(subMesh, hardwareInstancedRendering)) {
  44048. engine.enableEffect(this._effect);
  44049. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  44050. this._effect.setFloat3("biasAndScale", this.bias, this.normalBias, this.depthScale);
  44051. this._effect.setMatrix("viewProjection", this.getTransformMatrix());
  44052. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  44053. this._effect.setVector3("lightData", this._cachedDirection);
  44054. }
  44055. else {
  44056. this._effect.setVector3("lightData", this._cachedPosition);
  44057. }
  44058. if (scene.activeCamera) {
  44059. this._effect.setFloat2("depthValues", this.getLight().getDepthMinZ(scene.activeCamera), this.getLight().getDepthMinZ(scene.activeCamera) + this.getLight().getDepthMaxZ(scene.activeCamera));
  44060. }
  44061. // Alpha test
  44062. if (material && material.needAlphaTesting()) {
  44063. var alphaTexture = material.getAlphaTestTexture();
  44064. if (alphaTexture) {
  44065. this._effect.setTexture("diffuseSampler", alphaTexture);
  44066. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix() || this._defaultTextureMatrix);
  44067. }
  44068. }
  44069. // Bones
  44070. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  44071. var skeleton = mesh.skeleton;
  44072. if (skeleton.isUsingTextureForMatrices) {
  44073. var boneTexture = skeleton.getTransformMatrixTexture();
  44074. if (!boneTexture) {
  44075. return;
  44076. }
  44077. this._effect.setTexture("boneSampler", boneTexture);
  44078. this._effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  44079. }
  44080. else {
  44081. this._effect.setMatrices("mBones", skeleton.getTransformMatrices((mesh)));
  44082. }
  44083. }
  44084. // Morph targets
  44085. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effect);
  44086. if (this.forceBackFacesOnly) {
  44087. engine.setState(true, 0, false, true);
  44088. }
  44089. // Observable
  44090. this.onBeforeShadowMapRenderObservable.notifyObservers(this._effect);
  44091. // Draw
  44092. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  44093. if (this.forceBackFacesOnly) {
  44094. engine.setState(true, 0, false, false);
  44095. }
  44096. }
  44097. else {
  44098. // Need to reset refresh rate of the shadowMap
  44099. if (this._shadowMap) {
  44100. this._shadowMap.resetRefreshCounter();
  44101. }
  44102. }
  44103. };
  44104. ShadowGenerator.prototype._applyFilterValues = function () {
  44105. if (!this._shadowMap) {
  44106. return;
  44107. }
  44108. if (this.filter === ShadowGenerator.FILTER_NONE || this.filter === ShadowGenerator.FILTER_PCSS) {
  44109. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].NEAREST_SAMPLINGMODE);
  44110. }
  44111. else {
  44112. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  44113. }
  44114. };
  44115. /**
  44116. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44117. * @param onCompiled Callback triggered at the and of the effects compilation
  44118. * @param options Sets of optional options forcing the compilation with different modes
  44119. */
  44120. ShadowGenerator.prototype.forceCompilation = function (onCompiled, options) {
  44121. var _this = this;
  44122. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ useInstances: false }, options);
  44123. var shadowMap = this.getShadowMap();
  44124. if (!shadowMap) {
  44125. if (onCompiled) {
  44126. onCompiled(this);
  44127. }
  44128. return;
  44129. }
  44130. var renderList = shadowMap.renderList;
  44131. if (!renderList) {
  44132. if (onCompiled) {
  44133. onCompiled(this);
  44134. }
  44135. return;
  44136. }
  44137. var subMeshes = new Array();
  44138. for (var _i = 0, renderList_1 = renderList; _i < renderList_1.length; _i++) {
  44139. var mesh = renderList_1[_i];
  44140. subMeshes.push.apply(subMeshes, mesh.subMeshes);
  44141. }
  44142. if (subMeshes.length === 0) {
  44143. if (onCompiled) {
  44144. onCompiled(this);
  44145. }
  44146. return;
  44147. }
  44148. var currentIndex = 0;
  44149. var checkReady = function () {
  44150. if (!_this._scene || !_this._scene.getEngine()) {
  44151. return;
  44152. }
  44153. while (_this.isReady(subMeshes[currentIndex], localOptions.useInstances)) {
  44154. currentIndex++;
  44155. if (currentIndex >= subMeshes.length) {
  44156. if (onCompiled) {
  44157. onCompiled(_this);
  44158. }
  44159. return;
  44160. }
  44161. }
  44162. setTimeout(checkReady, 16);
  44163. };
  44164. checkReady();
  44165. };
  44166. /**
  44167. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44168. * @param options Sets of optional options forcing the compilation with different modes
  44169. * @returns A promise that resolves when the compilation completes
  44170. */
  44171. ShadowGenerator.prototype.forceCompilationAsync = function (options) {
  44172. var _this = this;
  44173. return new Promise(function (resolve) {
  44174. _this.forceCompilation(function () {
  44175. resolve();
  44176. }, options);
  44177. });
  44178. };
  44179. /**
  44180. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44181. * @param subMesh The submesh we want to render in the shadow map
  44182. * @param useInstances Defines wether will draw in the map using instances
  44183. * @returns true if ready otherwise, false
  44184. */
  44185. ShadowGenerator.prototype.isReady = function (subMesh, useInstances) {
  44186. var defines = [];
  44187. if (this._textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  44188. defines.push("#define FLOAT");
  44189. }
  44190. if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  44191. defines.push("#define ESM");
  44192. }
  44193. else if (this.usePercentageCloserFiltering || this.useContactHardeningShadow) {
  44194. defines.push("#define DEPTHTEXTURE");
  44195. }
  44196. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind];
  44197. var mesh = subMesh.getMesh();
  44198. var material = subMesh.getMaterial();
  44199. // Normal bias.
  44200. if (this.normalBias && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  44201. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  44202. defines.push("#define NORMAL");
  44203. if (mesh.nonUniformScaling) {
  44204. defines.push("#define NONUNIFORMSCALING");
  44205. }
  44206. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  44207. defines.push("#define DIRECTIONINLIGHTDATA");
  44208. }
  44209. }
  44210. // Alpha test
  44211. if (material && material.needAlphaTesting()) {
  44212. var alphaTexture = material.getAlphaTestTexture();
  44213. if (alphaTexture) {
  44214. defines.push("#define ALPHATEST");
  44215. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  44216. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  44217. defines.push("#define UV1");
  44218. }
  44219. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  44220. if (alphaTexture.coordinatesIndex === 1) {
  44221. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  44222. defines.push("#define UV2");
  44223. }
  44224. }
  44225. }
  44226. }
  44227. // Bones
  44228. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  44229. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  44230. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  44231. if (mesh.numBoneInfluencers > 4) {
  44232. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  44233. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind);
  44234. }
  44235. var skeleton = mesh.skeleton;
  44236. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  44237. if (skeleton.isUsingTextureForMatrices) {
  44238. defines.push("#define BONETEXTURE");
  44239. }
  44240. else {
  44241. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  44242. }
  44243. }
  44244. else {
  44245. defines.push("#define NUM_BONE_INFLUENCERS 0");
  44246. }
  44247. // Morph targets
  44248. var manager = mesh.morphTargetManager;
  44249. var morphInfluencers = 0;
  44250. if (manager) {
  44251. if (manager.numInfluencers > 0) {
  44252. defines.push("#define MORPHTARGETS");
  44253. morphInfluencers = manager.numInfluencers;
  44254. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  44255. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  44256. }
  44257. }
  44258. // Instances
  44259. if (useInstances) {
  44260. defines.push("#define INSTANCES");
  44261. attribs.push("world0");
  44262. attribs.push("world1");
  44263. attribs.push("world2");
  44264. attribs.push("world3");
  44265. }
  44266. if (this.customShaderOptions) {
  44267. if (this.customShaderOptions.defines) {
  44268. for (var _i = 0, _a = this.customShaderOptions.defines; _i < _a.length; _i++) {
  44269. var define = _a[_i];
  44270. if (defines.indexOf(define) === -1) {
  44271. defines.push(define);
  44272. }
  44273. }
  44274. }
  44275. }
  44276. // Get correct effect
  44277. var join = defines.join("\n");
  44278. if (this._cachedDefines !== join) {
  44279. this._cachedDefines = join;
  44280. var shaderName = "shadowMap";
  44281. var uniforms = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightData", "depthValues", "biasAndScale", "morphTargetInfluences", "boneTextureWidth"];
  44282. var samplers = ["diffuseSampler", "boneSampler"];
  44283. // Custom shader?
  44284. if (this.customShaderOptions) {
  44285. shaderName = this.customShaderOptions.shaderName;
  44286. if (this.customShaderOptions.attributes) {
  44287. for (var _b = 0, _c = this.customShaderOptions.attributes; _b < _c.length; _b++) {
  44288. var attrib = _c[_b];
  44289. if (attribs.indexOf(attrib) === -1) {
  44290. attribs.push(attrib);
  44291. }
  44292. }
  44293. }
  44294. if (this.customShaderOptions.uniforms) {
  44295. for (var _d = 0, _e = this.customShaderOptions.uniforms; _d < _e.length; _d++) {
  44296. var uniform = _e[_d];
  44297. if (uniforms.indexOf(uniform) === -1) {
  44298. uniforms.push(uniform);
  44299. }
  44300. }
  44301. }
  44302. if (this.customShaderOptions.samplers) {
  44303. for (var _f = 0, _g = this.customShaderOptions.samplers; _f < _g.length; _f++) {
  44304. var sampler = _g[_f];
  44305. if (samplers.indexOf(sampler) === -1) {
  44306. samplers.push(sampler);
  44307. }
  44308. }
  44309. }
  44310. }
  44311. this._effect = this._scene.getEngine().createEffect(shaderName, attribs, uniforms, samplers, join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  44312. }
  44313. if (!this._effect.isReady()) {
  44314. return false;
  44315. }
  44316. if (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  44317. if (!this._blurPostProcesses || !this._blurPostProcesses.length) {
  44318. this._initializeBlurRTTAndPostProcesses();
  44319. }
  44320. }
  44321. if (this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady()) {
  44322. return false;
  44323. }
  44324. if (this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady()) {
  44325. return false;
  44326. }
  44327. if (this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady()) {
  44328. return false;
  44329. }
  44330. return true;
  44331. };
  44332. /**
  44333. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44334. * @param defines Defines of the material we want to update
  44335. * @param lightIndex Index of the light in the enabled light list of the material
  44336. */
  44337. ShadowGenerator.prototype.prepareDefines = function (defines, lightIndex) {
  44338. var scene = this._scene;
  44339. var light = this._light;
  44340. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  44341. return;
  44342. }
  44343. defines["SHADOW" + lightIndex] = true;
  44344. if (this.useContactHardeningShadow) {
  44345. defines["SHADOWPCSS" + lightIndex] = true;
  44346. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  44347. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  44348. }
  44349. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  44350. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  44351. }
  44352. // else default to high.
  44353. }
  44354. if (this.usePercentageCloserFiltering) {
  44355. defines["SHADOWPCF" + lightIndex] = true;
  44356. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  44357. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  44358. }
  44359. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  44360. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  44361. }
  44362. // else default to high.
  44363. }
  44364. else if (this.usePoissonSampling) {
  44365. defines["SHADOWPOISSON" + lightIndex] = true;
  44366. }
  44367. else if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  44368. defines["SHADOWESM" + lightIndex] = true;
  44369. }
  44370. else if (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  44371. defines["SHADOWCLOSEESM" + lightIndex] = true;
  44372. }
  44373. if (light.needCube()) {
  44374. defines["SHADOWCUBE" + lightIndex] = true;
  44375. }
  44376. };
  44377. /**
  44378. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44379. * defined in the generator but impacting the effect).
  44380. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44381. * @param effect The effect we are binfing the information for
  44382. */
  44383. ShadowGenerator.prototype.bindShadowLight = function (lightIndex, effect) {
  44384. var light = this._light;
  44385. var scene = this._scene;
  44386. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  44387. return;
  44388. }
  44389. var camera = scene.activeCamera;
  44390. if (!camera) {
  44391. return;
  44392. }
  44393. var shadowMap = this.getShadowMap();
  44394. if (!shadowMap) {
  44395. return;
  44396. }
  44397. if (!light.needCube()) {
  44398. effect.setMatrix("lightMatrix" + lightIndex, this.getTransformMatrix());
  44399. }
  44400. // Only PCF uses depth stencil texture.
  44401. if (this._filter === ShadowGenerator.FILTER_PCF) {
  44402. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  44403. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), shadowMap.getSize().width, 1 / shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  44404. }
  44405. else if (this._filter === ShadowGenerator.FILTER_PCSS) {
  44406. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  44407. effect.setTexture("depthSampler" + lightIndex, this.getShadowMapForRendering());
  44408. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / shadowMap.getSize().width, this._contactHardeningLightSizeUVRatio * shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  44409. }
  44410. else {
  44411. effect.setTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  44412. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / shadowMap.getSize().width, this.depthScale, this.frustumEdgeFalloff, lightIndex);
  44413. }
  44414. light._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(camera), this.getLight().getDepthMinZ(camera) + this.getLight().getDepthMaxZ(camera), lightIndex);
  44415. };
  44416. /**
  44417. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44418. * (eq to shadow prjection matrix * light transform matrix)
  44419. * @returns The transform matrix used to create the shadow map
  44420. */
  44421. ShadowGenerator.prototype.getTransformMatrix = function () {
  44422. var scene = this._scene;
  44423. if (this._currentRenderID === scene.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex) {
  44424. return this._transformMatrix;
  44425. }
  44426. this._currentRenderID = scene.getRenderId();
  44427. this._currentFaceIndexCache = this._currentFaceIndex;
  44428. var lightPosition = this._light.position;
  44429. if (this._light.computeTransformedInformation()) {
  44430. lightPosition = this._light.transformedPosition;
  44431. }
  44432. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection);
  44433. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this._lightDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up())) === 1.0) {
  44434. this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
  44435. }
  44436. if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
  44437. this._cachedPosition.copyFrom(lightPosition);
  44438. this._cachedDirection.copyFrom(this._lightDirection);
  44439. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up(), this._viewMatrix);
  44440. var shadowMap = this.getShadowMap();
  44441. if (shadowMap) {
  44442. var renderList = shadowMap.renderList;
  44443. if (renderList) {
  44444. this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, renderList);
  44445. }
  44446. }
  44447. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  44448. }
  44449. return this._transformMatrix;
  44450. };
  44451. /**
  44452. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44453. * Cube and 2D textures for instance.
  44454. */
  44455. ShadowGenerator.prototype.recreateShadowMap = function () {
  44456. var shadowMap = this._shadowMap;
  44457. if (!shadowMap) {
  44458. return;
  44459. }
  44460. // Track render list.
  44461. var renderList = shadowMap.renderList;
  44462. // Clean up existing data.
  44463. this._disposeRTTandPostProcesses();
  44464. // Reinitializes.
  44465. this._initializeGenerator();
  44466. // Reaffect the filter to ensure a correct fallback if necessary.
  44467. this.filter = this.filter;
  44468. // Reaffect the filter.
  44469. this._applyFilterValues();
  44470. // Reaffect Render List.
  44471. this._shadowMap.renderList = renderList;
  44472. };
  44473. ShadowGenerator.prototype._disposeBlurPostProcesses = function () {
  44474. if (this._shadowMap2) {
  44475. this._shadowMap2.dispose();
  44476. this._shadowMap2 = null;
  44477. }
  44478. if (this._boxBlurPostprocess) {
  44479. this._boxBlurPostprocess.dispose();
  44480. this._boxBlurPostprocess = null;
  44481. }
  44482. if (this._kernelBlurXPostprocess) {
  44483. this._kernelBlurXPostprocess.dispose();
  44484. this._kernelBlurXPostprocess = null;
  44485. }
  44486. if (this._kernelBlurYPostprocess) {
  44487. this._kernelBlurYPostprocess.dispose();
  44488. this._kernelBlurYPostprocess = null;
  44489. }
  44490. this._blurPostProcesses = [];
  44491. };
  44492. ShadowGenerator.prototype._disposeRTTandPostProcesses = function () {
  44493. if (this._shadowMap) {
  44494. this._shadowMap.dispose();
  44495. this._shadowMap = null;
  44496. }
  44497. this._disposeBlurPostProcesses();
  44498. };
  44499. /**
  44500. * Disposes the ShadowGenerator.
  44501. * Returns nothing.
  44502. */
  44503. ShadowGenerator.prototype.dispose = function () {
  44504. this._disposeRTTandPostProcesses();
  44505. if (this._light) {
  44506. this._light._shadowGenerator = null;
  44507. this._light._markMeshesAsLightDirty();
  44508. }
  44509. };
  44510. /**
  44511. * Serializes the shadow generator setup to a json object.
  44512. * @returns The serialized JSON object
  44513. */
  44514. ShadowGenerator.prototype.serialize = function () {
  44515. var serializationObject = {};
  44516. var shadowMap = this.getShadowMap();
  44517. if (!shadowMap) {
  44518. return serializationObject;
  44519. }
  44520. serializationObject.lightId = this._light.id;
  44521. serializationObject.mapSize = shadowMap.getRenderSize();
  44522. serializationObject.useExponentialShadowMap = this.useExponentialShadowMap;
  44523. serializationObject.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap;
  44524. serializationObject.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  44525. serializationObject.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  44526. serializationObject.usePoissonSampling = this.usePoissonSampling;
  44527. serializationObject.forceBackFacesOnly = this.forceBackFacesOnly;
  44528. serializationObject.depthScale = this.depthScale;
  44529. serializationObject.darkness = this.getDarkness();
  44530. serializationObject.blurBoxOffset = this.blurBoxOffset;
  44531. serializationObject.blurKernel = this.blurKernel;
  44532. serializationObject.blurScale = this.blurScale;
  44533. serializationObject.useKernelBlur = this.useKernelBlur;
  44534. serializationObject.transparencyShadow = this._transparencyShadow;
  44535. serializationObject.frustumEdgeFalloff = this.frustumEdgeFalloff;
  44536. serializationObject.bias = this.bias;
  44537. serializationObject.normalBias = this.normalBias;
  44538. serializationObject.usePercentageCloserFiltering = this.usePercentageCloserFiltering;
  44539. serializationObject.useContactHardeningShadow = this.useContactHardeningShadow;
  44540. serializationObject.filteringQuality = this.filteringQuality;
  44541. serializationObject.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio;
  44542. serializationObject.renderList = [];
  44543. if (shadowMap.renderList) {
  44544. for (var meshIndex = 0; meshIndex < shadowMap.renderList.length; meshIndex++) {
  44545. var mesh = shadowMap.renderList[meshIndex];
  44546. serializationObject.renderList.push(mesh.id);
  44547. }
  44548. }
  44549. return serializationObject;
  44550. };
  44551. /**
  44552. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44553. * @param parsedShadowGenerator The JSON object to parse
  44554. * @param scene The scene to create the shadow map for
  44555. * @returns The parsed shadow generator
  44556. */
  44557. ShadowGenerator.Parse = function (parsedShadowGenerator, scene) {
  44558. var light = scene.getLightByID(parsedShadowGenerator.lightId);
  44559. var shadowGenerator = new ShadowGenerator(parsedShadowGenerator.mapSize, light);
  44560. var shadowMap = shadowGenerator.getShadowMap();
  44561. for (var meshIndex = 0; meshIndex < parsedShadowGenerator.renderList.length; meshIndex++) {
  44562. var meshes = scene.getMeshesByID(parsedShadowGenerator.renderList[meshIndex]);
  44563. meshes.forEach(function (mesh) {
  44564. if (!shadowMap) {
  44565. return;
  44566. }
  44567. if (!shadowMap.renderList) {
  44568. shadowMap.renderList = [];
  44569. }
  44570. shadowMap.renderList.push(mesh);
  44571. });
  44572. }
  44573. if (parsedShadowGenerator.usePoissonSampling) {
  44574. shadowGenerator.usePoissonSampling = true;
  44575. }
  44576. else if (parsedShadowGenerator.useExponentialShadowMap) {
  44577. shadowGenerator.useExponentialShadowMap = true;
  44578. }
  44579. else if (parsedShadowGenerator.useBlurExponentialShadowMap) {
  44580. shadowGenerator.useBlurExponentialShadowMap = true;
  44581. }
  44582. else if (parsedShadowGenerator.useCloseExponentialShadowMap) {
  44583. shadowGenerator.useCloseExponentialShadowMap = true;
  44584. }
  44585. else if (parsedShadowGenerator.useBlurCloseExponentialShadowMap) {
  44586. shadowGenerator.useBlurCloseExponentialShadowMap = true;
  44587. }
  44588. else if (parsedShadowGenerator.usePercentageCloserFiltering) {
  44589. shadowGenerator.usePercentageCloserFiltering = true;
  44590. }
  44591. else if (parsedShadowGenerator.useContactHardeningShadow) {
  44592. shadowGenerator.useContactHardeningShadow = true;
  44593. }
  44594. if (parsedShadowGenerator.filteringQuality) {
  44595. shadowGenerator.filteringQuality = parsedShadowGenerator.filteringQuality;
  44596. }
  44597. if (parsedShadowGenerator.contactHardeningLightSizeUVRatio) {
  44598. shadowGenerator.contactHardeningLightSizeUVRatio = parsedShadowGenerator.contactHardeningLightSizeUVRatio;
  44599. }
  44600. // Backward compat
  44601. else if (parsedShadowGenerator.useVarianceShadowMap) {
  44602. shadowGenerator.useExponentialShadowMap = true;
  44603. }
  44604. else if (parsedShadowGenerator.useBlurVarianceShadowMap) {
  44605. shadowGenerator.useBlurExponentialShadowMap = true;
  44606. }
  44607. if (parsedShadowGenerator.depthScale) {
  44608. shadowGenerator.depthScale = parsedShadowGenerator.depthScale;
  44609. }
  44610. if (parsedShadowGenerator.blurScale) {
  44611. shadowGenerator.blurScale = parsedShadowGenerator.blurScale;
  44612. }
  44613. if (parsedShadowGenerator.blurBoxOffset) {
  44614. shadowGenerator.blurBoxOffset = parsedShadowGenerator.blurBoxOffset;
  44615. }
  44616. if (parsedShadowGenerator.useKernelBlur) {
  44617. shadowGenerator.useKernelBlur = parsedShadowGenerator.useKernelBlur;
  44618. }
  44619. if (parsedShadowGenerator.blurKernel) {
  44620. shadowGenerator.blurKernel = parsedShadowGenerator.blurKernel;
  44621. }
  44622. if (parsedShadowGenerator.bias !== undefined) {
  44623. shadowGenerator.bias = parsedShadowGenerator.bias;
  44624. }
  44625. if (parsedShadowGenerator.normalBias !== undefined) {
  44626. shadowGenerator.normalBias = parsedShadowGenerator.normalBias;
  44627. }
  44628. if (parsedShadowGenerator.frustumEdgeFalloff !== undefined) {
  44629. shadowGenerator.frustumEdgeFalloff = parsedShadowGenerator.frustumEdgeFalloff;
  44630. }
  44631. if (parsedShadowGenerator.darkness) {
  44632. shadowGenerator.setDarkness(parsedShadowGenerator.darkness);
  44633. }
  44634. if (parsedShadowGenerator.transparencyShadow) {
  44635. shadowGenerator.setTransparencyShadow(true);
  44636. }
  44637. shadowGenerator.forceBackFacesOnly = parsedShadowGenerator.forceBackFacesOnly;
  44638. return shadowGenerator;
  44639. };
  44640. /**
  44641. * Shadow generator mode None: no filtering applied.
  44642. */
  44643. ShadowGenerator.FILTER_NONE = 0;
  44644. /**
  44645. * Shadow generator mode ESM: Exponential Shadow Mapping.
  44646. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44647. */
  44648. ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP = 1;
  44649. /**
  44650. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  44651. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  44652. */
  44653. ShadowGenerator.FILTER_POISSONSAMPLING = 2;
  44654. /**
  44655. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  44656. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44657. */
  44658. ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP = 3;
  44659. /**
  44660. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  44661. * edge artifacts on steep falloff.
  44662. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44663. */
  44664. ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4;
  44665. /**
  44666. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  44667. * edge artifacts on steep falloff.
  44668. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44669. */
  44670. ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5;
  44671. /**
  44672. * Shadow generator mode PCF: Percentage Closer Filtering
  44673. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44674. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  44675. */
  44676. ShadowGenerator.FILTER_PCF = 6;
  44677. /**
  44678. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  44679. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44680. * Contact Hardening
  44681. */
  44682. ShadowGenerator.FILTER_PCSS = 7;
  44683. /**
  44684. * Reserved for PCF and PCSS
  44685. * Highest Quality.
  44686. *
  44687. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  44688. *
  44689. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  44690. */
  44691. ShadowGenerator.QUALITY_HIGH = 0;
  44692. /**
  44693. * Reserved for PCF and PCSS
  44694. * Good tradeoff for quality/perf cross devices
  44695. *
  44696. * Execute PCF on a 3*3 kernel.
  44697. *
  44698. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  44699. */
  44700. ShadowGenerator.QUALITY_MEDIUM = 1;
  44701. /**
  44702. * Reserved for PCF and PCSS
  44703. * The lowest quality but the fastest.
  44704. *
  44705. * Execute PCF on a 1*1 kernel.
  44706. *
  44707. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  44708. */
  44709. ShadowGenerator.QUALITY_LOW = 2;
  44710. /** @hidden */
  44711. ShadowGenerator._SceneComponentInitialization = function (_) {
  44712. throw "Import ShadowGeneratorSceneComponent before creating ShadowGenerator.";
  44713. };
  44714. return ShadowGenerator;
  44715. }());
  44716. /***/ }),
  44717. /***/ "./Lights/Shadows/shadowGeneratorSceneComponent.ts":
  44718. /*!*********************************************************!*\
  44719. !*** ./Lights/Shadows/shadowGeneratorSceneComponent.ts ***!
  44720. \*********************************************************/
  44721. /*! exports provided: ShadowGeneratorSceneComponent */
  44722. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44723. "use strict";
  44724. __webpack_require__.r(__webpack_exports__);
  44725. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return ShadowGeneratorSceneComponent; });
  44726. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  44727. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  44728. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  44729. // Adds the parser to the scene parsers.
  44730. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR, function (parsedData, scene) {
  44731. // Shadows
  44732. if (parsedData.shadowGenerators !== undefined && parsedData.shadowGenerators !== null) {
  44733. for (var index = 0, cache = parsedData.shadowGenerators.length; index < cache; index++) {
  44734. var parsedShadowGenerator = parsedData.shadowGenerators[index];
  44735. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"].Parse(parsedShadowGenerator, scene);
  44736. // SG would be available on their associated lights
  44737. }
  44738. }
  44739. });
  44740. /**
  44741. * Defines the shadow generator component responsible to manage any shadow generators
  44742. * in a given scene.
  44743. */
  44744. var ShadowGeneratorSceneComponent = /** @class */ (function () {
  44745. /**
  44746. * Creates a new instance of the component for the given scene
  44747. * @param scene Defines the scene to register the component in
  44748. */
  44749. function ShadowGeneratorSceneComponent(scene) {
  44750. /**
  44751. * The component name helpfull to identify the component in the list of scene components.
  44752. */
  44753. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR;
  44754. this.scene = scene;
  44755. }
  44756. /**
  44757. * Registers the component in a given scene
  44758. */
  44759. ShadowGeneratorSceneComponent.prototype.register = function () {
  44760. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets);
  44761. };
  44762. /**
  44763. * Rebuilds the elements related to this component in case of
  44764. * context lost for instance.
  44765. */
  44766. ShadowGeneratorSceneComponent.prototype.rebuild = function () {
  44767. // Nothing To Do Here.
  44768. };
  44769. /**
  44770. * Serializes the component data to the specified json object
  44771. * @param serializationObject The object to serialize to
  44772. */
  44773. ShadowGeneratorSceneComponent.prototype.serialize = function (serializationObject) {
  44774. // Shadows
  44775. serializationObject.shadowGenerators = [];
  44776. var lights = this.scene.lights;
  44777. for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
  44778. var light = lights_1[_i];
  44779. var shadowGenerator = light.getShadowGenerator();
  44780. if (shadowGenerator) {
  44781. serializationObject.shadowGenerators.push(shadowGenerator.serialize());
  44782. }
  44783. }
  44784. };
  44785. /**
  44786. * Adds all the element from the container to the scene
  44787. * @param container the container holding the elements
  44788. */
  44789. ShadowGeneratorSceneComponent.prototype.addFromContainer = function (container) {
  44790. // Nothing To Do Here. (directly attached to a light)
  44791. };
  44792. /**
  44793. * Removes all the elements in the container from the scene
  44794. * @param container contains the elements to remove
  44795. */
  44796. ShadowGeneratorSceneComponent.prototype.removeFromContainer = function (container) {
  44797. // Nothing To Do Here. (directly attached to a light)
  44798. };
  44799. /**
  44800. * Rebuilds the elements related to this component in case of
  44801. * context lost for instance.
  44802. */
  44803. ShadowGeneratorSceneComponent.prototype.dispose = function () {
  44804. // Nothing To Do Here.
  44805. };
  44806. ShadowGeneratorSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  44807. // Shadows
  44808. var scene = this.scene;
  44809. if (this.scene.shadowsEnabled) {
  44810. for (var lightIndex = 0; lightIndex < scene.lights.length; lightIndex++) {
  44811. var light = scene.lights[lightIndex];
  44812. var shadowGenerator = light.getShadowGenerator();
  44813. if (light.isEnabled() && light.shadowEnabled && shadowGenerator) {
  44814. var shadowMap = (shadowGenerator.getShadowMap());
  44815. if (scene.textures.indexOf(shadowMap) !== -1) {
  44816. renderTargets.push(shadowMap);
  44817. }
  44818. }
  44819. }
  44820. }
  44821. };
  44822. return ShadowGeneratorSceneComponent;
  44823. }());
  44824. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]._SceneComponentInitialization = function (scene) {
  44825. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR);
  44826. if (!component) {
  44827. component = new ShadowGeneratorSceneComponent(scene);
  44828. scene._addComponent(component);
  44829. }
  44830. };
  44831. /***/ }),
  44832. /***/ "./Lights/directionalLight.ts":
  44833. /*!************************************!*\
  44834. !*** ./Lights/directionalLight.ts ***!
  44835. \************************************/
  44836. /*! exports provided: DirectionalLight */
  44837. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44838. "use strict";
  44839. __webpack_require__.r(__webpack_exports__);
  44840. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return DirectionalLight; });
  44841. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  44842. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  44843. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  44844. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  44845. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  44846. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  44847. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_1", function (name, scene) {
  44848. return function () { return new DirectionalLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  44849. });
  44850. /**
  44851. * A directional light is defined by a direction (what a surprise!).
  44852. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44853. * 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.
  44854. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44855. */
  44856. var DirectionalLight = /** @class */ (function (_super) {
  44857. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DirectionalLight, _super);
  44858. /**
  44859. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44860. * The directional light is emitted from everywhere in the given direction.
  44861. * It can cast shadows.
  44862. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44863. * @param name The friendly name of the light
  44864. * @param direction The direction of the light
  44865. * @param scene The scene the light belongs to
  44866. */
  44867. function DirectionalLight(name, direction, scene) {
  44868. var _this = _super.call(this, name, scene) || this;
  44869. _this._shadowFrustumSize = 0;
  44870. _this._shadowOrthoScale = 0.1;
  44871. /**
  44872. * Automatically compute the projection matrix to best fit (including all the casters)
  44873. * on each frame.
  44874. */
  44875. _this.autoUpdateExtends = true;
  44876. // Cache
  44877. _this._orthoLeft = Number.MAX_VALUE;
  44878. _this._orthoRight = Number.MIN_VALUE;
  44879. _this._orthoTop = Number.MIN_VALUE;
  44880. _this._orthoBottom = Number.MAX_VALUE;
  44881. _this.position = direction.scale(-1.0);
  44882. _this.direction = direction;
  44883. return _this;
  44884. }
  44885. Object.defineProperty(DirectionalLight.prototype, "shadowFrustumSize", {
  44886. /**
  44887. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44888. */
  44889. get: function () {
  44890. return this._shadowFrustumSize;
  44891. },
  44892. /**
  44893. * Specifies a fix frustum size for the shadow generation.
  44894. */
  44895. set: function (value) {
  44896. this._shadowFrustumSize = value;
  44897. this.forceProjectionMatrixCompute();
  44898. },
  44899. enumerable: true,
  44900. configurable: true
  44901. });
  44902. Object.defineProperty(DirectionalLight.prototype, "shadowOrthoScale", {
  44903. /**
  44904. * Gets the shadow projection scale against the optimal computed one.
  44905. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44906. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44907. */
  44908. get: function () {
  44909. return this._shadowOrthoScale;
  44910. },
  44911. /**
  44912. * Sets the shadow projection scale against the optimal computed one.
  44913. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44914. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44915. */
  44916. set: function (value) {
  44917. this._shadowOrthoScale = value;
  44918. this.forceProjectionMatrixCompute();
  44919. },
  44920. enumerable: true,
  44921. configurable: true
  44922. });
  44923. /**
  44924. * Returns the string "DirectionalLight".
  44925. * @return The class name
  44926. */
  44927. DirectionalLight.prototype.getClassName = function () {
  44928. return "DirectionalLight";
  44929. };
  44930. /**
  44931. * Returns the integer 1.
  44932. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44933. */
  44934. DirectionalLight.prototype.getTypeID = function () {
  44935. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT;
  44936. };
  44937. /**
  44938. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44939. * Returns the DirectionalLight Shadow projection matrix.
  44940. */
  44941. DirectionalLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  44942. if (this.shadowFrustumSize > 0) {
  44943. this._setDefaultFixedFrustumShadowProjectionMatrix(matrix);
  44944. }
  44945. else {
  44946. this._setDefaultAutoExtendShadowProjectionMatrix(matrix, viewMatrix, renderList);
  44947. }
  44948. };
  44949. /**
  44950. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44951. * Returns the DirectionalLight Shadow projection matrix.
  44952. */
  44953. DirectionalLight.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function (matrix) {
  44954. var activeCamera = this.getScene().activeCamera;
  44955. if (!activeCamera) {
  44956. return;
  44957. }
  44958. _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);
  44959. };
  44960. /**
  44961. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44962. * Returns the DirectionalLight Shadow projection matrix.
  44963. */
  44964. DirectionalLight.prototype._setDefaultAutoExtendShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  44965. var activeCamera = this.getScene().activeCamera;
  44966. if (!activeCamera) {
  44967. return;
  44968. }
  44969. // Check extends
  44970. if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
  44971. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  44972. this._orthoLeft = Number.MAX_VALUE;
  44973. this._orthoRight = Number.MIN_VALUE;
  44974. this._orthoTop = Number.MIN_VALUE;
  44975. this._orthoBottom = Number.MAX_VALUE;
  44976. for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) {
  44977. var mesh = renderList[meshIndex];
  44978. if (!mesh) {
  44979. continue;
  44980. }
  44981. var boundingInfo = mesh.getBoundingInfo();
  44982. var boundingBox = boundingInfo.boundingBox;
  44983. for (var index = 0; index < boundingBox.vectorsWorld.length; index++) {
  44984. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(boundingBox.vectorsWorld[index], viewMatrix, tempVector3);
  44985. if (tempVector3.x < this._orthoLeft) {
  44986. this._orthoLeft = tempVector3.x;
  44987. }
  44988. if (tempVector3.y < this._orthoBottom) {
  44989. this._orthoBottom = tempVector3.y;
  44990. }
  44991. if (tempVector3.x > this._orthoRight) {
  44992. this._orthoRight = tempVector3.x;
  44993. }
  44994. if (tempVector3.y > this._orthoTop) {
  44995. this._orthoTop = tempVector3.y;
  44996. }
  44997. }
  44998. }
  44999. }
  45000. var xOffset = this._orthoRight - this._orthoLeft;
  45001. var yOffset = this._orthoTop - this._orthoBottom;
  45002. _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);
  45003. };
  45004. DirectionalLight.prototype._buildUniformLayout = function () {
  45005. this._uniformBuffer.addUniform("vLightData", 4);
  45006. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  45007. this._uniformBuffer.addUniform("vLightSpecular", 3);
  45008. this._uniformBuffer.addUniform("shadowsInfo", 3);
  45009. this._uniformBuffer.addUniform("depthValues", 2);
  45010. this._uniformBuffer.create();
  45011. };
  45012. /**
  45013. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45014. * @param effect The effect to update
  45015. * @param lightIndex The index of the light in the effect to update
  45016. * @returns The directional light
  45017. */
  45018. DirectionalLight.prototype.transferToEffect = function (effect, lightIndex) {
  45019. if (this.computeTransformedInformation()) {
  45020. this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, lightIndex);
  45021. return this;
  45022. }
  45023. this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, lightIndex);
  45024. return this;
  45025. };
  45026. /**
  45027. * Gets the minZ used for shadow according to both the scene and the light.
  45028. *
  45029. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45030. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45031. * @param activeCamera The camera we are returning the min for
  45032. * @returns the depth min z
  45033. */
  45034. DirectionalLight.prototype.getDepthMinZ = function (activeCamera) {
  45035. return 1;
  45036. };
  45037. /**
  45038. * Gets the maxZ used for shadow according to both the scene and the light.
  45039. *
  45040. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45041. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45042. * @param activeCamera The camera we are returning the max for
  45043. * @returns the depth max z
  45044. */
  45045. DirectionalLight.prototype.getDepthMaxZ = function (activeCamera) {
  45046. return 1;
  45047. };
  45048. /**
  45049. * Prepares the list of defines specific to the light type.
  45050. * @param defines the list of defines
  45051. * @param lightIndex defines the index of the light for the effect
  45052. */
  45053. DirectionalLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  45054. defines["DIRLIGHT" + lightIndex] = true;
  45055. };
  45056. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45057. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45058. ], DirectionalLight.prototype, "shadowFrustumSize", null);
  45059. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45060. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45061. ], DirectionalLight.prototype, "shadowOrthoScale", null);
  45062. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45063. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45064. ], DirectionalLight.prototype, "autoUpdateExtends", void 0);
  45065. return DirectionalLight;
  45066. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  45067. /***/ }),
  45068. /***/ "./Lights/hemisphericLight.ts":
  45069. /*!************************************!*\
  45070. !*** ./Lights/hemisphericLight.ts ***!
  45071. \************************************/
  45072. /*! exports provided: HemisphericLight */
  45073. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45074. "use strict";
  45075. __webpack_require__.r(__webpack_exports__);
  45076. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return HemisphericLight; });
  45077. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45078. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  45079. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  45080. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  45081. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  45082. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_3", function (name, scene) {
  45083. return function () { return new HemisphericLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  45084. });
  45085. /**
  45086. * The HemisphericLight simulates the ambient environment light,
  45087. * so the passed direction is the light reflection direction, not the incoming direction.
  45088. */
  45089. var HemisphericLight = /** @class */ (function (_super) {
  45090. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HemisphericLight, _super);
  45091. /**
  45092. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  45093. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  45094. * The HemisphericLight can't cast shadows.
  45095. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45096. * @param name The friendly name of the light
  45097. * @param direction The direction of the light reflection
  45098. * @param scene The scene the light belongs to
  45099. */
  45100. function HemisphericLight(name, direction, scene) {
  45101. var _this = _super.call(this, name, scene) || this;
  45102. /**
  45103. * The groundColor is the light in the opposite direction to the one specified during creation.
  45104. * 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.
  45105. */
  45106. _this.groundColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.0, 0.0, 0.0);
  45107. _this.direction = direction || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  45108. return _this;
  45109. }
  45110. HemisphericLight.prototype._buildUniformLayout = function () {
  45111. this._uniformBuffer.addUniform("vLightData", 4);
  45112. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  45113. this._uniformBuffer.addUniform("vLightSpecular", 3);
  45114. this._uniformBuffer.addUniform("vLightGround", 3);
  45115. this._uniformBuffer.addUniform("shadowsInfo", 3);
  45116. this._uniformBuffer.addUniform("depthValues", 2);
  45117. this._uniformBuffer.create();
  45118. };
  45119. /**
  45120. * Returns the string "HemisphericLight".
  45121. * @return The class name
  45122. */
  45123. HemisphericLight.prototype.getClassName = function () {
  45124. return "HemisphericLight";
  45125. };
  45126. /**
  45127. * Sets the HemisphericLight direction towards the passed target (Vector3).
  45128. * Returns the updated direction.
  45129. * @param target The target the direction should point to
  45130. * @return The computed direction
  45131. */
  45132. HemisphericLight.prototype.setDirectionToTarget = function (target) {
  45133. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero()));
  45134. return this.direction;
  45135. };
  45136. /**
  45137. * Returns the shadow generator associated to the light.
  45138. * @returns Always null for hemispheric lights because it does not support shadows.
  45139. */
  45140. HemisphericLight.prototype.getShadowGenerator = function () {
  45141. return null;
  45142. };
  45143. /**
  45144. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  45145. * @param effect The effect to update
  45146. * @param lightIndex The index of the light in the effect to update
  45147. * @returns The hemispheric light
  45148. */
  45149. HemisphericLight.prototype.transferToEffect = function (effect, lightIndex) {
  45150. var normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  45151. this._uniformBuffer.updateFloat4("vLightData", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0.0, lightIndex);
  45152. this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), lightIndex);
  45153. return this;
  45154. };
  45155. /**
  45156. * Computes the world matrix of the node
  45157. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  45158. * @param useWasUpdatedFlag defines a reserved property
  45159. * @returns the world matrix
  45160. */
  45161. HemisphericLight.prototype.computeWorldMatrix = function () {
  45162. if (!this._worldMatrix) {
  45163. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  45164. }
  45165. return this._worldMatrix;
  45166. };
  45167. /**
  45168. * Returns the integer 3.
  45169. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45170. */
  45171. HemisphericLight.prototype.getTypeID = function () {
  45172. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_HEMISPHERICLIGHT;
  45173. };
  45174. /**
  45175. * Prepares the list of defines specific to the light type.
  45176. * @param defines the list of defines
  45177. * @param lightIndex defines the index of the light for the effect
  45178. */
  45179. HemisphericLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  45180. defines["HEMILIGHT" + lightIndex] = true;
  45181. };
  45182. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45183. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  45184. ], HemisphericLight.prototype, "groundColor", void 0);
  45185. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45186. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  45187. ], HemisphericLight.prototype, "direction", void 0);
  45188. return HemisphericLight;
  45189. }(_light__WEBPACK_IMPORTED_MODULE_4__["Light"]));
  45190. /***/ }),
  45191. /***/ "./Lights/index.ts":
  45192. /*!*************************!*\
  45193. !*** ./Lights/index.ts ***!
  45194. \*************************/
  45195. /*! exports provided: Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, ShadowGenerator, ShadowGeneratorSceneComponent */
  45196. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45197. "use strict";
  45198. __webpack_require__.r(__webpack_exports__);
  45199. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  45200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _light__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  45201. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  45202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _shadowLight__WEBPACK_IMPORTED_MODULE_1__["ShadowLight"]; });
  45203. /* harmony import */ var _Shadows_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Shadows/index */ "./Lights/Shadows/index.ts");
  45204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGenerator"]; });
  45205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGeneratorSceneComponent"]; });
  45206. /* harmony import */ var _directionalLight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./directionalLight */ "./Lights/directionalLight.ts");
  45207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _directionalLight__WEBPACK_IMPORTED_MODULE_3__["DirectionalLight"]; });
  45208. /* harmony import */ var _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphericLight */ "./Lights/hemisphericLight.ts");
  45209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]; });
  45210. /* harmony import */ var _pointLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pointLight */ "./Lights/pointLight.ts");
  45211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _pointLight__WEBPACK_IMPORTED_MODULE_5__["PointLight"]; });
  45212. /* harmony import */ var _spotLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./spotLight */ "./Lights/spotLight.ts");
  45213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _spotLight__WEBPACK_IMPORTED_MODULE_6__["SpotLight"]; });
  45214. /***/ }),
  45215. /***/ "./Lights/light.ts":
  45216. /*!*************************!*\
  45217. !*** ./Lights/light.ts ***!
  45218. \*************************/
  45219. /*! exports provided: Light */
  45220. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45221. "use strict";
  45222. __webpack_require__.r(__webpack_exports__);
  45223. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return Light; });
  45224. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45225. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  45226. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  45227. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  45228. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  45229. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  45230. /**
  45231. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  45232. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  45233. * 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.
  45234. */
  45235. var Light = /** @class */ (function (_super) {
  45236. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Light, _super);
  45237. /**
  45238. * Creates a Light object in the scene.
  45239. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45240. * @param name The firendly name of the light
  45241. * @param scene The scene the light belongs too
  45242. */
  45243. function Light(name, scene) {
  45244. var _this = _super.call(this, name, scene) || this;
  45245. /**
  45246. * Diffuse gives the basic color to an object.
  45247. */
  45248. _this.diffuse = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  45249. /**
  45250. * Specular produces a highlight color on an object.
  45251. * Note: This is note affecting PBR materials.
  45252. */
  45253. _this.specular = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  45254. /**
  45255. * Defines the falloff type for this light. This lets overrriding how punctual light are
  45256. * falling off base on range or angle.
  45257. * This can be set to any values in Light.FALLOFF_x.
  45258. *
  45259. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  45260. * other types of materials.
  45261. */
  45262. _this.falloffType = Light.FALLOFF_DEFAULT;
  45263. /**
  45264. * Strength of the light.
  45265. * Note: By default it is define in the framework own unit.
  45266. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  45267. */
  45268. _this.intensity = 1.0;
  45269. _this._range = Number.MAX_VALUE;
  45270. _this._inverseSquaredRange = 0;
  45271. /**
  45272. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  45273. * of light.
  45274. */
  45275. _this._photometricScale = 1.0;
  45276. _this._intensityMode = Light.INTENSITYMODE_AUTOMATIC;
  45277. _this._radius = 0.00001;
  45278. /**
  45279. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  45280. * exceeding the number allowed of the materials.
  45281. */
  45282. _this.renderPriority = 0;
  45283. _this._shadowEnabled = true;
  45284. _this._excludeWithLayerMask = 0;
  45285. _this._includeOnlyWithLayerMask = 0;
  45286. _this._lightmapMode = 0;
  45287. /**
  45288. * @hidden Internal use only.
  45289. */
  45290. _this._excludedMeshesIds = new Array();
  45291. /**
  45292. * @hidden Internal use only.
  45293. */
  45294. _this._includedOnlyMeshesIds = new Array();
  45295. /** @hidden */
  45296. _this._isLight = true;
  45297. _this.getScene().addLight(_this);
  45298. _this._uniformBuffer = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__["UniformBuffer"](_this.getScene().getEngine());
  45299. _this._buildUniformLayout();
  45300. _this.includedOnlyMeshes = new Array();
  45301. _this.excludedMeshes = new Array();
  45302. _this._resyncMeshes();
  45303. return _this;
  45304. }
  45305. Object.defineProperty(Light.prototype, "range", {
  45306. /**
  45307. * Defines how far from the source the light is impacting in scene units.
  45308. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  45309. */
  45310. get: function () {
  45311. return this._range;
  45312. },
  45313. /**
  45314. * Defines how far from the source the light is impacting in scene units.
  45315. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  45316. */
  45317. set: function (value) {
  45318. this._range = value;
  45319. this._inverseSquaredRange = 1.0 / (this.range * this.range);
  45320. },
  45321. enumerable: true,
  45322. configurable: true
  45323. });
  45324. Object.defineProperty(Light.prototype, "intensityMode", {
  45325. /**
  45326. * Gets the photometric scale used to interpret the intensity.
  45327. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  45328. */
  45329. get: function () {
  45330. return this._intensityMode;
  45331. },
  45332. /**
  45333. * Sets the photometric scale used to interpret the intensity.
  45334. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  45335. */
  45336. set: function (value) {
  45337. this._intensityMode = value;
  45338. this._computePhotometricScale();
  45339. },
  45340. enumerable: true,
  45341. configurable: true
  45342. });
  45343. Object.defineProperty(Light.prototype, "radius", {
  45344. /**
  45345. * Gets the light radius used by PBR Materials to simulate soft area lights.
  45346. */
  45347. get: function () {
  45348. return this._radius;
  45349. },
  45350. /**
  45351. * sets the light radius used by PBR Materials to simulate soft area lights.
  45352. */
  45353. set: function (value) {
  45354. this._radius = value;
  45355. this._computePhotometricScale();
  45356. },
  45357. enumerable: true,
  45358. configurable: true
  45359. });
  45360. Object.defineProperty(Light.prototype, "shadowEnabled", {
  45361. /**
  45362. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  45363. * the current shadow generator.
  45364. */
  45365. get: function () {
  45366. return this._shadowEnabled;
  45367. },
  45368. /**
  45369. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  45370. * the current shadow generator.
  45371. */
  45372. set: function (value) {
  45373. if (this._shadowEnabled === value) {
  45374. return;
  45375. }
  45376. this._shadowEnabled = value;
  45377. this._markMeshesAsLightDirty();
  45378. },
  45379. enumerable: true,
  45380. configurable: true
  45381. });
  45382. Object.defineProperty(Light.prototype, "includedOnlyMeshes", {
  45383. /**
  45384. * Gets the only meshes impacted by this light.
  45385. */
  45386. get: function () {
  45387. return this._includedOnlyMeshes;
  45388. },
  45389. /**
  45390. * Sets the only meshes impacted by this light.
  45391. */
  45392. set: function (value) {
  45393. this._includedOnlyMeshes = value;
  45394. this._hookArrayForIncludedOnly(value);
  45395. },
  45396. enumerable: true,
  45397. configurable: true
  45398. });
  45399. Object.defineProperty(Light.prototype, "excludedMeshes", {
  45400. /**
  45401. * Gets the meshes not impacted by this light.
  45402. */
  45403. get: function () {
  45404. return this._excludedMeshes;
  45405. },
  45406. /**
  45407. * Sets the meshes not impacted by this light.
  45408. */
  45409. set: function (value) {
  45410. this._excludedMeshes = value;
  45411. this._hookArrayForExcluded(value);
  45412. },
  45413. enumerable: true,
  45414. configurable: true
  45415. });
  45416. Object.defineProperty(Light.prototype, "excludeWithLayerMask", {
  45417. /**
  45418. * Gets the layer id use to find what meshes are not impacted by the light.
  45419. * Inactive if 0
  45420. */
  45421. get: function () {
  45422. return this._excludeWithLayerMask;
  45423. },
  45424. /**
  45425. * Sets the layer id use to find what meshes are not impacted by the light.
  45426. * Inactive if 0
  45427. */
  45428. set: function (value) {
  45429. this._excludeWithLayerMask = value;
  45430. this._resyncMeshes();
  45431. },
  45432. enumerable: true,
  45433. configurable: true
  45434. });
  45435. Object.defineProperty(Light.prototype, "includeOnlyWithLayerMask", {
  45436. /**
  45437. * Gets the layer id use to find what meshes are impacted by the light.
  45438. * Inactive if 0
  45439. */
  45440. get: function () {
  45441. return this._includeOnlyWithLayerMask;
  45442. },
  45443. /**
  45444. * Sets the layer id use to find what meshes are impacted by the light.
  45445. * Inactive if 0
  45446. */
  45447. set: function (value) {
  45448. this._includeOnlyWithLayerMask = value;
  45449. this._resyncMeshes();
  45450. },
  45451. enumerable: true,
  45452. configurable: true
  45453. });
  45454. Object.defineProperty(Light.prototype, "lightmapMode", {
  45455. /**
  45456. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  45457. */
  45458. get: function () {
  45459. return this._lightmapMode;
  45460. },
  45461. /**
  45462. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  45463. */
  45464. set: function (value) {
  45465. if (this._lightmapMode === value) {
  45466. return;
  45467. }
  45468. this._lightmapMode = value;
  45469. this._markMeshesAsLightDirty();
  45470. },
  45471. enumerable: true,
  45472. configurable: true
  45473. });
  45474. /**
  45475. * Returns the string "Light".
  45476. * @returns the class name
  45477. */
  45478. Light.prototype.getClassName = function () {
  45479. return "Light";
  45480. };
  45481. /**
  45482. * Converts the light information to a readable string for debug purpose.
  45483. * @param fullDetails Supports for multiple levels of logging within scene loading
  45484. * @returns the human readable light info
  45485. */
  45486. Light.prototype.toString = function (fullDetails) {
  45487. var ret = "Name: " + this.name;
  45488. ret += ", type: " + (["Point", "Directional", "Spot", "Hemispheric"])[this.getTypeID()];
  45489. if (this.animations) {
  45490. for (var i = 0; i < this.animations.length; i++) {
  45491. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  45492. }
  45493. }
  45494. if (fullDetails) {
  45495. }
  45496. return ret;
  45497. };
  45498. /** @hidden */
  45499. Light.prototype._syncParentEnabledState = function () {
  45500. _super.prototype._syncParentEnabledState.call(this);
  45501. this._resyncMeshes();
  45502. };
  45503. /**
  45504. * Set the enabled state of this node.
  45505. * @param value - the new enabled state
  45506. */
  45507. Light.prototype.setEnabled = function (value) {
  45508. _super.prototype.setEnabled.call(this, value);
  45509. this._resyncMeshes();
  45510. };
  45511. /**
  45512. * Returns the Light associated shadow generator if any.
  45513. * @return the associated shadow generator.
  45514. */
  45515. Light.prototype.getShadowGenerator = function () {
  45516. return this._shadowGenerator;
  45517. };
  45518. /**
  45519. * Returns a Vector3, the absolute light position in the World.
  45520. * @returns the world space position of the light
  45521. */
  45522. Light.prototype.getAbsolutePosition = function () {
  45523. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  45524. };
  45525. /**
  45526. * Specifies if the light will affect the passed mesh.
  45527. * @param mesh The mesh to test against the light
  45528. * @return true the mesh is affected otherwise, false.
  45529. */
  45530. Light.prototype.canAffectMesh = function (mesh) {
  45531. if (!mesh) {
  45532. return true;
  45533. }
  45534. if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
  45535. return false;
  45536. }
  45537. if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  45538. return false;
  45539. }
  45540. if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {
  45541. return false;
  45542. }
  45543. if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {
  45544. return false;
  45545. }
  45546. return true;
  45547. };
  45548. /**
  45549. * Sort function to order lights for rendering.
  45550. * @param a First Light object to compare to second.
  45551. * @param b Second Light object to compare first.
  45552. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  45553. */
  45554. Light.CompareLightsPriority = function (a, b) {
  45555. //shadow-casting lights have priority over non-shadow-casting lights
  45556. //the renderPrioirty is a secondary sort criterion
  45557. if (a.shadowEnabled !== b.shadowEnabled) {
  45558. return (b.shadowEnabled ? 1 : 0) - (a.shadowEnabled ? 1 : 0);
  45559. }
  45560. return b.renderPriority - a.renderPriority;
  45561. };
  45562. /**
  45563. * Releases resources associated with this node.
  45564. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45565. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45566. */
  45567. Light.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  45568. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  45569. if (this._shadowGenerator) {
  45570. this._shadowGenerator.dispose();
  45571. this._shadowGenerator = null;
  45572. }
  45573. // Animations
  45574. this.getScene().stopAnimation(this);
  45575. // Remove from meshes
  45576. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  45577. var mesh = _a[_i];
  45578. mesh._removeLightSource(this);
  45579. }
  45580. this._uniformBuffer.dispose();
  45581. // Remove from scene
  45582. this.getScene().removeLight(this);
  45583. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  45584. };
  45585. /**
  45586. * Returns the light type ID (integer).
  45587. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45588. */
  45589. Light.prototype.getTypeID = function () {
  45590. return 0;
  45591. };
  45592. /**
  45593. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  45594. * @returns the scaled intensity in intensity mode unit
  45595. */
  45596. Light.prototype.getScaledIntensity = function () {
  45597. return this._photometricScale * this.intensity;
  45598. };
  45599. /**
  45600. * Returns a new Light object, named "name", from the current one.
  45601. * @param name The name of the cloned light
  45602. * @returns the new created light
  45603. */
  45604. Light.prototype.clone = function (name) {
  45605. var constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());
  45606. if (!constructor) {
  45607. return null;
  45608. }
  45609. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(constructor, this);
  45610. };
  45611. /**
  45612. * Serializes the current light into a Serialization object.
  45613. * @returns the serialized object.
  45614. */
  45615. Light.prototype.serialize = function () {
  45616. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  45617. // Type
  45618. serializationObject.type = this.getTypeID();
  45619. // Parent
  45620. if (this.parent) {
  45621. serializationObject.parentId = this.parent.id;
  45622. }
  45623. // Inclusion / exclusions
  45624. if (this.excludedMeshes.length > 0) {
  45625. serializationObject.excludedMeshesIds = [];
  45626. this.excludedMeshes.forEach(function (mesh) {
  45627. serializationObject.excludedMeshesIds.push(mesh.id);
  45628. });
  45629. }
  45630. if (this.includedOnlyMeshes.length > 0) {
  45631. serializationObject.includedOnlyMeshesIds = [];
  45632. this.includedOnlyMeshes.forEach(function (mesh) {
  45633. serializationObject.includedOnlyMeshesIds.push(mesh.id);
  45634. });
  45635. }
  45636. // Animations
  45637. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  45638. serializationObject.ranges = this.serializeAnimationRanges();
  45639. return serializationObject;
  45640. };
  45641. /**
  45642. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  45643. * This new light is named "name" and added to the passed scene.
  45644. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  45645. * @param name The friendly name of the light
  45646. * @param scene The scene the new light will belong to
  45647. * @returns the constructor function
  45648. */
  45649. Light.GetConstructorFromName = function (type, name, scene) {
  45650. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_3__["Node"].Construct("Light_Type_" + type, name, scene);
  45651. if (constructorFunc) {
  45652. return constructorFunc;
  45653. }
  45654. // Default to no light for none present once.
  45655. return null;
  45656. };
  45657. /**
  45658. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  45659. * @param parsedLight The JSON representation of the light
  45660. * @param scene The scene to create the parsed light in
  45661. * @returns the created light after parsing
  45662. */
  45663. Light.Parse = function (parsedLight, scene) {
  45664. var constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);
  45665. if (!constructor) {
  45666. return null;
  45667. }
  45668. var light = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(constructor, parsedLight, scene);
  45669. // Inclusion / exclusions
  45670. if (parsedLight.excludedMeshesIds) {
  45671. light._excludedMeshesIds = parsedLight.excludedMeshesIds;
  45672. }
  45673. if (parsedLight.includedOnlyMeshesIds) {
  45674. light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
  45675. }
  45676. // Parent
  45677. if (parsedLight.parentId) {
  45678. light._waitingParentId = parsedLight.parentId;
  45679. }
  45680. // Animations
  45681. if (parsedLight.animations) {
  45682. for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
  45683. var parsedAnimation = parsedLight.animations[animationIndex];
  45684. light.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].Parse(parsedAnimation));
  45685. }
  45686. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].ParseAnimationRanges(light, parsedLight, scene);
  45687. }
  45688. if (parsedLight.autoAnimate) {
  45689. scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);
  45690. }
  45691. return light;
  45692. };
  45693. Light.prototype._hookArrayForExcluded = function (array) {
  45694. var _this = this;
  45695. var oldPush = array.push;
  45696. array.push = function () {
  45697. var items = [];
  45698. for (var _i = 0; _i < arguments.length; _i++) {
  45699. items[_i] = arguments[_i];
  45700. }
  45701. var result = oldPush.apply(array, items);
  45702. for (var _a = 0, items_1 = items; _a < items_1.length; _a++) {
  45703. var item = items_1[_a];
  45704. item._resyncLighSource(_this);
  45705. }
  45706. return result;
  45707. };
  45708. var oldSplice = array.splice;
  45709. array.splice = function (index, deleteCount) {
  45710. var deleted = oldSplice.apply(array, [index, deleteCount]);
  45711. for (var _i = 0, deleted_1 = deleted; _i < deleted_1.length; _i++) {
  45712. var item = deleted_1[_i];
  45713. item._resyncLighSource(_this);
  45714. }
  45715. return deleted;
  45716. };
  45717. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  45718. var item = array_1[_i];
  45719. item._resyncLighSource(this);
  45720. }
  45721. };
  45722. Light.prototype._hookArrayForIncludedOnly = function (array) {
  45723. var _this = this;
  45724. var oldPush = array.push;
  45725. array.push = function () {
  45726. var items = [];
  45727. for (var _i = 0; _i < arguments.length; _i++) {
  45728. items[_i] = arguments[_i];
  45729. }
  45730. var result = oldPush.apply(array, items);
  45731. _this._resyncMeshes();
  45732. return result;
  45733. };
  45734. var oldSplice = array.splice;
  45735. array.splice = function (index, deleteCount) {
  45736. var deleted = oldSplice.apply(array, [index, deleteCount]);
  45737. _this._resyncMeshes();
  45738. return deleted;
  45739. };
  45740. this._resyncMeshes();
  45741. };
  45742. Light.prototype._resyncMeshes = function () {
  45743. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  45744. var mesh = _a[_i];
  45745. mesh._resyncLighSource(this);
  45746. }
  45747. };
  45748. /**
  45749. * Forces the meshes to update their light related information in their rendering used effects
  45750. * @hidden Internal Use Only
  45751. */
  45752. Light.prototype._markMeshesAsLightDirty = function () {
  45753. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  45754. var mesh = _a[_i];
  45755. if (mesh._lightSources.indexOf(this) !== -1) {
  45756. mesh._markSubMeshesAsLightDirty();
  45757. }
  45758. }
  45759. };
  45760. /**
  45761. * Recomputes the cached photometric scale if needed.
  45762. */
  45763. Light.prototype._computePhotometricScale = function () {
  45764. this._photometricScale = this._getPhotometricScale();
  45765. this.getScene().resetCachedMaterial();
  45766. };
  45767. /**
  45768. * Returns the Photometric Scale according to the light type and intensity mode.
  45769. */
  45770. Light.prototype._getPhotometricScale = function () {
  45771. var photometricScale = 0.0;
  45772. var lightTypeID = this.getTypeID();
  45773. //get photometric mode
  45774. var photometricMode = this.intensityMode;
  45775. if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {
  45776. if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {
  45777. photometricMode = Light.INTENSITYMODE_ILLUMINANCE;
  45778. }
  45779. else {
  45780. photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;
  45781. }
  45782. }
  45783. //compute photometric scale
  45784. switch (lightTypeID) {
  45785. case Light.LIGHTTYPEID_POINTLIGHT:
  45786. case Light.LIGHTTYPEID_SPOTLIGHT:
  45787. switch (photometricMode) {
  45788. case Light.INTENSITYMODE_LUMINOUSPOWER:
  45789. photometricScale = 1.0 / (4.0 * Math.PI);
  45790. break;
  45791. case Light.INTENSITYMODE_LUMINOUSINTENSITY:
  45792. photometricScale = 1.0;
  45793. break;
  45794. case Light.INTENSITYMODE_LUMINANCE:
  45795. photometricScale = this.radius * this.radius;
  45796. break;
  45797. }
  45798. break;
  45799. case Light.LIGHTTYPEID_DIRECTIONALLIGHT:
  45800. switch (photometricMode) {
  45801. case Light.INTENSITYMODE_ILLUMINANCE:
  45802. photometricScale = 1.0;
  45803. break;
  45804. case Light.INTENSITYMODE_LUMINANCE:
  45805. // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.
  45806. // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).
  45807. var apexAngleRadians = this.radius;
  45808. // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).
  45809. apexAngleRadians = Math.max(apexAngleRadians, 0.001);
  45810. var solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));
  45811. photometricScale = solidAngle;
  45812. break;
  45813. }
  45814. break;
  45815. case Light.LIGHTTYPEID_HEMISPHERICLIGHT:
  45816. // No fall off in hemisperic light.
  45817. photometricScale = 1.0;
  45818. break;
  45819. }
  45820. return photometricScale;
  45821. };
  45822. /**
  45823. * Reorder the light in the scene according to their defined priority.
  45824. * @hidden Internal Use Only
  45825. */
  45826. Light.prototype._reorderLightsInScene = function () {
  45827. var scene = this.getScene();
  45828. if (this._renderPriority != 0) {
  45829. scene.requireLightSorting = true;
  45830. }
  45831. this.getScene().sortLightsByPriority();
  45832. };
  45833. /**
  45834. * Falloff Default: light is falling off following the material specification:
  45835. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  45836. */
  45837. Light.FALLOFF_DEFAULT = 0;
  45838. /**
  45839. * Falloff Physical: light is falling off following the inverse squared distance law.
  45840. */
  45841. Light.FALLOFF_PHYSICAL = 1;
  45842. /**
  45843. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  45844. * to enhance interoperability with other engines.
  45845. */
  45846. Light.FALLOFF_GLTF = 2;
  45847. /**
  45848. * Falloff Standard: light is falling off like in the standard material
  45849. * to enhance interoperability with other materials.
  45850. */
  45851. Light.FALLOFF_STANDARD = 3;
  45852. //lightmapMode Consts
  45853. /**
  45854. * If every light affecting the material is in this lightmapMode,
  45855. * material.lightmapTexture adds or multiplies
  45856. * (depends on material.useLightmapAsShadowmap)
  45857. * after every other light calculations.
  45858. */
  45859. Light.LIGHTMAP_DEFAULT = 0;
  45860. /**
  45861. * material.lightmapTexture as only diffuse lighting from this light
  45862. * adds only specular lighting from this light
  45863. * adds dynamic shadows
  45864. */
  45865. Light.LIGHTMAP_SPECULAR = 1;
  45866. /**
  45867. * material.lightmapTexture as only lighting
  45868. * no light calculation from this light
  45869. * only adds dynamic shadows from this light
  45870. */
  45871. Light.LIGHTMAP_SHADOWSONLY = 2;
  45872. // Intensity Mode Consts
  45873. /**
  45874. * Each light type uses the default quantity according to its type:
  45875. * point/spot lights use luminous intensity
  45876. * directional lights use illuminance
  45877. */
  45878. Light.INTENSITYMODE_AUTOMATIC = 0;
  45879. /**
  45880. * lumen (lm)
  45881. */
  45882. Light.INTENSITYMODE_LUMINOUSPOWER = 1;
  45883. /**
  45884. * candela (lm/sr)
  45885. */
  45886. Light.INTENSITYMODE_LUMINOUSINTENSITY = 2;
  45887. /**
  45888. * lux (lm/m^2)
  45889. */
  45890. Light.INTENSITYMODE_ILLUMINANCE = 3;
  45891. /**
  45892. * nit (cd/m^2)
  45893. */
  45894. Light.INTENSITYMODE_LUMINANCE = 4;
  45895. // Light types ids const.
  45896. /**
  45897. * Light type const id of the point light.
  45898. */
  45899. Light.LIGHTTYPEID_POINTLIGHT = 0;
  45900. /**
  45901. * Light type const id of the directional light.
  45902. */
  45903. Light.LIGHTTYPEID_DIRECTIONALLIGHT = 1;
  45904. /**
  45905. * Light type const id of the spot light.
  45906. */
  45907. Light.LIGHTTYPEID_SPOTLIGHT = 2;
  45908. /**
  45909. * Light type const id of the hemispheric light.
  45910. */
  45911. Light.LIGHTTYPEID_HEMISPHERICLIGHT = 3;
  45912. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45913. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  45914. ], Light.prototype, "diffuse", void 0);
  45915. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45916. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  45917. ], Light.prototype, "specular", void 0);
  45918. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45919. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45920. ], Light.prototype, "falloffType", void 0);
  45921. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45922. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45923. ], Light.prototype, "intensity", void 0);
  45924. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45925. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45926. ], Light.prototype, "range", null);
  45927. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45928. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45929. ], Light.prototype, "intensityMode", null);
  45930. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45931. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45932. ], Light.prototype, "radius", null);
  45933. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45934. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45935. ], Light.prototype, "_renderPriority", void 0);
  45936. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45937. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_reorderLightsInScene")
  45938. ], Light.prototype, "renderPriority", void 0);
  45939. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45940. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("shadowEnabled")
  45941. ], Light.prototype, "_shadowEnabled", void 0);
  45942. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45943. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("excludeWithLayerMask")
  45944. ], Light.prototype, "_excludeWithLayerMask", void 0);
  45945. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45946. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("includeOnlyWithLayerMask")
  45947. ], Light.prototype, "_includeOnlyWithLayerMask", void 0);
  45948. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45949. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("lightmapMode")
  45950. ], Light.prototype, "_lightmapMode", void 0);
  45951. return Light;
  45952. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  45953. /***/ }),
  45954. /***/ "./Lights/pointLight.ts":
  45955. /*!******************************!*\
  45956. !*** ./Lights/pointLight.ts ***!
  45957. \******************************/
  45958. /*! exports provided: PointLight */
  45959. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45960. "use strict";
  45961. __webpack_require__.r(__webpack_exports__);
  45962. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return PointLight; });
  45963. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45964. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  45965. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  45966. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  45967. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  45968. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  45969. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_0", function (name, scene) {
  45970. return function () { return new PointLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  45971. });
  45972. /**
  45973. * A point light is a light defined by an unique point in world space.
  45974. * The light is emitted in every direction from this point.
  45975. * A good example of a point light is a standard light bulb.
  45976. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45977. */
  45978. var PointLight = /** @class */ (function (_super) {
  45979. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointLight, _super);
  45980. /**
  45981. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  45982. * A PointLight emits the light in every direction.
  45983. * It can cast shadows.
  45984. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  45985. * ```javascript
  45986. * var pointLight = new PointLight("pl", camera.position, scene);
  45987. * ```
  45988. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45989. * @param name The light friendly name
  45990. * @param position The position of the point light in the scene
  45991. * @param scene The scene the lights belongs to
  45992. */
  45993. function PointLight(name, position, scene) {
  45994. var _this = _super.call(this, name, scene) || this;
  45995. _this._shadowAngle = Math.PI / 2;
  45996. _this.position = position;
  45997. return _this;
  45998. }
  45999. Object.defineProperty(PointLight.prototype, "shadowAngle", {
  46000. /**
  46001. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46002. * This specifies what angle the shadow will use to be created.
  46003. *
  46004. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46005. */
  46006. get: function () {
  46007. return this._shadowAngle;
  46008. },
  46009. /**
  46010. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46011. * This specifies what angle the shadow will use to be created.
  46012. *
  46013. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46014. */
  46015. set: function (value) {
  46016. this._shadowAngle = value;
  46017. this.forceProjectionMatrixCompute();
  46018. },
  46019. enumerable: true,
  46020. configurable: true
  46021. });
  46022. Object.defineProperty(PointLight.prototype, "direction", {
  46023. /**
  46024. * Gets the direction if it has been set.
  46025. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46026. */
  46027. get: function () {
  46028. return this._direction;
  46029. },
  46030. /**
  46031. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46032. */
  46033. set: function (value) {
  46034. var previousNeedCube = this.needCube();
  46035. this._direction = value;
  46036. if (this.needCube() !== previousNeedCube && this._shadowGenerator) {
  46037. this._shadowGenerator.recreateShadowMap();
  46038. }
  46039. },
  46040. enumerable: true,
  46041. configurable: true
  46042. });
  46043. /**
  46044. * Returns the string "PointLight"
  46045. * @returns the class name
  46046. */
  46047. PointLight.prototype.getClassName = function () {
  46048. return "PointLight";
  46049. };
  46050. /**
  46051. * Returns the integer 0.
  46052. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46053. */
  46054. PointLight.prototype.getTypeID = function () {
  46055. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_POINTLIGHT;
  46056. };
  46057. /**
  46058. * Specifies wether or not the shadowmap should be a cube texture.
  46059. * @returns true if the shadowmap needs to be a cube texture.
  46060. */
  46061. PointLight.prototype.needCube = function () {
  46062. return !this.direction;
  46063. };
  46064. /**
  46065. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  46066. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46067. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46068. */
  46069. PointLight.prototype.getShadowDirection = function (faceIndex) {
  46070. if (this.direction) {
  46071. return _super.prototype.getShadowDirection.call(this, faceIndex);
  46072. }
  46073. else {
  46074. switch (faceIndex) {
  46075. case 0:
  46076. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1.0, 0.0, 0.0);
  46077. case 1:
  46078. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](-1.0, 0.0, 0.0);
  46079. case 2:
  46080. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, -1.0, 0.0);
  46081. case 3:
  46082. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 1.0, 0.0);
  46083. case 4:
  46084. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, 1.0);
  46085. case 5:
  46086. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, -1.0);
  46087. }
  46088. }
  46089. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46090. };
  46091. /**
  46092. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  46093. * - fov = PI / 2
  46094. * - aspect ratio : 1.0
  46095. * - z-near and far equal to the active camera minZ and maxZ.
  46096. * Returns the PointLight.
  46097. */
  46098. PointLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  46099. var activeCamera = this.getScene().activeCamera;
  46100. if (!activeCamera) {
  46101. return;
  46102. }
  46103. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(this.shadowAngle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  46104. };
  46105. PointLight.prototype._buildUniformLayout = function () {
  46106. this._uniformBuffer.addUniform("vLightData", 4);
  46107. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  46108. this._uniformBuffer.addUniform("vLightSpecular", 3);
  46109. this._uniformBuffer.addUniform("vLightFalloff", 4);
  46110. this._uniformBuffer.addUniform("shadowsInfo", 3);
  46111. this._uniformBuffer.addUniform("depthValues", 2);
  46112. this._uniformBuffer.create();
  46113. };
  46114. /**
  46115. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  46116. * @param effect The effect to update
  46117. * @param lightIndex The index of the light in the effect to update
  46118. * @returns The point light
  46119. */
  46120. PointLight.prototype.transferToEffect = function (effect, lightIndex) {
  46121. if (this.computeTransformedInformation()) {
  46122. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0.0, lightIndex);
  46123. }
  46124. else {
  46125. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, lightIndex);
  46126. }
  46127. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, lightIndex);
  46128. return this;
  46129. };
  46130. /**
  46131. * Prepares the list of defines specific to the light type.
  46132. * @param defines the list of defines
  46133. * @param lightIndex defines the index of the light for the effect
  46134. */
  46135. PointLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  46136. defines["POINTLIGHT" + lightIndex] = true;
  46137. };
  46138. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46139. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46140. ], PointLight.prototype, "shadowAngle", null);
  46141. return PointLight;
  46142. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  46143. /***/ }),
  46144. /***/ "./Lights/shadowLight.ts":
  46145. /*!*******************************!*\
  46146. !*** ./Lights/shadowLight.ts ***!
  46147. \*******************************/
  46148. /*! exports provided: ShadowLight */
  46149. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46150. "use strict";
  46151. __webpack_require__.r(__webpack_exports__);
  46152. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return ShadowLight; });
  46153. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46154. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46155. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46156. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46157. /**
  46158. * Base implementation IShadowLight
  46159. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  46160. */
  46161. var ShadowLight = /** @class */ (function (_super) {
  46162. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowLight, _super);
  46163. function ShadowLight() {
  46164. var _this = _super !== null && _super.apply(this, arguments) || this;
  46165. _this._needProjectionMatrixCompute = true;
  46166. return _this;
  46167. }
  46168. ShadowLight.prototype._setPosition = function (value) {
  46169. this._position = value;
  46170. };
  46171. Object.defineProperty(ShadowLight.prototype, "position", {
  46172. /**
  46173. * Sets the position the shadow will be casted from. Also use as the light position for both
  46174. * point and spot lights.
  46175. */
  46176. get: function () {
  46177. return this._position;
  46178. },
  46179. /**
  46180. * Sets the position the shadow will be casted from. Also use as the light position for both
  46181. * point and spot lights.
  46182. */
  46183. set: function (value) {
  46184. this._setPosition(value);
  46185. },
  46186. enumerable: true,
  46187. configurable: true
  46188. });
  46189. ShadowLight.prototype._setDirection = function (value) {
  46190. this._direction = value;
  46191. };
  46192. Object.defineProperty(ShadowLight.prototype, "direction", {
  46193. /**
  46194. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  46195. * Also use as the light direction on spot and directional lights.
  46196. */
  46197. get: function () {
  46198. return this._direction;
  46199. },
  46200. /**
  46201. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  46202. * Also use as the light direction on spot and directional lights.
  46203. */
  46204. set: function (value) {
  46205. this._setDirection(value);
  46206. },
  46207. enumerable: true,
  46208. configurable: true
  46209. });
  46210. Object.defineProperty(ShadowLight.prototype, "shadowMinZ", {
  46211. /**
  46212. * Gets the shadow projection clipping minimum z value.
  46213. */
  46214. get: function () {
  46215. return this._shadowMinZ;
  46216. },
  46217. /**
  46218. * Sets the shadow projection clipping minimum z value.
  46219. */
  46220. set: function (value) {
  46221. this._shadowMinZ = value;
  46222. this.forceProjectionMatrixCompute();
  46223. },
  46224. enumerable: true,
  46225. configurable: true
  46226. });
  46227. Object.defineProperty(ShadowLight.prototype, "shadowMaxZ", {
  46228. /**
  46229. * Sets the shadow projection clipping maximum z value.
  46230. */
  46231. get: function () {
  46232. return this._shadowMaxZ;
  46233. },
  46234. /**
  46235. * Gets the shadow projection clipping maximum z value.
  46236. */
  46237. set: function (value) {
  46238. this._shadowMaxZ = value;
  46239. this.forceProjectionMatrixCompute();
  46240. },
  46241. enumerable: true,
  46242. configurable: true
  46243. });
  46244. /**
  46245. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  46246. * @returns true if the information has been computed, false if it does not need to (no parenting)
  46247. */
  46248. ShadowLight.prototype.computeTransformedInformation = function () {
  46249. if (this.parent && this.parent.getWorldMatrix) {
  46250. if (!this.transformedPosition) {
  46251. this.transformedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46252. }
  46253. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
  46254. // In case the direction is present.
  46255. if (this.direction) {
  46256. if (!this.transformedDirection) {
  46257. this.transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46258. }
  46259. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection);
  46260. }
  46261. return true;
  46262. }
  46263. return false;
  46264. };
  46265. /**
  46266. * Return the depth scale used for the shadow map.
  46267. * @returns the depth scale.
  46268. */
  46269. ShadowLight.prototype.getDepthScale = function () {
  46270. return 50.0;
  46271. };
  46272. /**
  46273. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  46274. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46275. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46276. */
  46277. ShadowLight.prototype.getShadowDirection = function (faceIndex) {
  46278. return this.transformedDirection ? this.transformedDirection : this.direction;
  46279. };
  46280. /**
  46281. * Returns the ShadowLight absolute position in the World.
  46282. * @returns the position vector in world space
  46283. */
  46284. ShadowLight.prototype.getAbsolutePosition = function () {
  46285. return this.transformedPosition ? this.transformedPosition : this.position;
  46286. };
  46287. /**
  46288. * Sets the ShadowLight direction toward the passed target.
  46289. * @param target The point tot target in local space
  46290. * @returns the updated ShadowLight direction
  46291. */
  46292. ShadowLight.prototype.setDirectionToTarget = function (target) {
  46293. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(this.position));
  46294. return this.direction;
  46295. };
  46296. /**
  46297. * Returns the light rotation in euler definition.
  46298. * @returns the x y z rotation in local space.
  46299. */
  46300. ShadowLight.prototype.getRotation = function () {
  46301. this.direction.normalize();
  46302. var xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y);
  46303. var yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(xaxis, this.direction);
  46304. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].RotationFromAxis(xaxis, yaxis, this.direction);
  46305. };
  46306. /**
  46307. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  46308. * @returns true if a cube texture needs to be use
  46309. */
  46310. ShadowLight.prototype.needCube = function () {
  46311. return false;
  46312. };
  46313. /**
  46314. * Detects if the projection matrix requires to be recomputed this frame.
  46315. * @returns true if it requires to be recomputed otherwise, false.
  46316. */
  46317. ShadowLight.prototype.needProjectionMatrixCompute = function () {
  46318. return this._needProjectionMatrixCompute;
  46319. };
  46320. /**
  46321. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  46322. */
  46323. ShadowLight.prototype.forceProjectionMatrixCompute = function () {
  46324. this._needProjectionMatrixCompute = true;
  46325. };
  46326. /** @hidden */
  46327. ShadowLight.prototype._initCache = function () {
  46328. _super.prototype._initCache.call(this);
  46329. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46330. };
  46331. /** @hidden */
  46332. ShadowLight.prototype._isSynchronized = function () {
  46333. if (!this._cache.position.equals(this.position)) {
  46334. return false;
  46335. }
  46336. return true;
  46337. };
  46338. /**
  46339. * Computes the world matrix of the node
  46340. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  46341. * @returns the world matrix
  46342. */
  46343. ShadowLight.prototype.computeWorldMatrix = function (force) {
  46344. if (!force && this.isSynchronized()) {
  46345. this._currentRenderId = this.getScene().getRenderId();
  46346. return this._worldMatrix;
  46347. }
  46348. this._updateCache();
  46349. this._cache.position.copyFrom(this.position);
  46350. if (!this._worldMatrix) {
  46351. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  46352. }
  46353. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
  46354. if (this.parent && this.parent.getWorldMatrix) {
  46355. this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  46356. this._markSyncedWithParent();
  46357. }
  46358. // Cache the determinant
  46359. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  46360. return this._worldMatrix;
  46361. };
  46362. /**
  46363. * Gets the minZ used for shadow according to both the scene and the light.
  46364. * @param activeCamera The camera we are returning the min for
  46365. * @returns the depth min z
  46366. */
  46367. ShadowLight.prototype.getDepthMinZ = function (activeCamera) {
  46368. return this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;
  46369. };
  46370. /**
  46371. * Gets the maxZ used for shadow according to both the scene and the light.
  46372. * @param activeCamera The camera we are returning the max for
  46373. * @returns the depth max z
  46374. */
  46375. ShadowLight.prototype.getDepthMaxZ = function (activeCamera) {
  46376. return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;
  46377. };
  46378. /**
  46379. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  46380. * @param matrix The materix to updated with the projection information
  46381. * @param viewMatrix The transform matrix of the light
  46382. * @param renderList The list of mesh to render in the map
  46383. * @returns The current light
  46384. */
  46385. ShadowLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  46386. if (this.customProjectionMatrixBuilder) {
  46387. this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
  46388. }
  46389. else {
  46390. this._setDefaultShadowProjectionMatrix(matrix, viewMatrix, renderList);
  46391. }
  46392. return this;
  46393. };
  46394. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46395. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  46396. ], ShadowLight.prototype, "position", null);
  46397. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46398. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  46399. ], ShadowLight.prototype, "direction", null);
  46400. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46401. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46402. ], ShadowLight.prototype, "shadowMinZ", null);
  46403. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46404. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46405. ], ShadowLight.prototype, "shadowMaxZ", null);
  46406. return ShadowLight;
  46407. }(_light__WEBPACK_IMPORTED_MODULE_3__["Light"]));
  46408. /***/ }),
  46409. /***/ "./Lights/spotLight.ts":
  46410. /*!*****************************!*\
  46411. !*** ./Lights/spotLight.ts ***!
  46412. \*****************************/
  46413. /*! exports provided: SpotLight */
  46414. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46415. "use strict";
  46416. __webpack_require__.r(__webpack_exports__);
  46417. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return SpotLight; });
  46418. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46419. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46420. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46421. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46422. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46423. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46424. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_2", function (name, scene) {
  46425. 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); };
  46426. });
  46427. /**
  46428. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46429. * These values define a cone of light starting from the position, emitting toward the direction.
  46430. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46431. * and the exponent defines the speed of the decay of the light with distance (reach).
  46432. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46433. */
  46434. var SpotLight = /** @class */ (function (_super) {
  46435. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpotLight, _super);
  46436. /**
  46437. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46438. * It can cast shadows.
  46439. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46440. * @param name The light friendly name
  46441. * @param position The position of the spot light in the scene
  46442. * @param direction The direction of the light in the scene
  46443. * @param angle The cone angle of the light in Radians
  46444. * @param exponent The light decay speed with the distance from the emission spot
  46445. * @param scene The scene the lights belongs to
  46446. */
  46447. function SpotLight(name, position, direction, angle, exponent, scene) {
  46448. var _this = _super.call(this, name, scene) || this;
  46449. _this._innerAngle = 0;
  46450. _this._projectionTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  46451. _this._projectionTextureLightNear = 1e-6;
  46452. _this._projectionTextureLightFar = 1000.0;
  46453. _this._projectionTextureUpDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  46454. _this._projectionTextureViewLightDirty = true;
  46455. _this._projectionTextureProjectionLightDirty = true;
  46456. _this._projectionTextureDirty = true;
  46457. _this._projectionTextureViewTargetVector = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46458. _this._projectionTextureViewLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  46459. _this._projectionTextureProjectionLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  46460. _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);
  46461. _this.position = position;
  46462. _this.direction = direction;
  46463. _this.angle = angle;
  46464. _this.exponent = exponent;
  46465. return _this;
  46466. }
  46467. Object.defineProperty(SpotLight.prototype, "angle", {
  46468. /**
  46469. * Gets the cone angle of the spot light in Radians.
  46470. */
  46471. get: function () {
  46472. return this._angle;
  46473. },
  46474. /**
  46475. * Sets the cone angle of the spot light in Radians.
  46476. */
  46477. set: function (value) {
  46478. this._angle = value;
  46479. this._cosHalfAngle = Math.cos(value * 0.5);
  46480. this._projectionTextureProjectionLightDirty = true;
  46481. this.forceProjectionMatrixCompute();
  46482. this._computeAngleValues();
  46483. },
  46484. enumerable: true,
  46485. configurable: true
  46486. });
  46487. Object.defineProperty(SpotLight.prototype, "innerAngle", {
  46488. /**
  46489. * Only used in gltf falloff mode, this defines the angle where
  46490. * the directional falloff will start before cutting at angle which could be seen
  46491. * as outer angle.
  46492. */
  46493. get: function () {
  46494. return this._innerAngle;
  46495. },
  46496. /**
  46497. * Only used in gltf falloff mode, this defines the angle where
  46498. * the directional falloff will start before cutting at angle which could be seen
  46499. * as outer angle.
  46500. */
  46501. set: function (value) {
  46502. this._innerAngle = value;
  46503. this._computeAngleValues();
  46504. },
  46505. enumerable: true,
  46506. configurable: true
  46507. });
  46508. Object.defineProperty(SpotLight.prototype, "shadowAngleScale", {
  46509. /**
  46510. * Allows scaling the angle of the light for shadow generation only.
  46511. */
  46512. get: function () {
  46513. return this._shadowAngleScale;
  46514. },
  46515. /**
  46516. * Allows scaling the angle of the light for shadow generation only.
  46517. */
  46518. set: function (value) {
  46519. this._shadowAngleScale = value;
  46520. this.forceProjectionMatrixCompute();
  46521. },
  46522. enumerable: true,
  46523. configurable: true
  46524. });
  46525. Object.defineProperty(SpotLight.prototype, "projectionTextureMatrix", {
  46526. /**
  46527. * Allows reading the projecton texture
  46528. */
  46529. get: function () {
  46530. return this._projectionTextureMatrix;
  46531. },
  46532. enumerable: true,
  46533. configurable: true
  46534. });
  46535. Object.defineProperty(SpotLight.prototype, "projectionTextureLightNear", {
  46536. /**
  46537. * Gets the near clip of the Spotlight for texture projection.
  46538. */
  46539. get: function () {
  46540. return this._projectionTextureLightNear;
  46541. },
  46542. /**
  46543. * Sets the near clip of the Spotlight for texture projection.
  46544. */
  46545. set: function (value) {
  46546. this._projectionTextureLightNear = value;
  46547. this._projectionTextureProjectionLightDirty = true;
  46548. },
  46549. enumerable: true,
  46550. configurable: true
  46551. });
  46552. Object.defineProperty(SpotLight.prototype, "projectionTextureLightFar", {
  46553. /**
  46554. * Gets the far clip of the Spotlight for texture projection.
  46555. */
  46556. get: function () {
  46557. return this._projectionTextureLightFar;
  46558. },
  46559. /**
  46560. * Sets the far clip of the Spotlight for texture projection.
  46561. */
  46562. set: function (value) {
  46563. this._projectionTextureLightFar = value;
  46564. this._projectionTextureProjectionLightDirty = true;
  46565. },
  46566. enumerable: true,
  46567. configurable: true
  46568. });
  46569. Object.defineProperty(SpotLight.prototype, "projectionTextureUpDirection", {
  46570. /**
  46571. * Gets the Up vector of the Spotlight for texture projection.
  46572. */
  46573. get: function () {
  46574. return this._projectionTextureUpDirection;
  46575. },
  46576. /**
  46577. * Sets the Up vector of the Spotlight for texture projection.
  46578. */
  46579. set: function (value) {
  46580. this._projectionTextureUpDirection = value;
  46581. this._projectionTextureProjectionLightDirty = true;
  46582. },
  46583. enumerable: true,
  46584. configurable: true
  46585. });
  46586. Object.defineProperty(SpotLight.prototype, "projectionTexture", {
  46587. /**
  46588. * Gets the projection texture of the light.
  46589. */
  46590. get: function () {
  46591. return this._projectionTexture;
  46592. },
  46593. /**
  46594. * Sets the projection texture of the light.
  46595. */
  46596. set: function (value) {
  46597. this._projectionTexture = value;
  46598. this._projectionTextureDirty = true;
  46599. },
  46600. enumerable: true,
  46601. configurable: true
  46602. });
  46603. /**
  46604. * Returns the string "SpotLight".
  46605. * @returns the class name
  46606. */
  46607. SpotLight.prototype.getClassName = function () {
  46608. return "SpotLight";
  46609. };
  46610. /**
  46611. * Returns the integer 2.
  46612. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46613. */
  46614. SpotLight.prototype.getTypeID = function () {
  46615. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_SPOTLIGHT;
  46616. };
  46617. /**
  46618. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46619. */
  46620. SpotLight.prototype._setDirection = function (value) {
  46621. _super.prototype._setDirection.call(this, value);
  46622. this._projectionTextureViewLightDirty = true;
  46623. };
  46624. /**
  46625. * Overrides the position setter to recompute the projection texture view light Matrix.
  46626. */
  46627. SpotLight.prototype._setPosition = function (value) {
  46628. _super.prototype._setPosition.call(this, value);
  46629. this._projectionTextureViewLightDirty = true;
  46630. };
  46631. /**
  46632. * 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.
  46633. * Returns the SpotLight.
  46634. */
  46635. SpotLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  46636. var activeCamera = this.getScene().activeCamera;
  46637. if (!activeCamera) {
  46638. return;
  46639. }
  46640. this._shadowAngleScale = this._shadowAngleScale || 1;
  46641. var angle = this._shadowAngleScale * this._angle;
  46642. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(angle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  46643. };
  46644. SpotLight.prototype._computeProjectionTextureViewLightMatrix = function () {
  46645. this._projectionTextureViewLightDirty = false;
  46646. this._projectionTextureDirty = true;
  46647. this.position.addToRef(this.direction, this._projectionTextureViewTargetVector);
  46648. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);
  46649. };
  46650. SpotLight.prototype._computeProjectionTextureProjectionLightMatrix = function () {
  46651. this._projectionTextureProjectionLightDirty = false;
  46652. this._projectionTextureDirty = true;
  46653. var light_far = this.projectionTextureLightFar;
  46654. var light_near = this.projectionTextureLightNear;
  46655. var P = light_far / (light_far - light_near);
  46656. var Q = -P * light_near;
  46657. var S = 1.0 / Math.tan(this._angle / 2.0);
  46658. var A = 1.0;
  46659. _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);
  46660. };
  46661. /**
  46662. * Main function for light texture projection matrix computing.
  46663. */
  46664. SpotLight.prototype._computeProjectionTextureMatrix = function () {
  46665. this._projectionTextureDirty = false;
  46666. this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix);
  46667. this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);
  46668. };
  46669. SpotLight.prototype._buildUniformLayout = function () {
  46670. this._uniformBuffer.addUniform("vLightData", 4);
  46671. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  46672. this._uniformBuffer.addUniform("vLightSpecular", 3);
  46673. this._uniformBuffer.addUniform("vLightDirection", 3);
  46674. this._uniformBuffer.addUniform("vLightFalloff", 4);
  46675. this._uniformBuffer.addUniform("shadowsInfo", 3);
  46676. this._uniformBuffer.addUniform("depthValues", 2);
  46677. this._uniformBuffer.create();
  46678. };
  46679. SpotLight.prototype._computeAngleValues = function () {
  46680. this._lightAngleScale = 1.0 / Math.max(0.001, (Math.cos(this._innerAngle * 0.5) - this._cosHalfAngle));
  46681. this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;
  46682. };
  46683. /**
  46684. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46685. * @param effect The effect to update
  46686. * @param lightIndex The index of the light in the effect to update
  46687. * @returns The spot light
  46688. */
  46689. SpotLight.prototype.transferToEffect = function (effect, lightIndex) {
  46690. var normalizeDirection;
  46691. if (this.computeTransformedInformation()) {
  46692. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, lightIndex);
  46693. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.transformedDirection);
  46694. }
  46695. else {
  46696. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, lightIndex);
  46697. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  46698. }
  46699. this._uniformBuffer.updateFloat4("vLightDirection", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, this._cosHalfAngle, lightIndex);
  46700. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, lightIndex);
  46701. if (this.projectionTexture && this.projectionTexture.isReady()) {
  46702. if (this._projectionTextureViewLightDirty) {
  46703. this._computeProjectionTextureViewLightMatrix();
  46704. }
  46705. if (this._projectionTextureProjectionLightDirty) {
  46706. this._computeProjectionTextureProjectionLightMatrix();
  46707. }
  46708. if (this._projectionTextureDirty) {
  46709. this._computeProjectionTextureMatrix();
  46710. }
  46711. effect.setMatrix("textureProjectionMatrix" + lightIndex, this._projectionTextureMatrix);
  46712. effect.setTexture("projectionLightSampler" + lightIndex, this.projectionTexture);
  46713. }
  46714. return this;
  46715. };
  46716. /**
  46717. * Disposes the light and the associated resources.
  46718. */
  46719. SpotLight.prototype.dispose = function () {
  46720. _super.prototype.dispose.call(this);
  46721. if (this._projectionTexture) {
  46722. this._projectionTexture.dispose();
  46723. }
  46724. };
  46725. /**
  46726. * Prepares the list of defines specific to the light type.
  46727. * @param defines the list of defines
  46728. * @param lightIndex defines the index of the light for the effect
  46729. */
  46730. SpotLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  46731. defines["SPOTLIGHT" + lightIndex] = true;
  46732. defines["PROJECTEDLIGHTTEXTURE" + lightIndex] = this.projectionTexture ? true : false;
  46733. };
  46734. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46735. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46736. ], SpotLight.prototype, "angle", null);
  46737. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46738. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46739. ], SpotLight.prototype, "innerAngle", null);
  46740. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46741. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46742. ], SpotLight.prototype, "shadowAngleScale", null);
  46743. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46744. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46745. ], SpotLight.prototype, "exponent", void 0);
  46746. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46747. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46748. ], SpotLight.prototype, "projectionTextureLightNear", null);
  46749. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46750. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46751. ], SpotLight.prototype, "projectionTextureLightFar", null);
  46752. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46753. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46754. ], SpotLight.prototype, "projectionTextureUpDirection", null);
  46755. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46756. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("projectedLightTexture")
  46757. ], SpotLight.prototype, "_projectionTexture", void 0);
  46758. return SpotLight;
  46759. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  46760. /***/ }),
  46761. /***/ "./Loading/Plugins/babylonFileLoader.ts":
  46762. /*!**********************************************!*\
  46763. !*** ./Loading/Plugins/babylonFileLoader.ts ***!
  46764. \**********************************************/
  46765. /*! exports provided: _BabylonLoaderRegistered */
  46766. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46767. "use strict";
  46768. __webpack_require__.r(__webpack_exports__);
  46769. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _BabylonLoaderRegistered; });
  46770. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  46771. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  46772. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  46773. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  46774. /* harmony import */ var _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/geometry */ "./Meshes/geometry.ts");
  46775. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/transformNode */ "./Meshes/transformNode.ts");
  46776. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  46777. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  46778. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  46779. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  46780. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  46781. /* harmony import */ var _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Animations/animationGroup */ "./Animations/animationGroup.ts");
  46782. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  46783. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  46784. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  46785. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  46786. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../assetContainer */ "./assetContainer.ts");
  46787. /* harmony import */ var _Actions_actionManager__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Actions/actionManager */ "./Actions/actionManager.ts");
  46788. /* harmony import */ var _Bones_skeleton__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Bones/skeleton */ "./Bones/skeleton.ts");
  46789. /* harmony import */ var _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Morph/morphTargetManager */ "./Morph/morphTargetManager.ts");
  46790. /* harmony import */ var _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Physics/Plugins/cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  46791. /* harmony import */ var _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Physics/Plugins/oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  46792. /* harmony import */ var _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Probes/reflectionProbe */ "./Probes/reflectionProbe.ts");
  46793. /** @hidden */
  46794. var _BabylonLoaderRegistered = true;
  46795. var parseMaterialById = function (id, parsedData, scene, rootUrl) {
  46796. for (var index = 0, cache = parsedData.materials.length; index < cache; index++) {
  46797. var parsedMaterial = parsedData.materials[index];
  46798. if (parsedMaterial.id === id) {
  46799. return _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  46800. }
  46801. }
  46802. return null;
  46803. };
  46804. var isDescendantOf = function (mesh, names, hierarchyIds) {
  46805. for (var i in names) {
  46806. if (mesh.name === names[i]) {
  46807. hierarchyIds.push(mesh.id);
  46808. return true;
  46809. }
  46810. }
  46811. if (mesh.parentId && hierarchyIds.indexOf(mesh.parentId) !== -1) {
  46812. hierarchyIds.push(mesh.id);
  46813. return true;
  46814. }
  46815. return false;
  46816. };
  46817. var logOperation = function (operation, producer) {
  46818. return operation + " of " + (producer ? producer.file + " from " + producer.name + " version: " + producer.version + ", exporter version: " + producer.exporter_version : "unknown");
  46819. };
  46820. var loadAssetContainer = function (scene, data, rootUrl, onError, addToScene) {
  46821. if (addToScene === void 0) { addToScene = false; }
  46822. var container = new _assetContainer__WEBPACK_IMPORTED_MODULE_16__["AssetContainer"](scene);
  46823. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  46824. // when SceneLoader.debugLogging = true (default), or exception encountered.
  46825. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  46826. // and avoid problems with multiple concurrent .babylon loads.
  46827. var log = "importScene has failed JSON parse";
  46828. try {
  46829. var parsedData = JSON.parse(data);
  46830. log = "";
  46831. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].DETAILED_LOGGING;
  46832. var index;
  46833. var cache;
  46834. // Lights
  46835. if (parsedData.lights !== undefined && parsedData.lights !== null) {
  46836. for (index = 0, cache = parsedData.lights.length; index < cache; index++) {
  46837. var parsedLight = parsedData.lights[index];
  46838. var light = _Lights_light__WEBPACK_IMPORTED_MODULE_12__["Light"].Parse(parsedLight, scene);
  46839. if (light) {
  46840. container.lights.push(light);
  46841. log += (index === 0 ? "\n\tLights:" : "");
  46842. log += "\n\t\t" + light.toString(fullDetails);
  46843. }
  46844. }
  46845. }
  46846. // Reflection probes
  46847. if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
  46848. for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
  46849. var parsedReflectionProbe = parsedData.reflectionProbes[index];
  46850. var reflectionProbe = _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_22__["ReflectionProbe"].Parse(parsedReflectionProbe, scene, rootUrl);
  46851. if (reflectionProbe) {
  46852. container.reflectionProbes.push(reflectionProbe);
  46853. log += (index === 0 ? "\n\tReflection Probes:" : "");
  46854. log += "\n\t\t" + reflectionProbe.toString(fullDetails);
  46855. }
  46856. }
  46857. }
  46858. // Animations
  46859. if (parsedData.animations !== undefined && parsedData.animations !== null) {
  46860. for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
  46861. var parsedAnimation = parsedData.animations[index];
  46862. var animation = _Animations_animation__WEBPACK_IMPORTED_MODULE_10__["Animation"].Parse(parsedAnimation);
  46863. scene.animations.push(animation);
  46864. container.animations.push(animation);
  46865. log += (index === 0 ? "\n\tAnimations:" : "");
  46866. log += "\n\t\t" + animation.toString(fullDetails);
  46867. }
  46868. }
  46869. // Materials
  46870. if (parsedData.materials !== undefined && parsedData.materials !== null) {
  46871. for (index = 0, cache = parsedData.materials.length; index < cache; index++) {
  46872. var parsedMaterial = parsedData.materials[index];
  46873. var mat = _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  46874. container.materials.push(mat);
  46875. log += (index === 0 ? "\n\tMaterials:" : "");
  46876. log += "\n\t\t" + mat.toString(fullDetails);
  46877. }
  46878. }
  46879. if (parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  46880. for (index = 0, cache = parsedData.multiMaterials.length; index < cache; index++) {
  46881. var parsedMultiMaterial = parsedData.multiMaterials[index];
  46882. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  46883. container.multiMaterials.push(mmat);
  46884. log += (index === 0 ? "\n\tMultiMaterials:" : "");
  46885. log += "\n\t\t" + mmat.toString(fullDetails);
  46886. }
  46887. }
  46888. // Morph targets
  46889. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  46890. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  46891. var managerData = _a[_i];
  46892. container.morphTargetManagers.push(_Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_19__["MorphTargetManager"].Parse(managerData, scene));
  46893. }
  46894. }
  46895. // Skeletons
  46896. if (parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  46897. for (index = 0, cache = parsedData.skeletons.length; index < cache; index++) {
  46898. var parsedSkeleton = parsedData.skeletons[index];
  46899. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_18__["Skeleton"].Parse(parsedSkeleton, scene);
  46900. container.skeletons.push(skeleton);
  46901. log += (index === 0 ? "\n\tSkeletons:" : "");
  46902. log += "\n\t\t" + skeleton.toString(fullDetails);
  46903. }
  46904. }
  46905. // Geometries
  46906. var geometries = parsedData.geometries;
  46907. if (geometries !== undefined && geometries !== null) {
  46908. var addedGeometry = new Array();
  46909. // Boxes
  46910. var boxes = geometries.boxes;
  46911. if (boxes !== undefined && boxes !== null) {
  46912. for (index = 0, cache = boxes.length; index < cache; index++) {
  46913. var parsedBox = boxes[index];
  46914. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["BoxGeometry"].Parse(parsedBox, scene));
  46915. }
  46916. }
  46917. // Spheres
  46918. var spheres = geometries.spheres;
  46919. if (spheres !== undefined && spheres !== null) {
  46920. for (index = 0, cache = spheres.length; index < cache; index++) {
  46921. var parsedSphere = spheres[index];
  46922. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["SphereGeometry"].Parse(parsedSphere, scene));
  46923. }
  46924. }
  46925. // Cylinders
  46926. var cylinders = geometries.cylinders;
  46927. if (cylinders !== undefined && cylinders !== null) {
  46928. for (index = 0, cache = cylinders.length; index < cache; index++) {
  46929. var parsedCylinder = cylinders[index];
  46930. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["CylinderGeometry"].Parse(parsedCylinder, scene));
  46931. }
  46932. }
  46933. // Toruses
  46934. var toruses = geometries.toruses;
  46935. if (toruses !== undefined && toruses !== null) {
  46936. for (index = 0, cache = toruses.length; index < cache; index++) {
  46937. var parsedTorus = toruses[index];
  46938. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["TorusGeometry"].Parse(parsedTorus, scene));
  46939. }
  46940. }
  46941. // Grounds
  46942. var grounds = geometries.grounds;
  46943. if (grounds !== undefined && grounds !== null) {
  46944. for (index = 0, cache = grounds.length; index < cache; index++) {
  46945. var parsedGround = grounds[index];
  46946. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["GroundGeometry"].Parse(parsedGround, scene));
  46947. }
  46948. }
  46949. // Planes
  46950. var planes = geometries.planes;
  46951. if (planes !== undefined && planes !== null) {
  46952. for (index = 0, cache = planes.length; index < cache; index++) {
  46953. var parsedPlane = planes[index];
  46954. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["PlaneGeometry"].Parse(parsedPlane, scene));
  46955. }
  46956. }
  46957. // TorusKnots
  46958. var torusKnots = geometries.torusKnots;
  46959. if (torusKnots !== undefined && torusKnots !== null) {
  46960. for (index = 0, cache = torusKnots.length; index < cache; index++) {
  46961. var parsedTorusKnot = torusKnots[index];
  46962. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["TorusKnotGeometry"].Parse(parsedTorusKnot, scene));
  46963. }
  46964. }
  46965. // VertexData
  46966. var vertexData = geometries.vertexData;
  46967. if (vertexData !== undefined && vertexData !== null) {
  46968. for (index = 0, cache = vertexData.length; index < cache; index++) {
  46969. var parsedVertexData = vertexData[index];
  46970. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedVertexData, scene, rootUrl));
  46971. }
  46972. }
  46973. addedGeometry.forEach(function (g) {
  46974. if (g) {
  46975. container.geometries.push(g);
  46976. }
  46977. });
  46978. }
  46979. // Transform nodes
  46980. if (parsedData.transformNodes !== undefined && parsedData.transformNodes !== null) {
  46981. for (index = 0, cache = parsedData.transformNodes.length; index < cache; index++) {
  46982. var parsedTransformNode = parsedData.transformNodes[index];
  46983. var node = _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__["TransformNode"].Parse(parsedTransformNode, scene, rootUrl);
  46984. container.transformNodes.push(node);
  46985. }
  46986. }
  46987. // Meshes
  46988. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  46989. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  46990. var parsedMesh = parsedData.meshes[index];
  46991. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  46992. container.meshes.push(mesh);
  46993. log += (index === 0 ? "\n\tMeshes:" : "");
  46994. log += "\n\t\t" + mesh.toString(fullDetails);
  46995. }
  46996. }
  46997. // Cameras
  46998. if (parsedData.cameras !== undefined && parsedData.cameras !== null) {
  46999. for (index = 0, cache = parsedData.cameras.length; index < cache; index++) {
  47000. var parsedCamera = parsedData.cameras[index];
  47001. var camera = _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].Parse(parsedCamera, scene);
  47002. container.cameras.push(camera);
  47003. log += (index === 0 ? "\n\tCameras:" : "");
  47004. log += "\n\t\t" + camera.toString(fullDetails);
  47005. }
  47006. }
  47007. // Animation Groups
  47008. if (parsedData.animationGroups !== undefined && parsedData.animationGroups !== null) {
  47009. for (index = 0, cache = parsedData.animationGroups.length; index < cache; index++) {
  47010. var parsedAnimationGroup = parsedData.animationGroups[index];
  47011. var animationGroup = _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_11__["AnimationGroup"].Parse(parsedAnimationGroup, scene);
  47012. container.animationGroups.push(animationGroup);
  47013. log += (index === 0 ? "\n\tAnimationGroups:" : "");
  47014. log += "\n\t\t" + animationGroup.toString(fullDetails);
  47015. }
  47016. }
  47017. // Browsing all the graph to connect the dots
  47018. for (index = 0, cache = scene.cameras.length; index < cache; index++) {
  47019. var camera = scene.cameras[index];
  47020. if (camera._waitingParentId) {
  47021. camera.parent = scene.getLastEntryByID(camera._waitingParentId);
  47022. camera._waitingParentId = null;
  47023. }
  47024. }
  47025. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  47026. var light_1 = scene.lights[index];
  47027. if (light_1 && light_1._waitingParentId) {
  47028. light_1.parent = scene.getLastEntryByID(light_1._waitingParentId);
  47029. light_1._waitingParentId = null;
  47030. }
  47031. }
  47032. // Connect parents & children and parse actions
  47033. for (index = 0, cache = scene.transformNodes.length; index < cache; index++) {
  47034. var transformNode = scene.transformNodes[index];
  47035. if (transformNode._waitingParentId) {
  47036. transformNode.parent = scene.getLastEntryByID(transformNode._waitingParentId);
  47037. transformNode._waitingParentId = null;
  47038. }
  47039. }
  47040. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47041. var mesh = scene.meshes[index];
  47042. if (mesh._waitingParentId) {
  47043. mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
  47044. mesh._waitingParentId = null;
  47045. }
  47046. }
  47047. // freeze world matrix application
  47048. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47049. var currentMesh = scene.meshes[index];
  47050. if (currentMesh._waitingFreezeWorldMatrix) {
  47051. currentMesh.freezeWorldMatrix();
  47052. currentMesh._waitingFreezeWorldMatrix = null;
  47053. }
  47054. else {
  47055. currentMesh.computeWorldMatrix(true);
  47056. }
  47057. }
  47058. // Lights exclusions / inclusions
  47059. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  47060. var light_2 = scene.lights[index];
  47061. // Excluded check
  47062. if (light_2._excludedMeshesIds.length > 0) {
  47063. for (var excludedIndex = 0; excludedIndex < light_2._excludedMeshesIds.length; excludedIndex++) {
  47064. var excludedMesh = scene.getMeshByID(light_2._excludedMeshesIds[excludedIndex]);
  47065. if (excludedMesh) {
  47066. light_2.excludedMeshes.push(excludedMesh);
  47067. }
  47068. }
  47069. light_2._excludedMeshesIds = [];
  47070. }
  47071. // Included check
  47072. if (light_2._includedOnlyMeshesIds.length > 0) {
  47073. for (var includedOnlyIndex = 0; includedOnlyIndex < light_2._includedOnlyMeshesIds.length; includedOnlyIndex++) {
  47074. var includedOnlyMesh = scene.getMeshByID(light_2._includedOnlyMeshesIds[includedOnlyIndex]);
  47075. if (includedOnlyMesh) {
  47076. light_2.includedOnlyMeshes.push(includedOnlyMesh);
  47077. }
  47078. }
  47079. light_2._includedOnlyMeshesIds = [];
  47080. }
  47081. }
  47082. _abstractScene__WEBPACK_IMPORTED_MODULE_15__["AbstractScene"].Parse(parsedData, scene, container, rootUrl);
  47083. // Actions (scene) Done last as it can access other objects.
  47084. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47085. var mesh = scene.meshes[index];
  47086. if (mesh._waitingActions) {
  47087. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_17__["ActionManager"].Parse(mesh._waitingActions, mesh, scene);
  47088. mesh._waitingActions = null;
  47089. }
  47090. }
  47091. if (parsedData.actions !== undefined && parsedData.actions !== null) {
  47092. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_17__["ActionManager"].Parse(parsedData.actions, null, scene);
  47093. }
  47094. if (!addToScene) {
  47095. container.removeAllFromScene();
  47096. }
  47097. }
  47098. catch (err) {
  47099. var msg = logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + log;
  47100. if (onError) {
  47101. onError(msg, err);
  47102. }
  47103. else {
  47104. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  47105. throw err;
  47106. }
  47107. }
  47108. finally {
  47109. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].NO_LOGGING) {
  47110. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].MINIMAL_LOGGING ? log : ""));
  47111. }
  47112. }
  47113. return container;
  47114. };
  47115. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].RegisterPlugin({
  47116. name: "babylon.js",
  47117. extensions: ".babylon",
  47118. canDirectLoad: function (data) {
  47119. if (data.indexOf("babylon") !== -1) { // We consider that the producer string is filled
  47120. return true;
  47121. }
  47122. return false;
  47123. },
  47124. importMesh: function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons, onError) {
  47125. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  47126. // when SceneLoader.debugLogging = true (default), or exception encountered.
  47127. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  47128. // and avoid problems with multiple concurrent .babylon loads.
  47129. var log = "importMesh has failed JSON parse";
  47130. try {
  47131. var parsedData = JSON.parse(data);
  47132. log = "";
  47133. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].DETAILED_LOGGING;
  47134. if (!meshesNames) {
  47135. meshesNames = null;
  47136. }
  47137. else if (!Array.isArray(meshesNames)) {
  47138. meshesNames = [meshesNames];
  47139. }
  47140. var hierarchyIds = new Array();
  47141. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  47142. var loadedSkeletonsIds = [];
  47143. var loadedMaterialsIds = [];
  47144. var index;
  47145. var cache;
  47146. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  47147. var parsedMesh = parsedData.meshes[index];
  47148. if (meshesNames === null || isDescendantOf(parsedMesh, meshesNames, hierarchyIds)) {
  47149. if (meshesNames !== null) {
  47150. // Remove found mesh name from list.
  47151. delete meshesNames[meshesNames.indexOf(parsedMesh.name)];
  47152. }
  47153. //Geometry?
  47154. if (parsedMesh.geometryId !== undefined && parsedMesh.geometryId !== null) {
  47155. //does the file contain geometries?
  47156. if (parsedData.geometries !== undefined && parsedData.geometries !== null) {
  47157. //find the correct geometry and add it to the scene
  47158. var found = false;
  47159. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function (geometryType) {
  47160. if (found === true || !parsedData.geometries[geometryType] || !(Array.isArray(parsedData.geometries[geometryType]))) {
  47161. return;
  47162. }
  47163. else {
  47164. parsedData.geometries[geometryType].forEach(function (parsedGeometryData) {
  47165. if (parsedGeometryData.id === parsedMesh.geometryId) {
  47166. switch (geometryType) {
  47167. case "boxes":
  47168. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["BoxGeometry"].Parse(parsedGeometryData, scene);
  47169. break;
  47170. case "spheres":
  47171. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["SphereGeometry"].Parse(parsedGeometryData, scene);
  47172. break;
  47173. case "cylinders":
  47174. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["CylinderGeometry"].Parse(parsedGeometryData, scene);
  47175. break;
  47176. case "toruses":
  47177. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["TorusGeometry"].Parse(parsedGeometryData, scene);
  47178. break;
  47179. case "grounds":
  47180. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["GroundGeometry"].Parse(parsedGeometryData, scene);
  47181. break;
  47182. case "planes":
  47183. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["PlaneGeometry"].Parse(parsedGeometryData, scene);
  47184. break;
  47185. case "torusKnots":
  47186. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["TorusKnotGeometry"].Parse(parsedGeometryData, scene);
  47187. break;
  47188. case "vertexData":
  47189. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedGeometryData, scene, rootUrl);
  47190. break;
  47191. }
  47192. found = true;
  47193. }
  47194. });
  47195. }
  47196. });
  47197. if (found === false) {
  47198. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Geometry not found for mesh " + parsedMesh.id);
  47199. }
  47200. }
  47201. }
  47202. // Material ?
  47203. if (parsedMesh.materialId) {
  47204. var materialFound = (loadedMaterialsIds.indexOf(parsedMesh.materialId) !== -1);
  47205. if (materialFound === false && parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  47206. for (var multimatIndex = 0, multimatCache = parsedData.multiMaterials.length; multimatIndex < multimatCache; multimatIndex++) {
  47207. var parsedMultiMaterial = parsedData.multiMaterials[multimatIndex];
  47208. if (parsedMultiMaterial.id === parsedMesh.materialId) {
  47209. for (var matIndex = 0, matCache = parsedMultiMaterial.materials.length; matIndex < matCache; matIndex++) {
  47210. var subMatId = parsedMultiMaterial.materials[matIndex];
  47211. loadedMaterialsIds.push(subMatId);
  47212. var mat = parseMaterialById(subMatId, parsedData, scene, rootUrl);
  47213. if (mat) {
  47214. log += "\n\tMaterial " + mat.toString(fullDetails);
  47215. }
  47216. }
  47217. loadedMaterialsIds.push(parsedMultiMaterial.id);
  47218. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  47219. if (mmat) {
  47220. materialFound = true;
  47221. log += "\n\tMulti-Material " + mmat.toString(fullDetails);
  47222. }
  47223. break;
  47224. }
  47225. }
  47226. }
  47227. if (materialFound === false) {
  47228. loadedMaterialsIds.push(parsedMesh.materialId);
  47229. var mat = parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
  47230. if (!mat) {
  47231. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Material not found for mesh " + parsedMesh.id);
  47232. }
  47233. else {
  47234. log += "\n\tMaterial " + mat.toString(fullDetails);
  47235. }
  47236. }
  47237. }
  47238. // Skeleton ?
  47239. if (parsedMesh.skeletonId > -1 && parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  47240. var skeletonAlreadyLoaded = (loadedSkeletonsIds.indexOf(parsedMesh.skeletonId) > -1);
  47241. if (skeletonAlreadyLoaded === false) {
  47242. for (var skeletonIndex = 0, skeletonCache = parsedData.skeletons.length; skeletonIndex < skeletonCache; skeletonIndex++) {
  47243. var parsedSkeleton = parsedData.skeletons[skeletonIndex];
  47244. if (parsedSkeleton.id === parsedMesh.skeletonId) {
  47245. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_18__["Skeleton"].Parse(parsedSkeleton, scene);
  47246. skeletons.push(skeleton);
  47247. loadedSkeletonsIds.push(parsedSkeleton.id);
  47248. log += "\n\tSkeleton " + skeleton.toString(fullDetails);
  47249. }
  47250. }
  47251. }
  47252. }
  47253. // Morph targets ?
  47254. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  47255. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  47256. var managerData = _a[_i];
  47257. _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_19__["MorphTargetManager"].Parse(managerData, scene);
  47258. }
  47259. }
  47260. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  47261. meshes.push(mesh);
  47262. log += "\n\tMesh " + mesh.toString(fullDetails);
  47263. }
  47264. }
  47265. // Connecting parents
  47266. var currentMesh;
  47267. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47268. currentMesh = scene.meshes[index];
  47269. if (currentMesh._waitingParentId) {
  47270. currentMesh.parent = scene.getLastEntryByID(currentMesh._waitingParentId);
  47271. currentMesh._waitingParentId = null;
  47272. }
  47273. }
  47274. // freeze and compute world matrix application
  47275. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47276. currentMesh = scene.meshes[index];
  47277. if (currentMesh._waitingFreezeWorldMatrix) {
  47278. currentMesh.freezeWorldMatrix();
  47279. currentMesh._waitingFreezeWorldMatrix = null;
  47280. }
  47281. else {
  47282. currentMesh.computeWorldMatrix(true);
  47283. }
  47284. }
  47285. }
  47286. // Particles
  47287. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  47288. var parser = _abstractScene__WEBPACK_IMPORTED_MODULE_15__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_13__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  47289. if (parser) {
  47290. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  47291. var parsedParticleSystem = parsedData.particleSystems[index];
  47292. if (hierarchyIds.indexOf(parsedParticleSystem.emitterId) !== -1) {
  47293. particleSystems.push(parser(parsedParticleSystem, scene, rootUrl));
  47294. }
  47295. }
  47296. }
  47297. }
  47298. return true;
  47299. }
  47300. catch (err) {
  47301. var msg = logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + log;
  47302. if (onError) {
  47303. onError(msg, err);
  47304. }
  47305. else {
  47306. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  47307. throw err;
  47308. }
  47309. }
  47310. finally {
  47311. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].NO_LOGGING) {
  47312. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].MINIMAL_LOGGING ? log : ""));
  47313. }
  47314. }
  47315. return false;
  47316. },
  47317. load: function (scene, data, rootUrl, onError) {
  47318. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  47319. // when SceneLoader.debugLogging = true (default), or exception encountered.
  47320. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  47321. // and avoid problems with multiple concurrent .babylon loads.
  47322. var log = "importScene has failed JSON parse";
  47323. try {
  47324. var parsedData = JSON.parse(data);
  47325. log = "";
  47326. // Scene
  47327. if (parsedData.useDelayedTextureLoading !== undefined && parsedData.useDelayedTextureLoading !== null) {
  47328. scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].ForceFullSceneLoadingForIncremental;
  47329. }
  47330. if (parsedData.autoClear !== undefined && parsedData.autoClear !== null) {
  47331. scene.autoClear = parsedData.autoClear;
  47332. }
  47333. if (parsedData.clearColor !== undefined && parsedData.clearColor !== null) {
  47334. scene.clearColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(parsedData.clearColor);
  47335. }
  47336. if (parsedData.ambientColor !== undefined && parsedData.ambientColor !== null) {
  47337. scene.ambientColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.ambientColor);
  47338. }
  47339. if (parsedData.gravity !== undefined && parsedData.gravity !== null) {
  47340. scene.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.gravity);
  47341. }
  47342. // Fog
  47343. if (parsedData.fogMode && parsedData.fogMode !== 0) {
  47344. scene.fogMode = parsedData.fogMode;
  47345. scene.fogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.fogColor);
  47346. scene.fogStart = parsedData.fogStart;
  47347. scene.fogEnd = parsedData.fogEnd;
  47348. scene.fogDensity = parsedData.fogDensity;
  47349. log += "\tFog mode for scene: ";
  47350. switch (scene.fogMode) {
  47351. // getters not compiling, so using hardcoded
  47352. case 1:
  47353. log += "exp\n";
  47354. break;
  47355. case 2:
  47356. log += "exp2\n";
  47357. break;
  47358. case 3:
  47359. log += "linear\n";
  47360. break;
  47361. }
  47362. }
  47363. //Physics
  47364. if (parsedData.physicsEnabled) {
  47365. var physicsPlugin;
  47366. if (parsedData.physicsEngine === "cannon") {
  47367. physicsPlugin = new _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_20__["CannonJSPlugin"]();
  47368. }
  47369. else if (parsedData.physicsEngine === "oimo") {
  47370. physicsPlugin = new _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_21__["OimoJSPlugin"]();
  47371. }
  47372. log = "\tPhysics engine " + (parsedData.physicsEngine ? parsedData.physicsEngine : "oimo") + " enabled\n";
  47373. //else - default engine, which is currently oimo
  47374. var physicsGravity = parsedData.physicsGravity ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.physicsGravity) : null;
  47375. scene.enablePhysics(physicsGravity, physicsPlugin);
  47376. }
  47377. // Metadata
  47378. if (parsedData.metadata !== undefined && parsedData.metadata !== null) {
  47379. scene.metadata = parsedData.metadata;
  47380. }
  47381. //collisions, if defined. otherwise, default is true
  47382. if (parsedData.collisionsEnabled !== undefined && parsedData.collisionsEnabled !== null) {
  47383. scene.collisionsEnabled = parsedData.collisionsEnabled;
  47384. }
  47385. var container = loadAssetContainer(scene, data, rootUrl, onError, true);
  47386. if (!container) {
  47387. return false;
  47388. }
  47389. if (parsedData.autoAnimate) {
  47390. scene.beginAnimation(scene, parsedData.autoAnimateFrom, parsedData.autoAnimateTo, parsedData.autoAnimateLoop, parsedData.autoAnimateSpeed || 1.0);
  47391. }
  47392. if (parsedData.activeCameraID !== undefined && parsedData.activeCameraID !== null) {
  47393. scene.setActiveCameraByID(parsedData.activeCameraID);
  47394. }
  47395. // Environment texture
  47396. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  47397. // PBR needed for both HDR texture (gamma space) & a sky box
  47398. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  47399. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  47400. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  47401. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"](rootUrl + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  47402. if (parsedData.environmentTextureRotationY) {
  47403. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  47404. }
  47405. scene.environmentTexture = hdrTexture;
  47406. }
  47407. else {
  47408. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
  47409. if (parsedData.environmentTextureRotationY) {
  47410. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  47411. }
  47412. scene.environmentTexture = cubeTexture;
  47413. }
  47414. if (parsedData.createDefaultSkybox === true) {
  47415. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  47416. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  47417. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  47418. }
  47419. }
  47420. // Finish
  47421. return true;
  47422. }
  47423. catch (err) {
  47424. var msg = logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + log;
  47425. if (onError) {
  47426. onError(msg, err);
  47427. }
  47428. else {
  47429. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  47430. throw err;
  47431. }
  47432. }
  47433. finally {
  47434. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].NO_LOGGING) {
  47435. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_14__["SceneLoader"].MINIMAL_LOGGING ? log : ""));
  47436. }
  47437. }
  47438. return false;
  47439. },
  47440. loadAssetContainer: function (scene, data, rootUrl, onError) {
  47441. var container = loadAssetContainer(scene, data, rootUrl, onError);
  47442. return container;
  47443. }
  47444. });
  47445. /***/ }),
  47446. /***/ "./Loading/Plugins/index.ts":
  47447. /*!**********************************!*\
  47448. !*** ./Loading/Plugins/index.ts ***!
  47449. \**********************************/
  47450. /*! exports provided: _BabylonLoaderRegistered */
  47451. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47452. "use strict";
  47453. __webpack_require__.r(__webpack_exports__);
  47454. /* harmony import */ var _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./babylonFileLoader */ "./Loading/Plugins/babylonFileLoader.ts");
  47455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  47456. /***/ }),
  47457. /***/ "./Loading/index.ts":
  47458. /*!**************************!*\
  47459. !*** ./Loading/index.ts ***!
  47460. \**************************/
  47461. /*! exports provided: DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, _BabylonLoaderRegistered */
  47462. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47463. "use strict";
  47464. __webpack_require__.r(__webpack_exports__);
  47465. /* harmony import */ var _loadingScreen__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./loadingScreen */ "./Loading/loadingScreen.ts");
  47466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _loadingScreen__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  47467. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Plugins/index */ "./Loading/Plugins/index.ts");
  47468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_1__["_BabylonLoaderRegistered"]; });
  47469. /* harmony import */ var _sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneLoader */ "./Loading/sceneLoader.ts");
  47470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoaderProgressEvent"]; });
  47471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"]; });
  47472. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  47473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__["SceneLoaderFlags"]; });
  47474. /***/ }),
  47475. /***/ "./Loading/loadingScreen.ts":
  47476. /*!**********************************!*\
  47477. !*** ./Loading/loadingScreen.ts ***!
  47478. \**********************************/
  47479. /*! exports provided: DefaultLoadingScreen */
  47480. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47481. "use strict";
  47482. __webpack_require__.r(__webpack_exports__);
  47483. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return DefaultLoadingScreen; });
  47484. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  47485. /**
  47486. * Class used for the default loading screen
  47487. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  47488. */
  47489. var DefaultLoadingScreen = /** @class */ (function () {
  47490. /**
  47491. * Creates a new default loading screen
  47492. * @param _renderingCanvas defines the canvas used to render the scene
  47493. * @param _loadingText defines the default text to display
  47494. * @param _loadingDivBackgroundColor defines the default background color
  47495. */
  47496. function DefaultLoadingScreen(_renderingCanvas, _loadingText, _loadingDivBackgroundColor) {
  47497. if (_loadingText === void 0) { _loadingText = ""; }
  47498. if (_loadingDivBackgroundColor === void 0) { _loadingDivBackgroundColor = "black"; }
  47499. var _this = this;
  47500. this._renderingCanvas = _renderingCanvas;
  47501. this._loadingText = _loadingText;
  47502. this._loadingDivBackgroundColor = _loadingDivBackgroundColor;
  47503. // Resize
  47504. this._resizeLoadingUI = function () {
  47505. var canvasRect = _this._renderingCanvas.getBoundingClientRect();
  47506. var canvasPositioning = window.getComputedStyle(_this._renderingCanvas).position;
  47507. if (!_this._loadingDiv) {
  47508. return;
  47509. }
  47510. _this._loadingDiv.style.position = (canvasPositioning === "fixed") ? "fixed" : "absolute";
  47511. _this._loadingDiv.style.left = canvasRect.left + "px";
  47512. _this._loadingDiv.style.top = canvasRect.top + "px";
  47513. _this._loadingDiv.style.width = canvasRect.width + "px";
  47514. _this._loadingDiv.style.height = canvasRect.height + "px";
  47515. };
  47516. }
  47517. /**
  47518. * Function called to display the loading screen
  47519. */
  47520. DefaultLoadingScreen.prototype.displayLoadingUI = function () {
  47521. if (this._loadingDiv) {
  47522. // Do not add a loading screen if there is already one
  47523. return;
  47524. }
  47525. this._loadingDiv = document.createElement("div");
  47526. this._loadingDiv.id = "babylonjsLoadingDiv";
  47527. this._loadingDiv.style.opacity = "0";
  47528. this._loadingDiv.style.transition = "opacity 1.5s ease";
  47529. this._loadingDiv.style.pointerEvents = "none";
  47530. // Loading text
  47531. this._loadingTextDiv = document.createElement("div");
  47532. this._loadingTextDiv.style.position = "absolute";
  47533. this._loadingTextDiv.style.left = "0";
  47534. this._loadingTextDiv.style.top = "50%";
  47535. this._loadingTextDiv.style.marginTop = "80px";
  47536. this._loadingTextDiv.style.width = "100%";
  47537. this._loadingTextDiv.style.height = "20px";
  47538. this._loadingTextDiv.style.fontFamily = "Arial";
  47539. this._loadingTextDiv.style.fontSize = "14px";
  47540. this._loadingTextDiv.style.color = "white";
  47541. this._loadingTextDiv.style.textAlign = "center";
  47542. this._loadingTextDiv.innerHTML = "Loading";
  47543. this._loadingDiv.appendChild(this._loadingTextDiv);
  47544. //set the predefined text
  47545. this._loadingTextDiv.innerHTML = this._loadingText;
  47546. // Generating keyframes
  47547. var style = document.createElement('style');
  47548. style.type = 'text/css';
  47549. 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 }";
  47550. style.innerHTML = keyFrames;
  47551. document.getElementsByTagName('head')[0].appendChild(style);
  47552. // Loading img
  47553. var imgBack = new Image();
  47554. 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";
  47555. imgBack.style.position = "absolute";
  47556. imgBack.style.left = "50%";
  47557. imgBack.style.top = "50%";
  47558. imgBack.style.marginLeft = "-60px";
  47559. imgBack.style.marginTop = "-60px";
  47560. imgBack.style.animation = "spin1 2s infinite ease-in-out";
  47561. imgBack.style.webkitAnimation = "spin1 2s infinite ease-in-out";
  47562. imgBack.style.transformOrigin = "50% 50%";
  47563. imgBack.style.webkitTransformOrigin = "50% 50%";
  47564. this._loadingDiv.appendChild(imgBack);
  47565. this._resizeLoadingUI();
  47566. window.addEventListener("resize", this._resizeLoadingUI);
  47567. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  47568. document.body.appendChild(this._loadingDiv);
  47569. this._loadingDiv.style.opacity = "1";
  47570. };
  47571. /**
  47572. * Function called to hide the loading screen
  47573. */
  47574. DefaultLoadingScreen.prototype.hideLoadingUI = function () {
  47575. var _this = this;
  47576. if (!this._loadingDiv) {
  47577. return;
  47578. }
  47579. var onTransitionEnd = function () {
  47580. if (!_this._loadingDiv) {
  47581. return;
  47582. }
  47583. if (_this._loadingDiv.parentElement) {
  47584. _this._loadingDiv.parentElement.removeChild(_this._loadingDiv);
  47585. }
  47586. window.removeEventListener("resize", _this._resizeLoadingUI);
  47587. _this._loadingDiv = null;
  47588. };
  47589. this._loadingDiv.style.opacity = "0";
  47590. this._loadingDiv.addEventListener("transitionend", onTransitionEnd);
  47591. };
  47592. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIText", {
  47593. get: function () {
  47594. return this._loadingText;
  47595. },
  47596. /**
  47597. * Gets or sets the text to display while loading
  47598. */
  47599. set: function (text) {
  47600. this._loadingText = text;
  47601. if (this._loadingTextDiv) {
  47602. this._loadingTextDiv.innerHTML = this._loadingText;
  47603. }
  47604. },
  47605. enumerable: true,
  47606. configurable: true
  47607. });
  47608. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIBackgroundColor", {
  47609. /**
  47610. * Gets or sets the color to use for the background
  47611. */
  47612. get: function () {
  47613. return this._loadingDivBackgroundColor;
  47614. },
  47615. set: function (color) {
  47616. this._loadingDivBackgroundColor = color;
  47617. if (!this._loadingDiv) {
  47618. return;
  47619. }
  47620. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  47621. },
  47622. enumerable: true,
  47623. configurable: true
  47624. });
  47625. return DefaultLoadingScreen;
  47626. }());
  47627. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].DefaultLoadingScreenFactory = function (canvas) { return new DefaultLoadingScreen(canvas); };
  47628. /***/ }),
  47629. /***/ "./Loading/sceneLoader.ts":
  47630. /*!********************************!*\
  47631. !*** ./Loading/sceneLoader.ts ***!
  47632. \********************************/
  47633. /*! exports provided: SceneLoaderProgressEvent, SceneLoader */
  47634. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47635. "use strict";
  47636. __webpack_require__.r(__webpack_exports__);
  47637. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return SceneLoaderProgressEvent; });
  47638. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return SceneLoader; });
  47639. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  47640. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  47641. /* harmony import */ var _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/filesInputStore */ "./Misc/filesInputStore.ts");
  47642. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  47643. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  47644. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  47645. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  47646. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  47647. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  47648. /**
  47649. * Class used to represent data loading progression
  47650. */
  47651. var SceneLoaderProgressEvent = /** @class */ (function () {
  47652. /**
  47653. * Create a new progress event
  47654. * @param lengthComputable defines if data length to load can be evaluated
  47655. * @param loaded defines the loaded data length
  47656. * @param total defines the data length to load
  47657. */
  47658. function SceneLoaderProgressEvent(
  47659. /** defines if data length to load can be evaluated */
  47660. lengthComputable,
  47661. /** defines the loaded data length */
  47662. loaded,
  47663. /** defines the data length to load */
  47664. total) {
  47665. this.lengthComputable = lengthComputable;
  47666. this.loaded = loaded;
  47667. this.total = total;
  47668. }
  47669. /**
  47670. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  47671. * @param event defines the source event
  47672. * @returns a new SceneLoaderProgressEvent
  47673. */
  47674. SceneLoaderProgressEvent.FromProgressEvent = function (event) {
  47675. return new SceneLoaderProgressEvent(event.lengthComputable, event.loaded, event.total);
  47676. };
  47677. return SceneLoaderProgressEvent;
  47678. }());
  47679. /**
  47680. * Class used to load scene from various file formats using registered plugins
  47681. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  47682. */
  47683. var SceneLoader = /** @class */ (function () {
  47684. function SceneLoader() {
  47685. }
  47686. Object.defineProperty(SceneLoader, "ForceFullSceneLoadingForIncremental", {
  47687. /**
  47688. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47689. */
  47690. get: function () {
  47691. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental;
  47692. },
  47693. set: function (value) {
  47694. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental = value;
  47695. },
  47696. enumerable: true,
  47697. configurable: true
  47698. });
  47699. Object.defineProperty(SceneLoader, "ShowLoadingScreen", {
  47700. /**
  47701. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47702. */
  47703. get: function () {
  47704. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen;
  47705. },
  47706. set: function (value) {
  47707. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen = value;
  47708. },
  47709. enumerable: true,
  47710. configurable: true
  47711. });
  47712. Object.defineProperty(SceneLoader, "loggingLevel", {
  47713. /**
  47714. * Defines the current logging level (while loading the scene)
  47715. * @ignorenaming
  47716. */
  47717. get: function () {
  47718. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel;
  47719. },
  47720. set: function (value) {
  47721. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel = value;
  47722. },
  47723. enumerable: true,
  47724. configurable: true
  47725. });
  47726. Object.defineProperty(SceneLoader, "CleanBoneMatrixWeights", {
  47727. /**
  47728. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47729. */
  47730. get: function () {
  47731. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights;
  47732. },
  47733. set: function (value) {
  47734. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights = value;
  47735. },
  47736. enumerable: true,
  47737. configurable: true
  47738. });
  47739. SceneLoader._getDefaultPlugin = function () {
  47740. return SceneLoader._registeredPlugins[".babylon"];
  47741. };
  47742. SceneLoader._getPluginForExtension = function (extension) {
  47743. var registeredPlugin = SceneLoader._registeredPlugins[extension];
  47744. if (registeredPlugin) {
  47745. return registeredPlugin;
  47746. }
  47747. _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");
  47748. return SceneLoader._getDefaultPlugin();
  47749. };
  47750. SceneLoader._getPluginForDirectLoad = function (data) {
  47751. for (var extension in SceneLoader._registeredPlugins) {
  47752. var plugin = SceneLoader._registeredPlugins[extension].plugin;
  47753. if (plugin.canDirectLoad && plugin.canDirectLoad(data)) {
  47754. return SceneLoader._registeredPlugins[extension];
  47755. }
  47756. }
  47757. return SceneLoader._getDefaultPlugin();
  47758. };
  47759. SceneLoader._getPluginForFilename = function (sceneFilename) {
  47760. var queryStringPosition = sceneFilename.indexOf("?");
  47761. if (queryStringPosition !== -1) {
  47762. sceneFilename = sceneFilename.substring(0, queryStringPosition);
  47763. }
  47764. var dotPosition = sceneFilename.lastIndexOf(".");
  47765. var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
  47766. return SceneLoader._getPluginForExtension(extension);
  47767. };
  47768. // use babylon file loader directly if sceneFilename is prefixed with "data:"
  47769. SceneLoader._getDirectLoad = function (sceneFilename) {
  47770. if (sceneFilename.substr(0, 5) === "data:") {
  47771. return sceneFilename.substr(5);
  47772. }
  47773. return null;
  47774. };
  47775. SceneLoader._loadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
  47776. var directLoad = SceneLoader._getDirectLoad(fileInfo.name);
  47777. var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(fileInfo.name) : SceneLoader._getPluginForFilename(fileInfo.name));
  47778. var plugin;
  47779. if (registeredPlugin.plugin.createPlugin) {
  47780. plugin = registeredPlugin.plugin.createPlugin();
  47781. }
  47782. else {
  47783. plugin = registeredPlugin.plugin;
  47784. }
  47785. var useArrayBuffer = registeredPlugin.isBinary;
  47786. var offlineProvider;
  47787. SceneLoader.OnPluginActivatedObservable.notifyObservers(plugin);
  47788. var dataCallback = function (data, responseURL) {
  47789. if (scene.isDisposed) {
  47790. onError("Scene has been disposed");
  47791. return;
  47792. }
  47793. scene.offlineProvider = offlineProvider;
  47794. onSuccess(plugin, data, responseURL);
  47795. };
  47796. var request = null;
  47797. var pluginDisposed = false;
  47798. var onDisposeObservable = plugin.onDisposeObservable;
  47799. if (onDisposeObservable) {
  47800. onDisposeObservable.add(function () {
  47801. pluginDisposed = true;
  47802. if (request) {
  47803. request.abort();
  47804. request = null;
  47805. }
  47806. onDispose();
  47807. });
  47808. }
  47809. var manifestChecked = function () {
  47810. if (pluginDisposed) {
  47811. return;
  47812. }
  47813. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(fileInfo.url, dataCallback, onProgress ? function (event) {
  47814. onProgress(SceneLoaderProgressEvent.FromProgressEvent(event));
  47815. } : undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  47816. onError("Failed to load scene." + (exception ? " " + exception.message : ""), exception);
  47817. });
  47818. };
  47819. if (directLoad) {
  47820. dataCallback(directLoad);
  47821. return plugin;
  47822. }
  47823. var file = fileInfo.file || _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad[fileInfo.name.toLowerCase()];
  47824. if (fileInfo.rootUrl.indexOf("file:") === -1 || (fileInfo.rootUrl.indexOf("file:") !== -1 && !file)) {
  47825. var engine = scene.getEngine();
  47826. var canUseOfflineSupport = engine.enableOfflineSupport;
  47827. if (canUseOfflineSupport) {
  47828. // Also check for exceptions
  47829. var exceptionFound = false;
  47830. for (var _i = 0, _a = scene.disableOfflineSupportExceptionRules; _i < _a.length; _i++) {
  47831. var regex = _a[_i];
  47832. if (regex.test(fileInfo.url)) {
  47833. exceptionFound = true;
  47834. break;
  47835. }
  47836. }
  47837. canUseOfflineSupport = !exceptionFound;
  47838. }
  47839. if (canUseOfflineSupport && _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory) {
  47840. // Checking if a manifest file has been set for this scene and if offline mode has been requested
  47841. offlineProvider = _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory(fileInfo.url, manifestChecked, engine.disableManifestCheck);
  47842. }
  47843. else {
  47844. manifestChecked();
  47845. }
  47846. }
  47847. // Loading file from disk via input file or drag'n'drop
  47848. else {
  47849. if (file) {
  47850. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ReadFile(file, dataCallback, onProgress, useArrayBuffer);
  47851. }
  47852. else {
  47853. onError("Unable to find file named " + fileInfo.name);
  47854. }
  47855. }
  47856. return plugin;
  47857. };
  47858. SceneLoader._getFileInfo = function (rootUrl, sceneFilename) {
  47859. var url;
  47860. var name;
  47861. var file = null;
  47862. if (!sceneFilename) {
  47863. url = rootUrl;
  47864. name = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(rootUrl);
  47865. rootUrl = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFolderPath(rootUrl);
  47866. }
  47867. else if (sceneFilename.lastModified) {
  47868. var sceneFile = sceneFilename;
  47869. url = rootUrl + sceneFile.name;
  47870. name = sceneFile.name;
  47871. file = sceneFile;
  47872. }
  47873. else {
  47874. var filename = sceneFilename;
  47875. if (filename.substr(0, 1) === "/") {
  47876. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Wrong sceneFilename parameter");
  47877. return null;
  47878. }
  47879. url = rootUrl + filename;
  47880. name = filename;
  47881. }
  47882. return {
  47883. url: url,
  47884. rootUrl: rootUrl,
  47885. name: name,
  47886. file: file
  47887. };
  47888. };
  47889. // Public functions
  47890. /**
  47891. * Gets a plugin that can load the given extension
  47892. * @param extension defines the extension to load
  47893. * @returns a plugin or null if none works
  47894. */
  47895. SceneLoader.GetPluginForExtension = function (extension) {
  47896. return SceneLoader._getPluginForExtension(extension).plugin;
  47897. };
  47898. /**
  47899. * Gets a boolean indicating that the given extension can be loaded
  47900. * @param extension defines the extension to load
  47901. * @returns true if the extension is supported
  47902. */
  47903. SceneLoader.IsPluginForExtensionAvailable = function (extension) {
  47904. return !!SceneLoader._registeredPlugins[extension];
  47905. };
  47906. /**
  47907. * Adds a new plugin to the list of registered plugins
  47908. * @param plugin defines the plugin to add
  47909. */
  47910. SceneLoader.RegisterPlugin = function (plugin) {
  47911. if (typeof plugin.extensions === "string") {
  47912. var extension = plugin.extensions;
  47913. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  47914. plugin: plugin,
  47915. isBinary: false
  47916. };
  47917. }
  47918. else {
  47919. var extensions = plugin.extensions;
  47920. Object.keys(extensions).forEach(function (extension) {
  47921. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  47922. plugin: plugin,
  47923. isBinary: extensions[extension].isBinary
  47924. };
  47925. });
  47926. }
  47927. };
  47928. /**
  47929. * Import meshes into a scene
  47930. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47931. * @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)
  47932. * @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)
  47933. * @param scene the instance of BABYLON.Scene to append to
  47934. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47935. * @param onProgress a callback with a progress event for each file being loaded
  47936. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47937. * @param pluginExtension the extension used to determine the plugin
  47938. * @returns The loaded plugin
  47939. */
  47940. SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  47941. if (sceneFilename === void 0) { sceneFilename = ""; }
  47942. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  47943. if (onSuccess === void 0) { onSuccess = null; }
  47944. if (onProgress === void 0) { onProgress = null; }
  47945. if (onError === void 0) { onError = null; }
  47946. if (pluginExtension === void 0) { pluginExtension = null; }
  47947. if (!scene) {
  47948. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to import mesh to");
  47949. return null;
  47950. }
  47951. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  47952. if (!fileInfo) {
  47953. return null;
  47954. }
  47955. var loadingToken = {};
  47956. scene._addPendingData(loadingToken);
  47957. var disposeHandler = function () {
  47958. scene._removePendingData(loadingToken);
  47959. };
  47960. var errorHandler = function (message, exception) {
  47961. var errorMessage = "Unable to import meshes from " + fileInfo.url + ": " + message;
  47962. if (onError) {
  47963. onError(scene, errorMessage, exception);
  47964. }
  47965. else {
  47966. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  47967. // should the exception be thrown?
  47968. }
  47969. disposeHandler();
  47970. };
  47971. var progressHandler = onProgress ? function (event) {
  47972. try {
  47973. onProgress(event);
  47974. }
  47975. catch (e) {
  47976. errorHandler("Error in onProgress callback", e);
  47977. }
  47978. } : undefined;
  47979. var successHandler = function (meshes, particleSystems, skeletons, animationGroups) {
  47980. scene.importedMeshesFiles.push(fileInfo.url);
  47981. if (onSuccess) {
  47982. try {
  47983. onSuccess(meshes, particleSystems, skeletons, animationGroups);
  47984. }
  47985. catch (e) {
  47986. errorHandler("Error in onSuccess callback", e);
  47987. }
  47988. }
  47989. scene._removePendingData(loadingToken);
  47990. };
  47991. return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
  47992. if (plugin.rewriteRootURL) {
  47993. fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
  47994. }
  47995. if (plugin.importMesh) {
  47996. var syncedPlugin = plugin;
  47997. var meshes = new Array();
  47998. var particleSystems = new Array();
  47999. var skeletons = new Array();
  48000. if (!syncedPlugin.importMesh(meshNames, scene, data, fileInfo.rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
  48001. return;
  48002. }
  48003. scene.loadingPluginName = plugin.name;
  48004. successHandler(meshes, particleSystems, skeletons, []);
  48005. }
  48006. else {
  48007. var asyncedPlugin = plugin;
  48008. asyncedPlugin.importMeshAsync(meshNames, scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (result) {
  48009. scene.loadingPluginName = plugin.name;
  48010. successHandler(result.meshes, result.particleSystems, result.skeletons, result.animationGroups);
  48011. }).catch(function (error) {
  48012. errorHandler(error.message, error);
  48013. });
  48014. }
  48015. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  48016. };
  48017. /**
  48018. * Import meshes into a scene
  48019. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48020. * @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)
  48021. * @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)
  48022. * @param scene the instance of BABYLON.Scene to append to
  48023. * @param onProgress a callback with a progress event for each file being loaded
  48024. * @param pluginExtension the extension used to determine the plugin
  48025. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48026. */
  48027. SceneLoader.ImportMeshAsync = function (meshNames, rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  48028. if (sceneFilename === void 0) { sceneFilename = ""; }
  48029. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48030. if (onProgress === void 0) { onProgress = null; }
  48031. if (pluginExtension === void 0) { pluginExtension = null; }
  48032. return new Promise(function (resolve, reject) {
  48033. SceneLoader.ImportMesh(meshNames, rootUrl, sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  48034. resolve({
  48035. meshes: meshes,
  48036. particleSystems: particleSystems,
  48037. skeletons: skeletons,
  48038. animationGroups: animationGroups
  48039. });
  48040. }, onProgress, function (scene, message, exception) {
  48041. reject(exception || new Error(message));
  48042. }, pluginExtension);
  48043. });
  48044. };
  48045. /**
  48046. * Load a scene
  48047. * @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)
  48048. * @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)
  48049. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48050. * @param onSuccess a callback with the scene when import succeeds
  48051. * @param onProgress a callback with a progress event for each file being loaded
  48052. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48053. * @param pluginExtension the extension used to determine the plugin
  48054. * @returns The loaded plugin
  48055. */
  48056. SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
  48057. if (sceneFilename === void 0) { sceneFilename = ""; }
  48058. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  48059. if (onSuccess === void 0) { onSuccess = null; }
  48060. if (onProgress === void 0) { onProgress = null; }
  48061. if (onError === void 0) { onError = null; }
  48062. if (pluginExtension === void 0) { pluginExtension = null; }
  48063. if (!engine) {
  48064. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("No engine available");
  48065. return null;
  48066. }
  48067. return SceneLoader.Append(rootUrl, sceneFilename, new _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"](engine), onSuccess, onProgress, onError, pluginExtension);
  48068. };
  48069. /**
  48070. * Load a scene
  48071. * @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)
  48072. * @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)
  48073. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48074. * @param onProgress a callback with a progress event for each file being loaded
  48075. * @param pluginExtension the extension used to determine the plugin
  48076. * @returns The loaded scene
  48077. */
  48078. SceneLoader.LoadAsync = function (rootUrl, sceneFilename, engine, onProgress, pluginExtension) {
  48079. if (sceneFilename === void 0) { sceneFilename = ""; }
  48080. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  48081. if (onProgress === void 0) { onProgress = null; }
  48082. if (pluginExtension === void 0) { pluginExtension = null; }
  48083. return new Promise(function (resolve, reject) {
  48084. SceneLoader.Load(rootUrl, sceneFilename, engine, function (scene) {
  48085. resolve(scene);
  48086. }, onProgress, function (scene, message, exception) {
  48087. reject(exception || new Error(message));
  48088. }, pluginExtension);
  48089. });
  48090. };
  48091. /**
  48092. * Append a scene
  48093. * @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)
  48094. * @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)
  48095. * @param scene is the instance of BABYLON.Scene to append to
  48096. * @param onSuccess a callback with the scene when import succeeds
  48097. * @param onProgress a callback with a progress event for each file being loaded
  48098. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48099. * @param pluginExtension the extension used to determine the plugin
  48100. * @returns The loaded plugin
  48101. */
  48102. SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  48103. if (sceneFilename === void 0) { sceneFilename = ""; }
  48104. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48105. if (onSuccess === void 0) { onSuccess = null; }
  48106. if (onProgress === void 0) { onProgress = null; }
  48107. if (onError === void 0) { onError = null; }
  48108. if (pluginExtension === void 0) { pluginExtension = null; }
  48109. if (!scene) {
  48110. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to append to");
  48111. return null;
  48112. }
  48113. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  48114. if (!fileInfo) {
  48115. return null;
  48116. }
  48117. if (SceneLoader.ShowLoadingScreen) {
  48118. scene.getEngine().displayLoadingUI();
  48119. }
  48120. var loadingToken = {};
  48121. scene._addPendingData(loadingToken);
  48122. var disposeHandler = function () {
  48123. scene._removePendingData(loadingToken);
  48124. scene.getEngine().hideLoadingUI();
  48125. };
  48126. var errorHandler = function (message, exception) {
  48127. var errorMessage = "Unable to load from " + fileInfo.url + (message ? ": " + message : "");
  48128. if (onError) {
  48129. onError(scene, errorMessage, exception);
  48130. }
  48131. else {
  48132. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  48133. // should the exception be thrown?
  48134. }
  48135. disposeHandler();
  48136. };
  48137. var progressHandler = onProgress ? function (event) {
  48138. try {
  48139. onProgress(event);
  48140. }
  48141. catch (e) {
  48142. errorHandler("Error in onProgress callback", e);
  48143. }
  48144. } : undefined;
  48145. var successHandler = function () {
  48146. if (onSuccess) {
  48147. try {
  48148. onSuccess(scene);
  48149. }
  48150. catch (e) {
  48151. errorHandler("Error in onSuccess callback", e);
  48152. }
  48153. }
  48154. scene._removePendingData(loadingToken);
  48155. };
  48156. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  48157. if (plugin.load) {
  48158. var syncedPlugin = plugin;
  48159. if (!syncedPlugin.load(scene, data, fileInfo.rootUrl, errorHandler)) {
  48160. return;
  48161. }
  48162. scene.loadingPluginName = plugin.name;
  48163. successHandler();
  48164. }
  48165. else {
  48166. var asyncedPlugin = plugin;
  48167. asyncedPlugin.loadAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function () {
  48168. scene.loadingPluginName = plugin.name;
  48169. successHandler();
  48170. }).catch(function (error) {
  48171. errorHandler(error.message, error);
  48172. });
  48173. }
  48174. if (SceneLoader.ShowLoadingScreen) {
  48175. scene.executeWhenReady(function () {
  48176. scene.getEngine().hideLoadingUI();
  48177. });
  48178. }
  48179. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  48180. };
  48181. /**
  48182. * Append a scene
  48183. * @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)
  48184. * @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)
  48185. * @param scene is the instance of BABYLON.Scene to append to
  48186. * @param onProgress a callback with a progress event for each file being loaded
  48187. * @param pluginExtension the extension used to determine the plugin
  48188. * @returns The given scene
  48189. */
  48190. SceneLoader.AppendAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  48191. if (sceneFilename === void 0) { sceneFilename = ""; }
  48192. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48193. if (onProgress === void 0) { onProgress = null; }
  48194. if (pluginExtension === void 0) { pluginExtension = null; }
  48195. return new Promise(function (resolve, reject) {
  48196. SceneLoader.Append(rootUrl, sceneFilename, scene, function (scene) {
  48197. resolve(scene);
  48198. }, onProgress, function (scene, message, exception) {
  48199. reject(exception || new Error(message));
  48200. }, pluginExtension);
  48201. });
  48202. };
  48203. /**
  48204. * Load a scene into an asset container
  48205. * @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)
  48206. * @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)
  48207. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48208. * @param onSuccess a callback with the scene when import succeeds
  48209. * @param onProgress a callback with a progress event for each file being loaded
  48210. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48211. * @param pluginExtension the extension used to determine the plugin
  48212. * @returns The loaded plugin
  48213. */
  48214. SceneLoader.LoadAssetContainer = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  48215. if (sceneFilename === void 0) { sceneFilename = ""; }
  48216. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48217. if (onSuccess === void 0) { onSuccess = null; }
  48218. if (onProgress === void 0) { onProgress = null; }
  48219. if (onError === void 0) { onError = null; }
  48220. if (pluginExtension === void 0) { pluginExtension = null; }
  48221. if (!scene) {
  48222. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to load asset container to");
  48223. return null;
  48224. }
  48225. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  48226. if (!fileInfo) {
  48227. return null;
  48228. }
  48229. var loadingToken = {};
  48230. scene._addPendingData(loadingToken);
  48231. var disposeHandler = function () {
  48232. scene._removePendingData(loadingToken);
  48233. };
  48234. var errorHandler = function (message, exception) {
  48235. var errorMessage = "Unable to load assets from " + fileInfo.url + (message ? ": " + message : "");
  48236. if (onError) {
  48237. onError(scene, errorMessage, exception);
  48238. }
  48239. else {
  48240. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  48241. // should the exception be thrown?
  48242. }
  48243. disposeHandler();
  48244. };
  48245. var progressHandler = onProgress ? function (event) {
  48246. try {
  48247. onProgress(event);
  48248. }
  48249. catch (e) {
  48250. errorHandler("Error in onProgress callback", e);
  48251. }
  48252. } : undefined;
  48253. var successHandler = function (assets) {
  48254. if (onSuccess) {
  48255. try {
  48256. onSuccess(assets);
  48257. }
  48258. catch (e) {
  48259. errorHandler("Error in onSuccess callback", e);
  48260. }
  48261. }
  48262. scene._removePendingData(loadingToken);
  48263. };
  48264. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  48265. if (plugin.loadAssetContainer) {
  48266. var syncedPlugin = plugin;
  48267. var assetContainer = syncedPlugin.loadAssetContainer(scene, data, fileInfo.rootUrl, errorHandler);
  48268. if (!assetContainer) {
  48269. return;
  48270. }
  48271. scene.loadingPluginName = plugin.name;
  48272. successHandler(assetContainer);
  48273. }
  48274. else if (plugin.loadAssetContainerAsync) {
  48275. var asyncedPlugin = plugin;
  48276. asyncedPlugin.loadAssetContainerAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (assetContainer) {
  48277. scene.loadingPluginName = plugin.name;
  48278. successHandler(assetContainer);
  48279. }).catch(function (error) {
  48280. errorHandler(error.message, error);
  48281. });
  48282. }
  48283. else {
  48284. errorHandler("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");
  48285. }
  48286. if (SceneLoader.ShowLoadingScreen) {
  48287. scene.executeWhenReady(function () {
  48288. scene.getEngine().hideLoadingUI();
  48289. });
  48290. }
  48291. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  48292. };
  48293. /**
  48294. * Load a scene into an asset container
  48295. * @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)
  48296. * @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)
  48297. * @param scene is the instance of Scene to append to
  48298. * @param onProgress a callback with a progress event for each file being loaded
  48299. * @param pluginExtension the extension used to determine the plugin
  48300. * @returns The loaded asset container
  48301. */
  48302. SceneLoader.LoadAssetContainerAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  48303. if (sceneFilename === void 0) { sceneFilename = ""; }
  48304. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48305. if (onProgress === void 0) { onProgress = null; }
  48306. if (pluginExtension === void 0) { pluginExtension = null; }
  48307. return new Promise(function (resolve, reject) {
  48308. SceneLoader.LoadAssetContainer(rootUrl, sceneFilename, scene, function (assetContainer) {
  48309. resolve(assetContainer);
  48310. }, onProgress, function (scene, message, exception) {
  48311. reject(exception || new Error(message));
  48312. }, pluginExtension);
  48313. });
  48314. };
  48315. /**
  48316. * No logging while loading
  48317. */
  48318. SceneLoader.NO_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_NO_LOGGING;
  48319. /**
  48320. * Minimal logging while loading
  48321. */
  48322. SceneLoader.MINIMAL_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_MINIMAL_LOGGING;
  48323. /**
  48324. * Summary logging while loading
  48325. */
  48326. SceneLoader.SUMMARY_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_SUMMARY_LOGGING;
  48327. /**
  48328. * Detailled logging while loading
  48329. */
  48330. SceneLoader.DETAILED_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_DETAILED_LOGGING;
  48331. // Members
  48332. /**
  48333. * Event raised when a plugin is used to load a scene
  48334. */
  48335. SceneLoader.OnPluginActivatedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  48336. SceneLoader._registeredPlugins = {};
  48337. return SceneLoader;
  48338. }());
  48339. /***/ }),
  48340. /***/ "./Loading/sceneLoaderFlags.ts":
  48341. /*!*************************************!*\
  48342. !*** ./Loading/sceneLoaderFlags.ts ***!
  48343. \*************************************/
  48344. /*! exports provided: SceneLoaderFlags */
  48345. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48346. "use strict";
  48347. __webpack_require__.r(__webpack_exports__);
  48348. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return SceneLoaderFlags; });
  48349. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  48350. /**
  48351. * Class used to represent data loading progression
  48352. */
  48353. var SceneLoaderFlags = /** @class */ (function () {
  48354. function SceneLoaderFlags() {
  48355. }
  48356. Object.defineProperty(SceneLoaderFlags, "ForceFullSceneLoadingForIncremental", {
  48357. /**
  48358. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48359. */
  48360. get: function () {
  48361. return SceneLoaderFlags._ForceFullSceneLoadingForIncremental;
  48362. },
  48363. set: function (value) {
  48364. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = value;
  48365. },
  48366. enumerable: true,
  48367. configurable: true
  48368. });
  48369. Object.defineProperty(SceneLoaderFlags, "ShowLoadingScreen", {
  48370. /**
  48371. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48372. */
  48373. get: function () {
  48374. return SceneLoaderFlags._ShowLoadingScreen;
  48375. },
  48376. set: function (value) {
  48377. SceneLoaderFlags._ShowLoadingScreen = value;
  48378. },
  48379. enumerable: true,
  48380. configurable: true
  48381. });
  48382. Object.defineProperty(SceneLoaderFlags, "loggingLevel", {
  48383. /**
  48384. * Defines the current logging level (while loading the scene)
  48385. * @ignorenaming
  48386. */
  48387. get: function () {
  48388. return SceneLoaderFlags._loggingLevel;
  48389. },
  48390. set: function (value) {
  48391. SceneLoaderFlags._loggingLevel = value;
  48392. },
  48393. enumerable: true,
  48394. configurable: true
  48395. });
  48396. Object.defineProperty(SceneLoaderFlags, "CleanBoneMatrixWeights", {
  48397. /**
  48398. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48399. */
  48400. get: function () {
  48401. return SceneLoaderFlags._CleanBoneMatrixWeights;
  48402. },
  48403. set: function (value) {
  48404. SceneLoaderFlags._CleanBoneMatrixWeights = value;
  48405. },
  48406. enumerable: true,
  48407. configurable: true
  48408. });
  48409. // Flags
  48410. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = false;
  48411. SceneLoaderFlags._ShowLoadingScreen = true;
  48412. SceneLoaderFlags._CleanBoneMatrixWeights = false;
  48413. SceneLoaderFlags._loggingLevel = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].SCENELOADER_NO_LOGGING;
  48414. return SceneLoaderFlags;
  48415. }());
  48416. /***/ }),
  48417. /***/ "./Materials/Background/backgroundMaterial.ts":
  48418. /*!****************************************************!*\
  48419. !*** ./Materials/Background/backgroundMaterial.ts ***!
  48420. \****************************************************/
  48421. /*! exports provided: BackgroundMaterial */
  48422. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48423. "use strict";
  48424. __webpack_require__.r(__webpack_exports__);
  48425. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return BackgroundMaterial; });
  48426. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  48427. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  48428. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  48429. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  48430. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  48431. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  48432. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  48433. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  48434. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  48435. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  48436. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  48437. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  48438. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  48439. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  48440. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  48441. /* harmony import */ var _Shaders_background_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Shaders/background.fragment */ "./Shaders/background.fragment.ts");
  48442. /* harmony import */ var _Shaders_background_vertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/background.vertex */ "./Shaders/background.vertex.ts");
  48443. /**
  48444. * Background material defines definition.
  48445. * @hidden Mainly internal Use
  48446. */
  48447. var BackgroundMaterialDefines = /** @class */ (function (_super) {
  48448. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterialDefines, _super);
  48449. /**
  48450. * Constructor of the defines.
  48451. */
  48452. function BackgroundMaterialDefines() {
  48453. var _this = _super.call(this) || this;
  48454. /**
  48455. * True if the diffuse texture is in use.
  48456. */
  48457. _this.DIFFUSE = false;
  48458. /**
  48459. * The direct UV channel to use.
  48460. */
  48461. _this.DIFFUSEDIRECTUV = 0;
  48462. /**
  48463. * True if the diffuse texture is in gamma space.
  48464. */
  48465. _this.GAMMADIFFUSE = false;
  48466. /**
  48467. * True if the diffuse texture has opacity in the alpha channel.
  48468. */
  48469. _this.DIFFUSEHASALPHA = false;
  48470. /**
  48471. * True if you want the material to fade to transparent at grazing angle.
  48472. */
  48473. _this.OPACITYFRESNEL = false;
  48474. /**
  48475. * True if an extra blur needs to be added in the reflection.
  48476. */
  48477. _this.REFLECTIONBLUR = false;
  48478. /**
  48479. * True if you want the material to fade to reflection at grazing angle.
  48480. */
  48481. _this.REFLECTIONFRESNEL = false;
  48482. /**
  48483. * True if you want the material to falloff as far as you move away from the scene center.
  48484. */
  48485. _this.REFLECTIONFALLOFF = false;
  48486. /**
  48487. * False if the current Webgl implementation does not support the texture lod extension.
  48488. */
  48489. _this.TEXTURELODSUPPORT = false;
  48490. /**
  48491. * True to ensure the data are premultiplied.
  48492. */
  48493. _this.PREMULTIPLYALPHA = false;
  48494. /**
  48495. * True if the texture contains cooked RGB values and not gray scaled multipliers.
  48496. */
  48497. _this.USERGBCOLOR = false;
  48498. /**
  48499. * True if highlight and shadow levels have been specified. It can help ensuring the main perceived color
  48500. * stays aligned with the desired configuration.
  48501. */
  48502. _this.USEHIGHLIGHTANDSHADOWCOLORS = false;
  48503. /**
  48504. * True to add noise in order to reduce the banding effect.
  48505. */
  48506. _this.NOISE = false;
  48507. /**
  48508. * is the reflection texture in BGR color scheme?
  48509. * Mainly used to solve a bug in ios10 video tag
  48510. */
  48511. _this.REFLECTIONBGR = false;
  48512. _this.IMAGEPROCESSING = false;
  48513. _this.VIGNETTE = false;
  48514. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  48515. _this.VIGNETTEBLENDMODEOPAQUE = false;
  48516. _this.TONEMAPPING = false;
  48517. _this.TONEMAPPING_ACES = false;
  48518. _this.CONTRAST = false;
  48519. _this.COLORCURVES = false;
  48520. _this.COLORGRADING = false;
  48521. _this.COLORGRADING3D = false;
  48522. _this.SAMPLER3DGREENDEPTH = false;
  48523. _this.SAMPLER3DBGRMAP = false;
  48524. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  48525. _this.EXPOSURE = false;
  48526. // Reflection.
  48527. _this.REFLECTION = false;
  48528. _this.REFLECTIONMAP_3D = false;
  48529. _this.REFLECTIONMAP_SPHERICAL = false;
  48530. _this.REFLECTIONMAP_PLANAR = false;
  48531. _this.REFLECTIONMAP_CUBIC = false;
  48532. _this.REFLECTIONMAP_PROJECTION = false;
  48533. _this.REFLECTIONMAP_SKYBOX = false;
  48534. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  48535. _this.REFLECTIONMAP_EXPLICIT = false;
  48536. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  48537. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  48538. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  48539. _this.INVERTCUBICMAP = false;
  48540. _this.REFLECTIONMAP_OPPOSITEZ = false;
  48541. _this.LODINREFLECTIONALPHA = false;
  48542. _this.GAMMAREFLECTION = false;
  48543. _this.RGBDREFLECTION = false;
  48544. _this.EQUIRECTANGULAR_RELFECTION_FOV = false;
  48545. // Default BJS.
  48546. _this.MAINUV1 = false;
  48547. _this.MAINUV2 = false;
  48548. _this.UV1 = false;
  48549. _this.UV2 = false;
  48550. _this.CLIPPLANE = false;
  48551. _this.CLIPPLANE2 = false;
  48552. _this.CLIPPLANE3 = false;
  48553. _this.CLIPPLANE4 = false;
  48554. _this.POINTSIZE = false;
  48555. _this.FOG = false;
  48556. _this.NORMAL = false;
  48557. _this.NUM_BONE_INFLUENCERS = 0;
  48558. _this.BonesPerMesh = 0;
  48559. _this.INSTANCES = false;
  48560. _this.SHADOWFLOAT = false;
  48561. _this.rebuild();
  48562. return _this;
  48563. }
  48564. return BackgroundMaterialDefines;
  48565. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  48566. /**
  48567. * Background material used to create an efficient environement around your scene.
  48568. */
  48569. var BackgroundMaterial = /** @class */ (function (_super) {
  48570. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterial, _super);
  48571. /**
  48572. * Instantiates a Background Material in the given scene
  48573. * @param name The friendly name of the material
  48574. * @param scene The scene to add the material to
  48575. */
  48576. function BackgroundMaterial(name, scene) {
  48577. var _this = _super.call(this, name, scene) || this;
  48578. /**
  48579. * Key light Color (multiply against the environement texture)
  48580. */
  48581. _this.primaryColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  48582. _this._primaryColorShadowLevel = 0;
  48583. _this._primaryColorHighlightLevel = 0;
  48584. /**
  48585. * Reflection Texture used in the material.
  48586. * Should be author in a specific way for the best result (refer to the documentation).
  48587. */
  48588. _this.reflectionTexture = null;
  48589. /**
  48590. * Reflection Texture level of blur.
  48591. *
  48592. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48593. * texture twice.
  48594. */
  48595. _this.reflectionBlur = 0;
  48596. /**
  48597. * Diffuse Texture used in the material.
  48598. * Should be author in a specific way for the best result (refer to the documentation).
  48599. */
  48600. _this.diffuseTexture = null;
  48601. _this._shadowLights = null;
  48602. /**
  48603. * Specify the list of lights casting shadow on the material.
  48604. * All scene shadow lights will be included if null.
  48605. */
  48606. _this.shadowLights = null;
  48607. /**
  48608. * Helps adjusting the shadow to a softer level if required.
  48609. * 0 means black shadows and 1 means no shadows.
  48610. */
  48611. _this.shadowLevel = 0;
  48612. /**
  48613. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48614. * It is usually zero but might be interesting to modify according to your setup.
  48615. */
  48616. _this.sceneCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  48617. /**
  48618. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48619. * This helps ensuring a nice transition when the camera goes under the ground.
  48620. */
  48621. _this.opacityFresnel = true;
  48622. /**
  48623. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48624. * This helps adding a mirror texture on the ground.
  48625. */
  48626. _this.reflectionFresnel = false;
  48627. /**
  48628. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48629. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48630. */
  48631. _this.reflectionFalloffDistance = 0.0;
  48632. /**
  48633. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48634. */
  48635. _this.reflectionAmount = 1.0;
  48636. /**
  48637. * This specifies the weight of the reflection at grazing angle.
  48638. */
  48639. _this.reflectionReflectance0 = 0.05;
  48640. /**
  48641. * This specifies the weight of the reflection at a perpendicular point of view.
  48642. */
  48643. _this.reflectionReflectance90 = 0.5;
  48644. /**
  48645. * Helps to directly use the maps channels instead of their level.
  48646. */
  48647. _this.useRGBColor = true;
  48648. /**
  48649. * This helps reducing the banding effect that could occur on the background.
  48650. */
  48651. _this.enableNoise = false;
  48652. _this._fovMultiplier = 1.0;
  48653. /**
  48654. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48655. */
  48656. _this.useEquirectangularFOV = false;
  48657. _this._maxSimultaneousLights = 4;
  48658. /**
  48659. * Number of Simultaneous lights allowed on the material.
  48660. */
  48661. _this.maxSimultaneousLights = 4;
  48662. /**
  48663. * Keep track of the image processing observer to allow dispose and replace.
  48664. */
  48665. _this._imageProcessingObserver = null;
  48666. /**
  48667. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48668. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48669. */
  48670. _this.switchToBGR = false;
  48671. // Temp values kept as cache in the material.
  48672. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  48673. _this._reflectionControls = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector4"].Zero();
  48674. _this._white = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  48675. _this._primaryShadowColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  48676. _this._primaryHighlightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  48677. // Setup the default processing configuration to the scene.
  48678. _this._attachImageProcessingConfiguration(null);
  48679. _this.getRenderTargetTextures = function () {
  48680. _this._renderTargets.reset();
  48681. if (_this._diffuseTexture && _this._diffuseTexture.isRenderTarget) {
  48682. _this._renderTargets.push(_this._diffuseTexture);
  48683. }
  48684. if (_this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  48685. _this._renderTargets.push(_this._reflectionTexture);
  48686. }
  48687. return _this._renderTargets;
  48688. };
  48689. return _this;
  48690. }
  48691. Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
  48692. /**
  48693. * Experimental Internal Use Only.
  48694. *
  48695. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48696. * This acts as a helper to set the primary color to a more "human friendly" value.
  48697. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48698. * output color as close as possible from the chosen value.
  48699. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48700. * part of lighting setup.)
  48701. */
  48702. get: function () {
  48703. return this.__perceptualColor;
  48704. },
  48705. set: function (value) {
  48706. this.__perceptualColor = value;
  48707. this._computePrimaryColorFromPerceptualColor();
  48708. this._markAllSubMeshesAsLightsDirty();
  48709. },
  48710. enumerable: true,
  48711. configurable: true
  48712. });
  48713. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorShadowLevel", {
  48714. /**
  48715. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48716. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48717. */
  48718. get: function () {
  48719. return this._primaryColorShadowLevel;
  48720. },
  48721. set: function (value) {
  48722. this._primaryColorShadowLevel = value;
  48723. this._computePrimaryColors();
  48724. this._markAllSubMeshesAsLightsDirty();
  48725. },
  48726. enumerable: true,
  48727. configurable: true
  48728. });
  48729. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorHighlightLevel", {
  48730. /**
  48731. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48732. * The primary color is used at the level chosen to define what the white area would look.
  48733. */
  48734. get: function () {
  48735. return this._primaryColorHighlightLevel;
  48736. },
  48737. set: function (value) {
  48738. this._primaryColorHighlightLevel = value;
  48739. this._computePrimaryColors();
  48740. this._markAllSubMeshesAsLightsDirty();
  48741. },
  48742. enumerable: true,
  48743. configurable: true
  48744. });
  48745. Object.defineProperty(BackgroundMaterial.prototype, "reflectionStandardFresnelWeight", {
  48746. /**
  48747. * Sets the reflection reflectance fresnel values according to the default standard
  48748. * empirically know to work well :-)
  48749. */
  48750. set: function (value) {
  48751. var reflectionWeight = value;
  48752. if (reflectionWeight < 0.5) {
  48753. reflectionWeight = reflectionWeight * 2.0;
  48754. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 * reflectionWeight;
  48755. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 * reflectionWeight;
  48756. }
  48757. else {
  48758. reflectionWeight = reflectionWeight * 2.0 - 1.0;
  48759. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 + (1.0 - BackgroundMaterial.StandardReflectance0) * reflectionWeight;
  48760. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 + (1.0 - BackgroundMaterial.StandardReflectance90) * reflectionWeight;
  48761. }
  48762. },
  48763. enumerable: true,
  48764. configurable: true
  48765. });
  48766. Object.defineProperty(BackgroundMaterial.prototype, "fovMultiplier", {
  48767. /**
  48768. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48769. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48770. * Recommended to be keep at 1.0 except for special cases.
  48771. */
  48772. get: function () {
  48773. return this._fovMultiplier;
  48774. },
  48775. set: function (value) {
  48776. if (isNaN(value)) {
  48777. value = 1.0;
  48778. }
  48779. this._fovMultiplier = Math.max(0.0, Math.min(2.0, value));
  48780. },
  48781. enumerable: true,
  48782. configurable: true
  48783. });
  48784. /**
  48785. * Attaches a new image processing configuration to the PBR Material.
  48786. * @param configuration (if null the scene configuration will be use)
  48787. */
  48788. BackgroundMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  48789. var _this = this;
  48790. if (configuration === this._imageProcessingConfiguration) {
  48791. return;
  48792. }
  48793. // Detaches observer.
  48794. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  48795. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  48796. }
  48797. // Pick the scene configuration if needed.
  48798. if (!configuration) {
  48799. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  48800. }
  48801. else {
  48802. this._imageProcessingConfiguration = configuration;
  48803. }
  48804. // Attaches observer.
  48805. if (this._imageProcessingConfiguration) {
  48806. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  48807. _this._computePrimaryColorFromPerceptualColor();
  48808. _this._markAllSubMeshesAsImageProcessingDirty();
  48809. });
  48810. }
  48811. };
  48812. Object.defineProperty(BackgroundMaterial.prototype, "imageProcessingConfiguration", {
  48813. /**
  48814. * Gets the image processing configuration used either in this material.
  48815. */
  48816. get: function () {
  48817. return this._imageProcessingConfiguration;
  48818. },
  48819. /**
  48820. * Sets the Default image processing configuration used either in the this material.
  48821. *
  48822. * If sets to null, the scene one is in use.
  48823. */
  48824. set: function (value) {
  48825. this._attachImageProcessingConfiguration(value);
  48826. // Ensure the effect will be rebuilt.
  48827. this._markAllSubMeshesAsTexturesDirty();
  48828. },
  48829. enumerable: true,
  48830. configurable: true
  48831. });
  48832. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurvesEnabled", {
  48833. /**
  48834. * Gets wether the color curves effect is enabled.
  48835. */
  48836. get: function () {
  48837. return this.imageProcessingConfiguration.colorCurvesEnabled;
  48838. },
  48839. /**
  48840. * Sets wether the color curves effect is enabled.
  48841. */
  48842. set: function (value) {
  48843. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  48844. },
  48845. enumerable: true,
  48846. configurable: true
  48847. });
  48848. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingEnabled", {
  48849. /**
  48850. * Gets wether the color grading effect is enabled.
  48851. */
  48852. get: function () {
  48853. return this.imageProcessingConfiguration.colorGradingEnabled;
  48854. },
  48855. /**
  48856. * Gets wether the color grading effect is enabled.
  48857. */
  48858. set: function (value) {
  48859. this.imageProcessingConfiguration.colorGradingEnabled = value;
  48860. },
  48861. enumerable: true,
  48862. configurable: true
  48863. });
  48864. Object.defineProperty(BackgroundMaterial.prototype, "cameraToneMappingEnabled", {
  48865. /**
  48866. * Gets wether tonemapping is enabled or not.
  48867. */
  48868. get: function () {
  48869. return this._imageProcessingConfiguration.toneMappingEnabled;
  48870. },
  48871. /**
  48872. * Sets wether tonemapping is enabled or not
  48873. */
  48874. set: function (value) {
  48875. this._imageProcessingConfiguration.toneMappingEnabled = value;
  48876. },
  48877. enumerable: true,
  48878. configurable: true
  48879. });
  48880. Object.defineProperty(BackgroundMaterial.prototype, "cameraExposure", {
  48881. /**
  48882. * The camera exposure used on this material.
  48883. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48884. * This corresponds to a photographic exposure.
  48885. */
  48886. get: function () {
  48887. return this._imageProcessingConfiguration.exposure;
  48888. },
  48889. /**
  48890. * The camera exposure used on this material.
  48891. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48892. * This corresponds to a photographic exposure.
  48893. */
  48894. set: function (value) {
  48895. this._imageProcessingConfiguration.exposure = value;
  48896. },
  48897. enumerable: true,
  48898. configurable: true
  48899. });
  48900. Object.defineProperty(BackgroundMaterial.prototype, "cameraContrast", {
  48901. /**
  48902. * Gets The camera contrast used on this material.
  48903. */
  48904. get: function () {
  48905. return this._imageProcessingConfiguration.contrast;
  48906. },
  48907. /**
  48908. * Sets The camera contrast used on this material.
  48909. */
  48910. set: function (value) {
  48911. this._imageProcessingConfiguration.contrast = value;
  48912. },
  48913. enumerable: true,
  48914. configurable: true
  48915. });
  48916. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingTexture", {
  48917. /**
  48918. * Gets the Color Grading 2D Lookup Texture.
  48919. */
  48920. get: function () {
  48921. return this._imageProcessingConfiguration.colorGradingTexture;
  48922. },
  48923. /**
  48924. * Sets the Color Grading 2D Lookup Texture.
  48925. */
  48926. set: function (value) {
  48927. this.imageProcessingConfiguration.colorGradingTexture = value;
  48928. },
  48929. enumerable: true,
  48930. configurable: true
  48931. });
  48932. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurves", {
  48933. /**
  48934. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48935. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48936. * 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;
  48937. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48938. */
  48939. get: function () {
  48940. return this.imageProcessingConfiguration.colorCurves;
  48941. },
  48942. /**
  48943. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48944. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48945. * 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;
  48946. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48947. */
  48948. set: function (value) {
  48949. this.imageProcessingConfiguration.colorCurves = value;
  48950. },
  48951. enumerable: true,
  48952. configurable: true
  48953. });
  48954. Object.defineProperty(BackgroundMaterial.prototype, "hasRenderTargetTextures", {
  48955. /**
  48956. * Gets a boolean indicating that current material needs to register RTT
  48957. */
  48958. get: function () {
  48959. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  48960. return true;
  48961. }
  48962. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  48963. return true;
  48964. }
  48965. return false;
  48966. },
  48967. enumerable: true,
  48968. configurable: true
  48969. });
  48970. /**
  48971. * The entire material has been created in order to prevent overdraw.
  48972. * @returns false
  48973. */
  48974. BackgroundMaterial.prototype.needAlphaTesting = function () {
  48975. return true;
  48976. };
  48977. /**
  48978. * The entire material has been created in order to prevent overdraw.
  48979. * @returns true if blending is enable
  48980. */
  48981. BackgroundMaterial.prototype.needAlphaBlending = function () {
  48982. return ((this.alpha < 0) || (this._diffuseTexture != null && this._diffuseTexture.hasAlpha));
  48983. };
  48984. /**
  48985. * Checks wether the material is ready to be rendered for a given mesh.
  48986. * @param mesh The mesh to render
  48987. * @param subMesh The submesh to check against
  48988. * @param useInstances Specify wether or not the material is used with instances
  48989. * @returns true if all the dependencies are ready (Textures, Effects...)
  48990. */
  48991. BackgroundMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  48992. var _this = this;
  48993. if (useInstances === void 0) { useInstances = false; }
  48994. if (subMesh.effect && this.isFrozen) {
  48995. if (this._wasPreviouslyReady) {
  48996. return true;
  48997. }
  48998. }
  48999. if (!subMesh._materialDefines) {
  49000. subMesh._materialDefines = new BackgroundMaterialDefines();
  49001. }
  49002. var scene = this.getScene();
  49003. var defines = subMesh._materialDefines;
  49004. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  49005. if (defines._renderId === scene.getRenderId()) {
  49006. return true;
  49007. }
  49008. }
  49009. var engine = scene.getEngine();
  49010. // Lights
  49011. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
  49012. defines._needNormals = true;
  49013. // Textures
  49014. if (defines._areTexturesDirty) {
  49015. defines._needUVs = false;
  49016. if (scene.texturesEnabled) {
  49017. if (scene.getEngine().getCaps().textureLOD) {
  49018. defines.TEXTURELODSUPPORT = true;
  49019. }
  49020. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  49021. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  49022. return false;
  49023. }
  49024. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  49025. defines.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha;
  49026. defines.GAMMADIFFUSE = this._diffuseTexture.gammaSpace;
  49027. defines.OPACITYFRESNEL = this._opacityFresnel;
  49028. }
  49029. else {
  49030. defines.DIFFUSE = false;
  49031. defines.DIFFUSEHASALPHA = false;
  49032. defines.GAMMADIFFUSE = false;
  49033. defines.OPACITYFRESNEL = false;
  49034. }
  49035. var reflectionTexture = this._reflectionTexture;
  49036. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  49037. if (!reflectionTexture.isReadyOrNotBlocking()) {
  49038. return false;
  49039. }
  49040. defines.REFLECTION = true;
  49041. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  49042. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  49043. defines.REFLECTIONBLUR = this._reflectionBlur > 0;
  49044. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  49045. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  49046. defines.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV;
  49047. defines.REFLECTIONBGR = this.switchToBGR;
  49048. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE) {
  49049. defines.INVERTCUBICMAP = true;
  49050. }
  49051. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  49052. switch (reflectionTexture.coordinatesMode) {
  49053. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  49054. defines.REFLECTIONMAP_EXPLICIT = true;
  49055. break;
  49056. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  49057. defines.REFLECTIONMAP_PLANAR = true;
  49058. break;
  49059. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  49060. defines.REFLECTIONMAP_PROJECTION = true;
  49061. break;
  49062. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  49063. defines.REFLECTIONMAP_SKYBOX = true;
  49064. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  49065. break;
  49066. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  49067. defines.REFLECTIONMAP_SPHERICAL = true;
  49068. break;
  49069. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  49070. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  49071. break;
  49072. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  49073. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  49074. break;
  49075. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  49076. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  49077. break;
  49078. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  49079. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  49080. default:
  49081. defines.REFLECTIONMAP_CUBIC = true;
  49082. break;
  49083. }
  49084. if (this.reflectionFresnel) {
  49085. defines.REFLECTIONFRESNEL = true;
  49086. defines.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0;
  49087. this._reflectionControls.x = this.reflectionAmount;
  49088. this._reflectionControls.y = this.reflectionReflectance0;
  49089. this._reflectionControls.z = this.reflectionReflectance90;
  49090. this._reflectionControls.w = 1 / this.reflectionFalloffDistance;
  49091. }
  49092. else {
  49093. defines.REFLECTIONFRESNEL = false;
  49094. defines.REFLECTIONFALLOFF = false;
  49095. }
  49096. }
  49097. else {
  49098. defines.REFLECTION = false;
  49099. defines.REFLECTIONFRESNEL = false;
  49100. defines.REFLECTIONFALLOFF = false;
  49101. defines.REFLECTIONBLUR = false;
  49102. defines.REFLECTIONMAP_3D = false;
  49103. defines.REFLECTIONMAP_SPHERICAL = false;
  49104. defines.REFLECTIONMAP_PLANAR = false;
  49105. defines.REFLECTIONMAP_CUBIC = false;
  49106. defines.REFLECTIONMAP_PROJECTION = false;
  49107. defines.REFLECTIONMAP_SKYBOX = false;
  49108. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  49109. defines.REFLECTIONMAP_EXPLICIT = false;
  49110. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  49111. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  49112. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  49113. defines.INVERTCUBICMAP = false;
  49114. defines.REFLECTIONMAP_OPPOSITEZ = false;
  49115. defines.LODINREFLECTIONALPHA = false;
  49116. defines.GAMMAREFLECTION = false;
  49117. defines.RGBDREFLECTION = false;
  49118. }
  49119. }
  49120. 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);
  49121. defines.USERGBCOLOR = this._useRGBColor;
  49122. defines.NOISE = this._enableNoise;
  49123. }
  49124. if (defines._areLightsDirty) {
  49125. defines.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0);
  49126. }
  49127. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  49128. if (!this._imageProcessingConfiguration.isReady()) {
  49129. return false;
  49130. }
  49131. this._imageProcessingConfiguration.prepareDefines(defines);
  49132. }
  49133. // Misc.
  49134. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  49135. // Values that need to be evaluated on every frame
  49136. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  49137. // Attribs
  49138. if (_Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
  49139. if (mesh) {
  49140. if (!scene.getEngine().getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  49141. mesh.createNormals(true);
  49142. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("BackgroundMaterial: Normals have been created for the mesh: " + mesh.name);
  49143. }
  49144. }
  49145. }
  49146. // Get correct effect
  49147. if (defines.isDirty) {
  49148. defines.markAsProcessed();
  49149. scene.resetCachedMaterial();
  49150. // Fallbacks
  49151. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  49152. if (defines.FOG) {
  49153. fallbacks.addFallback(0, "FOG");
  49154. }
  49155. if (defines.POINTSIZE) {
  49156. fallbacks.addFallback(1, "POINTSIZE");
  49157. }
  49158. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  49159. if (defines.NUM_BONE_INFLUENCERS > 0) {
  49160. fallbacks.addCPUSkinningFallback(0, mesh);
  49161. }
  49162. //Attributes
  49163. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  49164. if (defines.NORMAL) {
  49165. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  49166. }
  49167. if (defines.UV1) {
  49168. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  49169. }
  49170. if (defines.UV2) {
  49171. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  49172. }
  49173. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  49174. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  49175. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
  49176. "vFogInfos", "vFogColor", "pointSize",
  49177. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "mBones",
  49178. "vPrimaryColor", "vPrimaryColorShadow",
  49179. "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier",
  49180. "shadowLevel", "alpha",
  49181. "vBackgroundCenter", "vReflectionControl",
  49182. "vDiffuseInfos", "diffuseMatrix",
  49183. ];
  49184. var samplers = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"];
  49185. var uniformBuffers = ["Material", "Scene"];
  49186. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"]) {
  49187. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  49188. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  49189. }
  49190. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareUniformsAndSamplersList({
  49191. uniformsNames: uniforms,
  49192. uniformBuffersNames: uniformBuffers,
  49193. samplers: samplers,
  49194. defines: defines,
  49195. maxSimultaneousLights: this._maxSimultaneousLights
  49196. });
  49197. var onCompiled = function (effect) {
  49198. if (_this.onCompiled) {
  49199. _this.onCompiled(effect);
  49200. }
  49201. _this.bindSceneUniformBuffer(effect, scene.getSceneUniformBuffer());
  49202. };
  49203. var join = defines.toString();
  49204. subMesh.setEffect(scene.getEngine().createEffect("background", {
  49205. attributes: attribs,
  49206. uniformsNames: uniforms,
  49207. uniformBuffersNames: uniformBuffers,
  49208. samplers: samplers,
  49209. defines: join,
  49210. fallbacks: fallbacks,
  49211. onCompiled: onCompiled,
  49212. onError: this.onError,
  49213. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
  49214. }, engine), defines);
  49215. this.buildUniformLayout();
  49216. }
  49217. if (!subMesh.effect || !subMesh.effect.isReady()) {
  49218. return false;
  49219. }
  49220. defines._renderId = scene.getRenderId();
  49221. this._wasPreviouslyReady = true;
  49222. return true;
  49223. };
  49224. /**
  49225. * Compute the primary color according to the chosen perceptual color.
  49226. */
  49227. BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
  49228. if (!this.__perceptualColor) {
  49229. return;
  49230. }
  49231. this._primaryColor.copyFrom(this.__perceptualColor);
  49232. // Revert gamma space.
  49233. this._primaryColor.toLinearSpaceToRef(this._primaryColor);
  49234. // Revert image processing configuration.
  49235. if (this._imageProcessingConfiguration) {
  49236. // Revert Exposure.
  49237. this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
  49238. }
  49239. this._computePrimaryColors();
  49240. };
  49241. /**
  49242. * Compute the highlights and shadow colors according to their chosen levels.
  49243. */
  49244. BackgroundMaterial.prototype._computePrimaryColors = function () {
  49245. if (this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0) {
  49246. return;
  49247. }
  49248. // Find the highlight color based on the configuration.
  49249. this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
  49250. this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
  49251. // Find the shadow color based on the configuration.
  49252. this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
  49253. this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
  49254. this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
  49255. };
  49256. /**
  49257. * Build the uniform buffer used in the material.
  49258. */
  49259. BackgroundMaterial.prototype.buildUniformLayout = function () {
  49260. // Order is important !
  49261. this._uniformBuffer.addUniform("vPrimaryColor", 4);
  49262. this._uniformBuffer.addUniform("vPrimaryColorShadow", 4);
  49263. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  49264. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  49265. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  49266. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  49267. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  49268. this._uniformBuffer.addUniform("fFovMultiplier", 1);
  49269. this._uniformBuffer.addUniform("pointSize", 1);
  49270. this._uniformBuffer.addUniform("shadowLevel", 1);
  49271. this._uniformBuffer.addUniform("alpha", 1);
  49272. this._uniformBuffer.addUniform("vBackgroundCenter", 3);
  49273. this._uniformBuffer.addUniform("vReflectionControl", 4);
  49274. this._uniformBuffer.create();
  49275. };
  49276. /**
  49277. * Unbind the material.
  49278. */
  49279. BackgroundMaterial.prototype.unbind = function () {
  49280. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  49281. this._uniformBuffer.setTexture("diffuseSampler", null);
  49282. }
  49283. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  49284. this._uniformBuffer.setTexture("reflectionSampler", null);
  49285. }
  49286. _super.prototype.unbind.call(this);
  49287. };
  49288. /**
  49289. * Bind only the world matrix to the material.
  49290. * @param world The world matrix to bind.
  49291. */
  49292. BackgroundMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  49293. this._activeEffect.setMatrix("world", world);
  49294. };
  49295. /**
  49296. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49297. * @param world The world matrix to bind.
  49298. * @param subMesh The submesh to bind for.
  49299. */
  49300. BackgroundMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  49301. var scene = this.getScene();
  49302. var defines = subMesh._materialDefines;
  49303. if (!defines) {
  49304. return;
  49305. }
  49306. var effect = subMesh.effect;
  49307. if (!effect) {
  49308. return;
  49309. }
  49310. this._activeEffect = effect;
  49311. // Matrices
  49312. this.bindOnlyWorldMatrix(world);
  49313. // Bones
  49314. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  49315. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  49316. if (mustRebind) {
  49317. this._uniformBuffer.bindToEffect(effect, "Material");
  49318. this.bindViewProjection(effect);
  49319. var reflectionTexture = this._reflectionTexture;
  49320. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  49321. // Texture uniforms
  49322. if (scene.texturesEnabled) {
  49323. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  49324. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  49325. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  49326. }
  49327. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  49328. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  49329. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, this._reflectionBlur);
  49330. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  49331. }
  49332. }
  49333. if (this.shadowLevel > 0) {
  49334. this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel);
  49335. }
  49336. this._uniformBuffer.updateFloat("alpha", this.alpha);
  49337. // Point size
  49338. if (this.pointsCloud) {
  49339. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  49340. }
  49341. if (defines.USEHIGHLIGHTANDSHADOWCOLORS) {
  49342. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1.0);
  49343. this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1.0);
  49344. }
  49345. else {
  49346. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1.0);
  49347. }
  49348. }
  49349. this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier);
  49350. // Textures
  49351. if (scene.texturesEnabled) {
  49352. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  49353. this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture);
  49354. }
  49355. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  49356. if (defines.REFLECTIONBLUR && defines.TEXTURELODSUPPORT) {
  49357. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  49358. }
  49359. else if (!defines.REFLECTIONBLUR) {
  49360. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  49361. }
  49362. else {
  49363. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  49364. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  49365. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  49366. }
  49367. if (defines.REFLECTIONFRESNEL) {
  49368. this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z);
  49369. this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w);
  49370. }
  49371. }
  49372. }
  49373. // Clip plane
  49374. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  49375. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindEyePosition(effect, scene);
  49376. }
  49377. if (mustRebind || !this.isFrozen) {
  49378. if (scene.lightsEnabled) {
  49379. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, false);
  49380. }
  49381. // View
  49382. this.bindView(effect);
  49383. // Fog
  49384. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  49385. // image processing
  49386. if (this._imageProcessingConfiguration) {
  49387. this._imageProcessingConfiguration.bind(this._activeEffect);
  49388. }
  49389. }
  49390. this._uniformBuffer.update();
  49391. this._afterBind(mesh, this._activeEffect);
  49392. };
  49393. /**
  49394. * Dispose the material.
  49395. * @param forceDisposeEffect Force disposal of the associated effect.
  49396. * @param forceDisposeTextures Force disposal of the associated textures.
  49397. */
  49398. BackgroundMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  49399. if (forceDisposeEffect === void 0) { forceDisposeEffect = false; }
  49400. if (forceDisposeTextures === void 0) { forceDisposeTextures = false; }
  49401. if (forceDisposeTextures) {
  49402. if (this.diffuseTexture) {
  49403. this.diffuseTexture.dispose();
  49404. }
  49405. if (this.reflectionTexture) {
  49406. this.reflectionTexture.dispose();
  49407. }
  49408. }
  49409. this._renderTargets.dispose();
  49410. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  49411. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  49412. }
  49413. _super.prototype.dispose.call(this, forceDisposeEffect);
  49414. };
  49415. /**
  49416. * Clones the material.
  49417. * @param name The cloned name.
  49418. * @returns The cloned material.
  49419. */
  49420. BackgroundMaterial.prototype.clone = function (name) {
  49421. var _this = this;
  49422. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new BackgroundMaterial(name, _this.getScene()); }, this);
  49423. };
  49424. /**
  49425. * Serializes the current material to its JSON representation.
  49426. * @returns The JSON representation.
  49427. */
  49428. BackgroundMaterial.prototype.serialize = function () {
  49429. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  49430. serializationObject.customType = "BABYLON.BackgroundMaterial";
  49431. return serializationObject;
  49432. };
  49433. /**
  49434. * Gets the class name of the material
  49435. * @returns "BackgroundMaterial"
  49436. */
  49437. BackgroundMaterial.prototype.getClassName = function () {
  49438. return "BackgroundMaterial";
  49439. };
  49440. /**
  49441. * Parse a JSON input to create back a background material.
  49442. * @param source The JSON data to parse
  49443. * @param scene The scene to create the parsed material in
  49444. * @param rootUrl The root url of the assets the material depends upon
  49445. * @returns the instantiated BackgroundMaterial.
  49446. */
  49447. BackgroundMaterial.Parse = function (source, scene, rootUrl) {
  49448. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new BackgroundMaterial(source.name, scene); }, source, scene, rootUrl);
  49449. };
  49450. /**
  49451. * Standard reflectance value at parallel view angle.
  49452. */
  49453. BackgroundMaterial.StandardReflectance0 = 0.05;
  49454. /**
  49455. * Standard reflectance value at grazing angle.
  49456. */
  49457. BackgroundMaterial.StandardReflectance90 = 0.5;
  49458. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49459. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  49460. ], BackgroundMaterial.prototype, "_primaryColor", void 0);
  49461. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49462. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  49463. ], BackgroundMaterial.prototype, "primaryColor", void 0);
  49464. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49465. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  49466. ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
  49467. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49468. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49469. ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
  49470. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49471. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49472. ], BackgroundMaterial.prototype, "_primaryColorHighlightLevel", void 0);
  49473. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49474. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  49475. ], BackgroundMaterial.prototype, "primaryColorHighlightLevel", null);
  49476. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49477. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  49478. ], BackgroundMaterial.prototype, "_reflectionTexture", void 0);
  49479. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49480. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49481. ], BackgroundMaterial.prototype, "reflectionTexture", void 0);
  49482. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49483. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49484. ], BackgroundMaterial.prototype, "_reflectionBlur", void 0);
  49485. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49486. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49487. ], BackgroundMaterial.prototype, "reflectionBlur", void 0);
  49488. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49489. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  49490. ], BackgroundMaterial.prototype, "_diffuseTexture", void 0);
  49491. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49492. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49493. ], BackgroundMaterial.prototype, "diffuseTexture", void 0);
  49494. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49495. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49496. ], BackgroundMaterial.prototype, "shadowLights", void 0);
  49497. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49498. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49499. ], BackgroundMaterial.prototype, "_shadowLevel", void 0);
  49500. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49501. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49502. ], BackgroundMaterial.prototype, "shadowLevel", void 0);
  49503. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49504. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  49505. ], BackgroundMaterial.prototype, "_sceneCenter", void 0);
  49506. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49507. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49508. ], BackgroundMaterial.prototype, "sceneCenter", void 0);
  49509. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49510. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49511. ], BackgroundMaterial.prototype, "_opacityFresnel", void 0);
  49512. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49513. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49514. ], BackgroundMaterial.prototype, "opacityFresnel", void 0);
  49515. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49516. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49517. ], BackgroundMaterial.prototype, "_reflectionFresnel", void 0);
  49518. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49519. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49520. ], BackgroundMaterial.prototype, "reflectionFresnel", void 0);
  49521. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49522. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49523. ], BackgroundMaterial.prototype, "_reflectionFalloffDistance", void 0);
  49524. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49525. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49526. ], BackgroundMaterial.prototype, "reflectionFalloffDistance", void 0);
  49527. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49528. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49529. ], BackgroundMaterial.prototype, "_reflectionAmount", void 0);
  49530. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49531. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49532. ], BackgroundMaterial.prototype, "reflectionAmount", void 0);
  49533. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49534. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49535. ], BackgroundMaterial.prototype, "_reflectionReflectance0", void 0);
  49536. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49537. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49538. ], BackgroundMaterial.prototype, "reflectionReflectance0", void 0);
  49539. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49540. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49541. ], BackgroundMaterial.prototype, "_reflectionReflectance90", void 0);
  49542. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49543. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49544. ], BackgroundMaterial.prototype, "reflectionReflectance90", void 0);
  49545. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49546. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49547. ], BackgroundMaterial.prototype, "_useRGBColor", void 0);
  49548. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49549. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49550. ], BackgroundMaterial.prototype, "useRGBColor", void 0);
  49551. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49552. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49553. ], BackgroundMaterial.prototype, "_enableNoise", void 0);
  49554. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49555. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49556. ], BackgroundMaterial.prototype, "enableNoise", void 0);
  49557. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49558. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  49559. ], BackgroundMaterial.prototype, "_maxSimultaneousLights", void 0);
  49560. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49561. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  49562. ], BackgroundMaterial.prototype, "maxSimultaneousLights", void 0);
  49563. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  49564. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  49565. ], BackgroundMaterial.prototype, "_imageProcessingConfiguration", void 0);
  49566. return BackgroundMaterial;
  49567. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  49568. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__["_TypeStore"].RegisteredTypes["BABYLON.BackgroundMaterial"] = BackgroundMaterial;
  49569. /***/ }),
  49570. /***/ "./Materials/Background/index.ts":
  49571. /*!***************************************!*\
  49572. !*** ./Materials/Background/index.ts ***!
  49573. \***************************************/
  49574. /*! exports provided: BackgroundMaterial */
  49575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49576. "use strict";
  49577. __webpack_require__.r(__webpack_exports__);
  49578. /* harmony import */ var _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  49579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  49580. /***/ }),
  49581. /***/ "./Materials/PBR/index.ts":
  49582. /*!********************************!*\
  49583. !*** ./Materials/PBR/index.ts ***!
  49584. \********************************/
  49585. /*! exports provided: PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial */
  49586. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49587. "use strict";
  49588. __webpack_require__.r(__webpack_exports__);
  49589. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  49590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  49591. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  49592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__["PBRBaseSimpleMaterial"]; });
  49593. /* harmony import */ var _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  49594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRMaterial"]; });
  49595. /* harmony import */ var _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrMetallicRoughnessMaterial */ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts");
  49596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRMetallicRoughnessMaterial"]; });
  49597. /* harmony import */ var _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrSpecularGlossinessMaterial */ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts");
  49598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRSpecularGlossinessMaterial"]; });
  49599. /***/ }),
  49600. /***/ "./Materials/PBR/pbrBaseMaterial.ts":
  49601. /*!******************************************!*\
  49602. !*** ./Materials/PBR/pbrBaseMaterial.ts ***!
  49603. \******************************************/
  49604. /*! exports provided: PBRBaseMaterial */
  49605. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49606. "use strict";
  49607. __webpack_require__.r(__webpack_exports__);
  49608. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return PBRBaseMaterial; });
  49609. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  49610. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  49611. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  49612. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  49613. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  49614. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  49615. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  49616. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  49617. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  49618. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  49619. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  49620. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  49621. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  49622. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  49623. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  49624. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  49625. /* harmony import */ var _Shaders_pbr_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/pbr.fragment */ "./Shaders/pbr.fragment.ts");
  49626. /* harmony import */ var _Shaders_pbr_vertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Shaders/pbr.vertex */ "./Shaders/pbr.vertex.ts");
  49627. /**
  49628. * Manages the defines for the PBR Material.
  49629. * @hiddenChildren
  49630. */
  49631. var PBRMaterialDefines = /** @class */ (function (_super) {
  49632. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterialDefines, _super);
  49633. /**
  49634. * Initializes the PBR Material defines.
  49635. */
  49636. function PBRMaterialDefines() {
  49637. var _this = _super.call(this) || this;
  49638. _this.PBR = true;
  49639. _this.MAINUV1 = false;
  49640. _this.MAINUV2 = false;
  49641. _this.UV1 = false;
  49642. _this.UV2 = false;
  49643. _this.ALBEDO = false;
  49644. _this.ALBEDODIRECTUV = 0;
  49645. _this.VERTEXCOLOR = false;
  49646. _this.AMBIENT = false;
  49647. _this.AMBIENTDIRECTUV = 0;
  49648. _this.AMBIENTINGRAYSCALE = false;
  49649. _this.OPACITY = false;
  49650. _this.VERTEXALPHA = false;
  49651. _this.OPACITYDIRECTUV = 0;
  49652. _this.OPACITYRGB = false;
  49653. _this.ALPHATEST = false;
  49654. _this.DEPTHPREPASS = false;
  49655. _this.ALPHABLEND = false;
  49656. _this.ALPHAFROMALBEDO = false;
  49657. _this.ALPHATESTVALUE = "0.5";
  49658. _this.SPECULAROVERALPHA = false;
  49659. _this.RADIANCEOVERALPHA = false;
  49660. _this.ALPHAFRESNEL = false;
  49661. _this.LINEARALPHAFRESNEL = false;
  49662. _this.PREMULTIPLYALPHA = false;
  49663. _this.EMISSIVE = false;
  49664. _this.EMISSIVEDIRECTUV = 0;
  49665. _this.REFLECTIVITY = false;
  49666. _this.REFLECTIVITYDIRECTUV = 0;
  49667. _this.SPECULARTERM = false;
  49668. _this.MICROSURFACEFROMREFLECTIVITYMAP = false;
  49669. _this.MICROSURFACEAUTOMATIC = false;
  49670. _this.LODBASEDMICROSFURACE = false;
  49671. _this.MICROSURFACEMAP = false;
  49672. _this.MICROSURFACEMAPDIRECTUV = 0;
  49673. _this.METALLICWORKFLOW = false;
  49674. _this.ROUGHNESSSTOREINMETALMAPALPHA = false;
  49675. _this.ROUGHNESSSTOREINMETALMAPGREEN = false;
  49676. _this.METALLNESSSTOREINMETALMAPBLUE = false;
  49677. _this.AOSTOREINMETALMAPRED = false;
  49678. _this.ENVIRONMENTBRDF = false;
  49679. _this.NORMAL = false;
  49680. _this.TANGENT = false;
  49681. _this.BUMP = false;
  49682. _this.BUMPDIRECTUV = 0;
  49683. _this.OBJECTSPACE_NORMALMAP = false;
  49684. _this.PARALLAX = false;
  49685. _this.PARALLAXOCCLUSION = false;
  49686. _this.NORMALXYSCALE = true;
  49687. _this.LIGHTMAP = false;
  49688. _this.LIGHTMAPDIRECTUV = 0;
  49689. _this.USELIGHTMAPASSHADOWMAP = false;
  49690. _this.GAMMALIGHTMAP = false;
  49691. _this.REFLECTION = false;
  49692. _this.REFLECTIONMAP_3D = false;
  49693. _this.REFLECTIONMAP_SPHERICAL = false;
  49694. _this.REFLECTIONMAP_PLANAR = false;
  49695. _this.REFLECTIONMAP_CUBIC = false;
  49696. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  49697. _this.REFLECTIONMAP_PROJECTION = false;
  49698. _this.REFLECTIONMAP_SKYBOX = false;
  49699. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  49700. _this.REFLECTIONMAP_EXPLICIT = false;
  49701. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  49702. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  49703. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  49704. _this.INVERTCUBICMAP = false;
  49705. _this.USESPHERICALFROMREFLECTIONMAP = false;
  49706. _this.USESPHERICALINVERTEX = false;
  49707. _this.REFLECTIONMAP_OPPOSITEZ = false;
  49708. _this.LODINREFLECTIONALPHA = false;
  49709. _this.GAMMAREFLECTION = false;
  49710. _this.RGBDREFLECTION = false;
  49711. _this.RADIANCEOCCLUSION = false;
  49712. _this.HORIZONOCCLUSION = false;
  49713. _this.REFRACTION = false;
  49714. _this.REFRACTIONMAP_3D = false;
  49715. _this.REFRACTIONMAP_OPPOSITEZ = false;
  49716. _this.LODINREFRACTIONALPHA = false;
  49717. _this.GAMMAREFRACTION = false;
  49718. _this.RGBDREFRACTION = false;
  49719. _this.LINKREFRACTIONTOTRANSPARENCY = false;
  49720. _this.INSTANCES = false;
  49721. _this.NUM_BONE_INFLUENCERS = 0;
  49722. _this.BonesPerMesh = 0;
  49723. _this.BONETEXTURE = false;
  49724. _this.NONUNIFORMSCALING = false;
  49725. _this.MORPHTARGETS = false;
  49726. _this.MORPHTARGETS_NORMAL = false;
  49727. _this.MORPHTARGETS_TANGENT = false;
  49728. _this.NUM_MORPH_INFLUENCERS = 0;
  49729. _this.IMAGEPROCESSING = false;
  49730. _this.VIGNETTE = false;
  49731. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  49732. _this.VIGNETTEBLENDMODEOPAQUE = false;
  49733. _this.TONEMAPPING = false;
  49734. _this.TONEMAPPING_ACES = false;
  49735. _this.CONTRAST = false;
  49736. _this.COLORCURVES = false;
  49737. _this.COLORGRADING = false;
  49738. _this.COLORGRADING3D = false;
  49739. _this.SAMPLER3DGREENDEPTH = false;
  49740. _this.SAMPLER3DBGRMAP = false;
  49741. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  49742. _this.EXPOSURE = false;
  49743. _this.USEPHYSICALLIGHTFALLOFF = false;
  49744. _this.USEGLTFLIGHTFALLOFF = false;
  49745. _this.TWOSIDEDLIGHTING = false;
  49746. _this.SHADOWFLOAT = false;
  49747. _this.CLIPPLANE = false;
  49748. _this.CLIPPLANE2 = false;
  49749. _this.CLIPPLANE3 = false;
  49750. _this.CLIPPLANE4 = false;
  49751. _this.POINTSIZE = false;
  49752. _this.FOG = false;
  49753. _this.LOGARITHMICDEPTH = false;
  49754. _this.FORCENORMALFORWARD = false;
  49755. _this.SPECULARAA = false;
  49756. _this.UNLIT = false;
  49757. _this.rebuild();
  49758. return _this;
  49759. }
  49760. /**
  49761. * Resets the PBR Material defines.
  49762. */
  49763. PBRMaterialDefines.prototype.reset = function () {
  49764. _super.prototype.reset.call(this);
  49765. this.ALPHATESTVALUE = "0.5";
  49766. this.PBR = true;
  49767. };
  49768. return PBRMaterialDefines;
  49769. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_10__["MaterialDefines"]));
  49770. /**
  49771. * The Physically based material base class of BJS.
  49772. *
  49773. * This offers the main features of a standard PBR material.
  49774. * For more information, please refer to the documentation :
  49775. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  49776. */
  49777. var PBRBaseMaterial = /** @class */ (function (_super) {
  49778. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseMaterial, _super);
  49779. /**
  49780. * Instantiates a new PBRMaterial instance.
  49781. *
  49782. * @param name The material name
  49783. * @param scene The scene the material will be use in.
  49784. */
  49785. function PBRBaseMaterial(name, scene) {
  49786. var _this = _super.call(this, name, scene) || this;
  49787. /**
  49788. * Intensity of the direct lights e.g. the four lights available in your scene.
  49789. * This impacts both the direct diffuse and specular highlights.
  49790. */
  49791. _this._directIntensity = 1.0;
  49792. /**
  49793. * Intensity of the emissive part of the material.
  49794. * This helps controlling the emissive effect without modifying the emissive color.
  49795. */
  49796. _this._emissiveIntensity = 1.0;
  49797. /**
  49798. * Intensity of the environment e.g. how much the environment will light the object
  49799. * either through harmonics for rough material or through the refelction for shiny ones.
  49800. */
  49801. _this._environmentIntensity = 1.0;
  49802. /**
  49803. * This is a special control allowing the reduction of the specular highlights coming from the
  49804. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49805. */
  49806. _this._specularIntensity = 1.0;
  49807. /**
  49808. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49809. */
  49810. _this._lightingInfos = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](_this._directIntensity, _this._emissiveIntensity, _this._environmentIntensity, _this._specularIntensity);
  49811. /**
  49812. * Debug Control allowing disabling the bump map on this material.
  49813. */
  49814. _this._disableBumpMap = false;
  49815. /**
  49816. * AKA Occlusion Texture Intensity in other nomenclature.
  49817. */
  49818. _this._ambientTextureStrength = 1.0;
  49819. /**
  49820. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49821. * 1 means it completely occludes it
  49822. * 0 mean it has no impact
  49823. */
  49824. _this._ambientTextureImpactOnAnalyticalLights = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  49825. /**
  49826. * The color of a material in ambient lighting.
  49827. */
  49828. _this._ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  49829. /**
  49830. * AKA Diffuse Color in other nomenclature.
  49831. */
  49832. _this._albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  49833. /**
  49834. * AKA Specular Color in other nomenclature.
  49835. */
  49836. _this._reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  49837. /**
  49838. * The color applied when light is reflected from a material.
  49839. */
  49840. _this._reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  49841. /**
  49842. * The color applied when light is emitted from a material.
  49843. */
  49844. _this._emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  49845. /**
  49846. * AKA Glossiness in other nomenclature.
  49847. */
  49848. _this._microSurface = 0.9;
  49849. /**
  49850. * source material index of refraction (IOR)' / 'destination material IOR.
  49851. */
  49852. _this._indexOfRefraction = 0.66;
  49853. /**
  49854. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49855. */
  49856. _this._invertRefractionY = false;
  49857. /**
  49858. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49859. * Materials half opaque for instance using refraction could benefit from this control.
  49860. */
  49861. _this._linkRefractionWithTransparency = false;
  49862. /**
  49863. * Specifies that the material will use the light map as a show map.
  49864. */
  49865. _this._useLightmapAsShadowmap = false;
  49866. /**
  49867. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49868. * makes the reflect vector face the model (under horizon).
  49869. */
  49870. _this._useHorizonOcclusion = true;
  49871. /**
  49872. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49873. * too much the area relying on ambient texture to define their ambient occlusion.
  49874. */
  49875. _this._useRadianceOcclusion = true;
  49876. /**
  49877. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49878. */
  49879. _this._useAlphaFromAlbedoTexture = false;
  49880. /**
  49881. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49882. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49883. */
  49884. _this._useSpecularOverAlpha = true;
  49885. /**
  49886. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49887. */
  49888. _this._useMicroSurfaceFromReflectivityMapAlpha = false;
  49889. /**
  49890. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49891. */
  49892. _this._useRoughnessFromMetallicTextureAlpha = true;
  49893. /**
  49894. * Specifies if the metallic texture contains the roughness information in its green channel.
  49895. */
  49896. _this._useRoughnessFromMetallicTextureGreen = false;
  49897. /**
  49898. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49899. */
  49900. _this._useMetallnessFromMetallicTextureBlue = false;
  49901. /**
  49902. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49903. */
  49904. _this._useAmbientOcclusionFromMetallicTextureRed = false;
  49905. /**
  49906. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49907. */
  49908. _this._useAmbientInGrayScale = false;
  49909. /**
  49910. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49911. * The material will try to infer what glossiness each pixel should be.
  49912. */
  49913. _this._useAutoMicroSurfaceFromReflectivityMap = false;
  49914. /**
  49915. * Defines the falloff type used in this material.
  49916. * It by default is Physical.
  49917. */
  49918. _this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL;
  49919. /**
  49920. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49921. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49922. */
  49923. _this._useRadianceOverAlpha = true;
  49924. /**
  49925. * Allows using an object space normal map (instead of tangent space).
  49926. */
  49927. _this._useObjectSpaceNormalMap = false;
  49928. /**
  49929. * Allows using the bump map in parallax mode.
  49930. */
  49931. _this._useParallax = false;
  49932. /**
  49933. * Allows using the bump map in parallax occlusion mode.
  49934. */
  49935. _this._useParallaxOcclusion = false;
  49936. /**
  49937. * Controls the scale bias of the parallax mode.
  49938. */
  49939. _this._parallaxScaleBias = 0.05;
  49940. /**
  49941. * If sets to true, disables all the lights affecting the material.
  49942. */
  49943. _this._disableLighting = false;
  49944. /**
  49945. * Number of Simultaneous lights allowed on the material.
  49946. */
  49947. _this._maxSimultaneousLights = 4;
  49948. /**
  49949. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49950. */
  49951. _this._invertNormalMapX = false;
  49952. /**
  49953. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49954. */
  49955. _this._invertNormalMapY = false;
  49956. /**
  49957. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49958. */
  49959. _this._twoSidedLighting = false;
  49960. /**
  49961. * Defines the alpha limits in alpha test mode.
  49962. */
  49963. _this._alphaCutOff = 0.4;
  49964. /**
  49965. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49966. */
  49967. _this._forceAlphaTest = false;
  49968. /**
  49969. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49970. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49971. */
  49972. _this._useAlphaFresnel = false;
  49973. /**
  49974. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49975. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49976. */
  49977. _this._useLinearAlphaFresnel = false;
  49978. /**
  49979. * The transparency mode of the material.
  49980. */
  49981. _this._transparencyMode = null;
  49982. /**
  49983. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49984. * from cos thetav and roughness:
  49985. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49986. */
  49987. _this._environmentBRDFTexture = null;
  49988. /**
  49989. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49990. */
  49991. _this._forceIrradianceInFragment = false;
  49992. /**
  49993. * Force normal to face away from face.
  49994. */
  49995. _this._forceNormalForward = false;
  49996. /**
  49997. * Enables specular anti aliasing in the PBR shader.
  49998. * It will both interacts on the Geometry for analytical and IBL lighting.
  49999. * It also prefilter the roughness map based on the bump values.
  50000. */
  50001. _this._enableSpecularAntiAliasing = false;
  50002. /**
  50003. * Stores the available render targets.
  50004. */
  50005. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__["SmartArray"](16);
  50006. /**
  50007. * Sets the global ambient color for the material used in lighting calculations.
  50008. */
  50009. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  50010. /**
  50011. * If set to true, no lighting calculations will be applied.
  50012. */
  50013. _this._unlit = false;
  50014. // Setup the default processing configuration to the scene.
  50015. _this._attachImageProcessingConfiguration(null);
  50016. _this.getRenderTargetTextures = function () {
  50017. _this._renderTargets.reset();
  50018. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  50019. _this._renderTargets.push(_this._reflectionTexture);
  50020. }
  50021. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  50022. _this._renderTargets.push(_this._refractionTexture);
  50023. }
  50024. return _this._renderTargets;
  50025. };
  50026. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  50027. return _this;
  50028. }
  50029. /**
  50030. * Attaches a new image processing configuration to the PBR Material.
  50031. * @param configuration
  50032. */
  50033. PBRBaseMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  50034. var _this = this;
  50035. if (configuration === this._imageProcessingConfiguration) {
  50036. return;
  50037. }
  50038. // Detaches observer.
  50039. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50040. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50041. }
  50042. // Pick the scene configuration if needed.
  50043. if (!configuration) {
  50044. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  50045. }
  50046. else {
  50047. this._imageProcessingConfiguration = configuration;
  50048. }
  50049. // Attaches observer.
  50050. if (this._imageProcessingConfiguration) {
  50051. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  50052. _this._markAllSubMeshesAsImageProcessingDirty();
  50053. });
  50054. }
  50055. };
  50056. Object.defineProperty(PBRBaseMaterial.prototype, "hasRenderTargetTextures", {
  50057. /**
  50058. * Gets a boolean indicating that current material needs to register RTT
  50059. */
  50060. get: function () {
  50061. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  50062. return true;
  50063. }
  50064. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  50065. return true;
  50066. }
  50067. return false;
  50068. },
  50069. enumerable: true,
  50070. configurable: true
  50071. });
  50072. /**
  50073. * Gets the name of the material class.
  50074. */
  50075. PBRBaseMaterial.prototype.getClassName = function () {
  50076. return "PBRBaseMaterial";
  50077. };
  50078. Object.defineProperty(PBRBaseMaterial.prototype, "useLogarithmicDepth", {
  50079. /**
  50080. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50081. */
  50082. get: function () {
  50083. return this._useLogarithmicDepth;
  50084. },
  50085. /**
  50086. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50087. */
  50088. set: function (value) {
  50089. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  50090. },
  50091. enumerable: true,
  50092. configurable: true
  50093. });
  50094. Object.defineProperty(PBRBaseMaterial.prototype, "transparencyMode", {
  50095. /**
  50096. * Gets the current transparency mode.
  50097. */
  50098. get: function () {
  50099. return this._transparencyMode;
  50100. },
  50101. /**
  50102. * Sets the transparency mode of the material.
  50103. *
  50104. * | Value | Type | Description |
  50105. * | ----- | ----------------------------------- | ----------- |
  50106. * | 0 | OPAQUE | |
  50107. * | 1 | ALPHATEST | |
  50108. * | 2 | ALPHABLEND | |
  50109. * | 3 | ALPHATESTANDBLEND | |
  50110. *
  50111. */
  50112. set: function (value) {
  50113. if (this._transparencyMode === value) {
  50114. return;
  50115. }
  50116. this._transparencyMode = value;
  50117. this._forceAlphaTest = (value === PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
  50118. this._markAllSubMeshesAsTexturesAndMiscDirty();
  50119. },
  50120. enumerable: true,
  50121. configurable: true
  50122. });
  50123. Object.defineProperty(PBRBaseMaterial.prototype, "_disableAlphaBlending", {
  50124. /**
  50125. * Returns true if alpha blending should be disabled.
  50126. */
  50127. get: function () {
  50128. return (this._linkRefractionWithTransparency ||
  50129. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_OPAQUE ||
  50130. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  50131. },
  50132. enumerable: true,
  50133. configurable: true
  50134. });
  50135. /**
  50136. * Specifies whether or not this material should be rendered in alpha blend mode.
  50137. */
  50138. PBRBaseMaterial.prototype.needAlphaBlending = function () {
  50139. if (this._disableAlphaBlending) {
  50140. return false;
  50141. }
  50142. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromAlbedoTexture();
  50143. };
  50144. /**
  50145. * Specifies if the mesh will require alpha blending.
  50146. * @param mesh - BJS mesh.
  50147. */
  50148. PBRBaseMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
  50149. if (this._disableAlphaBlending) {
  50150. return false;
  50151. }
  50152. return _super.prototype.needAlphaBlendingForMesh.call(this, mesh);
  50153. };
  50154. /**
  50155. * Specifies whether or not this material should be rendered in alpha test mode.
  50156. */
  50157. PBRBaseMaterial.prototype.needAlphaTesting = function () {
  50158. if (this._forceAlphaTest) {
  50159. return true;
  50160. }
  50161. if (this._linkRefractionWithTransparency) {
  50162. return false;
  50163. }
  50164. return this._albedoTexture != null && this._albedoTexture.hasAlpha && (this._transparencyMode == null || this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  50165. };
  50166. /**
  50167. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50168. */
  50169. PBRBaseMaterial.prototype._shouldUseAlphaFromAlbedoTexture = function () {
  50170. return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE;
  50171. };
  50172. /**
  50173. * Gets the texture used for the alpha test.
  50174. */
  50175. PBRBaseMaterial.prototype.getAlphaTestTexture = function () {
  50176. return this._albedoTexture;
  50177. };
  50178. /**
  50179. * Specifies that the submesh is ready to be used.
  50180. * @param mesh - BJS mesh.
  50181. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50182. * @param useInstances - Specifies that instances should be used.
  50183. * @returns - boolean indicating that the submesh is ready or not.
  50184. */
  50185. PBRBaseMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  50186. if (subMesh.effect && this.isFrozen) {
  50187. if (this._wasPreviouslyReady) {
  50188. return true;
  50189. }
  50190. }
  50191. if (!subMesh._materialDefines) {
  50192. subMesh._materialDefines = new PBRMaterialDefines();
  50193. }
  50194. var defines = subMesh._materialDefines;
  50195. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  50196. if (defines._renderId === this.getScene().getRenderId()) {
  50197. return true;
  50198. }
  50199. }
  50200. var scene = this.getScene();
  50201. var engine = scene.getEngine();
  50202. if (defines._areTexturesDirty) {
  50203. if (scene.texturesEnabled) {
  50204. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50205. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  50206. return false;
  50207. }
  50208. }
  50209. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  50210. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  50211. return false;
  50212. }
  50213. }
  50214. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  50215. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  50216. return false;
  50217. }
  50218. }
  50219. var reflectionTexture = this._getReflectionTexture();
  50220. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50221. if (!reflectionTexture.isReadyOrNotBlocking()) {
  50222. return false;
  50223. }
  50224. }
  50225. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  50226. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  50227. return false;
  50228. }
  50229. }
  50230. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  50231. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  50232. return false;
  50233. }
  50234. }
  50235. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  50236. if (this._metallicTexture) {
  50237. if (!this._metallicTexture.isReadyOrNotBlocking()) {
  50238. return false;
  50239. }
  50240. }
  50241. else if (this._reflectivityTexture) {
  50242. if (!this._reflectivityTexture.isReadyOrNotBlocking()) {
  50243. return false;
  50244. }
  50245. }
  50246. if (this._microSurfaceTexture) {
  50247. if (!this._microSurfaceTexture.isReadyOrNotBlocking()) {
  50248. return false;
  50249. }
  50250. }
  50251. }
  50252. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  50253. // Bump texture cannot be not blocking.
  50254. if (!this._bumpTexture.isReady()) {
  50255. return false;
  50256. }
  50257. }
  50258. var refractionTexture = this._getRefractionTexture();
  50259. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  50260. if (!refractionTexture.isReadyOrNotBlocking()) {
  50261. return false;
  50262. }
  50263. }
  50264. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50265. // This is blocking.
  50266. if (!this._environmentBRDFTexture.isReady()) {
  50267. return false;
  50268. }
  50269. }
  50270. }
  50271. }
  50272. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  50273. if (!this._imageProcessingConfiguration.isReady()) {
  50274. return false;
  50275. }
  50276. }
  50277. if (!engine.getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  50278. mesh.createNormals(true);
  50279. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
  50280. }
  50281. var previousEffect = subMesh.effect;
  50282. var effect = this._prepareEffect(mesh, defines, this.onCompiled, this.onError, useInstances);
  50283. if (effect) {
  50284. // Use previous effect while new one is compiling
  50285. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  50286. effect = previousEffect;
  50287. defines.markAsUnprocessed();
  50288. }
  50289. else {
  50290. scene.resetCachedMaterial();
  50291. subMesh.setEffect(effect, defines);
  50292. this.buildUniformLayout();
  50293. }
  50294. }
  50295. if (!subMesh.effect || !subMesh.effect.isReady()) {
  50296. return false;
  50297. }
  50298. defines._renderId = scene.getRenderId();
  50299. this._wasPreviouslyReady = true;
  50300. return true;
  50301. };
  50302. /**
  50303. * Specifies if the material uses metallic roughness workflow.
  50304. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50305. */
  50306. PBRBaseMaterial.prototype.isMetallicWorkflow = function () {
  50307. if (this._metallic != null || this._roughness != null || this._metallicTexture) {
  50308. return true;
  50309. }
  50310. return false;
  50311. };
  50312. PBRBaseMaterial.prototype._prepareEffect = function (mesh, defines, onCompiled, onError, useInstances, useClipPlane) {
  50313. if (onCompiled === void 0) { onCompiled = null; }
  50314. if (onError === void 0) { onError = null; }
  50315. if (useInstances === void 0) { useInstances = null; }
  50316. if (useClipPlane === void 0) { useClipPlane = null; }
  50317. this._prepareDefines(mesh, defines, useInstances, useClipPlane);
  50318. if (!defines.isDirty) {
  50319. return null;
  50320. }
  50321. defines.markAsProcessed();
  50322. var scene = this.getScene();
  50323. var engine = scene.getEngine();
  50324. // Fallbacks
  50325. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["EffectFallbacks"]();
  50326. var fallbackRank = 0;
  50327. if (defines.USESPHERICALINVERTEX) {
  50328. fallbacks.addFallback(fallbackRank++, "USESPHERICALINVERTEX");
  50329. }
  50330. if (defines.FOG) {
  50331. fallbacks.addFallback(fallbackRank, "FOG");
  50332. }
  50333. if (defines.SPECULARAA) {
  50334. fallbacks.addFallback(fallbackRank, "SPECULARAA");
  50335. }
  50336. if (defines.POINTSIZE) {
  50337. fallbacks.addFallback(fallbackRank, "POINTSIZE");
  50338. }
  50339. if (defines.LOGARITHMICDEPTH) {
  50340. fallbacks.addFallback(fallbackRank, "LOGARITHMICDEPTH");
  50341. }
  50342. if (defines.PARALLAX) {
  50343. fallbacks.addFallback(fallbackRank, "PARALLAX");
  50344. }
  50345. if (defines.PARALLAXOCCLUSION) {
  50346. fallbacks.addFallback(fallbackRank++, "PARALLAXOCCLUSION");
  50347. }
  50348. if (defines.ENVIRONMENTBRDF) {
  50349. fallbacks.addFallback(fallbackRank++, "ENVIRONMENTBRDF");
  50350. }
  50351. if (defines.TANGENT) {
  50352. fallbacks.addFallback(fallbackRank++, "TANGENT");
  50353. }
  50354. if (defines.BUMP) {
  50355. fallbacks.addFallback(fallbackRank++, "BUMP");
  50356. }
  50357. fallbackRank = _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights, fallbackRank++);
  50358. if (defines.SPECULARTERM) {
  50359. fallbacks.addFallback(fallbackRank++, "SPECULARTERM");
  50360. }
  50361. if (defines.USESPHERICALFROMREFLECTIONMAP) {
  50362. fallbacks.addFallback(fallbackRank++, "USESPHERICALFROMREFLECTIONMAP");
  50363. }
  50364. if (defines.LIGHTMAP) {
  50365. fallbacks.addFallback(fallbackRank++, "LIGHTMAP");
  50366. }
  50367. if (defines.NORMAL) {
  50368. fallbacks.addFallback(fallbackRank++, "NORMAL");
  50369. }
  50370. if (defines.AMBIENT) {
  50371. fallbacks.addFallback(fallbackRank++, "AMBIENT");
  50372. }
  50373. if (defines.EMISSIVE) {
  50374. fallbacks.addFallback(fallbackRank++, "EMISSIVE");
  50375. }
  50376. if (defines.VERTEXCOLOR) {
  50377. fallbacks.addFallback(fallbackRank++, "VERTEXCOLOR");
  50378. }
  50379. if (defines.NUM_BONE_INFLUENCERS > 0) {
  50380. fallbacks.addCPUSkinningFallback(fallbackRank++, mesh);
  50381. }
  50382. if (defines.MORPHTARGETS) {
  50383. fallbacks.addFallback(fallbackRank++, "MORPHTARGETS");
  50384. }
  50385. //Attributes
  50386. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  50387. if (defines.NORMAL) {
  50388. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  50389. }
  50390. if (defines.TANGENT) {
  50391. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind);
  50392. }
  50393. if (defines.UV1) {
  50394. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  50395. }
  50396. if (defines.UV2) {
  50397. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  50398. }
  50399. if (defines.VERTEXCOLOR) {
  50400. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  50401. }
  50402. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  50403. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  50404. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  50405. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vEmissiveColor", "vReflectionColor",
  50406. "vFogInfos", "vFogColor", "pointSize",
  50407. "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos",
  50408. "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  50409. "mBones",
  50410. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix",
  50411. "vLightingIntensity",
  50412. "logarithmicDepthConstant",
  50413. "vSphericalX", "vSphericalY", "vSphericalZ",
  50414. "vSphericalXX", "vSphericalYY", "vSphericalZZ",
  50415. "vSphericalXY", "vSphericalYZ", "vSphericalZX",
  50416. "vReflectionMicrosurfaceInfos", "vRefractionMicrosurfaceInfos",
  50417. "vTangentSpaceParams", "boneTextureWidth"
  50418. ];
  50419. var samplers = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler",
  50420. "bumpSampler", "lightmapSampler", "opacitySampler",
  50421. "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh",
  50422. "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh",
  50423. "microSurfaceSampler", "environmentBrdfSampler", "boneSampler"];
  50424. var uniformBuffers = ["Material", "Scene"];
  50425. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"]) {
  50426. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  50427. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_8__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  50428. }
  50429. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareUniformsAndSamplersList({
  50430. uniformsNames: uniforms,
  50431. uniformBuffersNames: uniformBuffers,
  50432. samplers: samplers,
  50433. defines: defines,
  50434. maxSimultaneousLights: this._maxSimultaneousLights
  50435. });
  50436. var join = defines.toString();
  50437. return engine.createEffect("pbr", {
  50438. attributes: attribs,
  50439. uniformsNames: uniforms,
  50440. uniformBuffersNames: uniformBuffers,
  50441. samplers: samplers,
  50442. defines: join,
  50443. fallbacks: fallbacks,
  50444. onCompiled: onCompiled,
  50445. onError: onError,
  50446. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  50447. }, engine);
  50448. };
  50449. PBRBaseMaterial.prototype._prepareDefines = function (mesh, defines, useInstances, useClipPlane) {
  50450. if (useInstances === void 0) { useInstances = null; }
  50451. if (useClipPlane === void 0) { useClipPlane = null; }
  50452. var scene = this.getScene();
  50453. var engine = scene.getEngine();
  50454. // Lights
  50455. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  50456. defines._needNormals = true;
  50457. // Textures
  50458. defines.METALLICWORKFLOW = this.isMetallicWorkflow();
  50459. if (defines._areTexturesDirty) {
  50460. defines._needUVs = false;
  50461. if (scene.texturesEnabled) {
  50462. if (scene.getEngine().getCaps().textureLOD) {
  50463. defines.LODBASEDMICROSFURACE = true;
  50464. }
  50465. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50466. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._albedoTexture, defines, "ALBEDO");
  50467. }
  50468. else {
  50469. defines.ALBEDO = false;
  50470. }
  50471. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  50472. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  50473. defines.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale;
  50474. }
  50475. else {
  50476. defines.AMBIENT = false;
  50477. }
  50478. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  50479. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  50480. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  50481. }
  50482. else {
  50483. defines.OPACITY = false;
  50484. }
  50485. var reflectionTexture = this._getReflectionTexture();
  50486. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50487. defines.REFLECTION = true;
  50488. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  50489. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  50490. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  50491. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  50492. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].INVCUBIC_MODE) {
  50493. defines.INVERTCUBICMAP = true;
  50494. }
  50495. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  50496. defines.REFLECTIONMAP_CUBIC = false;
  50497. defines.REFLECTIONMAP_EXPLICIT = false;
  50498. defines.REFLECTIONMAP_PLANAR = false;
  50499. defines.REFLECTIONMAP_PROJECTION = false;
  50500. defines.REFLECTIONMAP_SKYBOX = false;
  50501. defines.REFLECTIONMAP_SPHERICAL = false;
  50502. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  50503. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  50504. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  50505. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  50506. switch (reflectionTexture.coordinatesMode) {
  50507. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].EXPLICIT_MODE:
  50508. defines.REFLECTIONMAP_EXPLICIT = true;
  50509. break;
  50510. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].PLANAR_MODE:
  50511. defines.REFLECTIONMAP_PLANAR = true;
  50512. break;
  50513. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].PROJECTION_MODE:
  50514. defines.REFLECTIONMAP_PROJECTION = true;
  50515. break;
  50516. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SKYBOX_MODE:
  50517. defines.REFLECTIONMAP_SKYBOX = true;
  50518. break;
  50519. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SPHERICAL_MODE:
  50520. defines.REFLECTIONMAP_SPHERICAL = true;
  50521. break;
  50522. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].EQUIRECTANGULAR_MODE:
  50523. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  50524. break;
  50525. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  50526. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  50527. break;
  50528. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  50529. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  50530. break;
  50531. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].CUBIC_MODE:
  50532. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].INVCUBIC_MODE:
  50533. default:
  50534. defines.REFLECTIONMAP_CUBIC = true;
  50535. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = reflectionTexture.boundingBoxSize ? true : false;
  50536. break;
  50537. }
  50538. if (reflectionTexture.coordinatesMode !== _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].SKYBOX_MODE) {
  50539. if (reflectionTexture.sphericalPolynomial) {
  50540. defines.USESPHERICALFROMREFLECTIONMAP = true;
  50541. if (this._forceIrradianceInFragment || scene.getEngine().getCaps().maxVaryingVectors <= 8) {
  50542. defines.USESPHERICALINVERTEX = false;
  50543. }
  50544. else {
  50545. defines.USESPHERICALINVERTEX = true;
  50546. }
  50547. }
  50548. }
  50549. else {
  50550. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  50551. }
  50552. }
  50553. else {
  50554. defines.REFLECTION = false;
  50555. defines.REFLECTIONMAP_3D = false;
  50556. defines.REFLECTIONMAP_SPHERICAL = false;
  50557. defines.REFLECTIONMAP_PLANAR = false;
  50558. defines.REFLECTIONMAP_CUBIC = false;
  50559. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  50560. defines.REFLECTIONMAP_PROJECTION = false;
  50561. defines.REFLECTIONMAP_SKYBOX = false;
  50562. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  50563. defines.REFLECTIONMAP_EXPLICIT = false;
  50564. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  50565. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  50566. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  50567. defines.INVERTCUBICMAP = false;
  50568. defines.USESPHERICALFROMREFLECTIONMAP = false;
  50569. defines.USESPHERICALINVERTEX = false;
  50570. defines.REFLECTIONMAP_OPPOSITEZ = false;
  50571. defines.LODINREFLECTIONALPHA = false;
  50572. defines.GAMMAREFLECTION = false;
  50573. defines.RGBDREFLECTION = false;
  50574. }
  50575. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  50576. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  50577. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  50578. defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
  50579. }
  50580. else {
  50581. defines.LIGHTMAP = false;
  50582. }
  50583. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  50584. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  50585. }
  50586. else {
  50587. defines.EMISSIVE = false;
  50588. }
  50589. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  50590. if (this._metallicTexture) {
  50591. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._metallicTexture, defines, "REFLECTIVITY");
  50592. defines.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha;
  50593. defines.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen;
  50594. defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue;
  50595. defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;
  50596. }
  50597. else if (this._reflectivityTexture) {
  50598. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._reflectivityTexture, defines, "REFLECTIVITY");
  50599. defines.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha;
  50600. defines.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap;
  50601. }
  50602. else {
  50603. defines.REFLECTIVITY = false;
  50604. }
  50605. if (this._microSurfaceTexture) {
  50606. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._microSurfaceTexture, defines, "MICROSURFACEMAP");
  50607. }
  50608. else {
  50609. defines.MICROSURFACEMAP = false;
  50610. }
  50611. }
  50612. else {
  50613. defines.REFLECTIVITY = false;
  50614. defines.MICROSURFACEMAP = false;
  50615. }
  50616. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  50617. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  50618. if (this._useParallax && this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50619. defines.PARALLAX = true;
  50620. defines.PARALLAXOCCLUSION = !!this._useParallaxOcclusion;
  50621. }
  50622. else {
  50623. defines.PARALLAX = false;
  50624. }
  50625. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  50626. }
  50627. else {
  50628. defines.BUMP = false;
  50629. }
  50630. var refractionTexture = this._getRefractionTexture();
  50631. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  50632. defines.REFRACTION = true;
  50633. defines.REFRACTIONMAP_3D = refractionTexture.isCube;
  50634. defines.GAMMAREFRACTION = refractionTexture.gammaSpace;
  50635. defines.RGBDREFRACTION = refractionTexture.isRGBD;
  50636. defines.REFRACTIONMAP_OPPOSITEZ = refractionTexture.invertZ;
  50637. defines.LODINREFRACTIONALPHA = refractionTexture.lodLevelInAlpha;
  50638. if (this._linkRefractionWithTransparency) {
  50639. defines.LINKREFRACTIONTOTRANSPARENCY = true;
  50640. }
  50641. }
  50642. else {
  50643. defines.REFRACTION = false;
  50644. }
  50645. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50646. defines.ENVIRONMENTBRDF = true;
  50647. }
  50648. else {
  50649. defines.ENVIRONMENTBRDF = false;
  50650. }
  50651. if (this._shouldUseAlphaFromAlbedoTexture()) {
  50652. defines.ALPHAFROMALBEDO = true;
  50653. }
  50654. else {
  50655. defines.ALPHAFROMALBEDO = false;
  50656. }
  50657. }
  50658. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  50659. if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD) {
  50660. defines.USEPHYSICALLIGHTFALLOFF = false;
  50661. defines.USEGLTFLIGHTFALLOFF = false;
  50662. }
  50663. else if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF) {
  50664. defines.USEPHYSICALLIGHTFALLOFF = false;
  50665. defines.USEGLTFLIGHTFALLOFF = true;
  50666. }
  50667. else {
  50668. defines.USEPHYSICALLIGHTFALLOFF = true;
  50669. defines.USEGLTFLIGHTFALLOFF = false;
  50670. }
  50671. defines.RADIANCEOVERALPHA = this._useRadianceOverAlpha;
  50672. if (!this.backFaceCulling && this._twoSidedLighting) {
  50673. defines.TWOSIDEDLIGHTING = true;
  50674. }
  50675. else {
  50676. defines.TWOSIDEDLIGHTING = false;
  50677. }
  50678. defines.ALPHATESTVALUE = "" + this._alphaCutOff + (this._alphaCutOff % 1 === 0 ? "." : "");
  50679. 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);
  50680. defines.ALPHABLEND = this.needAlphaBlendingForMesh(mesh);
  50681. defines.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel;
  50682. defines.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel;
  50683. defines.SPECULARAA = scene.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
  50684. }
  50685. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  50686. this._imageProcessingConfiguration.prepareDefines(defines);
  50687. }
  50688. defines.FORCENORMALFORWARD = this._forceNormalForward;
  50689. defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
  50690. defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
  50691. // Misc.
  50692. if (defines._areMiscDirty) {
  50693. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
  50694. defines.UNLIT = this._unlit || ((this.pointsCloud || this.wireframe) && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind));
  50695. }
  50696. // Values that need to be evaluated on every frame
  50697. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, useClipPlane);
  50698. // Attribs
  50699. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE);
  50700. };
  50701. /**
  50702. * Force shader compilation
  50703. */
  50704. PBRBaseMaterial.prototype.forceCompilation = function (mesh, onCompiled, options) {
  50705. var _this = this;
  50706. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  50707. var defines = new PBRMaterialDefines();
  50708. var effect = this._prepareEffect(mesh, defines, undefined, undefined, undefined, localOptions.clipPlane);
  50709. if (effect.isReady()) {
  50710. if (onCompiled) {
  50711. onCompiled(this);
  50712. }
  50713. }
  50714. else {
  50715. effect.onCompileObservable.add(function () {
  50716. if (onCompiled) {
  50717. onCompiled(_this);
  50718. }
  50719. });
  50720. }
  50721. };
  50722. /**
  50723. * Initializes the uniform buffer layout for the shader.
  50724. */
  50725. PBRBaseMaterial.prototype.buildUniformLayout = function () {
  50726. // Order is important !
  50727. this._uniformBuffer.addUniform("vAlbedoInfos", 2);
  50728. this._uniformBuffer.addUniform("vAmbientInfos", 4);
  50729. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  50730. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  50731. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  50732. this._uniformBuffer.addUniform("vReflectivityInfos", 3);
  50733. this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos", 2);
  50734. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  50735. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  50736. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  50737. this._uniformBuffer.addUniform("vReflectionSize", 3);
  50738. this._uniformBuffer.addUniform("vBumpInfos", 3);
  50739. this._uniformBuffer.addUniform("albedoMatrix", 16);
  50740. this._uniformBuffer.addUniform("ambientMatrix", 16);
  50741. this._uniformBuffer.addUniform("opacityMatrix", 16);
  50742. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  50743. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  50744. this._uniformBuffer.addUniform("reflectivityMatrix", 16);
  50745. this._uniformBuffer.addUniform("microSurfaceSamplerMatrix", 16);
  50746. this._uniformBuffer.addUniform("bumpMatrix", 16);
  50747. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  50748. this._uniformBuffer.addUniform("refractionMatrix", 16);
  50749. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  50750. this._uniformBuffer.addUniform("vReflectionColor", 3);
  50751. this._uniformBuffer.addUniform("vAlbedoColor", 4);
  50752. this._uniformBuffer.addUniform("vLightingIntensity", 4);
  50753. this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos", 3);
  50754. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  50755. this._uniformBuffer.addUniform("vReflectivityColor", 4);
  50756. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  50757. this._uniformBuffer.addUniform("pointSize", 1);
  50758. this._uniformBuffer.create();
  50759. };
  50760. /**
  50761. * Unbinds the textures.
  50762. */
  50763. PBRBaseMaterial.prototype.unbind = function () {
  50764. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  50765. this._uniformBuffer.setTexture("reflectionSampler", null);
  50766. }
  50767. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  50768. this._uniformBuffer.setTexture("refractionSampler", null);
  50769. }
  50770. _super.prototype.unbind.call(this);
  50771. };
  50772. /**
  50773. * Binds the submesh data.
  50774. * @param world - The world matrix.
  50775. * @param mesh - The BJS mesh.
  50776. * @param subMesh - A submesh of the BJS mesh.
  50777. */
  50778. PBRBaseMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  50779. var scene = this.getScene();
  50780. var defines = subMesh._materialDefines;
  50781. if (!defines) {
  50782. return;
  50783. }
  50784. var effect = subMesh.effect;
  50785. if (!effect) {
  50786. return;
  50787. }
  50788. this._activeEffect = effect;
  50789. // Matrices
  50790. this.bindOnlyWorldMatrix(world);
  50791. // Normal Matrix
  50792. if (defines.OBJECTSPACE_NORMALMAP) {
  50793. world.toNormalMatrix(this._normalMatrix);
  50794. this.bindOnlyNormalMatrix(this._normalMatrix);
  50795. }
  50796. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  50797. // Bones
  50798. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  50799. var reflectionTexture = null;
  50800. if (mustRebind) {
  50801. this._uniformBuffer.bindToEffect(effect, "Material");
  50802. this.bindViewProjection(effect);
  50803. reflectionTexture = this._getReflectionTexture();
  50804. var refractionTexture = this._getRefractionTexture();
  50805. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  50806. // Texture uniforms
  50807. if (scene.texturesEnabled) {
  50808. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50809. this._uniformBuffer.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level);
  50810. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._albedoTexture, this._uniformBuffer, "albedo");
  50811. }
  50812. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  50813. this._uniformBuffer.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights);
  50814. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  50815. }
  50816. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  50817. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  50818. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  50819. }
  50820. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50821. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  50822. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, 0);
  50823. if (reflectionTexture.boundingBoxSize) {
  50824. var cubeTexture = reflectionTexture;
  50825. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  50826. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  50827. }
  50828. var polynomials = reflectionTexture.sphericalPolynomial;
  50829. if (defines.USESPHERICALFROMREFLECTIONMAP && polynomials) {
  50830. this._activeEffect.setFloat3("vSphericalX", polynomials.x.x, polynomials.x.y, polynomials.x.z);
  50831. this._activeEffect.setFloat3("vSphericalY", polynomials.y.x, polynomials.y.y, polynomials.y.z);
  50832. this._activeEffect.setFloat3("vSphericalZ", polynomials.z.x, polynomials.z.y, polynomials.z.z);
  50833. this._activeEffect.setFloat3("vSphericalXX_ZZ", polynomials.xx.x - polynomials.zz.x, polynomials.xx.y - polynomials.zz.y, polynomials.xx.z - polynomials.zz.z);
  50834. this._activeEffect.setFloat3("vSphericalYY_ZZ", polynomials.yy.x - polynomials.zz.x, polynomials.yy.y - polynomials.zz.y, polynomials.yy.z - polynomials.zz.z);
  50835. this._activeEffect.setFloat3("vSphericalZZ", polynomials.zz.x, polynomials.zz.y, polynomials.zz.z);
  50836. this._activeEffect.setFloat3("vSphericalXY", polynomials.xy.x, polynomials.xy.y, polynomials.xy.z);
  50837. this._activeEffect.setFloat3("vSphericalYZ", polynomials.yz.x, polynomials.yz.y, polynomials.yz.z);
  50838. this._activeEffect.setFloat3("vSphericalZX", polynomials.zx.x, polynomials.zx.y, polynomials.zx.z);
  50839. }
  50840. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  50841. }
  50842. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  50843. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  50844. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  50845. }
  50846. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  50847. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  50848. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  50849. }
  50850. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  50851. if (this._metallicTexture) {
  50852. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength);
  50853. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._metallicTexture, this._uniformBuffer, "reflectivity");
  50854. }
  50855. else if (this._reflectivityTexture) {
  50856. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1.0);
  50857. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._reflectivityTexture, this._uniformBuffer, "reflectivity");
  50858. }
  50859. if (this._microSurfaceTexture) {
  50860. this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level);
  50861. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._microSurfaceTexture, this._uniformBuffer, "microSurfaceSampler");
  50862. }
  50863. }
  50864. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  50865. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias);
  50866. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  50867. if (scene._mirroredCameraPosition) {
  50868. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  50869. }
  50870. else {
  50871. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  50872. }
  50873. }
  50874. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  50875. this._uniformBuffer.updateMatrix("refractionMatrix", refractionTexture.getReflectionTextureMatrix());
  50876. var depth = 1.0;
  50877. if (!refractionTexture.isCube) {
  50878. if (refractionTexture.depth) {
  50879. depth = refractionTexture.depth;
  50880. }
  50881. }
  50882. this._uniformBuffer.updateFloat4("vRefractionInfos", refractionTexture.level, this._indexOfRefraction, depth, this._invertRefractionY ? -1 : 1);
  50883. this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos", refractionTexture.getSize().width, refractionTexture.lodGenerationScale, refractionTexture.lodGenerationOffset);
  50884. }
  50885. }
  50886. // Point size
  50887. if (this.pointsCloud) {
  50888. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  50889. }
  50890. // Colors
  50891. if (defines.METALLICWORKFLOW) {
  50892. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].r = (this._metallic === undefined || this._metallic === null) ? 1 : this._metallic;
  50893. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].g = (this._roughness === undefined || this._roughness === null) ? 1 : this._roughness;
  50894. this._uniformBuffer.updateColor4("vReflectivityColor", _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0], 0);
  50895. }
  50896. else {
  50897. this._uniformBuffer.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
  50898. }
  50899. this._uniformBuffer.updateColor3("vEmissiveColor", _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled ? this._emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"].BlackReadOnly);
  50900. this._uniformBuffer.updateColor3("vReflectionColor", this._reflectionColor);
  50901. this._uniformBuffer.updateColor4("vAlbedoColor", this._albedoColor, this.alpha * mesh.visibility);
  50902. // Misc
  50903. this._lightingInfos.x = this._directIntensity;
  50904. this._lightingInfos.y = this._emissiveIntensity;
  50905. this._lightingInfos.z = this._environmentIntensity;
  50906. this._lightingInfos.w = this._specularIntensity;
  50907. this._uniformBuffer.updateVector4("vLightingIntensity", this._lightingInfos);
  50908. }
  50909. // Textures
  50910. if (scene.texturesEnabled) {
  50911. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50912. this._uniformBuffer.setTexture("albedoSampler", this._albedoTexture);
  50913. }
  50914. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].AmbientTextureEnabled) {
  50915. this._uniformBuffer.setTexture("ambientSampler", this._ambientTexture);
  50916. }
  50917. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].OpacityTextureEnabled) {
  50918. this._uniformBuffer.setTexture("opacitySampler", this._opacityTexture);
  50919. }
  50920. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50921. if (defines.LODBASEDMICROSFURACE) {
  50922. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  50923. }
  50924. else {
  50925. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  50926. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  50927. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  50928. }
  50929. }
  50930. if (defines.ENVIRONMENTBRDF) {
  50931. this._uniformBuffer.setTexture("environmentBrdfSampler", this._environmentBRDFTexture);
  50932. }
  50933. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].RefractionTextureEnabled) {
  50934. if (defines.LODBASEDMICROSFURACE) {
  50935. this._uniformBuffer.setTexture("refractionSampler", refractionTexture);
  50936. }
  50937. else {
  50938. this._uniformBuffer.setTexture("refractionSampler", refractionTexture._lodTextureMid || refractionTexture);
  50939. this._uniformBuffer.setTexture("refractionSamplerLow", refractionTexture._lodTextureLow || refractionTexture);
  50940. this._uniformBuffer.setTexture("refractionSamplerHigh", refractionTexture._lodTextureHigh || refractionTexture);
  50941. }
  50942. }
  50943. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].EmissiveTextureEnabled) {
  50944. this._uniformBuffer.setTexture("emissiveSampler", this._emissiveTexture);
  50945. }
  50946. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].LightmapTextureEnabled) {
  50947. this._uniformBuffer.setTexture("lightmapSampler", this._lightmapTexture);
  50948. }
  50949. if (_materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].SpecularTextureEnabled) {
  50950. if (this._metallicTexture) {
  50951. this._uniformBuffer.setTexture("reflectivitySampler", this._metallicTexture);
  50952. }
  50953. else if (this._reflectivityTexture) {
  50954. this._uniformBuffer.setTexture("reflectivitySampler", this._reflectivityTexture);
  50955. }
  50956. if (this._microSurfaceTexture) {
  50957. this._uniformBuffer.setTexture("microSurfaceSampler", this._microSurfaceTexture);
  50958. }
  50959. }
  50960. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  50961. this._uniformBuffer.setTexture("bumpSampler", this._bumpTexture);
  50962. }
  50963. }
  50964. // Clip plane
  50965. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  50966. // Colors
  50967. scene.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor);
  50968. var eyePosition = scene._forcedViewPosition ? scene._forcedViewPosition : (scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  50969. var invertNormal = (scene.useRightHandedSystem === (scene._mirroredCameraPosition != null));
  50970. effect.setFloat4("vEyePosition", eyePosition.x, eyePosition.y, eyePosition.z, invertNormal ? -1 : 1);
  50971. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  50972. }
  50973. if (mustRebind || !this.isFrozen) {
  50974. // Lights
  50975. if (scene.lightsEnabled && !this._disableLighting) {
  50976. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, this._lightFalloff !== PBRBaseMaterial.LIGHTFALLOFF_STANDARD);
  50977. }
  50978. // View
  50979. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].FOGMODE_NONE || reflectionTexture) {
  50980. this.bindView(effect);
  50981. }
  50982. // Fog
  50983. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  50984. // Morph targets
  50985. if (defines.NUM_MORPH_INFLUENCERS) {
  50986. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindMorphTargetParameters(mesh, this._activeEffect);
  50987. }
  50988. // image processing
  50989. this._imageProcessingConfiguration.bind(this._activeEffect);
  50990. // Log. depth
  50991. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_12__["MaterialHelper"].BindLogDepth(defines, this._activeEffect, scene);
  50992. }
  50993. this._uniformBuffer.update();
  50994. this._afterBind(mesh, this._activeEffect);
  50995. };
  50996. /**
  50997. * Returns the animatable textures.
  50998. * @returns - Array of animatable textures.
  50999. */
  51000. PBRBaseMaterial.prototype.getAnimatables = function () {
  51001. var results = [];
  51002. if (this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0) {
  51003. results.push(this._albedoTexture);
  51004. }
  51005. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  51006. results.push(this._ambientTexture);
  51007. }
  51008. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  51009. results.push(this._opacityTexture);
  51010. }
  51011. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  51012. results.push(this._reflectionTexture);
  51013. }
  51014. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  51015. results.push(this._emissiveTexture);
  51016. }
  51017. if (this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0) {
  51018. results.push(this._metallicTexture);
  51019. }
  51020. else if (this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0) {
  51021. results.push(this._reflectivityTexture);
  51022. }
  51023. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  51024. results.push(this._bumpTexture);
  51025. }
  51026. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  51027. results.push(this._lightmapTexture);
  51028. }
  51029. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  51030. results.push(this._refractionTexture);
  51031. }
  51032. return results;
  51033. };
  51034. /**
  51035. * Returns the texture used for reflections.
  51036. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51037. */
  51038. PBRBaseMaterial.prototype._getReflectionTexture = function () {
  51039. if (this._reflectionTexture) {
  51040. return this._reflectionTexture;
  51041. }
  51042. return this.getScene().environmentTexture;
  51043. };
  51044. /**
  51045. * Returns the texture used for refraction or null if none is used.
  51046. * @returns - Refection texture if present. If no refraction texture and refraction
  51047. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51048. */
  51049. PBRBaseMaterial.prototype._getRefractionTexture = function () {
  51050. if (this._refractionTexture) {
  51051. return this._refractionTexture;
  51052. }
  51053. if (this._linkRefractionWithTransparency) {
  51054. return this.getScene().environmentTexture;
  51055. }
  51056. return null;
  51057. };
  51058. /**
  51059. * Disposes the resources of the material.
  51060. * @param forceDisposeEffect - Forces the disposal of effects.
  51061. * @param forceDisposeTextures - Forces the disposal of all textures.
  51062. */
  51063. PBRBaseMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  51064. if (forceDisposeTextures) {
  51065. if (this._albedoTexture) {
  51066. this._albedoTexture.dispose();
  51067. }
  51068. if (this._ambientTexture) {
  51069. this._ambientTexture.dispose();
  51070. }
  51071. if (this._opacityTexture) {
  51072. this._opacityTexture.dispose();
  51073. }
  51074. if (this._reflectionTexture) {
  51075. this._reflectionTexture.dispose();
  51076. }
  51077. if (this._environmentBRDFTexture && this.getScene()._environmentBRDFTexture !== this._environmentBRDFTexture) {
  51078. this._environmentBRDFTexture.dispose();
  51079. }
  51080. if (this._emissiveTexture) {
  51081. this._emissiveTexture.dispose();
  51082. }
  51083. if (this._metallicTexture) {
  51084. this._metallicTexture.dispose();
  51085. }
  51086. if (this._reflectivityTexture) {
  51087. this._reflectivityTexture.dispose();
  51088. }
  51089. if (this._bumpTexture) {
  51090. this._bumpTexture.dispose();
  51091. }
  51092. if (this._lightmapTexture) {
  51093. this._lightmapTexture.dispose();
  51094. }
  51095. if (this._refractionTexture) {
  51096. this._refractionTexture.dispose();
  51097. }
  51098. }
  51099. this._renderTargets.dispose();
  51100. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  51101. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  51102. }
  51103. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  51104. };
  51105. /**
  51106. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51107. */
  51108. PBRBaseMaterial.PBRMATERIAL_OPAQUE = 0;
  51109. /**
  51110. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51111. */
  51112. PBRBaseMaterial.PBRMATERIAL_ALPHATEST = 1;
  51113. /**
  51114. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51115. */
  51116. PBRBaseMaterial.PBRMATERIAL_ALPHABLEND = 2;
  51117. /**
  51118. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51119. * They are also discarded below the alpha cutoff threshold to improve performances.
  51120. */
  51121. PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND = 3;
  51122. /**
  51123. * Defines the default value of how much AO map is occluding the analytical lights
  51124. * (point spot...).
  51125. */
  51126. PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 1;
  51127. /**
  51128. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51129. */
  51130. PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL = 0;
  51131. /**
  51132. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51133. * to enhance interoperability with other engines.
  51134. */
  51135. PBRBaseMaterial.LIGHTFALLOFF_GLTF = 1;
  51136. /**
  51137. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51138. * to enhance interoperability with other materials.
  51139. */
  51140. PBRBaseMaterial.LIGHTFALLOFF_STANDARD = 2;
  51141. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51142. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  51143. ], PBRBaseMaterial.prototype, "_imageProcessingConfiguration", void 0);
  51144. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51145. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51146. ], PBRBaseMaterial.prototype, "useLogarithmicDepth", null);
  51147. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51148. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51149. ], PBRBaseMaterial.prototype, "transparencyMode", null);
  51150. return PBRBaseMaterial;
  51151. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_11__["PushMaterial"]));
  51152. /***/ }),
  51153. /***/ "./Materials/PBR/pbrBaseSimpleMaterial.ts":
  51154. /*!************************************************!*\
  51155. !*** ./Materials/PBR/pbrBaseSimpleMaterial.ts ***!
  51156. \************************************************/
  51157. /*! exports provided: PBRBaseSimpleMaterial */
  51158. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51159. "use strict";
  51160. __webpack_require__.r(__webpack_exports__);
  51161. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return PBRBaseSimpleMaterial; });
  51162. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51163. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51164. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  51165. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  51166. /**
  51167. * The Physically based simple base material of BJS.
  51168. *
  51169. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51170. * It is used as the base class for both the specGloss and metalRough conventions.
  51171. */
  51172. var PBRBaseSimpleMaterial = /** @class */ (function (_super) {
  51173. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseSimpleMaterial, _super);
  51174. /**
  51175. * Instantiates a new PBRMaterial instance.
  51176. *
  51177. * @param name The material name
  51178. * @param scene The scene the material will be use in.
  51179. */
  51180. function PBRBaseSimpleMaterial(name, scene) {
  51181. var _this = _super.call(this, name, scene) || this;
  51182. /**
  51183. * Number of Simultaneous lights allowed on the material.
  51184. */
  51185. _this.maxSimultaneousLights = 4;
  51186. /**
  51187. * If sets to true, disables all the lights affecting the material.
  51188. */
  51189. _this.disableLighting = false;
  51190. /**
  51191. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51192. */
  51193. _this.invertNormalMapX = false;
  51194. /**
  51195. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51196. */
  51197. _this.invertNormalMapY = false;
  51198. /**
  51199. * Emissivie color used to self-illuminate the model.
  51200. */
  51201. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0, 0, 0);
  51202. /**
  51203. * Occlusion Channel Strenght.
  51204. */
  51205. _this.occlusionStrength = 1.0;
  51206. /**
  51207. * If true, the light map contains occlusion information instead of lighting info.
  51208. */
  51209. _this.useLightmapAsShadowmap = false;
  51210. _this._useAlphaFromAlbedoTexture = true;
  51211. _this._useAmbientInGrayScale = true;
  51212. return _this;
  51213. }
  51214. Object.defineProperty(PBRBaseSimpleMaterial.prototype, "doubleSided", {
  51215. /**
  51216. * Gets the current double sided mode.
  51217. */
  51218. get: function () {
  51219. return this._twoSidedLighting;
  51220. },
  51221. /**
  51222. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51223. */
  51224. set: function (value) {
  51225. if (this._twoSidedLighting === value) {
  51226. return;
  51227. }
  51228. this._twoSidedLighting = value;
  51229. this.backFaceCulling = !value;
  51230. this._markAllSubMeshesAsTexturesDirty();
  51231. },
  51232. enumerable: true,
  51233. configurable: true
  51234. });
  51235. /**
  51236. * Return the active textures of the material.
  51237. */
  51238. PBRBaseSimpleMaterial.prototype.getActiveTextures = function () {
  51239. var activeTextures = _super.prototype.getActiveTextures.call(this);
  51240. if (this.environmentTexture) {
  51241. activeTextures.push(this.environmentTexture);
  51242. }
  51243. if (this.normalTexture) {
  51244. activeTextures.push(this.normalTexture);
  51245. }
  51246. if (this.emissiveTexture) {
  51247. activeTextures.push(this.emissiveTexture);
  51248. }
  51249. if (this.occlusionTexture) {
  51250. activeTextures.push(this.occlusionTexture);
  51251. }
  51252. if (this.lightmapTexture) {
  51253. activeTextures.push(this.lightmapTexture);
  51254. }
  51255. return activeTextures;
  51256. };
  51257. PBRBaseSimpleMaterial.prototype.hasTexture = function (texture) {
  51258. if (_super.prototype.hasTexture.call(this, texture)) {
  51259. return true;
  51260. }
  51261. if (this.lightmapTexture === texture) {
  51262. return true;
  51263. }
  51264. return false;
  51265. };
  51266. PBRBaseSimpleMaterial.prototype.getClassName = function () {
  51267. return "PBRBaseSimpleMaterial";
  51268. };
  51269. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51270. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51271. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51272. ], PBRBaseSimpleMaterial.prototype, "maxSimultaneousLights", void 0);
  51273. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51274. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51275. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51276. ], PBRBaseSimpleMaterial.prototype, "disableLighting", void 0);
  51277. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51278. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51279. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")
  51280. ], PBRBaseSimpleMaterial.prototype, "environmentTexture", void 0);
  51281. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51282. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51283. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51284. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapX", void 0);
  51285. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51286. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51288. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapY", void 0);
  51289. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51291. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")
  51292. ], PBRBaseSimpleMaterial.prototype, "normalTexture", void 0);
  51293. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51294. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  51295. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51296. ], PBRBaseSimpleMaterial.prototype, "emissiveColor", void 0);
  51297. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51298. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51299. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51300. ], PBRBaseSimpleMaterial.prototype, "emissiveTexture", void 0);
  51301. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51302. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51303. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")
  51304. ], PBRBaseSimpleMaterial.prototype, "occlusionStrength", void 0);
  51305. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51306. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51307. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")
  51308. ], PBRBaseSimpleMaterial.prototype, "occlusionTexture", void 0);
  51309. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51310. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51311. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")
  51312. ], PBRBaseSimpleMaterial.prototype, "alphaCutOff", void 0);
  51313. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51314. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51315. ], PBRBaseSimpleMaterial.prototype, "doubleSided", null);
  51316. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51317. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51318. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  51319. ], PBRBaseSimpleMaterial.prototype, "lightmapTexture", void 0);
  51320. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51321. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51322. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51323. ], PBRBaseSimpleMaterial.prototype, "useLightmapAsShadowmap", void 0);
  51324. return PBRBaseSimpleMaterial;
  51325. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRBaseMaterial"]));
  51326. /***/ }),
  51327. /***/ "./Materials/PBR/pbrMaterial.ts":
  51328. /*!**************************************!*\
  51329. !*** ./Materials/PBR/pbrMaterial.ts ***!
  51330. \**************************************/
  51331. /*! exports provided: PBRMaterial */
  51332. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51333. "use strict";
  51334. __webpack_require__.r(__webpack_exports__);
  51335. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return PBRMaterial; });
  51336. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51337. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51338. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  51339. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  51340. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  51341. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  51342. /**
  51343. * The Physically based material of BJS.
  51344. *
  51345. * This offers the main features of a standard PBR material.
  51346. * For more information, please refer to the documentation :
  51347. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  51348. */
  51349. var PBRMaterial = /** @class */ (function (_super) {
  51350. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterial, _super);
  51351. /**
  51352. * Instantiates a new PBRMaterial instance.
  51353. *
  51354. * @param name The material name
  51355. * @param scene The scene the material will be use in.
  51356. */
  51357. function PBRMaterial(name, scene) {
  51358. var _this = _super.call(this, name, scene) || this;
  51359. /**
  51360. * Intensity of the direct lights e.g. the four lights available in your scene.
  51361. * This impacts both the direct diffuse and specular highlights.
  51362. */
  51363. _this.directIntensity = 1.0;
  51364. /**
  51365. * Intensity of the emissive part of the material.
  51366. * This helps controlling the emissive effect without modifying the emissive color.
  51367. */
  51368. _this.emissiveIntensity = 1.0;
  51369. /**
  51370. * Intensity of the environment e.g. how much the environment will light the object
  51371. * either through harmonics for rough material or through the refelction for shiny ones.
  51372. */
  51373. _this.environmentIntensity = 1.0;
  51374. /**
  51375. * This is a special control allowing the reduction of the specular highlights coming from the
  51376. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51377. */
  51378. _this.specularIntensity = 1.0;
  51379. /**
  51380. * Debug Control allowing disabling the bump map on this material.
  51381. */
  51382. _this.disableBumpMap = false;
  51383. /**
  51384. * AKA Occlusion Texture Intensity in other nomenclature.
  51385. */
  51386. _this.ambientTextureStrength = 1.0;
  51387. /**
  51388. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51389. * 1 means it completely occludes it
  51390. * 0 mean it has no impact
  51391. */
  51392. _this.ambientTextureImpactOnAnalyticalLights = PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  51393. /**
  51394. * The color of a material in ambient lighting.
  51395. */
  51396. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  51397. /**
  51398. * AKA Diffuse Color in other nomenclature.
  51399. */
  51400. _this.albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  51401. /**
  51402. * AKA Specular Color in other nomenclature.
  51403. */
  51404. _this.reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  51405. /**
  51406. * The color reflected from the material.
  51407. */
  51408. _this.reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1.0, 1.0, 1.0);
  51409. /**
  51410. * The color emitted from the material.
  51411. */
  51412. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  51413. /**
  51414. * AKA Glossiness in other nomenclature.
  51415. */
  51416. _this.microSurface = 1.0;
  51417. /**
  51418. * source material index of refraction (IOR)' / 'destination material IOR.
  51419. */
  51420. _this.indexOfRefraction = 0.66;
  51421. /**
  51422. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51423. */
  51424. _this.invertRefractionY = false;
  51425. /**
  51426. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51427. * Materials half opaque for instance using refraction could benefit from this control.
  51428. */
  51429. _this.linkRefractionWithTransparency = false;
  51430. /**
  51431. * If true, the light map contains occlusion information instead of lighting info.
  51432. */
  51433. _this.useLightmapAsShadowmap = false;
  51434. /**
  51435. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51436. */
  51437. _this.useAlphaFromAlbedoTexture = false;
  51438. /**
  51439. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51440. */
  51441. _this.forceAlphaTest = false;
  51442. /**
  51443. * Defines the alpha limits in alpha test mode.
  51444. */
  51445. _this.alphaCutOff = 0.4;
  51446. /**
  51447. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51448. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51449. */
  51450. _this.useSpecularOverAlpha = true;
  51451. /**
  51452. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51453. */
  51454. _this.useMicroSurfaceFromReflectivityMapAlpha = false;
  51455. /**
  51456. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51457. */
  51458. _this.useRoughnessFromMetallicTextureAlpha = true;
  51459. /**
  51460. * Specifies if the metallic texture contains the roughness information in its green channel.
  51461. */
  51462. _this.useRoughnessFromMetallicTextureGreen = false;
  51463. /**
  51464. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51465. */
  51466. _this.useMetallnessFromMetallicTextureBlue = false;
  51467. /**
  51468. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51469. */
  51470. _this.useAmbientOcclusionFromMetallicTextureRed = false;
  51471. /**
  51472. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51473. */
  51474. _this.useAmbientInGrayScale = false;
  51475. /**
  51476. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51477. * The material will try to infer what glossiness each pixel should be.
  51478. */
  51479. _this.useAutoMicroSurfaceFromReflectivityMap = false;
  51480. /**
  51481. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51482. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51483. */
  51484. _this.useRadianceOverAlpha = true;
  51485. /**
  51486. * Allows using an object space normal map (instead of tangent space).
  51487. */
  51488. _this.useObjectSpaceNormalMap = false;
  51489. /**
  51490. * Allows using the bump map in parallax mode.
  51491. */
  51492. _this.useParallax = false;
  51493. /**
  51494. * Allows using the bump map in parallax occlusion mode.
  51495. */
  51496. _this.useParallaxOcclusion = false;
  51497. /**
  51498. * Controls the scale bias of the parallax mode.
  51499. */
  51500. _this.parallaxScaleBias = 0.05;
  51501. /**
  51502. * If sets to true, disables all the lights affecting the material.
  51503. */
  51504. _this.disableLighting = false;
  51505. /**
  51506. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51507. */
  51508. _this.forceIrradianceInFragment = false;
  51509. /**
  51510. * Number of Simultaneous lights allowed on the material.
  51511. */
  51512. _this.maxSimultaneousLights = 4;
  51513. /**
  51514. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51515. */
  51516. _this.invertNormalMapX = false;
  51517. /**
  51518. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51519. */
  51520. _this.invertNormalMapY = false;
  51521. /**
  51522. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51523. */
  51524. _this.twoSidedLighting = false;
  51525. /**
  51526. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51527. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51528. */
  51529. _this.useAlphaFresnel = false;
  51530. /**
  51531. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51532. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51533. */
  51534. _this.useLinearAlphaFresnel = false;
  51535. /**
  51536. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51537. * And/Or occlude the blended part.
  51538. */
  51539. _this.environmentBRDFTexture = null;
  51540. /**
  51541. * Force normal to face away from face.
  51542. */
  51543. _this.forceNormalForward = false;
  51544. /**
  51545. * Enables specular anti aliasing in the PBR shader.
  51546. * It will both interacts on the Geometry for analytical and IBL lighting.
  51547. * It also prefilter the roughness map based on the bump values.
  51548. */
  51549. _this.enableSpecularAntiAliasing = false;
  51550. /**
  51551. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51552. * makes the reflect vector face the model (under horizon).
  51553. */
  51554. _this.useHorizonOcclusion = true;
  51555. /**
  51556. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51557. * too much the area relying on ambient texture to define their ambient occlusion.
  51558. */
  51559. _this.useRadianceOcclusion = true;
  51560. /**
  51561. * If set to true, no lighting calculations will be applied.
  51562. */
  51563. _this.unlit = false;
  51564. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  51565. return _this;
  51566. }
  51567. Object.defineProperty(PBRMaterial.prototype, "usePhysicalLightFalloff", {
  51568. /**
  51569. * BJS is using an harcoded light falloff based on a manually sets up range.
  51570. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51571. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51572. */
  51573. get: function () {
  51574. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  51575. },
  51576. /**
  51577. * BJS is using an harcoded light falloff based on a manually sets up range.
  51578. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51579. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51580. */
  51581. set: function (value) {
  51582. if (value !== this.usePhysicalLightFalloff) {
  51583. // Ensure the effect will be rebuilt.
  51584. this._markAllSubMeshesAsTexturesDirty();
  51585. if (value) {
  51586. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  51587. }
  51588. else {
  51589. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  51590. }
  51591. }
  51592. },
  51593. enumerable: true,
  51594. configurable: true
  51595. });
  51596. Object.defineProperty(PBRMaterial.prototype, "useGLTFLightFalloff", {
  51597. /**
  51598. * In order to support the falloff compatibility with gltf, a special mode has been added
  51599. * to reproduce the gltf light falloff.
  51600. */
  51601. get: function () {
  51602. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  51603. },
  51604. /**
  51605. * In order to support the falloff compatibility with gltf, a special mode has been added
  51606. * to reproduce the gltf light falloff.
  51607. */
  51608. set: function (value) {
  51609. if (value !== this.useGLTFLightFalloff) {
  51610. // Ensure the effect will be rebuilt.
  51611. this._markAllSubMeshesAsTexturesDirty();
  51612. if (value) {
  51613. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  51614. }
  51615. else {
  51616. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  51617. }
  51618. }
  51619. },
  51620. enumerable: true,
  51621. configurable: true
  51622. });
  51623. Object.defineProperty(PBRMaterial.prototype, "imageProcessingConfiguration", {
  51624. /**
  51625. * Gets the image processing configuration used either in this material.
  51626. */
  51627. get: function () {
  51628. return this._imageProcessingConfiguration;
  51629. },
  51630. /**
  51631. * Sets the Default image processing configuration used either in the this material.
  51632. *
  51633. * If sets to null, the scene one is in use.
  51634. */
  51635. set: function (value) {
  51636. this._attachImageProcessingConfiguration(value);
  51637. // Ensure the effect will be rebuilt.
  51638. this._markAllSubMeshesAsTexturesDirty();
  51639. },
  51640. enumerable: true,
  51641. configurable: true
  51642. });
  51643. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurvesEnabled", {
  51644. /**
  51645. * Gets wether the color curves effect is enabled.
  51646. */
  51647. get: function () {
  51648. return this.imageProcessingConfiguration.colorCurvesEnabled;
  51649. },
  51650. /**
  51651. * Sets wether the color curves effect is enabled.
  51652. */
  51653. set: function (value) {
  51654. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  51655. },
  51656. enumerable: true,
  51657. configurable: true
  51658. });
  51659. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingEnabled", {
  51660. /**
  51661. * Gets wether the color grading effect is enabled.
  51662. */
  51663. get: function () {
  51664. return this.imageProcessingConfiguration.colorGradingEnabled;
  51665. },
  51666. /**
  51667. * Gets wether the color grading effect is enabled.
  51668. */
  51669. set: function (value) {
  51670. this.imageProcessingConfiguration.colorGradingEnabled = value;
  51671. },
  51672. enumerable: true,
  51673. configurable: true
  51674. });
  51675. Object.defineProperty(PBRMaterial.prototype, "cameraToneMappingEnabled", {
  51676. /**
  51677. * Gets wether tonemapping is enabled or not.
  51678. */
  51679. get: function () {
  51680. return this._imageProcessingConfiguration.toneMappingEnabled;
  51681. },
  51682. /**
  51683. * Sets wether tonemapping is enabled or not
  51684. */
  51685. set: function (value) {
  51686. this._imageProcessingConfiguration.toneMappingEnabled = value;
  51687. },
  51688. enumerable: true,
  51689. configurable: true
  51690. });
  51691. Object.defineProperty(PBRMaterial.prototype, "cameraExposure", {
  51692. /**
  51693. * The camera exposure used on this material.
  51694. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51695. * This corresponds to a photographic exposure.
  51696. */
  51697. get: function () {
  51698. return this._imageProcessingConfiguration.exposure;
  51699. },
  51700. /**
  51701. * The camera exposure used on this material.
  51702. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51703. * This corresponds to a photographic exposure.
  51704. */
  51705. set: function (value) {
  51706. this._imageProcessingConfiguration.exposure = value;
  51707. },
  51708. enumerable: true,
  51709. configurable: true
  51710. });
  51711. Object.defineProperty(PBRMaterial.prototype, "cameraContrast", {
  51712. /**
  51713. * Gets The camera contrast used on this material.
  51714. */
  51715. get: function () {
  51716. return this._imageProcessingConfiguration.contrast;
  51717. },
  51718. /**
  51719. * Sets The camera contrast used on this material.
  51720. */
  51721. set: function (value) {
  51722. this._imageProcessingConfiguration.contrast = value;
  51723. },
  51724. enumerable: true,
  51725. configurable: true
  51726. });
  51727. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingTexture", {
  51728. /**
  51729. * Gets the Color Grading 2D Lookup Texture.
  51730. */
  51731. get: function () {
  51732. return this._imageProcessingConfiguration.colorGradingTexture;
  51733. },
  51734. /**
  51735. * Sets the Color Grading 2D Lookup Texture.
  51736. */
  51737. set: function (value) {
  51738. this._imageProcessingConfiguration.colorGradingTexture = value;
  51739. },
  51740. enumerable: true,
  51741. configurable: true
  51742. });
  51743. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurves", {
  51744. /**
  51745. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51746. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51747. * 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;
  51748. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51749. */
  51750. get: function () {
  51751. return this._imageProcessingConfiguration.colorCurves;
  51752. },
  51753. /**
  51754. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51755. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51756. * 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;
  51757. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51758. */
  51759. set: function (value) {
  51760. this._imageProcessingConfiguration.colorCurves = value;
  51761. },
  51762. enumerable: true,
  51763. configurable: true
  51764. });
  51765. /**
  51766. * Returns the name of this material class.
  51767. */
  51768. PBRMaterial.prototype.getClassName = function () {
  51769. return "PBRMaterial";
  51770. };
  51771. /**
  51772. * Returns an array of the actively used textures.
  51773. * @returns - Array of BaseTextures
  51774. */
  51775. PBRMaterial.prototype.getActiveTextures = function () {
  51776. var activeTextures = _super.prototype.getActiveTextures.call(this);
  51777. if (this._albedoTexture) {
  51778. activeTextures.push(this._albedoTexture);
  51779. }
  51780. if (this._ambientTexture) {
  51781. activeTextures.push(this._ambientTexture);
  51782. }
  51783. if (this._opacityTexture) {
  51784. activeTextures.push(this._opacityTexture);
  51785. }
  51786. if (this._reflectionTexture) {
  51787. activeTextures.push(this._reflectionTexture);
  51788. }
  51789. if (this._emissiveTexture) {
  51790. activeTextures.push(this._emissiveTexture);
  51791. }
  51792. if (this._reflectivityTexture) {
  51793. activeTextures.push(this._reflectivityTexture);
  51794. }
  51795. if (this._metallicTexture) {
  51796. activeTextures.push(this._metallicTexture);
  51797. }
  51798. if (this._microSurfaceTexture) {
  51799. activeTextures.push(this._microSurfaceTexture);
  51800. }
  51801. if (this._bumpTexture) {
  51802. activeTextures.push(this._bumpTexture);
  51803. }
  51804. if (this._lightmapTexture) {
  51805. activeTextures.push(this._lightmapTexture);
  51806. }
  51807. if (this._refractionTexture) {
  51808. activeTextures.push(this._refractionTexture);
  51809. }
  51810. return activeTextures;
  51811. };
  51812. /**
  51813. * Checks to see if a texture is used in the material.
  51814. * @param texture - Base texture to use.
  51815. * @returns - Boolean specifying if a texture is used in the material.
  51816. */
  51817. PBRMaterial.prototype.hasTexture = function (texture) {
  51818. if (_super.prototype.hasTexture.call(this, texture)) {
  51819. return true;
  51820. }
  51821. if (this._albedoTexture === texture) {
  51822. return true;
  51823. }
  51824. if (this._ambientTexture === texture) {
  51825. return true;
  51826. }
  51827. if (this._opacityTexture === texture) {
  51828. return true;
  51829. }
  51830. if (this._reflectionTexture === texture) {
  51831. return true;
  51832. }
  51833. if (this._reflectivityTexture === texture) {
  51834. return true;
  51835. }
  51836. if (this._metallicTexture === texture) {
  51837. return true;
  51838. }
  51839. if (this._microSurfaceTexture === texture) {
  51840. return true;
  51841. }
  51842. if (this._bumpTexture === texture) {
  51843. return true;
  51844. }
  51845. if (this._lightmapTexture === texture) {
  51846. return true;
  51847. }
  51848. if (this._refractionTexture === texture) {
  51849. return true;
  51850. }
  51851. return false;
  51852. };
  51853. /**
  51854. * Makes a duplicate of the current material.
  51855. * @param name - name to use for the new material.
  51856. */
  51857. PBRMaterial.prototype.clone = function (name) {
  51858. var _this = this;
  51859. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMaterial(name, _this.getScene()); }, this);
  51860. clone.id = name;
  51861. clone.name = name;
  51862. return clone;
  51863. };
  51864. /**
  51865. * Serializes this PBR Material.
  51866. * @returns - An object with the serialized material.
  51867. */
  51868. PBRMaterial.prototype.serialize = function () {
  51869. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  51870. serializationObject.customType = "BABYLON.PBRMaterial";
  51871. return serializationObject;
  51872. };
  51873. // Statics
  51874. /**
  51875. * Parses a PBR Material from a serialized object.
  51876. * @param source - Serialized object.
  51877. * @param scene - BJS scene instance.
  51878. * @param rootUrl - url for the scene object
  51879. * @returns - PBRMaterial
  51880. */
  51881. PBRMaterial.Parse = function (source, scene, rootUrl) {
  51882. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMaterial(source.name, scene); }, source, scene, rootUrl);
  51883. };
  51884. /**
  51885. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51886. */
  51887. PBRMaterial.PBRMATERIAL_OPAQUE = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_OPAQUE;
  51888. /**
  51889. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51890. */
  51891. PBRMaterial.PBRMATERIAL_ALPHATEST = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATEST;
  51892. /**
  51893. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51894. */
  51895. PBRMaterial.PBRMATERIAL_ALPHABLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHABLEND;
  51896. /**
  51897. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51898. * They are also discarded below the alpha cutoff threshold to improve performances.
  51899. */
  51900. PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATESTANDBLEND;
  51901. /**
  51902. * Defines the default value of how much AO map is occluding the analytical lights
  51903. * (point spot...).
  51904. */
  51905. PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  51906. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51907. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51908. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51909. ], PBRMaterial.prototype, "directIntensity", void 0);
  51910. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51911. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51912. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51913. ], PBRMaterial.prototype, "emissiveIntensity", void 0);
  51914. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51915. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51916. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51917. ], PBRMaterial.prototype, "environmentIntensity", void 0);
  51918. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51919. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51920. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51921. ], PBRMaterial.prototype, "specularIntensity", void 0);
  51922. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51923. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51924. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51925. ], PBRMaterial.prototype, "disableBumpMap", void 0);
  51926. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51927. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51928. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51929. ], PBRMaterial.prototype, "albedoTexture", void 0);
  51930. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51931. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51932. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51933. ], PBRMaterial.prototype, "ambientTexture", void 0);
  51934. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51935. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51936. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51937. ], PBRMaterial.prototype, "ambientTextureStrength", void 0);
  51938. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51939. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51940. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51941. ], PBRMaterial.prototype, "ambientTextureImpactOnAnalyticalLights", void 0);
  51942. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51943. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51944. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  51945. ], PBRMaterial.prototype, "opacityTexture", void 0);
  51946. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51947. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51948. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51949. ], PBRMaterial.prototype, "reflectionTexture", void 0);
  51950. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51951. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51952. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51953. ], PBRMaterial.prototype, "emissiveTexture", void 0);
  51954. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51955. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51956. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51957. ], PBRMaterial.prototype, "reflectivityTexture", void 0);
  51958. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51959. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51960. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51961. ], PBRMaterial.prototype, "metallicTexture", void 0);
  51962. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51963. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51964. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51965. ], PBRMaterial.prototype, "metallic", void 0);
  51966. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51967. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  51968. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51969. ], PBRMaterial.prototype, "roughness", void 0);
  51970. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51971. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51972. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51973. ], PBRMaterial.prototype, "microSurfaceTexture", void 0);
  51974. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51975. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51976. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51977. ], PBRMaterial.prototype, "bumpTexture", void 0);
  51978. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51979. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51980. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  51981. ], PBRMaterial.prototype, "lightmapTexture", void 0);
  51982. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51983. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  51984. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51985. ], PBRMaterial.prototype, "refractionTexture", void 0);
  51986. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51987. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient"),
  51988. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51989. ], PBRMaterial.prototype, "ambientColor", void 0);
  51990. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51991. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("albedo"),
  51992. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51993. ], PBRMaterial.prototype, "albedoColor", void 0);
  51994. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51995. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflectivity"),
  51996. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51997. ], PBRMaterial.prototype, "reflectivityColor", void 0);
  51998. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51999. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflection"),
  52000. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52001. ], PBRMaterial.prototype, "reflectionColor", void 0);
  52002. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52003. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  52004. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52005. ], PBRMaterial.prototype, "emissiveColor", void 0);
  52006. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52007. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52008. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52009. ], PBRMaterial.prototype, "microSurface", void 0);
  52010. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52011. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52012. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52013. ], PBRMaterial.prototype, "indexOfRefraction", void 0);
  52014. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52015. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52016. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52017. ], PBRMaterial.prototype, "invertRefractionY", void 0);
  52018. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52019. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52020. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52021. ], PBRMaterial.prototype, "linkRefractionWithTransparency", void 0);
  52022. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52023. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52024. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52025. ], PBRMaterial.prototype, "useLightmapAsShadowmap", void 0);
  52026. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52027. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52028. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52029. ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", void 0);
  52030. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52031. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52032. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52033. ], PBRMaterial.prototype, "forceAlphaTest", void 0);
  52034. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52035. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52036. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  52037. ], PBRMaterial.prototype, "alphaCutOff", void 0);
  52038. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52039. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52040. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52041. ], PBRMaterial.prototype, "useSpecularOverAlpha", void 0);
  52042. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52043. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52044. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52045. ], PBRMaterial.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0);
  52046. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52047. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52048. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52049. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureAlpha", void 0);
  52050. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52051. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52052. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52053. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureGreen", void 0);
  52054. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52055. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52056. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52057. ], PBRMaterial.prototype, "useMetallnessFromMetallicTextureBlue", void 0);
  52058. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52059. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52060. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52061. ], PBRMaterial.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0);
  52062. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52063. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52064. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52065. ], PBRMaterial.prototype, "useAmbientInGrayScale", void 0);
  52066. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52067. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52068. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52069. ], PBRMaterial.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0);
  52070. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52071. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52072. ], PBRMaterial.prototype, "usePhysicalLightFalloff", null);
  52073. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52074. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52075. ], PBRMaterial.prototype, "useGLTFLightFalloff", null);
  52076. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52077. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52078. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52079. ], PBRMaterial.prototype, "useRadianceOverAlpha", void 0);
  52080. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52081. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52082. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52083. ], PBRMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  52084. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52085. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52086. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52087. ], PBRMaterial.prototype, "useParallax", void 0);
  52088. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52089. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52090. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52091. ], PBRMaterial.prototype, "useParallaxOcclusion", void 0);
  52092. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52093. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52094. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52095. ], PBRMaterial.prototype, "parallaxScaleBias", void 0);
  52096. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52097. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52098. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  52099. ], PBRMaterial.prototype, "disableLighting", void 0);
  52100. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52101. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52102. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52103. ], PBRMaterial.prototype, "forceIrradianceInFragment", void 0);
  52104. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52105. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52106. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  52107. ], PBRMaterial.prototype, "maxSimultaneousLights", void 0);
  52108. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52109. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52110. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52111. ], PBRMaterial.prototype, "invertNormalMapX", void 0);
  52112. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52113. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52114. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52115. ], PBRMaterial.prototype, "invertNormalMapY", void 0);
  52116. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52117. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52118. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52119. ], PBRMaterial.prototype, "twoSidedLighting", void 0);
  52120. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52121. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52122. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52123. ], PBRMaterial.prototype, "useAlphaFresnel", void 0);
  52124. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52125. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52126. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52127. ], PBRMaterial.prototype, "useLinearAlphaFresnel", void 0);
  52128. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52129. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52130. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52131. ], PBRMaterial.prototype, "environmentBRDFTexture", void 0);
  52132. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52133. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52134. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52135. ], PBRMaterial.prototype, "forceNormalForward", void 0);
  52136. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52137. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52138. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52139. ], PBRMaterial.prototype, "enableSpecularAntiAliasing", void 0);
  52140. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52141. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52142. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52143. ], PBRMaterial.prototype, "useHorizonOcclusion", void 0);
  52144. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52145. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52146. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52147. ], PBRMaterial.prototype, "useRadianceOcclusion", void 0);
  52148. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52149. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52150. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  52151. ], PBRMaterial.prototype, "unlit", void 0);
  52152. return PBRMaterial;
  52153. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"]));
  52154. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PBRMaterial"] = PBRMaterial;
  52155. /***/ }),
  52156. /***/ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts":
  52157. /*!*******************************************************!*\
  52158. !*** ./Materials/PBR/pbrMetallicRoughnessMaterial.ts ***!
  52159. \*******************************************************/
  52160. /*! exports provided: PBRMetallicRoughnessMaterial */
  52161. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52162. "use strict";
  52163. __webpack_require__.r(__webpack_exports__);
  52164. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return PBRMetallicRoughnessMaterial; });
  52165. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52166. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52167. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  52168. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  52169. /**
  52170. * The PBR material of BJS following the metal roughness convention.
  52171. *
  52172. * This fits to the PBR convention in the GLTF definition:
  52173. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52174. */
  52175. var PBRMetallicRoughnessMaterial = /** @class */ (function (_super) {
  52176. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMetallicRoughnessMaterial, _super);
  52177. /**
  52178. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52179. *
  52180. * @param name The material name
  52181. * @param scene The scene the material will be use in.
  52182. */
  52183. function PBRMetallicRoughnessMaterial(name, scene) {
  52184. var _this = _super.call(this, name, scene) || this;
  52185. _this._useRoughnessFromMetallicTextureAlpha = false;
  52186. _this._useRoughnessFromMetallicTextureGreen = true;
  52187. _this._useMetallnessFromMetallicTextureBlue = true;
  52188. _this.metallic = 1.0;
  52189. _this.roughness = 1.0;
  52190. return _this;
  52191. }
  52192. /**
  52193. * Return the currrent class name of the material.
  52194. */
  52195. PBRMetallicRoughnessMaterial.prototype.getClassName = function () {
  52196. return "PBRMetallicRoughnessMaterial";
  52197. };
  52198. /**
  52199. * Return the active textures of the material.
  52200. */
  52201. PBRMetallicRoughnessMaterial.prototype.getActiveTextures = function () {
  52202. var activeTextures = _super.prototype.getActiveTextures.call(this);
  52203. if (this.baseTexture) {
  52204. activeTextures.push(this.baseTexture);
  52205. }
  52206. if (this.metallicRoughnessTexture) {
  52207. activeTextures.push(this.metallicRoughnessTexture);
  52208. }
  52209. return activeTextures;
  52210. };
  52211. /**
  52212. * Checks to see if a texture is used in the material.
  52213. * @param texture - Base texture to use.
  52214. * @returns - Boolean specifying if a texture is used in the material.
  52215. */
  52216. PBRMetallicRoughnessMaterial.prototype.hasTexture = function (texture) {
  52217. if (_super.prototype.hasTexture.call(this, texture)) {
  52218. return true;
  52219. }
  52220. if (this.baseTexture === texture) {
  52221. return true;
  52222. }
  52223. if (this.metallicRoughnessTexture === texture) {
  52224. return true;
  52225. }
  52226. return false;
  52227. };
  52228. /**
  52229. * Makes a duplicate of the current material.
  52230. * @param name - name to use for the new material.
  52231. */
  52232. PBRMetallicRoughnessMaterial.prototype.clone = function (name) {
  52233. var _this = this;
  52234. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMetallicRoughnessMaterial(name, _this.getScene()); }, this);
  52235. clone.id = name;
  52236. clone.name = name;
  52237. return clone;
  52238. };
  52239. /**
  52240. * Serialize the material to a parsable JSON object.
  52241. */
  52242. PBRMetallicRoughnessMaterial.prototype.serialize = function () {
  52243. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  52244. serializationObject.customType = "BABYLON.PBRMetallicRoughnessMaterial";
  52245. return serializationObject;
  52246. };
  52247. /**
  52248. * Parses a JSON object correponding to the serialize function.
  52249. */
  52250. PBRMetallicRoughnessMaterial.Parse = function (source, scene, rootUrl) {
  52251. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMetallicRoughnessMaterial(source.name, scene); }, source, scene, rootUrl);
  52252. };
  52253. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])(),
  52255. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  52256. ], PBRMetallicRoughnessMaterial.prototype, "baseColor", void 0);
  52257. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52258. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52259. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  52260. ], PBRMetallicRoughnessMaterial.prototype, "baseTexture", void 0);
  52261. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52262. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52263. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52264. ], PBRMetallicRoughnessMaterial.prototype, "metallic", void 0);
  52265. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52266. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52267. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52268. ], PBRMetallicRoughnessMaterial.prototype, "roughness", void 0);
  52269. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52270. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52271. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")
  52272. ], PBRMetallicRoughnessMaterial.prototype, "metallicRoughnessTexture", void 0);
  52273. return PBRMetallicRoughnessMaterial;
  52274. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  52275. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"] = PBRMetallicRoughnessMaterial;
  52276. /***/ }),
  52277. /***/ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts":
  52278. /*!********************************************************!*\
  52279. !*** ./Materials/PBR/pbrSpecularGlossinessMaterial.ts ***!
  52280. \********************************************************/
  52281. /*! exports provided: PBRSpecularGlossinessMaterial */
  52282. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52283. "use strict";
  52284. __webpack_require__.r(__webpack_exports__);
  52285. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return PBRSpecularGlossinessMaterial; });
  52286. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52287. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52288. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  52289. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  52290. /**
  52291. * The PBR material of BJS following the specular glossiness convention.
  52292. *
  52293. * This fits to the PBR convention in the GLTF definition:
  52294. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52295. */
  52296. var PBRSpecularGlossinessMaterial = /** @class */ (function (_super) {
  52297. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRSpecularGlossinessMaterial, _super);
  52298. /**
  52299. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52300. *
  52301. * @param name The material name
  52302. * @param scene The scene the material will be use in.
  52303. */
  52304. function PBRSpecularGlossinessMaterial(name, scene) {
  52305. var _this = _super.call(this, name, scene) || this;
  52306. _this._useMicroSurfaceFromReflectivityMapAlpha = true;
  52307. return _this;
  52308. }
  52309. /**
  52310. * Return the currrent class name of the material.
  52311. */
  52312. PBRSpecularGlossinessMaterial.prototype.getClassName = function () {
  52313. return "PBRSpecularGlossinessMaterial";
  52314. };
  52315. /**
  52316. * Return the active textures of the material.
  52317. */
  52318. PBRSpecularGlossinessMaterial.prototype.getActiveTextures = function () {
  52319. var activeTextures = _super.prototype.getActiveTextures.call(this);
  52320. if (this.diffuseTexture) {
  52321. activeTextures.push(this.diffuseTexture);
  52322. }
  52323. if (this.specularGlossinessTexture) {
  52324. activeTextures.push(this.specularGlossinessTexture);
  52325. }
  52326. return activeTextures;
  52327. };
  52328. /**
  52329. * Checks to see if a texture is used in the material.
  52330. * @param texture - Base texture to use.
  52331. * @returns - Boolean specifying if a texture is used in the material.
  52332. */
  52333. PBRSpecularGlossinessMaterial.prototype.hasTexture = function (texture) {
  52334. if (_super.prototype.hasTexture.call(this, texture)) {
  52335. return true;
  52336. }
  52337. if (this.diffuseTexture === texture) {
  52338. return true;
  52339. }
  52340. if (this.specularGlossinessTexture === texture) {
  52341. return true;
  52342. }
  52343. return false;
  52344. };
  52345. /**
  52346. * Makes a duplicate of the current material.
  52347. * @param name - name to use for the new material.
  52348. */
  52349. PBRSpecularGlossinessMaterial.prototype.clone = function (name) {
  52350. var _this = this;
  52351. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRSpecularGlossinessMaterial(name, _this.getScene()); }, this);
  52352. clone.id = name;
  52353. clone.name = name;
  52354. return clone;
  52355. };
  52356. /**
  52357. * Serialize the material to a parsable JSON object.
  52358. */
  52359. PBRSpecularGlossinessMaterial.prototype.serialize = function () {
  52360. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  52361. serializationObject.customType = "BABYLON.PBRSpecularGlossinessMaterial";
  52362. return serializationObject;
  52363. };
  52364. /**
  52365. * Parses a JSON object correponding to the serialize function.
  52366. */
  52367. PBRSpecularGlossinessMaterial.Parse = function (source, scene, rootUrl) {
  52368. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRSpecularGlossinessMaterial(source.name, scene); }, source, scene, rootUrl);
  52369. };
  52370. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52371. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse"),
  52372. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  52373. ], PBRSpecularGlossinessMaterial.prototype, "diffuseColor", void 0);
  52374. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52375. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52376. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  52377. ], PBRSpecularGlossinessMaterial.prototype, "diffuseTexture", void 0);
  52378. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52379. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular"),
  52380. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")
  52381. ], PBRSpecularGlossinessMaterial.prototype, "specularColor", void 0);
  52382. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52383. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52384. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_microSurface")
  52385. ], PBRSpecularGlossinessMaterial.prototype, "glossiness", void 0);
  52386. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52387. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52388. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")
  52389. ], PBRSpecularGlossinessMaterial.prototype, "specularGlossinessTexture", void 0);
  52390. return PBRSpecularGlossinessMaterial;
  52391. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  52392. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"] = PBRSpecularGlossinessMaterial;
  52393. /***/ }),
  52394. /***/ "./Materials/Textures/Loaders/ddsTextureLoader.ts":
  52395. /*!********************************************************!*\
  52396. !*** ./Materials/Textures/Loaders/ddsTextureLoader.ts ***!
  52397. \********************************************************/
  52398. /*! exports provided: _DDSTextureLoader */
  52399. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52400. "use strict";
  52401. __webpack_require__.r(__webpack_exports__);
  52402. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _DDSTextureLoader; });
  52403. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  52404. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  52405. /* harmony import */ var _Misc_dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/dds */ "./Misc/dds.ts");
  52406. /**
  52407. * Implementation of the DDS Texture Loader.
  52408. * @hidden
  52409. */
  52410. var _DDSTextureLoader = /** @class */ (function () {
  52411. function _DDSTextureLoader() {
  52412. /**
  52413. * Defines wether the loader supports cascade loading the different faces.
  52414. */
  52415. this.supportCascades = true;
  52416. }
  52417. /**
  52418. * This returns if the loader support the current file information.
  52419. * @param extension defines the file extension of the file being loaded
  52420. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52421. * @param fallback defines the fallback internal texture if any
  52422. * @param isBase64 defines whether the texture is encoded as a base64
  52423. * @param isBuffer defines whether the texture data are stored as a buffer
  52424. * @returns true if the loader can load the specified file
  52425. */
  52426. _DDSTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  52427. return extension.indexOf(".dds") === 0;
  52428. };
  52429. /**
  52430. * Transform the url before loading if required.
  52431. * @param rootUrl the url of the texture
  52432. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52433. * @returns the transformed texture
  52434. */
  52435. _DDSTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  52436. return rootUrl;
  52437. };
  52438. /**
  52439. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52440. * @param rootUrl the url of the texture
  52441. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52442. * @returns the fallback texture
  52443. */
  52444. _DDSTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  52445. return null;
  52446. };
  52447. /**
  52448. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52449. * @param data contains the texture data
  52450. * @param texture defines the BabylonJS internal texture
  52451. * @param createPolynomials will be true if polynomials have been requested
  52452. * @param onLoad defines the callback to trigger once the texture is ready
  52453. * @param onError defines the callback to trigger in case of error
  52454. */
  52455. _DDSTextureLoader.prototype.loadCubeData = function (imgs, texture, createPolynomials, onLoad, onError) {
  52456. var engine = texture.getEngine();
  52457. var info;
  52458. var loadMipmap = false;
  52459. if (Array.isArray(imgs)) {
  52460. for (var index = 0; index < imgs.length; index++) {
  52461. var data_1 = imgs[index];
  52462. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data_1);
  52463. texture.width = info.width;
  52464. texture.height = info.height;
  52465. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  52466. engine._unpackFlipY(info.isCompressed);
  52467. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data_1, info, loadMipmap, 6, -1, index);
  52468. if (!info.isFourCC && info.mipmapCount === 1) {
  52469. engine.generateMipMapsForCubemap(texture);
  52470. }
  52471. }
  52472. }
  52473. else {
  52474. var data = imgs;
  52475. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  52476. texture.width = info.width;
  52477. texture.height = info.height;
  52478. if (createPolynomials) {
  52479. info.sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]();
  52480. }
  52481. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  52482. engine._unpackFlipY(info.isCompressed);
  52483. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data, info, loadMipmap, 6);
  52484. if (!info.isFourCC && info.mipmapCount === 1) {
  52485. engine.generateMipMapsForCubemap(texture);
  52486. }
  52487. }
  52488. engine._setCubeMapTextureParams(loadMipmap);
  52489. texture.isReady = true;
  52490. if (onLoad) {
  52491. onLoad({ isDDS: true, width: texture.width, info: info, data: imgs, texture: texture });
  52492. }
  52493. };
  52494. /**
  52495. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52496. * @param data contains the texture data
  52497. * @param texture defines the BabylonJS internal texture
  52498. * @param callback defines the method to call once ready to upload
  52499. */
  52500. _DDSTextureLoader.prototype.loadData = function (data, texture, callback) {
  52501. var info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  52502. var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && ((info.width >> (info.mipmapCount - 1)) === 1);
  52503. callback(info.width, info.height, loadMipmap, info.isFourCC, function () {
  52504. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);
  52505. });
  52506. };
  52507. return _DDSTextureLoader;
  52508. }());
  52509. // Register the loader.
  52510. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _DDSTextureLoader());
  52511. /***/ }),
  52512. /***/ "./Materials/Textures/Loaders/envTextureLoader.ts":
  52513. /*!********************************************************!*\
  52514. !*** ./Materials/Textures/Loaders/envTextureLoader.ts ***!
  52515. \********************************************************/
  52516. /*! exports provided: _ENVTextureLoader */
  52517. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52518. "use strict";
  52519. __webpack_require__.r(__webpack_exports__);
  52520. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _ENVTextureLoader; });
  52521. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  52522. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  52523. /**
  52524. * Implementation of the ENV Texture Loader.
  52525. * @hidden
  52526. */
  52527. var _ENVTextureLoader = /** @class */ (function () {
  52528. function _ENVTextureLoader() {
  52529. /**
  52530. * Defines wether the loader supports cascade loading the different faces.
  52531. */
  52532. this.supportCascades = false;
  52533. }
  52534. /**
  52535. * This returns if the loader support the current file information.
  52536. * @param extension defines the file extension of the file being loaded
  52537. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52538. * @param fallback defines the fallback internal texture if any
  52539. * @param isBase64 defines whether the texture is encoded as a base64
  52540. * @param isBuffer defines whether the texture data are stored as a buffer
  52541. * @returns true if the loader can load the specified file
  52542. */
  52543. _ENVTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  52544. return extension.indexOf(".env") === 0;
  52545. };
  52546. /**
  52547. * Transform the url before loading if required.
  52548. * @param rootUrl the url of the texture
  52549. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52550. * @returns the transformed texture
  52551. */
  52552. _ENVTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  52553. return rootUrl;
  52554. };
  52555. /**
  52556. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52557. * @param rootUrl the url of the texture
  52558. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52559. * @returns the fallback texture
  52560. */
  52561. _ENVTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  52562. return null;
  52563. };
  52564. /**
  52565. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52566. * @param data contains the texture data
  52567. * @param texture defines the BabylonJS internal texture
  52568. * @param createPolynomials will be true if polynomials have been requested
  52569. * @param onLoad defines the callback to trigger once the texture is ready
  52570. * @param onError defines the callback to trigger in case of error
  52571. */
  52572. _ENVTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  52573. if (Array.isArray(data)) {
  52574. return;
  52575. }
  52576. data = data;
  52577. var info = _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].GetEnvInfo(data);
  52578. if (info) {
  52579. texture.width = info.width;
  52580. texture.height = info.width;
  52581. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvSpherical(texture, info);
  52582. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvLevelsAsync(texture, data, info).then(function () {
  52583. texture.isReady = true;
  52584. if (onLoad) {
  52585. onLoad();
  52586. }
  52587. });
  52588. }
  52589. else if (onError) {
  52590. onError("Can not parse the environment file", null);
  52591. }
  52592. };
  52593. /**
  52594. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52595. * @param data contains the texture data
  52596. * @param texture defines the BabylonJS internal texture
  52597. * @param callback defines the method to call once ready to upload
  52598. */
  52599. _ENVTextureLoader.prototype.loadData = function (data, texture, callback) {
  52600. throw ".env not supported in 2d.";
  52601. };
  52602. return _ENVTextureLoader;
  52603. }());
  52604. // Register the loader.
  52605. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _ENVTextureLoader());
  52606. /***/ }),
  52607. /***/ "./Materials/Textures/Loaders/index.ts":
  52608. /*!*********************************************!*\
  52609. !*** ./Materials/Textures/Loaders/index.ts ***!
  52610. \*********************************************/
  52611. /*! exports provided: _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader */
  52612. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52613. "use strict";
  52614. __webpack_require__.r(__webpack_exports__);
  52615. /* harmony import */ var _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  52616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  52617. /* harmony import */ var _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  52618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__["_ENVTextureLoader"]; });
  52619. /* harmony import */ var _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  52620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__["_KTXTextureLoader"]; });
  52621. /* harmony import */ var _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tgaTextureLoader */ "./Materials/Textures/Loaders/tgaTextureLoader.ts");
  52622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__["_TGATextureLoader"]; });
  52623. /***/ }),
  52624. /***/ "./Materials/Textures/Loaders/ktxTextureLoader.ts":
  52625. /*!********************************************************!*\
  52626. !*** ./Materials/Textures/Loaders/ktxTextureLoader.ts ***!
  52627. \********************************************************/
  52628. /*! exports provided: _KTXTextureLoader */
  52629. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52630. "use strict";
  52631. __webpack_require__.r(__webpack_exports__);
  52632. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _KTXTextureLoader; });
  52633. /* harmony import */ var _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  52634. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  52635. /**
  52636. * Implementation of the KTX Texture Loader.
  52637. * @hidden
  52638. */
  52639. var _KTXTextureLoader = /** @class */ (function () {
  52640. function _KTXTextureLoader() {
  52641. /**
  52642. * Defines wether the loader supports cascade loading the different faces.
  52643. */
  52644. this.supportCascades = false;
  52645. }
  52646. /**
  52647. * This returns if the loader support the current file information.
  52648. * @param extension defines the file extension of the file being loaded
  52649. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52650. * @param fallback defines the fallback internal texture if any
  52651. * @param isBase64 defines whether the texture is encoded as a base64
  52652. * @param isBuffer defines whether the texture data are stored as a buffer
  52653. * @returns true if the loader can load the specified file
  52654. */
  52655. _KTXTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  52656. if (textureFormatInUse && !isBase64 && !fallback && !isBuffer) {
  52657. return true;
  52658. }
  52659. return false;
  52660. };
  52661. /**
  52662. * Transform the url before loading if required.
  52663. * @param rootUrl the url of the texture
  52664. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52665. * @returns the transformed texture
  52666. */
  52667. _KTXTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  52668. var lastDot = rootUrl.lastIndexOf('.');
  52669. if (lastDot != -1 && rootUrl.substring(lastDot + 1) == "ktx") {
  52670. // Already transformed
  52671. return rootUrl;
  52672. }
  52673. return (lastDot > -1 ? rootUrl.substring(0, lastDot) : rootUrl) + textureFormatInUse;
  52674. };
  52675. /**
  52676. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52677. * @param rootUrl the url of the texture
  52678. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52679. * @returns the fallback texture
  52680. */
  52681. _KTXTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  52682. // remove the format appended to the rootUrl in the original createCubeTexture call.
  52683. var exp = new RegExp("" + textureFormatInUse + "$");
  52684. return rootUrl.replace(exp, "");
  52685. };
  52686. /**
  52687. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52688. * @param data contains the texture data
  52689. * @param texture defines the BabylonJS internal texture
  52690. * @param createPolynomials will be true if polynomials have been requested
  52691. * @param onLoad defines the callback to trigger once the texture is ready
  52692. * @param onError defines the callback to trigger in case of error
  52693. */
  52694. _KTXTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  52695. if (Array.isArray(data)) {
  52696. return;
  52697. }
  52698. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  52699. texture._invertVScale = !texture.invertY;
  52700. var engine = texture.getEngine();
  52701. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 6);
  52702. var loadMipmap = ktx.numberOfMipmapLevels > 1 && texture.generateMipMaps;
  52703. engine._unpackFlipY(true);
  52704. ktx.uploadLevels(texture, texture.generateMipMaps);
  52705. texture.width = ktx.pixelWidth;
  52706. texture.height = ktx.pixelHeight;
  52707. engine._setCubeMapTextureParams(loadMipmap);
  52708. texture.isReady = true;
  52709. };
  52710. /**
  52711. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52712. * @param data contains the texture data
  52713. * @param texture defines the BabylonJS internal texture
  52714. * @param callback defines the method to call once ready to upload
  52715. */
  52716. _KTXTextureLoader.prototype.loadData = function (data, texture, callback) {
  52717. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  52718. texture._invertVScale = !texture.invertY;
  52719. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 1);
  52720. callback(ktx.pixelWidth, ktx.pixelHeight, false, true, function () {
  52721. ktx.uploadLevels(texture, texture.generateMipMaps);
  52722. }, ktx.isInvalid);
  52723. };
  52724. return _KTXTextureLoader;
  52725. }());
  52726. // Register the loader.
  52727. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.unshift(new _KTXTextureLoader());
  52728. /***/ }),
  52729. /***/ "./Materials/Textures/Loaders/tgaTextureLoader.ts":
  52730. /*!********************************************************!*\
  52731. !*** ./Materials/Textures/Loaders/tgaTextureLoader.ts ***!
  52732. \********************************************************/
  52733. /*! exports provided: _TGATextureLoader */
  52734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52735. "use strict";
  52736. __webpack_require__.r(__webpack_exports__);
  52737. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _TGATextureLoader; });
  52738. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tga */ "./Misc/tga.ts");
  52739. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  52740. /**
  52741. * Implementation of the TGA Texture Loader.
  52742. * @hidden
  52743. */
  52744. var _TGATextureLoader = /** @class */ (function () {
  52745. function _TGATextureLoader() {
  52746. /**
  52747. * Defines wether the loader supports cascade loading the different faces.
  52748. */
  52749. this.supportCascades = false;
  52750. }
  52751. /**
  52752. * This returns if the loader support the current file information.
  52753. * @param extension defines the file extension of the file being loaded
  52754. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52755. * @param fallback defines the fallback internal texture if any
  52756. * @param isBase64 defines whether the texture is encoded as a base64
  52757. * @param isBuffer defines whether the texture data are stored as a buffer
  52758. * @returns true if the loader can load the specified file
  52759. */
  52760. _TGATextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  52761. return extension.indexOf(".tga") === 0;
  52762. };
  52763. /**
  52764. * Transform the url before loading if required.
  52765. * @param rootUrl the url of the texture
  52766. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52767. * @returns the transformed texture
  52768. */
  52769. _TGATextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  52770. return rootUrl;
  52771. };
  52772. /**
  52773. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52774. * @param rootUrl the url of the texture
  52775. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52776. * @returns the fallback texture
  52777. */
  52778. _TGATextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  52779. return null;
  52780. };
  52781. /**
  52782. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52783. * @param data contains the texture data
  52784. * @param texture defines the BabylonJS internal texture
  52785. * @param createPolynomials will be true if polynomials have been requested
  52786. * @param onLoad defines the callback to trigger once the texture is ready
  52787. * @param onError defines the callback to trigger in case of error
  52788. */
  52789. _TGATextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  52790. throw ".env not supported in Cube.";
  52791. };
  52792. /**
  52793. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52794. * @param data contains the texture data
  52795. * @param texture defines the BabylonJS internal texture
  52796. * @param callback defines the method to call once ready to upload
  52797. */
  52798. _TGATextureLoader.prototype.loadData = function (data, texture, callback) {
  52799. var uintData = new Uint8Array(data);
  52800. var header = _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].GetTGAHeader(uintData);
  52801. callback(header.width, header.height, texture.generateMipMaps, false, function () {
  52802. _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].UploadContent(texture, uintData);
  52803. });
  52804. };
  52805. return _TGATextureLoader;
  52806. }());
  52807. // Register the loader.
  52808. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _TGATextureLoader());
  52809. /***/ }),
  52810. /***/ "./Materials/Textures/Procedurals/customProceduralTexture.ts":
  52811. /*!*******************************************************************!*\
  52812. !*** ./Materials/Textures/Procedurals/customProceduralTexture.ts ***!
  52813. \*******************************************************************/
  52814. /*! exports provided: CustomProceduralTexture */
  52815. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52816. "use strict";
  52817. __webpack_require__.r(__webpack_exports__);
  52818. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return CustomProceduralTexture; });
  52819. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52820. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  52821. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  52822. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  52823. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  52824. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  52825. /**
  52826. * 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.
  52827. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52828. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52829. */
  52830. var CustomProceduralTexture = /** @class */ (function (_super) {
  52831. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomProceduralTexture, _super);
  52832. /**
  52833. * Instantiates a new Custom Procedural Texture.
  52834. * 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.
  52835. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52836. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52837. * @param name Define the name of the texture
  52838. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52839. * @param size Define the size of the texture to create
  52840. * @param scene Define the scene the texture belongs to
  52841. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52842. * @param generateMipMaps Define if the texture should creates mip maps or not
  52843. */
  52844. function CustomProceduralTexture(name, texturePath, size, scene, fallbackTexture, generateMipMaps) {
  52845. var _this = _super.call(this, name, size, null, scene, fallbackTexture, generateMipMaps) || this;
  52846. _this._animate = true;
  52847. _this._time = 0;
  52848. _this._texturePath = texturePath;
  52849. //Try to load json
  52850. _this._loadJson(texturePath);
  52851. _this.refreshRate = 1;
  52852. return _this;
  52853. }
  52854. CustomProceduralTexture.prototype._loadJson = function (jsonUrl) {
  52855. var _this = this;
  52856. var noConfigFile = function () {
  52857. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
  52858. try {
  52859. _this.setFragment(_this._texturePath);
  52860. }
  52861. catch (ex) {
  52862. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
  52863. }
  52864. };
  52865. var configFileUrl = jsonUrl + "/config.json";
  52866. var xhr = new XMLHttpRequest();
  52867. xhr.open("GET", configFileUrl, true);
  52868. xhr.addEventListener("load", function () {
  52869. if (xhr.status === 200 || (xhr.responseText && xhr.responseText.length > 0)) {
  52870. try {
  52871. _this._config = JSON.parse(xhr.response);
  52872. _this.updateShaderUniforms();
  52873. _this.updateTextures();
  52874. _this.setFragment(_this._texturePath + "/custom");
  52875. _this._animate = _this._config.animate;
  52876. _this.refreshRate = _this._config.refreshrate;
  52877. }
  52878. catch (ex) {
  52879. noConfigFile();
  52880. }
  52881. }
  52882. else {
  52883. noConfigFile();
  52884. }
  52885. }, false);
  52886. xhr.addEventListener("error", function () {
  52887. noConfigFile();
  52888. }, false);
  52889. try {
  52890. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].UseCustomRequestHeaders) {
  52891. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].InjectCustomRequestHeaders(xhr);
  52892. }
  52893. xhr.send();
  52894. }
  52895. catch (ex) {
  52896. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("CustomProceduralTexture: Error on XHR send request.");
  52897. }
  52898. };
  52899. /**
  52900. * Is the texture ready to be used ? (rendered at least once)
  52901. * @returns true if ready, otherwise, false.
  52902. */
  52903. CustomProceduralTexture.prototype.isReady = function () {
  52904. if (!_super.prototype.isReady.call(this)) {
  52905. return false;
  52906. }
  52907. for (var name in this._textures) {
  52908. var texture = this._textures[name];
  52909. if (!texture.isReady()) {
  52910. return false;
  52911. }
  52912. }
  52913. return true;
  52914. };
  52915. /**
  52916. * Render the texture to its associated render target.
  52917. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52918. */
  52919. CustomProceduralTexture.prototype.render = function (useCameraPostProcess) {
  52920. var scene = this.getScene();
  52921. if (this._animate && scene) {
  52922. this._time += scene.getAnimationRatio() * 0.03;
  52923. this.updateShaderUniforms();
  52924. }
  52925. _super.prototype.render.call(this, useCameraPostProcess);
  52926. };
  52927. /**
  52928. * Update the list of dependant textures samplers in the shader.
  52929. */
  52930. CustomProceduralTexture.prototype.updateTextures = function () {
  52931. for (var i = 0; i < this._config.sampler2Ds.length; i++) {
  52932. 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()));
  52933. }
  52934. };
  52935. /**
  52936. * Update the uniform values of the procedural texture in the shader.
  52937. */
  52938. CustomProceduralTexture.prototype.updateShaderUniforms = function () {
  52939. if (this._config) {
  52940. for (var j = 0; j < this._config.uniforms.length; j++) {
  52941. var uniform = this._config.uniforms[j];
  52942. switch (uniform.type) {
  52943. case "float":
  52944. this.setFloat(uniform.name, uniform.value);
  52945. break;
  52946. case "color3":
  52947. this.setColor3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](uniform.r, uniform.g, uniform.b));
  52948. break;
  52949. case "color4":
  52950. this.setColor4(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](uniform.r, uniform.g, uniform.b, uniform.a));
  52951. break;
  52952. case "vector2":
  52953. this.setVector2(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](uniform.x, uniform.y));
  52954. break;
  52955. case "vector3":
  52956. this.setVector3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](uniform.x, uniform.y, uniform.z));
  52957. break;
  52958. }
  52959. }
  52960. }
  52961. this.setFloat("time", this._time);
  52962. };
  52963. Object.defineProperty(CustomProceduralTexture.prototype, "animate", {
  52964. /**
  52965. * Define if the texture animates or not.
  52966. */
  52967. get: function () {
  52968. return this._animate;
  52969. },
  52970. set: function (value) {
  52971. this._animate = value;
  52972. },
  52973. enumerable: true,
  52974. configurable: true
  52975. });
  52976. return CustomProceduralTexture;
  52977. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_5__["ProceduralTexture"]));
  52978. /***/ }),
  52979. /***/ "./Materials/Textures/Procedurals/index.ts":
  52980. /*!*************************************************!*\
  52981. !*** ./Materials/Textures/Procedurals/index.ts ***!
  52982. \*************************************************/
  52983. /*! exports provided: ProceduralTexture, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  52984. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52985. "use strict";
  52986. __webpack_require__.r(__webpack_exports__);
  52987. /* harmony import */ var _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./customProceduralTexture */ "./Materials/Textures/Procedurals/customProceduralTexture.ts");
  52988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  52989. /* harmony import */ var _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./noiseProceduralTexture */ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts");
  52990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__["NoiseProceduralTexture"]; });
  52991. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  52992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]; });
  52993. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  52994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__["ProceduralTextureSceneComponent"]; });
  52995. /***/ }),
  52996. /***/ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts":
  52997. /*!******************************************************************!*\
  52998. !*** ./Materials/Textures/Procedurals/noiseProceduralTexture.ts ***!
  52999. \******************************************************************/
  53000. /*! exports provided: NoiseProceduralTexture */
  53001. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53002. "use strict";
  53003. __webpack_require__.r(__webpack_exports__);
  53004. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return NoiseProceduralTexture; });
  53005. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53006. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  53007. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  53008. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  53009. /* harmony import */ var _Shaders_noise_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Shaders/noise.fragment */ "./Shaders/noise.fragment.ts");
  53010. /**
  53011. * Class used to generate noise procedural textures
  53012. */
  53013. var NoiseProceduralTexture = /** @class */ (function (_super) {
  53014. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NoiseProceduralTexture, _super);
  53015. /**
  53016. * Creates a new NoiseProceduralTexture
  53017. * @param name defines the name fo the texture
  53018. * @param size defines the size of the texture (default is 256)
  53019. * @param scene defines the hosting scene
  53020. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53021. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53022. */
  53023. function NoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  53024. if (size === void 0) { size = 256; }
  53025. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene; }
  53026. var _this = _super.call(this, name, size, "noise", scene, fallbackTexture, generateMipMaps) || this;
  53027. _this._time = 0;
  53028. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53029. _this.brightness = 0.2;
  53030. /** Defines the number of octaves to process */
  53031. _this.octaves = 3;
  53032. /** Defines the level of persistence (0.8 by default) */
  53033. _this.persistence = 0.8;
  53034. /** Gets or sets animation speed factor (default is 1) */
  53035. _this.animationSpeedFactor = 1;
  53036. _this.autoClear = false;
  53037. _this._updateShaderUniforms();
  53038. return _this;
  53039. }
  53040. NoiseProceduralTexture.prototype._updateShaderUniforms = function () {
  53041. var scene = this.getScene();
  53042. if (!scene) {
  53043. return;
  53044. }
  53045. this._time += scene.getAnimationRatio() * this.animationSpeedFactor * 0.01;
  53046. this.setFloat("brightness", this.brightness);
  53047. this.setFloat("persistence", this.persistence);
  53048. this.setFloat("timeScale", this._time);
  53049. };
  53050. NoiseProceduralTexture.prototype._getDefines = function () {
  53051. return "#define OCTAVES " + (this.octaves | 0);
  53052. };
  53053. /** Generate the current state of the procedural texture */
  53054. NoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  53055. this._updateShaderUniforms();
  53056. _super.prototype.render.call(this, useCameraPostProcess);
  53057. };
  53058. /**
  53059. * Serializes this noise procedural texture
  53060. * @returns a serialized noise procedural texture object
  53061. */
  53062. NoiseProceduralTexture.prototype.serialize = function () {
  53063. var serializationObject = {};
  53064. serializationObject.customType = "BABYLON.NoiseProceduralTexture";
  53065. serializationObject.brightness = this.brightness;
  53066. serializationObject.octaves = this.octaves;
  53067. serializationObject.persistence = this.persistence;
  53068. serializationObject.animationSpeedFactor = this.animationSpeedFactor;
  53069. serializationObject.size = this.getSize().width;
  53070. serializationObject.generateMipMaps = this._generateMipMaps;
  53071. return serializationObject;
  53072. };
  53073. /**
  53074. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53075. * @param parsedTexture defines parsed texture data
  53076. * @param scene defines the current scene
  53077. * @param rootUrl defines the root URL containing noise procedural texture information
  53078. * @returns a parsed NoiseProceduralTexture
  53079. */
  53080. NoiseProceduralTexture.Parse = function (parsedTexture, scene) {
  53081. var texture = new NoiseProceduralTexture(parsedTexture.name, parsedTexture.size, scene, undefined, parsedTexture.generateMipMaps);
  53082. texture.brightness = parsedTexture.brightness;
  53083. texture.octaves = parsedTexture.octaves;
  53084. texture.persistence = parsedTexture.persistence;
  53085. texture.animationSpeedFactor = parsedTexture.animationSpeedFactor;
  53086. return texture;
  53087. };
  53088. return NoiseProceduralTexture;
  53089. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]));
  53090. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.NoiseProceduralTexture"] = NoiseProceduralTexture;
  53091. /***/ }),
  53092. /***/ "./Materials/Textures/Procedurals/proceduralTexture.ts":
  53093. /*!*************************************************************!*\
  53094. !*** ./Materials/Textures/Procedurals/proceduralTexture.ts ***!
  53095. \*************************************************************/
  53096. /*! exports provided: ProceduralTexture */
  53097. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53098. "use strict";
  53099. __webpack_require__.r(__webpack_exports__);
  53100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return ProceduralTexture; });
  53101. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53102. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  53103. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/observable */ "./Misc/observable.ts");
  53104. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Meshes/buffer */ "./Meshes/buffer.ts");
  53105. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  53106. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/material */ "./Materials/material.ts");
  53107. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  53108. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  53109. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  53110. /* harmony import */ var _Shaders_procedural_vertex__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Shaders/procedural.vertex */ "./Shaders/procedural.vertex.ts");
  53111. /**
  53112. * 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.
  53113. * This is the base class of any Procedural texture and contains most of the shareable code.
  53114. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  53115. */
  53116. var ProceduralTexture = /** @class */ (function (_super) {
  53117. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ProceduralTexture, _super);
  53118. /**
  53119. * Instantiates a new procedural texture.
  53120. * 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.
  53121. * This is the base class of any Procedural texture and contains most of the shareable code.
  53122. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  53123. * @param name Define the name of the texture
  53124. * @param size Define the size of the texture to create
  53125. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  53126. * @param scene Define the scene the texture belongs to
  53127. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53128. * @param generateMipMaps Define if the texture should creates mip maps or not
  53129. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  53130. */
  53131. function ProceduralTexture(name, size, fragment, scene, fallbackTexture, generateMipMaps, isCube) {
  53132. if (fallbackTexture === void 0) { fallbackTexture = null; }
  53133. if (generateMipMaps === void 0) { generateMipMaps = true; }
  53134. if (isCube === void 0) { isCube = false; }
  53135. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  53136. _this.isCube = isCube;
  53137. /**
  53138. * Define if the texture is enabled or not (disabled texture will not render)
  53139. */
  53140. _this.isEnabled = true;
  53141. /**
  53142. * Define if the texture must be cleared before rendering (default is true)
  53143. */
  53144. _this.autoClear = true;
  53145. /**
  53146. * Event raised when the texture is generated
  53147. */
  53148. _this.onGeneratedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  53149. /** @hidden */
  53150. _this._textures = {};
  53151. _this._currentRefreshId = -1;
  53152. _this._refreshRate = 1;
  53153. _this._vertexBuffers = {};
  53154. _this._uniforms = new Array();
  53155. _this._samplers = new Array();
  53156. _this._floats = {};
  53157. _this._ints = {};
  53158. _this._floatsArrays = {};
  53159. _this._colors3 = {};
  53160. _this._colors4 = {};
  53161. _this._vectors2 = {};
  53162. _this._vectors3 = {};
  53163. _this._matrices = {};
  53164. _this._fallbackTextureUsed = false;
  53165. _this._cachedDefines = "";
  53166. _this._contentUpdateId = -1;
  53167. scene = _this.getScene();
  53168. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE);
  53169. if (!component) {
  53170. component = new _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__["ProceduralTextureSceneComponent"](scene);
  53171. scene._addComponent(component);
  53172. }
  53173. scene.proceduralTextures.push(_this);
  53174. _this._engine = scene.getEngine();
  53175. _this.name = name;
  53176. _this.isRenderTarget = true;
  53177. _this._size = size;
  53178. _this._generateMipMaps = generateMipMaps;
  53179. _this.setFragment(fragment);
  53180. _this._fallbackTexture = fallbackTexture;
  53181. if (isCube) {
  53182. _this._texture = _this._engine.createRenderTargetCubeTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  53183. _this.setFloat("face", 0);
  53184. }
  53185. else {
  53186. _this._texture = _this._engine.createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  53187. }
  53188. // VBO
  53189. var vertices = [];
  53190. vertices.push(1, 1);
  53191. vertices.push(-1, 1);
  53192. vertices.push(-1, -1);
  53193. vertices.push(1, -1);
  53194. _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);
  53195. _this._createIndexBuffer();
  53196. return _this;
  53197. }
  53198. /**
  53199. * The effect that is created when initializing the post process.
  53200. * @returns The created effect corrisponding the the postprocess.
  53201. */
  53202. ProceduralTexture.prototype.getEffect = function () {
  53203. return this._effect;
  53204. };
  53205. /**
  53206. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  53207. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  53208. */
  53209. ProceduralTexture.prototype.getContent = function () {
  53210. if (this._contentData && this._currentRefreshId == this._contentUpdateId) {
  53211. return this._contentData;
  53212. }
  53213. this._contentData = this.readPixels(0, 0, this._contentData);
  53214. this._contentUpdateId = this._currentRefreshId;
  53215. return this._contentData;
  53216. };
  53217. ProceduralTexture.prototype._createIndexBuffer = function () {
  53218. var engine = this._engine;
  53219. // Indices
  53220. var indices = [];
  53221. indices.push(0);
  53222. indices.push(1);
  53223. indices.push(2);
  53224. indices.push(0);
  53225. indices.push(2);
  53226. indices.push(3);
  53227. this._indexBuffer = engine.createIndexBuffer(indices);
  53228. };
  53229. /** @hidden */
  53230. ProceduralTexture.prototype._rebuild = function () {
  53231. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  53232. if (vb) {
  53233. vb._rebuild();
  53234. }
  53235. this._createIndexBuffer();
  53236. if (this.refreshRate === _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE) {
  53237. this.refreshRate = _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE;
  53238. }
  53239. };
  53240. /**
  53241. * Resets the texture in order to recreate its associated resources.
  53242. * This can be called in case of context loss
  53243. */
  53244. ProceduralTexture.prototype.reset = function () {
  53245. if (this._effect === undefined) {
  53246. return;
  53247. }
  53248. var engine = this._engine;
  53249. engine._releaseEffect(this._effect);
  53250. };
  53251. ProceduralTexture.prototype._getDefines = function () {
  53252. return "";
  53253. };
  53254. /**
  53255. * Is the texture ready to be used ? (rendered at least once)
  53256. * @returns true if ready, otherwise, false.
  53257. */
  53258. ProceduralTexture.prototype.isReady = function () {
  53259. var _this = this;
  53260. var engine = this._engine;
  53261. var shaders;
  53262. if (!this._fragment) {
  53263. return false;
  53264. }
  53265. if (this._fallbackTextureUsed) {
  53266. return true;
  53267. }
  53268. var defines = this._getDefines();
  53269. if (this._effect && defines === this._cachedDefines && this._effect.isReady()) {
  53270. return true;
  53271. }
  53272. if (this._fragment.fragmentElement !== undefined) {
  53273. shaders = { vertex: "procedural", fragmentElement: this._fragment.fragmentElement };
  53274. }
  53275. else {
  53276. shaders = { vertex: "procedural", fragment: this._fragment };
  53277. }
  53278. this._cachedDefines = defines;
  53279. this._effect = engine.createEffect(shaders, [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], this._uniforms, this._samplers, defines, undefined, undefined, function () {
  53280. _this.releaseInternalTexture();
  53281. if (_this._fallbackTexture) {
  53282. _this._texture = _this._fallbackTexture._texture;
  53283. if (_this._texture) {
  53284. _this._texture.incrementReferences();
  53285. }
  53286. }
  53287. _this._fallbackTextureUsed = true;
  53288. });
  53289. return this._effect.isReady();
  53290. };
  53291. /**
  53292. * Resets the refresh counter of the texture and start bak from scratch.
  53293. * Could be useful to regenerate the texture if it is setup to render only once.
  53294. */
  53295. ProceduralTexture.prototype.resetRefreshCounter = function () {
  53296. this._currentRefreshId = -1;
  53297. };
  53298. /**
  53299. * Set the fragment shader to use in order to render the texture.
  53300. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  53301. */
  53302. ProceduralTexture.prototype.setFragment = function (fragment) {
  53303. this._fragment = fragment;
  53304. };
  53305. Object.defineProperty(ProceduralTexture.prototype, "refreshRate", {
  53306. /**
  53307. * Define the refresh rate of the texture or the rendering frequency.
  53308. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  53309. */
  53310. get: function () {
  53311. return this._refreshRate;
  53312. },
  53313. set: function (value) {
  53314. this._refreshRate = value;
  53315. this.resetRefreshCounter();
  53316. },
  53317. enumerable: true,
  53318. configurable: true
  53319. });
  53320. /** @hidden */
  53321. ProceduralTexture.prototype._shouldRender = function () {
  53322. if (!this.isEnabled || !this.isReady() || !this._texture) {
  53323. if (this._texture) {
  53324. this._texture.isReady = false;
  53325. }
  53326. return false;
  53327. }
  53328. if (this._fallbackTextureUsed) {
  53329. return false;
  53330. }
  53331. if (this._currentRefreshId === -1) { // At least render once
  53332. this._currentRefreshId = 1;
  53333. return true;
  53334. }
  53335. if (this.refreshRate === this._currentRefreshId) {
  53336. this._currentRefreshId = 1;
  53337. return true;
  53338. }
  53339. this._currentRefreshId++;
  53340. return false;
  53341. };
  53342. /**
  53343. * Get the size the texture is rendering at.
  53344. * @returns the size (texture is always squared)
  53345. */
  53346. ProceduralTexture.prototype.getRenderSize = function () {
  53347. return this._size;
  53348. };
  53349. /**
  53350. * Resize the texture to new value.
  53351. * @param size Define the new size the texture should have
  53352. * @param generateMipMaps Define whether the new texture should create mip maps
  53353. */
  53354. ProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  53355. if (this._fallbackTextureUsed) {
  53356. return;
  53357. }
  53358. this.releaseInternalTexture();
  53359. this._texture = this._engine.createRenderTargetTexture(size, generateMipMaps);
  53360. // Update properties
  53361. this._size = size;
  53362. this._generateMipMaps = generateMipMaps;
  53363. };
  53364. ProceduralTexture.prototype._checkUniform = function (uniformName) {
  53365. if (this._uniforms.indexOf(uniformName) === -1) {
  53366. this._uniforms.push(uniformName);
  53367. }
  53368. };
  53369. /**
  53370. * Set a texture in the shader program used to render.
  53371. * @param name Define the name of the uniform samplers as defined in the shader
  53372. * @param texture Define the texture to bind to this sampler
  53373. * @return the texture itself allowing "fluent" like uniform updates
  53374. */
  53375. ProceduralTexture.prototype.setTexture = function (name, texture) {
  53376. if (this._samplers.indexOf(name) === -1) {
  53377. this._samplers.push(name);
  53378. }
  53379. this._textures[name] = texture;
  53380. return this;
  53381. };
  53382. /**
  53383. * Set a float in the shader.
  53384. * @param name Define the name of the uniform as defined in the shader
  53385. * @param value Define the value to give to the uniform
  53386. * @return the texture itself allowing "fluent" like uniform updates
  53387. */
  53388. ProceduralTexture.prototype.setFloat = function (name, value) {
  53389. this._checkUniform(name);
  53390. this._floats[name] = value;
  53391. return this;
  53392. };
  53393. /**
  53394. * Set a int in the shader.
  53395. * @param name Define the name of the uniform as defined in the shader
  53396. * @param value Define the value to give to the uniform
  53397. * @return the texture itself allowing "fluent" like uniform updates
  53398. */
  53399. ProceduralTexture.prototype.setInt = function (name, value) {
  53400. this._checkUniform(name);
  53401. this._ints[name] = value;
  53402. return this;
  53403. };
  53404. /**
  53405. * Set an array of floats in the shader.
  53406. * @param name Define the name of the uniform as defined in the shader
  53407. * @param value Define the value to give to the uniform
  53408. * @return the texture itself allowing "fluent" like uniform updates
  53409. */
  53410. ProceduralTexture.prototype.setFloats = function (name, value) {
  53411. this._checkUniform(name);
  53412. this._floatsArrays[name] = value;
  53413. return this;
  53414. };
  53415. /**
  53416. * Set a vec3 in the shader from a Color3.
  53417. * @param name Define the name of the uniform as defined in the shader
  53418. * @param value Define the value to give to the uniform
  53419. * @return the texture itself allowing "fluent" like uniform updates
  53420. */
  53421. ProceduralTexture.prototype.setColor3 = function (name, value) {
  53422. this._checkUniform(name);
  53423. this._colors3[name] = value;
  53424. return this;
  53425. };
  53426. /**
  53427. * Set a vec4 in the shader from a Color4.
  53428. * @param name Define the name of the uniform as defined in the shader
  53429. * @param value Define the value to give to the uniform
  53430. * @return the texture itself allowing "fluent" like uniform updates
  53431. */
  53432. ProceduralTexture.prototype.setColor4 = function (name, value) {
  53433. this._checkUniform(name);
  53434. this._colors4[name] = value;
  53435. return this;
  53436. };
  53437. /**
  53438. * Set a vec2 in the shader from a Vector2.
  53439. * @param name Define the name of the uniform as defined in the shader
  53440. * @param value Define the value to give to the uniform
  53441. * @return the texture itself allowing "fluent" like uniform updates
  53442. */
  53443. ProceduralTexture.prototype.setVector2 = function (name, value) {
  53444. this._checkUniform(name);
  53445. this._vectors2[name] = value;
  53446. return this;
  53447. };
  53448. /**
  53449. * Set a vec3 in the shader from a Vector3.
  53450. * @param name Define the name of the uniform as defined in the shader
  53451. * @param value Define the value to give to the uniform
  53452. * @return the texture itself allowing "fluent" like uniform updates
  53453. */
  53454. ProceduralTexture.prototype.setVector3 = function (name, value) {
  53455. this._checkUniform(name);
  53456. this._vectors3[name] = value;
  53457. return this;
  53458. };
  53459. /**
  53460. * Set a mat4 in the shader from a MAtrix.
  53461. * @param name Define the name of the uniform as defined in the shader
  53462. * @param value Define the value to give to the uniform
  53463. * @return the texture itself allowing "fluent" like uniform updates
  53464. */
  53465. ProceduralTexture.prototype.setMatrix = function (name, value) {
  53466. this._checkUniform(name);
  53467. this._matrices[name] = value;
  53468. return this;
  53469. };
  53470. /**
  53471. * Render the texture to its associated render target.
  53472. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53473. */
  53474. ProceduralTexture.prototype.render = function (useCameraPostProcess) {
  53475. var scene = this.getScene();
  53476. if (!scene) {
  53477. return;
  53478. }
  53479. var engine = this._engine;
  53480. // Render
  53481. engine.enableEffect(this._effect);
  53482. engine.setState(false);
  53483. // Texture
  53484. for (var name in this._textures) {
  53485. this._effect.setTexture(name, this._textures[name]);
  53486. }
  53487. // Float
  53488. for (name in this._ints) {
  53489. this._effect.setInt(name, this._ints[name]);
  53490. }
  53491. // Float
  53492. for (name in this._floats) {
  53493. this._effect.setFloat(name, this._floats[name]);
  53494. }
  53495. // Floats
  53496. for (name in this._floatsArrays) {
  53497. this._effect.setArray(name, this._floatsArrays[name]);
  53498. }
  53499. // Color3
  53500. for (name in this._colors3) {
  53501. this._effect.setColor3(name, this._colors3[name]);
  53502. }
  53503. // Color4
  53504. for (name in this._colors4) {
  53505. var color = this._colors4[name];
  53506. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  53507. }
  53508. // Vector2
  53509. for (name in this._vectors2) {
  53510. this._effect.setVector2(name, this._vectors2[name]);
  53511. }
  53512. // Vector3
  53513. for (name in this._vectors3) {
  53514. this._effect.setVector3(name, this._vectors3[name]);
  53515. }
  53516. // Matrix
  53517. for (name in this._matrices) {
  53518. this._effect.setMatrix(name, this._matrices[name]);
  53519. }
  53520. if (!this._texture) {
  53521. return;
  53522. }
  53523. if (this.isCube) {
  53524. for (var face = 0; face < 6; face++) {
  53525. engine.bindFramebuffer(this._texture, face, undefined, undefined, true);
  53526. // VBOs
  53527. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  53528. this._effect.setFloat("face", face);
  53529. // Clear
  53530. if (this.autoClear) {
  53531. engine.clear(scene.clearColor, true, false, false);
  53532. }
  53533. // Draw order
  53534. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  53535. // Mipmaps
  53536. if (face === 5) {
  53537. engine.generateMipMapsForCubemap(this._texture);
  53538. }
  53539. }
  53540. }
  53541. else {
  53542. engine.bindFramebuffer(this._texture, 0, undefined, undefined, true);
  53543. // VBOs
  53544. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  53545. // Clear
  53546. if (this.autoClear) {
  53547. engine.clear(scene.clearColor, true, false, false);
  53548. }
  53549. // Draw order
  53550. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  53551. }
  53552. // Unbind
  53553. engine.unBindFramebuffer(this._texture, this.isCube);
  53554. if (this.onGenerated) {
  53555. this.onGenerated();
  53556. }
  53557. this.onGeneratedObservable.notifyObservers(this);
  53558. };
  53559. /**
  53560. * Clone the texture.
  53561. * @returns the cloned texture
  53562. */
  53563. ProceduralTexture.prototype.clone = function () {
  53564. var textureSize = this.getSize();
  53565. var newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
  53566. // Base texture
  53567. newTexture.hasAlpha = this.hasAlpha;
  53568. newTexture.level = this.level;
  53569. // RenderTarget Texture
  53570. newTexture.coordinatesMode = this.coordinatesMode;
  53571. return newTexture;
  53572. };
  53573. /**
  53574. * Dispose the texture and release its asoociated resources.
  53575. */
  53576. ProceduralTexture.prototype.dispose = function () {
  53577. var scene = this.getScene();
  53578. if (!scene) {
  53579. return;
  53580. }
  53581. var index = scene.proceduralTextures.indexOf(this);
  53582. if (index >= 0) {
  53583. scene.proceduralTextures.splice(index, 1);
  53584. }
  53585. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  53586. if (vertexBuffer) {
  53587. vertexBuffer.dispose();
  53588. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  53589. }
  53590. if (this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer)) {
  53591. this._indexBuffer = null;
  53592. }
  53593. _super.prototype.dispose.call(this);
  53594. };
  53595. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53596. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53597. ], ProceduralTexture.prototype, "isEnabled", void 0);
  53598. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53599. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53600. ], ProceduralTexture.prototype, "autoClear", void 0);
  53601. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53602. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53603. ], ProceduralTexture.prototype, "_generateMipMaps", void 0);
  53604. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53605. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53606. ], ProceduralTexture.prototype, "_size", void 0);
  53607. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53608. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53609. ], ProceduralTexture.prototype, "refreshRate", null);
  53610. return ProceduralTexture;
  53611. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"]));
  53612. /***/ }),
  53613. /***/ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts":
  53614. /*!***************************************************************************!*\
  53615. !*** ./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts ***!
  53616. \***************************************************************************/
  53617. /*! exports provided: ProceduralTextureSceneComponent */
  53618. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53619. "use strict";
  53620. __webpack_require__.r(__webpack_exports__);
  53621. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return ProceduralTextureSceneComponent; });
  53622. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  53623. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  53624. /**
  53625. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  53626. * in a given scene.
  53627. */
  53628. var ProceduralTextureSceneComponent = /** @class */ (function () {
  53629. /**
  53630. * Creates a new instance of the component for the given scene
  53631. * @param scene Defines the scene to register the component in
  53632. */
  53633. function ProceduralTextureSceneComponent(scene) {
  53634. /**
  53635. * The component name helpfull to identify the component in the list of scene components.
  53636. */
  53637. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE;
  53638. this.scene = scene;
  53639. this.scene.proceduralTextures = new Array();
  53640. scene.layers = new Array();
  53641. }
  53642. /**
  53643. * Registers the component in a given scene
  53644. */
  53645. ProceduralTextureSceneComponent.prototype.register = function () {
  53646. this.scene._beforeClearStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
  53647. };
  53648. /**
  53649. * Rebuilds the elements related to this component in case of
  53650. * context lost for instance.
  53651. */
  53652. ProceduralTextureSceneComponent.prototype.rebuild = function () {
  53653. // Nothing to do here.
  53654. };
  53655. /**
  53656. * Disposes the component and the associated ressources.
  53657. */
  53658. ProceduralTextureSceneComponent.prototype.dispose = function () {
  53659. // Nothing to do here.
  53660. };
  53661. ProceduralTextureSceneComponent.prototype._beforeClear = function () {
  53662. if (this.scene.proceduralTexturesEnabled) {
  53663. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  53664. for (var proceduralIndex = 0; proceduralIndex < this.scene.proceduralTextures.length; proceduralIndex++) {
  53665. var proceduralTexture = this.scene.proceduralTextures[proceduralIndex];
  53666. if (proceduralTexture._shouldRender()) {
  53667. proceduralTexture.render();
  53668. }
  53669. }
  53670. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  53671. }
  53672. };
  53673. return ProceduralTextureSceneComponent;
  53674. }());
  53675. /***/ }),
  53676. /***/ "./Materials/Textures/baseTexture.ts":
  53677. /*!*******************************************!*\
  53678. !*** ./Materials/Textures/baseTexture.ts ***!
  53679. \*******************************************/
  53680. /*! exports provided: BaseTexture */
  53681. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53682. "use strict";
  53683. __webpack_require__.r(__webpack_exports__);
  53684. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return BaseTexture; });
  53685. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53686. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53687. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  53688. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  53689. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  53690. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  53691. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  53692. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  53693. /**
  53694. * Base class of all the textures in babylon.
  53695. * It groups all the common properties the materials, post process, lights... might need
  53696. * in order to make a correct use of the texture.
  53697. */
  53698. var BaseTexture = /** @class */ (function () {
  53699. /**
  53700. * Instantiates a new BaseTexture.
  53701. * Base class of all the textures in babylon.
  53702. * It groups all the common properties the materials, post process, lights... might need
  53703. * in order to make a correct use of the texture.
  53704. * @param scene Define the scene the texture blongs to
  53705. */
  53706. function BaseTexture(scene) {
  53707. /**
  53708. * Gets or sets an object used to store user defined information.
  53709. */
  53710. this.metadata = null;
  53711. /**
  53712. * For internal use only. Please do not use.
  53713. */
  53714. this.reservedDataStore = null;
  53715. this._hasAlpha = false;
  53716. /**
  53717. * Defines if the alpha value should be determined via the rgb values.
  53718. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  53719. */
  53720. this.getAlphaFromRGB = false;
  53721. /**
  53722. * Intensity or strength of the texture.
  53723. * It is commonly used by materials to fine tune the intensity of the texture
  53724. */
  53725. this.level = 1;
  53726. /**
  53727. * Define the UV chanel to use starting from 0 and defaulting to 0.
  53728. * This is part of the texture as textures usually maps to one uv set.
  53729. */
  53730. this.coordinatesIndex = 0;
  53731. this._coordinatesMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_EXPLICIT_MODE;
  53732. /**
  53733. * | Value | Type | Description |
  53734. * | ----- | ------------------ | ----------- |
  53735. * | 0 | CLAMP_ADDRESSMODE | |
  53736. * | 1 | WRAP_ADDRESSMODE | |
  53737. * | 2 | MIRROR_ADDRESSMODE | |
  53738. */
  53739. this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  53740. /**
  53741. * | Value | Type | Description |
  53742. * | ----- | ------------------ | ----------- |
  53743. * | 0 | CLAMP_ADDRESSMODE | |
  53744. * | 1 | WRAP_ADDRESSMODE | |
  53745. * | 2 | MIRROR_ADDRESSMODE | |
  53746. */
  53747. this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  53748. /**
  53749. * | Value | Type | Description |
  53750. * | ----- | ------------------ | ----------- |
  53751. * | 0 | CLAMP_ADDRESSMODE | |
  53752. * | 1 | WRAP_ADDRESSMODE | |
  53753. * | 2 | MIRROR_ADDRESSMODE | |
  53754. */
  53755. this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  53756. /**
  53757. * With compliant hardware and browser (supporting anisotropic filtering)
  53758. * this defines the level of anisotropic filtering in the texture.
  53759. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  53760. */
  53761. this.anisotropicFilteringLevel = BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL;
  53762. /**
  53763. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  53764. * HDR texture are usually stored in linear space.
  53765. * This only impacts the PBR and Background materials
  53766. */
  53767. this.gammaSpace = true;
  53768. /**
  53769. * Is Z inverted in the texture (useful in a cube texture).
  53770. */
  53771. this.invertZ = false;
  53772. /**
  53773. * @hidden
  53774. */
  53775. this.lodLevelInAlpha = false;
  53776. /**
  53777. * Define if the texture is a render target.
  53778. */
  53779. this.isRenderTarget = false;
  53780. /**
  53781. * Define the list of animation attached to the texture.
  53782. */
  53783. this.animations = new Array();
  53784. /**
  53785. * An event triggered when the texture is disposed.
  53786. */
  53787. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  53788. /**
  53789. * Define the current state of the loading sequence when in delayed load mode.
  53790. */
  53791. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  53792. this._cachedSize = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  53793. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  53794. if (this._scene) {
  53795. this.uniqueId = this._scene.getUniqueId();
  53796. this._scene.addTexture(this);
  53797. }
  53798. this._uid = null;
  53799. }
  53800. Object.defineProperty(BaseTexture.prototype, "hasAlpha", {
  53801. get: function () {
  53802. return this._hasAlpha;
  53803. },
  53804. /**
  53805. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  53806. */
  53807. set: function (value) {
  53808. if (this._hasAlpha === value) {
  53809. return;
  53810. }
  53811. this._hasAlpha = value;
  53812. if (this._scene) {
  53813. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag | _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_MiscDirtyFlag);
  53814. }
  53815. },
  53816. enumerable: true,
  53817. configurable: true
  53818. });
  53819. Object.defineProperty(BaseTexture.prototype, "coordinatesMode", {
  53820. get: function () {
  53821. return this._coordinatesMode;
  53822. },
  53823. /**
  53824. * How a texture is mapped.
  53825. *
  53826. * | Value | Type | Description |
  53827. * | ----- | ----------------------------------- | ----------- |
  53828. * | 0 | EXPLICIT_MODE | |
  53829. * | 1 | SPHERICAL_MODE | |
  53830. * | 2 | PLANAR_MODE | |
  53831. * | 3 | CUBIC_MODE | |
  53832. * | 4 | PROJECTION_MODE | |
  53833. * | 5 | SKYBOX_MODE | |
  53834. * | 6 | INVCUBIC_MODE | |
  53835. * | 7 | EQUIRECTANGULAR_MODE | |
  53836. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  53837. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  53838. */
  53839. set: function (value) {
  53840. if (this._coordinatesMode === value) {
  53841. return;
  53842. }
  53843. this._coordinatesMode = value;
  53844. if (this._scene) {
  53845. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  53846. }
  53847. },
  53848. enumerable: true,
  53849. configurable: true
  53850. });
  53851. Object.defineProperty(BaseTexture.prototype, "isCube", {
  53852. /**
  53853. * Define if the texture is a cube texture or if false a 2d texture.
  53854. */
  53855. get: function () {
  53856. if (!this._texture) {
  53857. return false;
  53858. }
  53859. return this._texture.isCube;
  53860. },
  53861. set: function (value) {
  53862. if (!this._texture) {
  53863. return;
  53864. }
  53865. this._texture.isCube = value;
  53866. },
  53867. enumerable: true,
  53868. configurable: true
  53869. });
  53870. Object.defineProperty(BaseTexture.prototype, "is3D", {
  53871. /**
  53872. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  53873. */
  53874. get: function () {
  53875. if (!this._texture) {
  53876. return false;
  53877. }
  53878. return this._texture.is3D;
  53879. },
  53880. set: function (value) {
  53881. if (!this._texture) {
  53882. return;
  53883. }
  53884. this._texture.is3D = value;
  53885. },
  53886. enumerable: true,
  53887. configurable: true
  53888. });
  53889. Object.defineProperty(BaseTexture.prototype, "isRGBD", {
  53890. /**
  53891. * Gets whether or not the texture contains RGBD data.
  53892. */
  53893. get: function () {
  53894. return this._texture != null && this._texture._isRGBD;
  53895. },
  53896. enumerable: true,
  53897. configurable: true
  53898. });
  53899. Object.defineProperty(BaseTexture.prototype, "noMipmap", {
  53900. /**
  53901. * Are mip maps generated for this texture or not.
  53902. */
  53903. get: function () {
  53904. return false;
  53905. },
  53906. enumerable: true,
  53907. configurable: true
  53908. });
  53909. Object.defineProperty(BaseTexture.prototype, "lodGenerationOffset", {
  53910. /**
  53911. * With prefiltered texture, defined the offset used during the prefiltering steps.
  53912. */
  53913. get: function () {
  53914. if (this._texture) {
  53915. return this._texture._lodGenerationOffset;
  53916. }
  53917. return 0.0;
  53918. },
  53919. set: function (value) {
  53920. if (this._texture) {
  53921. this._texture._lodGenerationOffset = value;
  53922. }
  53923. },
  53924. enumerable: true,
  53925. configurable: true
  53926. });
  53927. Object.defineProperty(BaseTexture.prototype, "lodGenerationScale", {
  53928. /**
  53929. * With prefiltered texture, defined the scale used during the prefiltering steps.
  53930. */
  53931. get: function () {
  53932. if (this._texture) {
  53933. return this._texture._lodGenerationScale;
  53934. }
  53935. return 0.0;
  53936. },
  53937. set: function (value) {
  53938. if (this._texture) {
  53939. this._texture._lodGenerationScale = value;
  53940. }
  53941. },
  53942. enumerable: true,
  53943. configurable: true
  53944. });
  53945. Object.defineProperty(BaseTexture.prototype, "uid", {
  53946. /**
  53947. * Define the unique id of the texture in the scene.
  53948. */
  53949. get: function () {
  53950. if (!this._uid) {
  53951. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].RandomId();
  53952. }
  53953. return this._uid;
  53954. },
  53955. enumerable: true,
  53956. configurable: true
  53957. });
  53958. /**
  53959. * Return a string representation of the texture.
  53960. * @returns the texture as a string
  53961. */
  53962. BaseTexture.prototype.toString = function () {
  53963. return this.name;
  53964. };
  53965. /**
  53966. * Get the class name of the texture.
  53967. * @returns "BaseTexture"
  53968. */
  53969. BaseTexture.prototype.getClassName = function () {
  53970. return "BaseTexture";
  53971. };
  53972. Object.defineProperty(BaseTexture.prototype, "onDispose", {
  53973. /**
  53974. * Callback triggered when the texture has been disposed.
  53975. * Kept for back compatibility, you can use the onDisposeObservable instead.
  53976. */
  53977. set: function (callback) {
  53978. if (this._onDisposeObserver) {
  53979. this.onDisposeObservable.remove(this._onDisposeObserver);
  53980. }
  53981. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  53982. },
  53983. enumerable: true,
  53984. configurable: true
  53985. });
  53986. Object.defineProperty(BaseTexture.prototype, "isBlocking", {
  53987. /**
  53988. * Define if the texture is preventinga material to render or not.
  53989. * If not and the texture is not ready, the engine will use a default black texture instead.
  53990. */
  53991. get: function () {
  53992. return true;
  53993. },
  53994. enumerable: true,
  53995. configurable: true
  53996. });
  53997. /**
  53998. * Get the scene the texture belongs to.
  53999. * @returns the scene or null if undefined
  54000. */
  54001. BaseTexture.prototype.getScene = function () {
  54002. return this._scene;
  54003. };
  54004. /**
  54005. * Get the texture transform matrix used to offset tile the texture for istance.
  54006. * @returns the transformation matrix
  54007. */
  54008. BaseTexture.prototype.getTextureMatrix = function () {
  54009. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  54010. };
  54011. /**
  54012. * Get the texture reflection matrix used to rotate/transform the reflection.
  54013. * @returns the reflection matrix
  54014. */
  54015. BaseTexture.prototype.getReflectionTextureMatrix = function () {
  54016. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  54017. };
  54018. /**
  54019. * Get the underlying lower level texture from Babylon.
  54020. * @returns the insternal texture
  54021. */
  54022. BaseTexture.prototype.getInternalTexture = function () {
  54023. return this._texture;
  54024. };
  54025. /**
  54026. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  54027. * @returns true if ready or not blocking
  54028. */
  54029. BaseTexture.prototype.isReadyOrNotBlocking = function () {
  54030. return !this.isBlocking || this.isReady();
  54031. };
  54032. /**
  54033. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  54034. * @returns true if fully ready
  54035. */
  54036. BaseTexture.prototype.isReady = function () {
  54037. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  54038. this.delayLoad();
  54039. return false;
  54040. }
  54041. if (this._texture) {
  54042. return this._texture.isReady;
  54043. }
  54044. return false;
  54045. };
  54046. /**
  54047. * Get the size of the texture.
  54048. * @returns the texture size.
  54049. */
  54050. BaseTexture.prototype.getSize = function () {
  54051. if (this._texture) {
  54052. if (this._texture.width) {
  54053. this._cachedSize.width = this._texture.width;
  54054. this._cachedSize.height = this._texture.height;
  54055. return this._cachedSize;
  54056. }
  54057. if (this._texture._size) {
  54058. this._cachedSize.width = this._texture._size;
  54059. this._cachedSize.height = this._texture._size;
  54060. return this._cachedSize;
  54061. }
  54062. }
  54063. return this._cachedSize;
  54064. };
  54065. /**
  54066. * Get the base size of the texture.
  54067. * It can be different from the size if the texture has been resized for POT for instance
  54068. * @returns the base size
  54069. */
  54070. BaseTexture.prototype.getBaseSize = function () {
  54071. if (!this.isReady() || !this._texture) {
  54072. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  54073. }
  54074. if (this._texture._size) {
  54075. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture._size, this._texture._size);
  54076. }
  54077. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture.baseWidth, this._texture.baseHeight);
  54078. };
  54079. /**
  54080. * Update the sampling mode of the texture.
  54081. * Default is Trilinear mode.
  54082. *
  54083. * | Value | Type | Description |
  54084. * | ----- | ------------------ | ----------- |
  54085. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  54086. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  54087. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  54088. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  54089. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  54090. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  54091. * | 7 | NEAREST_LINEAR | |
  54092. * | 8 | NEAREST_NEAREST | |
  54093. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  54094. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  54095. * | 11 | LINEAR_LINEAR | |
  54096. * | 12 | LINEAR_NEAREST | |
  54097. *
  54098. * > _mag_: magnification filter (close to the viewer)
  54099. * > _min_: minification filter (far from the viewer)
  54100. * > _mip_: filter used between mip map levels
  54101. *@param samplingMode Define the new sampling mode of the texture
  54102. */
  54103. BaseTexture.prototype.updateSamplingMode = function (samplingMode) {
  54104. if (!this._texture) {
  54105. return;
  54106. }
  54107. var scene = this.getScene();
  54108. if (!scene) {
  54109. return;
  54110. }
  54111. scene.getEngine().updateTextureSamplingMode(samplingMode, this._texture);
  54112. };
  54113. /**
  54114. * Scales the texture if is `canRescale()`
  54115. * @param ratio the resize factor we want to use to rescale
  54116. */
  54117. BaseTexture.prototype.scale = function (ratio) {
  54118. };
  54119. Object.defineProperty(BaseTexture.prototype, "canRescale", {
  54120. /**
  54121. * Get if the texture can rescale.
  54122. */
  54123. get: function () {
  54124. return false;
  54125. },
  54126. enumerable: true,
  54127. configurable: true
  54128. });
  54129. /** @hidden */
  54130. BaseTexture.prototype._getFromCache = function (url, noMipmap, sampling) {
  54131. if (!this._scene) {
  54132. return null;
  54133. }
  54134. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  54135. for (var index = 0; index < texturesCache.length; index++) {
  54136. var texturesCacheEntry = texturesCache[index];
  54137. if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {
  54138. if (!sampling || sampling === texturesCacheEntry.samplingMode) {
  54139. texturesCacheEntry.incrementReferences();
  54140. return texturesCacheEntry;
  54141. }
  54142. }
  54143. }
  54144. return null;
  54145. };
  54146. /** @hidden */
  54147. BaseTexture.prototype._rebuild = function () {
  54148. };
  54149. /**
  54150. * Triggers the load sequence in delayed load mode.
  54151. */
  54152. BaseTexture.prototype.delayLoad = function () {
  54153. };
  54154. /**
  54155. * Clones the texture.
  54156. * @returns the cloned texture
  54157. */
  54158. BaseTexture.prototype.clone = function () {
  54159. return null;
  54160. };
  54161. Object.defineProperty(BaseTexture.prototype, "textureType", {
  54162. /**
  54163. * Get the texture underlying type (INT, FLOAT...)
  54164. */
  54165. get: function () {
  54166. if (!this._texture) {
  54167. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  54168. }
  54169. return (this._texture.type !== undefined) ? this._texture.type : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  54170. },
  54171. enumerable: true,
  54172. configurable: true
  54173. });
  54174. Object.defineProperty(BaseTexture.prototype, "textureFormat", {
  54175. /**
  54176. * Get the texture underlying format (RGB, RGBA...)
  54177. */
  54178. get: function () {
  54179. if (!this._texture) {
  54180. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  54181. }
  54182. return (this._texture.format !== undefined) ? this._texture.format : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  54183. },
  54184. enumerable: true,
  54185. configurable: true
  54186. });
  54187. /**
  54188. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  54189. * This will returns an RGBA array buffer containing either in values (0-255) or
  54190. * float values (0-1) depending of the underlying buffer type.
  54191. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  54192. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  54193. * @param buffer defines a user defined buffer to fill with data (can be null)
  54194. * @returns The Array buffer containing the pixels data.
  54195. */
  54196. BaseTexture.prototype.readPixels = function (faceIndex, level, buffer) {
  54197. if (faceIndex === void 0) { faceIndex = 0; }
  54198. if (level === void 0) { level = 0; }
  54199. if (buffer === void 0) { buffer = null; }
  54200. if (!this._texture) {
  54201. return null;
  54202. }
  54203. var size = this.getSize();
  54204. var width = size.width;
  54205. var height = size.height;
  54206. var scene = this.getScene();
  54207. if (!scene) {
  54208. return null;
  54209. }
  54210. var engine = scene.getEngine();
  54211. if (level != 0) {
  54212. width = width / Math.pow(2, level);
  54213. height = height / Math.pow(2, level);
  54214. width = Math.round(width);
  54215. height = Math.round(height);
  54216. }
  54217. if (this._texture.isCube) {
  54218. return engine._readTexturePixels(this._texture, width, height, faceIndex, level, buffer);
  54219. }
  54220. return engine._readTexturePixels(this._texture, width, height, -1, level, buffer);
  54221. };
  54222. /**
  54223. * Release and destroy the underlying lower level texture aka internalTexture.
  54224. */
  54225. BaseTexture.prototype.releaseInternalTexture = function () {
  54226. if (this._texture) {
  54227. this._texture.dispose();
  54228. this._texture = null;
  54229. }
  54230. };
  54231. Object.defineProperty(BaseTexture.prototype, "sphericalPolynomial", {
  54232. /**
  54233. * Get the polynomial representation of the texture data.
  54234. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54235. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54236. */
  54237. get: function () {
  54238. if (!this._texture || !_Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"] || !this.isReady()) {
  54239. return null;
  54240. }
  54241. if (!this._texture._sphericalPolynomial) {
  54242. this._texture._sphericalPolynomial =
  54243. _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapTextureToSphericalPolynomial(this);
  54244. }
  54245. return this._texture._sphericalPolynomial;
  54246. },
  54247. set: function (value) {
  54248. if (this._texture) {
  54249. this._texture._sphericalPolynomial = value;
  54250. }
  54251. },
  54252. enumerable: true,
  54253. configurable: true
  54254. });
  54255. Object.defineProperty(BaseTexture.prototype, "_lodTextureHigh", {
  54256. /** @hidden */
  54257. get: function () {
  54258. if (this._texture) {
  54259. return this._texture._lodTextureHigh;
  54260. }
  54261. return null;
  54262. },
  54263. enumerable: true,
  54264. configurable: true
  54265. });
  54266. Object.defineProperty(BaseTexture.prototype, "_lodTextureMid", {
  54267. /** @hidden */
  54268. get: function () {
  54269. if (this._texture) {
  54270. return this._texture._lodTextureMid;
  54271. }
  54272. return null;
  54273. },
  54274. enumerable: true,
  54275. configurable: true
  54276. });
  54277. Object.defineProperty(BaseTexture.prototype, "_lodTextureLow", {
  54278. /** @hidden */
  54279. get: function () {
  54280. if (this._texture) {
  54281. return this._texture._lodTextureLow;
  54282. }
  54283. return null;
  54284. },
  54285. enumerable: true,
  54286. configurable: true
  54287. });
  54288. /**
  54289. * Dispose the texture and release its associated resources.
  54290. */
  54291. BaseTexture.prototype.dispose = function () {
  54292. if (!this._scene) {
  54293. return;
  54294. }
  54295. // Animations
  54296. this._scene.stopAnimation(this);
  54297. // Remove from scene
  54298. this._scene._removePendingData(this);
  54299. var index = this._scene.textures.indexOf(this);
  54300. if (index >= 0) {
  54301. this._scene.textures.splice(index, 1);
  54302. }
  54303. this._scene.onTextureRemovedObservable.notifyObservers(this);
  54304. if (this._texture === undefined) {
  54305. return;
  54306. }
  54307. // Release
  54308. this.releaseInternalTexture();
  54309. // Callback
  54310. this.onDisposeObservable.notifyObservers(this);
  54311. this.onDisposeObservable.clear();
  54312. };
  54313. /**
  54314. * Serialize the texture into a JSON representation that can be parsed later on.
  54315. * @returns the JSON representation of the texture
  54316. */
  54317. BaseTexture.prototype.serialize = function () {
  54318. if (!this.name) {
  54319. return null;
  54320. }
  54321. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54322. // Animations
  54323. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  54324. return serializationObject;
  54325. };
  54326. /**
  54327. * Helper function to be called back once a list of texture contains only ready textures.
  54328. * @param textures Define the list of textures to wait for
  54329. * @param callback Define the callback triggered once the entire list will be ready
  54330. */
  54331. BaseTexture.WhenAllReady = function (textures, callback) {
  54332. var numRemaining = textures.length;
  54333. if (numRemaining === 0) {
  54334. callback();
  54335. return;
  54336. }
  54337. var _loop_1 = function () {
  54338. texture = textures[i];
  54339. if (texture.isReady()) {
  54340. if (--numRemaining === 0) {
  54341. callback();
  54342. }
  54343. }
  54344. else {
  54345. onLoadObservable = texture.onLoadObservable;
  54346. var onLoadCallback_1 = function () {
  54347. onLoadObservable.removeCallback(onLoadCallback_1);
  54348. if (--numRemaining === 0) {
  54349. callback();
  54350. }
  54351. };
  54352. onLoadObservable.add(onLoadCallback_1);
  54353. }
  54354. };
  54355. var texture, onLoadObservable;
  54356. for (var i = 0; i < textures.length; i++) {
  54357. _loop_1();
  54358. }
  54359. };
  54360. /**
  54361. * Default anisotropic filtering level for the application.
  54362. * It is set to 4 as a good tradeoff between perf and quality.
  54363. */
  54364. BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4;
  54365. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54366. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54367. ], BaseTexture.prototype, "uniqueId", void 0);
  54368. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54369. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54370. ], BaseTexture.prototype, "name", void 0);
  54371. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54372. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54373. ], BaseTexture.prototype, "metadata", void 0);
  54374. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54375. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("hasAlpha")
  54376. ], BaseTexture.prototype, "_hasAlpha", void 0);
  54377. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54378. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54379. ], BaseTexture.prototype, "getAlphaFromRGB", void 0);
  54380. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54381. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54382. ], BaseTexture.prototype, "level", void 0);
  54383. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54384. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54385. ], BaseTexture.prototype, "coordinatesIndex", void 0);
  54386. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54387. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("coordinatesMode")
  54388. ], BaseTexture.prototype, "_coordinatesMode", void 0);
  54389. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54390. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54391. ], BaseTexture.prototype, "wrapU", void 0);
  54392. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54393. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54394. ], BaseTexture.prototype, "wrapV", void 0);
  54395. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54396. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54397. ], BaseTexture.prototype, "wrapR", void 0);
  54398. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54399. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54400. ], BaseTexture.prototype, "anisotropicFilteringLevel", void 0);
  54401. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54402. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54403. ], BaseTexture.prototype, "isCube", null);
  54404. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54405. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54406. ], BaseTexture.prototype, "is3D", null);
  54407. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54408. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54409. ], BaseTexture.prototype, "gammaSpace", void 0);
  54410. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54411. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54412. ], BaseTexture.prototype, "invertZ", void 0);
  54413. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54414. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54415. ], BaseTexture.prototype, "lodLevelInAlpha", void 0);
  54416. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54417. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54418. ], BaseTexture.prototype, "lodGenerationOffset", null);
  54419. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54420. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54421. ], BaseTexture.prototype, "lodGenerationScale", null);
  54422. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54423. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54424. ], BaseTexture.prototype, "isRenderTarget", void 0);
  54425. return BaseTexture;
  54426. }());
  54427. /***/ }),
  54428. /***/ "./Materials/Textures/colorGradingTexture.ts":
  54429. /*!***************************************************!*\
  54430. !*** ./Materials/Textures/colorGradingTexture.ts ***!
  54431. \***************************************************/
  54432. /*! exports provided: ColorGradingTexture */
  54433. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54434. "use strict";
  54435. __webpack_require__.r(__webpack_exports__);
  54436. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return ColorGradingTexture; });
  54437. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54438. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  54439. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  54440. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  54441. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  54442. /**
  54443. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54444. * It can help converting any input color in a desired output one. This can then be used to create effects
  54445. * from sepia, black and white to sixties or futuristic rendering...
  54446. *
  54447. * The only supported format is currently 3dl.
  54448. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54449. */
  54450. var ColorGradingTexture = /** @class */ (function (_super) {
  54451. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorGradingTexture, _super);
  54452. /**
  54453. * Instantiates a ColorGradingTexture from the following parameters.
  54454. *
  54455. * @param url The location of the color gradind data (currently only supporting 3dl)
  54456. * @param scene The scene the texture will be used in
  54457. */
  54458. function ColorGradingTexture(url, scene) {
  54459. var _this = _super.call(this, scene) || this;
  54460. if (!url) {
  54461. return _this;
  54462. }
  54463. _this._engine = scene.getEngine();
  54464. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  54465. _this.name = url;
  54466. _this.url = url;
  54467. _this.hasAlpha = false;
  54468. _this.isCube = false;
  54469. _this.is3D = _this._engine.webGLVersion > 1;
  54470. _this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  54471. _this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  54472. _this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  54473. _this.anisotropicFilteringLevel = 1;
  54474. _this._texture = _this._getFromCache(url, true);
  54475. if (!_this._texture) {
  54476. if (!scene.useDelayedTextureLoading) {
  54477. _this.loadTexture();
  54478. }
  54479. else {
  54480. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED;
  54481. }
  54482. }
  54483. return _this;
  54484. }
  54485. /**
  54486. * Returns the texture matrix used in most of the material.
  54487. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54488. */
  54489. ColorGradingTexture.prototype.getTextureMatrix = function () {
  54490. return this._textureMatrix;
  54491. };
  54492. /**
  54493. * Occurs when the file being loaded is a .3dl LUT file.
  54494. */
  54495. ColorGradingTexture.prototype.load3dlTexture = function () {
  54496. var engine = this._engine;
  54497. var texture;
  54498. if (engine.webGLVersion === 1) {
  54499. 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);
  54500. }
  54501. else {
  54502. 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);
  54503. }
  54504. this._texture = texture;
  54505. var callback = function (text) {
  54506. if (typeof text !== "string") {
  54507. return;
  54508. }
  54509. var data = null;
  54510. var tempData = null;
  54511. var line;
  54512. var lines = text.split('\n');
  54513. var size = 0, pixelIndexW = 0, pixelIndexH = 0, pixelIndexSlice = 0;
  54514. var maxColor = 0;
  54515. for (var i = 0; i < lines.length; i++) {
  54516. line = lines[i];
  54517. if (!ColorGradingTexture._noneEmptyLineRegex.test(line)) {
  54518. continue;
  54519. }
  54520. if (line.indexOf('#') === 0) {
  54521. continue;
  54522. }
  54523. var words = line.split(" ");
  54524. if (size === 0) {
  54525. // Number of space + one
  54526. size = words.length;
  54527. data = new Uint8Array(size * size * size * 4); // volume texture of side size and rgb 8
  54528. tempData = new Float32Array(size * size * size * 4);
  54529. continue;
  54530. }
  54531. if (size != 0) {
  54532. var r = Math.max(parseInt(words[0]), 0);
  54533. var g = Math.max(parseInt(words[1]), 0);
  54534. var b = Math.max(parseInt(words[2]), 0);
  54535. maxColor = Math.max(r, maxColor);
  54536. maxColor = Math.max(g, maxColor);
  54537. maxColor = Math.max(b, maxColor);
  54538. var pixelStorageIndex = (pixelIndexW + pixelIndexSlice * size + pixelIndexH * size * size) * 4;
  54539. if (tempData) {
  54540. tempData[pixelStorageIndex + 0] = r;
  54541. tempData[pixelStorageIndex + 1] = g;
  54542. tempData[pixelStorageIndex + 2] = b;
  54543. }
  54544. // Keep for reference in case of back compat problems.
  54545. // pixelIndexSlice++;
  54546. // if (pixelIndexSlice % size == 0) {
  54547. // pixelIndexH++;
  54548. // pixelIndexSlice = 0;
  54549. // if (pixelIndexH % size == 0) {
  54550. // pixelIndexW++;
  54551. // pixelIndexH = 0;
  54552. // }
  54553. // }
  54554. pixelIndexH++;
  54555. if (pixelIndexH % size == 0) {
  54556. pixelIndexSlice++;
  54557. pixelIndexH = 0;
  54558. if (pixelIndexSlice % size == 0) {
  54559. pixelIndexW++;
  54560. pixelIndexSlice = 0;
  54561. }
  54562. }
  54563. }
  54564. }
  54565. if (tempData && data) {
  54566. for (var i = 0; i < tempData.length; i++) {
  54567. if (i > 0 && (i + 1) % 4 === 0) {
  54568. data[i] = 255;
  54569. }
  54570. else {
  54571. var value = tempData[i];
  54572. data[i] = (value / maxColor * 255);
  54573. }
  54574. }
  54575. }
  54576. if (texture.is3D) {
  54577. texture.updateSize(size, size, size);
  54578. engine.updateRawTexture3D(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  54579. }
  54580. else {
  54581. texture.updateSize(size * size, size);
  54582. engine.updateRawTexture(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  54583. }
  54584. };
  54585. var scene = this.getScene();
  54586. if (scene) {
  54587. scene._loadFile(this.url, callback);
  54588. }
  54589. else {
  54590. this._engine._loadFile(this.url, callback);
  54591. }
  54592. return this._texture;
  54593. };
  54594. /**
  54595. * Starts the loading process of the texture.
  54596. */
  54597. ColorGradingTexture.prototype.loadTexture = function () {
  54598. if (this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == (this.url.length - 4)) {
  54599. this.load3dlTexture();
  54600. }
  54601. };
  54602. /**
  54603. * Clones the color gradind texture.
  54604. */
  54605. ColorGradingTexture.prototype.clone = function () {
  54606. var newTexture = new ColorGradingTexture(this.url, this.getScene());
  54607. // Base texture
  54608. newTexture.level = this.level;
  54609. return newTexture;
  54610. };
  54611. /**
  54612. * Called during delayed load for textures.
  54613. */
  54614. ColorGradingTexture.prototype.delayLoad = function () {
  54615. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  54616. return;
  54617. }
  54618. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED;
  54619. this._texture = this._getFromCache(this.url, true);
  54620. if (!this._texture) {
  54621. this.loadTexture();
  54622. }
  54623. };
  54624. /**
  54625. * Parses a color grading texture serialized by Babylon.
  54626. * @param parsedTexture The texture information being parsedTexture
  54627. * @param scene The scene to load the texture in
  54628. * @param rootUrl The root url of the data assets to load
  54629. * @return A color gradind texture
  54630. */
  54631. ColorGradingTexture.Parse = function (parsedTexture, scene) {
  54632. var texture = null;
  54633. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  54634. texture = new ColorGradingTexture(parsedTexture.name, scene);
  54635. texture.name = parsedTexture.name;
  54636. texture.level = parsedTexture.level;
  54637. }
  54638. return texture;
  54639. };
  54640. /**
  54641. * Serializes the LUT texture to json format.
  54642. */
  54643. ColorGradingTexture.prototype.serialize = function () {
  54644. if (!this.name) {
  54645. return null;
  54646. }
  54647. var serializationObject = {};
  54648. serializationObject.name = this.name;
  54649. serializationObject.level = this.level;
  54650. serializationObject.customType = "BABYLON.ColorGradingTexture";
  54651. return serializationObject;
  54652. };
  54653. /**
  54654. * Empty line regex stored for GC.
  54655. */
  54656. ColorGradingTexture._noneEmptyLineRegex = /\S+/;
  54657. return ColorGradingTexture;
  54658. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__["BaseTexture"]));
  54659. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ColorGradingTexture"] = ColorGradingTexture;
  54660. /***/ }),
  54661. /***/ "./Materials/Textures/cubeTexture.ts":
  54662. /*!*******************************************!*\
  54663. !*** ./Materials/Textures/cubeTexture.ts ***!
  54664. \*******************************************/
  54665. /*! exports provided: CubeTexture */
  54666. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54667. "use strict";
  54668. __webpack_require__.r(__webpack_exports__);
  54669. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return CubeTexture; });
  54670. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54671. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54672. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  54673. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  54674. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  54675. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  54676. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  54677. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  54678. /**
  54679. * Class for creating a cube texture
  54680. */
  54681. var CubeTexture = /** @class */ (function (_super) {
  54682. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTexture, _super);
  54683. /**
  54684. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  54685. * as prefiltered data.
  54686. * @param rootUrl defines the url of the texture or the root name of the six images
  54687. * @param scene defines the scene the texture is attached to
  54688. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  54689. * @param noMipmap defines if mipmaps should be created or not
  54690. * @param files defines the six files to load for the different faces
  54691. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  54692. * @param onError defines a callback triggered in case of error during load
  54693. * @param format defines the internal format to use for the texture once loaded
  54694. * @param prefiltered defines whether or not the texture is created from prefiltered data
  54695. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  54696. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  54697. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54698. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54699. * @return the cube texture
  54700. */
  54701. function CubeTexture(rootUrl, scene, extensions, noMipmap, files, onLoad, onError, format, prefiltered, forcedExtension, createPolynomials, lodScale, lodOffset) {
  54702. if (extensions === void 0) { extensions = null; }
  54703. if (noMipmap === void 0) { noMipmap = false; }
  54704. if (files === void 0) { files = null; }
  54705. if (onLoad === void 0) { onLoad = null; }
  54706. if (onError === void 0) { onError = null; }
  54707. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA; }
  54708. if (prefiltered === void 0) { prefiltered = false; }
  54709. if (forcedExtension === void 0) { forcedExtension = null; }
  54710. if (createPolynomials === void 0) { createPolynomials = false; }
  54711. if (lodScale === void 0) { lodScale = 0.8; }
  54712. if (lodOffset === void 0) { lodOffset = 0; }
  54713. var _this = _super.call(this, scene) || this;
  54714. /**
  54715. * Gets or sets the center of the bounding box associated with the cube texture.
  54716. * It must define where the camera used to render the texture was set
  54717. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  54718. */
  54719. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  54720. _this._rotationY = 0;
  54721. /** @hidden */
  54722. _this._prefiltered = false;
  54723. _this.name = rootUrl;
  54724. _this.url = rootUrl;
  54725. _this._noMipmap = noMipmap;
  54726. _this.hasAlpha = false;
  54727. _this._format = format;
  54728. _this.isCube = true;
  54729. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  54730. _this._createPolynomials = createPolynomials;
  54731. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CUBIC_MODE;
  54732. if (!rootUrl && !files) {
  54733. return _this;
  54734. }
  54735. var lastDot = rootUrl.lastIndexOf(".");
  54736. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  54737. var isDDS = (extension === ".dds");
  54738. var isEnv = (extension === ".env");
  54739. if (isEnv) {
  54740. _this.gammaSpace = false;
  54741. _this._prefiltered = false;
  54742. }
  54743. else {
  54744. _this._prefiltered = prefiltered;
  54745. if (prefiltered) {
  54746. _this.gammaSpace = false;
  54747. }
  54748. }
  54749. _this._texture = _this._getFromCache(rootUrl, noMipmap);
  54750. if (!files) {
  54751. if (!isEnv && !isDDS && !extensions) {
  54752. extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];
  54753. }
  54754. files = [];
  54755. if (extensions) {
  54756. for (var index = 0; index < extensions.length; index++) {
  54757. files.push(rootUrl + extensions[index]);
  54758. }
  54759. }
  54760. }
  54761. _this._files = files;
  54762. if (!_this._texture) {
  54763. if (!scene.useDelayedTextureLoading) {
  54764. if (prefiltered) {
  54765. _this._texture = scene.getEngine().createPrefilteredCubeTexture(rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, _this._createPolynomials);
  54766. }
  54767. else {
  54768. _this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, _this._format, forcedExtension, false, lodScale, lodOffset);
  54769. }
  54770. }
  54771. else {
  54772. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED;
  54773. }
  54774. }
  54775. else if (onLoad) {
  54776. if (_this._texture.isReady) {
  54777. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetImmediate(function () { return onLoad(); });
  54778. }
  54779. else {
  54780. _this._texture.onLoadedObservable.add(onLoad);
  54781. }
  54782. }
  54783. return _this;
  54784. }
  54785. Object.defineProperty(CubeTexture.prototype, "boundingBoxSize", {
  54786. /**
  54787. * Returns the bounding box size
  54788. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  54789. */
  54790. get: function () {
  54791. return this._boundingBoxSize;
  54792. },
  54793. /**
  54794. * Gets or sets the size of the bounding box associated with the cube texture
  54795. * When defined, the cubemap will switch to local mode
  54796. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54797. * @example https://www.babylonjs-playground.com/#RNASML
  54798. */
  54799. set: function (value) {
  54800. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  54801. return;
  54802. }
  54803. this._boundingBoxSize = value;
  54804. var scene = this.getScene();
  54805. if (scene) {
  54806. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  54807. }
  54808. },
  54809. enumerable: true,
  54810. configurable: true
  54811. });
  54812. Object.defineProperty(CubeTexture.prototype, "rotationY", {
  54813. /**
  54814. * Gets texture matrix rotation angle around Y axis radians.
  54815. */
  54816. get: function () {
  54817. return this._rotationY;
  54818. },
  54819. /**
  54820. * Sets texture matrix rotation angle around Y axis in radians.
  54821. */
  54822. set: function (value) {
  54823. this._rotationY = value;
  54824. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(this._rotationY));
  54825. },
  54826. enumerable: true,
  54827. configurable: true
  54828. });
  54829. Object.defineProperty(CubeTexture.prototype, "noMipmap", {
  54830. /**
  54831. * Are mip maps generated for this texture or not.
  54832. */
  54833. get: function () {
  54834. return this._noMipmap;
  54835. },
  54836. enumerable: true,
  54837. configurable: true
  54838. });
  54839. /**
  54840. * Creates a cube texture from an array of image urls
  54841. * @param files defines an array of image urls
  54842. * @param scene defines the hosting scene
  54843. * @param noMipmap specifies if mip maps are not used
  54844. * @returns a cube texture
  54845. */
  54846. CubeTexture.CreateFromImages = function (files, scene, noMipmap) {
  54847. var rootUrlKey = "";
  54848. files.forEach(function (url) { return rootUrlKey += url; });
  54849. return new CubeTexture(rootUrlKey, scene, null, noMipmap, files);
  54850. };
  54851. /**
  54852. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  54853. * @param url defines the url of the prefiltered texture
  54854. * @param scene defines the scene the texture is attached to
  54855. * @param forcedExtension defines the extension of the file if different from the url
  54856. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  54857. * @return the prefiltered texture
  54858. */
  54859. CubeTexture.CreateFromPrefilteredData = function (url, scene, forcedExtension, createPolynomials) {
  54860. if (forcedExtension === void 0) { forcedExtension = null; }
  54861. if (createPolynomials === void 0) { createPolynomials = true; }
  54862. return new CubeTexture(url, scene, null, false, null, null, null, undefined, true, forcedExtension, createPolynomials);
  54863. };
  54864. /**
  54865. * Get the current class name of the texture useful for serialization or dynamic coding.
  54866. * @returns "CubeTexture"
  54867. */
  54868. CubeTexture.prototype.getClassName = function () {
  54869. return "CubeTexture";
  54870. };
  54871. /**
  54872. * Update the url (and optional buffer) of this texture if url was null during construction.
  54873. * @param url the url of the texture
  54874. * @param forcedExtension defines the extension to use
  54875. * @param onLoad callback called when the texture is loaded (defaults to null)
  54876. */
  54877. CubeTexture.prototype.updateURL = function (url, forcedExtension, onLoad) {
  54878. if (this.url) {
  54879. this.releaseInternalTexture();
  54880. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  54881. }
  54882. this.url = url;
  54883. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED;
  54884. this._prefiltered = false;
  54885. if (onLoad) {
  54886. this._delayedOnLoad = onLoad;
  54887. }
  54888. this.delayLoad(forcedExtension);
  54889. };
  54890. /**
  54891. * Delays loading of the cube texture
  54892. * @param forcedExtension defines the extension to use
  54893. */
  54894. CubeTexture.prototype.delayLoad = function (forcedExtension) {
  54895. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  54896. return;
  54897. }
  54898. var scene = this.getScene();
  54899. if (!scene) {
  54900. return;
  54901. }
  54902. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_LOADED;
  54903. this._texture = this._getFromCache(this.url, this._noMipmap);
  54904. if (!this._texture) {
  54905. if (this._prefiltered) {
  54906. this._texture = scene.getEngine().createPrefilteredCubeTexture(this.url, scene, this.lodGenerationScale, this.lodGenerationOffset, this._delayedOnLoad, undefined, this._format, undefined, this._createPolynomials);
  54907. }
  54908. else {
  54909. this._texture = scene.getEngine().createCubeTexture(this.url, scene, this._files, this._noMipmap, this._delayedOnLoad, undefined, this._format, forcedExtension);
  54910. }
  54911. }
  54912. };
  54913. /**
  54914. * Returns the reflection texture matrix
  54915. * @returns the reflection texture matrix
  54916. */
  54917. CubeTexture.prototype.getReflectionTextureMatrix = function () {
  54918. return this._textureMatrix;
  54919. };
  54920. /**
  54921. * Sets the reflection texture matrix
  54922. * @param value Reflection texture matrix
  54923. */
  54924. CubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  54925. var _this = this;
  54926. if (value.updateFlag === this._textureMatrix.updateFlag) {
  54927. return;
  54928. }
  54929. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  54930. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  54931. }
  54932. this._textureMatrix = value;
  54933. };
  54934. /**
  54935. * Parses text to create a cube texture
  54936. * @param parsedTexture define the serialized text to read from
  54937. * @param scene defines the hosting scene
  54938. * @param rootUrl defines the root url of the cube texture
  54939. * @returns a cube texture
  54940. */
  54941. CubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  54942. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  54943. var prefiltered = false;
  54944. if (parsedTexture.prefiltered) {
  54945. prefiltered = parsedTexture.prefiltered;
  54946. }
  54947. return new CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions, false, null, null, null, undefined, prefiltered);
  54948. }, parsedTexture, scene);
  54949. // Local Cubemaps
  54950. if (parsedTexture.boundingBoxPosition) {
  54951. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  54952. }
  54953. if (parsedTexture.boundingBoxSize) {
  54954. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  54955. }
  54956. // Animations
  54957. if (parsedTexture.animations) {
  54958. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  54959. var parsedAnimation = parsedTexture.animations[animationIndex];
  54960. texture.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_6__["Animation"].Parse(parsedAnimation));
  54961. }
  54962. }
  54963. return texture;
  54964. };
  54965. /**
  54966. * Makes a clone, or deep copy, of the cube texture
  54967. * @returns a new cube texture
  54968. */
  54969. CubeTexture.prototype.clone = function () {
  54970. var _this = this;
  54971. var scene = this.getScene();
  54972. var uniqueId = 0;
  54973. var newCubeTexture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  54974. if (!scene) {
  54975. return _this;
  54976. }
  54977. var cubeTexture = new CubeTexture(_this.url, scene, _this._extensions, _this._noMipmap, _this._files);
  54978. uniqueId = cubeTexture.uniqueId;
  54979. return cubeTexture;
  54980. }, this);
  54981. newCubeTexture.uniqueId = uniqueId;
  54982. return newCubeTexture;
  54983. };
  54984. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54985. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("rotationY")
  54986. ], CubeTexture.prototype, "rotationY", null);
  54987. return CubeTexture;
  54988. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__["BaseTexture"]));
  54989. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"]._CubeTextureParser = CubeTexture.Parse;
  54990. /***/ }),
  54991. /***/ "./Materials/Textures/dynamicTexture.ts":
  54992. /*!**********************************************!*\
  54993. !*** ./Materials/Textures/dynamicTexture.ts ***!
  54994. \**********************************************/
  54995. /*! exports provided: DynamicTexture */
  54996. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54997. "use strict";
  54998. __webpack_require__.r(__webpack_exports__);
  54999. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return DynamicTexture; });
  55000. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55001. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  55002. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55003. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55004. /**
  55005. * A class extending Texture allowing drawing on a texture
  55006. * @see http://doc.babylonjs.com/how_to/dynamictexture
  55007. */
  55008. var DynamicTexture = /** @class */ (function (_super) {
  55009. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DynamicTexture, _super);
  55010. /**
  55011. * Creates a DynamicTexture
  55012. * @param name defines the name of the texture
  55013. * @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
  55014. * @param scene defines the scene where you want the texture
  55015. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  55016. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55017. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  55018. */
  55019. function DynamicTexture(name, options, scene, generateMipMaps, samplingMode, format) {
  55020. if (scene === void 0) { scene = null; }
  55021. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  55022. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA; }
  55023. var _this = _super.call(this, null, scene, !generateMipMaps, undefined, samplingMode, undefined, undefined, undefined, undefined, format) || this;
  55024. _this.name = name;
  55025. _this._engine = _this.getScene().getEngine();
  55026. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  55027. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  55028. _this._generateMipMaps = generateMipMaps;
  55029. if (options.getContext) {
  55030. _this._canvas = options;
  55031. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  55032. }
  55033. else {
  55034. _this._canvas = document.createElement("canvas");
  55035. if (options.width || options.width === 0) {
  55036. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  55037. }
  55038. else {
  55039. _this._texture = _this._engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);
  55040. }
  55041. }
  55042. var textureSize = _this.getSize();
  55043. _this._canvas.width = textureSize.width;
  55044. _this._canvas.height = textureSize.height;
  55045. _this._context = _this._canvas.getContext("2d");
  55046. return _this;
  55047. }
  55048. /**
  55049. * Get the current class name of the texture useful for serialization or dynamic coding.
  55050. * @returns "DynamicTexture"
  55051. */
  55052. DynamicTexture.prototype.getClassName = function () {
  55053. return "DynamicTexture";
  55054. };
  55055. Object.defineProperty(DynamicTexture.prototype, "canRescale", {
  55056. /**
  55057. * Gets the current state of canRescale
  55058. */
  55059. get: function () {
  55060. return true;
  55061. },
  55062. enumerable: true,
  55063. configurable: true
  55064. });
  55065. DynamicTexture.prototype._recreate = function (textureSize) {
  55066. this._canvas.width = textureSize.width;
  55067. this._canvas.height = textureSize.height;
  55068. this.releaseInternalTexture();
  55069. this._texture = this._engine.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);
  55070. };
  55071. /**
  55072. * Scales the texture
  55073. * @param ratio the scale factor to apply to both width and height
  55074. */
  55075. DynamicTexture.prototype.scale = function (ratio) {
  55076. var textureSize = this.getSize();
  55077. textureSize.width *= ratio;
  55078. textureSize.height *= ratio;
  55079. this._recreate(textureSize);
  55080. };
  55081. /**
  55082. * Resizes the texture
  55083. * @param width the new width
  55084. * @param height the new height
  55085. */
  55086. DynamicTexture.prototype.scaleTo = function (width, height) {
  55087. var textureSize = this.getSize();
  55088. textureSize.width = width;
  55089. textureSize.height = height;
  55090. this._recreate(textureSize);
  55091. };
  55092. /**
  55093. * Gets the context of the canvas used by the texture
  55094. * @returns the canvas context of the dynamic texture
  55095. */
  55096. DynamicTexture.prototype.getContext = function () {
  55097. return this._context;
  55098. };
  55099. /**
  55100. * Clears the texture
  55101. */
  55102. DynamicTexture.prototype.clear = function () {
  55103. var size = this.getSize();
  55104. this._context.fillRect(0, 0, size.width, size.height);
  55105. };
  55106. /**
  55107. * Updates the texture
  55108. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  55109. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  55110. */
  55111. DynamicTexture.prototype.update = function (invertY, premulAlpha) {
  55112. if (premulAlpha === void 0) { premulAlpha = false; }
  55113. this._engine.updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY, premulAlpha, this._format || undefined);
  55114. };
  55115. /**
  55116. * Draws text onto the texture
  55117. * @param text defines the text to be drawn
  55118. * @param x defines the placement of the text from the left
  55119. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  55120. * @param font defines the font to be used with font-style, font-size, font-name
  55121. * @param color defines the color used for the text
  55122. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  55123. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  55124. * @param update defines whether texture is immediately update (default is true)
  55125. */
  55126. DynamicTexture.prototype.drawText = function (text, x, y, font, color, clearColor, invertY, update) {
  55127. if (update === void 0) { update = true; }
  55128. var size = this.getSize();
  55129. if (clearColor) {
  55130. this._context.fillStyle = clearColor;
  55131. this._context.fillRect(0, 0, size.width, size.height);
  55132. }
  55133. this._context.font = font;
  55134. if (x === null || x === undefined) {
  55135. var textSize = this._context.measureText(text);
  55136. x = (size.width - textSize.width) / 2;
  55137. }
  55138. if (y === null || y === undefined) {
  55139. var fontSize = parseInt((font.replace(/\D/g, '')));
  55140. y = (size.height / 2) + (fontSize / 3.65);
  55141. }
  55142. this._context.fillStyle = color;
  55143. this._context.fillText(text, x, y);
  55144. if (update) {
  55145. this.update(invertY);
  55146. }
  55147. };
  55148. /**
  55149. * Clones the texture
  55150. * @returns the clone of the texture.
  55151. */
  55152. DynamicTexture.prototype.clone = function () {
  55153. var scene = this.getScene();
  55154. if (!scene) {
  55155. return this;
  55156. }
  55157. var textureSize = this.getSize();
  55158. var newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);
  55159. // Base texture
  55160. newTexture.hasAlpha = this.hasAlpha;
  55161. newTexture.level = this.level;
  55162. // Dynamic Texture
  55163. newTexture.wrapU = this.wrapU;
  55164. newTexture.wrapV = this.wrapV;
  55165. return newTexture;
  55166. };
  55167. /**
  55168. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  55169. * @returns a serialized dynamic texture object
  55170. */
  55171. DynamicTexture.prototype.serialize = function () {
  55172. var scene = this.getScene();
  55173. if (scene && !scene.isReady()) {
  55174. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The scene must be ready before serializing the dynamic texture");
  55175. }
  55176. var serializationObject = _super.prototype.serialize.call(this);
  55177. serializationObject.base64String = this._canvas.toDataURL();
  55178. serializationObject.invertY = this._invertY;
  55179. serializationObject.samplingMode = this.samplingMode;
  55180. return serializationObject;
  55181. };
  55182. /** @hidden */
  55183. DynamicTexture.prototype._rebuild = function () {
  55184. this.update();
  55185. };
  55186. return DynamicTexture;
  55187. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]));
  55188. /***/ }),
  55189. /***/ "./Materials/Textures/hdrCubeTexture.ts":
  55190. /*!**********************************************!*\
  55191. !*** ./Materials/Textures/hdrCubeTexture.ts ***!
  55192. \**********************************************/
  55193. /*! exports provided: HDRCubeTexture */
  55194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55195. "use strict";
  55196. __webpack_require__.r(__webpack_exports__);
  55197. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return HDRCubeTexture; });
  55198. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55199. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55200. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  55201. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  55202. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55203. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55204. /* harmony import */ var _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/hdr */ "./Misc/HighDynamicRange/hdr.ts");
  55205. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  55206. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55207. /**
  55208. * This represents a texture coming from an HDR input.
  55209. *
  55210. * The only supported format is currently panorama picture stored in RGBE format.
  55211. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55212. */
  55213. var HDRCubeTexture = /** @class */ (function (_super) {
  55214. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTexture, _super);
  55215. /**
  55216. * Instantiates an HDRTexture from the following parameters.
  55217. *
  55218. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55219. * @param scene The scene the texture will be used in
  55220. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55221. * @param noMipmap Forces to not generate the mipmap if true
  55222. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55223. * @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)
  55224. * @param reserved Reserved flag for internal use.
  55225. */
  55226. function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
  55227. if (noMipmap === void 0) { noMipmap = false; }
  55228. if (generateHarmonics === void 0) { generateHarmonics = true; }
  55229. if (gammaSpace === void 0) { gammaSpace = false; }
  55230. if (reserved === void 0) { reserved = false; }
  55231. if (onLoad === void 0) { onLoad = null; }
  55232. if (onError === void 0) { onError = null; }
  55233. var _this = _super.call(this, scene) || this;
  55234. _this._generateHarmonics = true;
  55235. _this._onLoad = null;
  55236. _this._onError = null;
  55237. /**
  55238. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55239. */
  55240. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  55241. _this._isBlocking = true;
  55242. _this._rotationY = 0;
  55243. /**
  55244. * Gets or sets the center of the bounding box associated with the cube texture
  55245. * It must define where the camera used to render the texture was set
  55246. */
  55247. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  55248. if (!url) {
  55249. return _this;
  55250. }
  55251. _this.name = url;
  55252. _this.url = url;
  55253. _this.hasAlpha = false;
  55254. _this.isCube = true;
  55255. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  55256. _this._onLoad = onLoad;
  55257. _this._onError = onError;
  55258. _this.gammaSpace = gammaSpace;
  55259. _this._noMipmap = noMipmap;
  55260. _this._size = size;
  55261. _this._texture = _this._getFromCache(url, _this._noMipmap);
  55262. if (!_this._texture) {
  55263. if (!scene.useDelayedTextureLoading) {
  55264. _this.loadTexture();
  55265. }
  55266. else {
  55267. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  55268. }
  55269. }
  55270. return _this;
  55271. }
  55272. Object.defineProperty(HDRCubeTexture.prototype, "isBlocking", {
  55273. /**
  55274. * Gets wether or not the texture is blocking during loading.
  55275. */
  55276. get: function () {
  55277. return this._isBlocking;
  55278. },
  55279. /**
  55280. * Sets wether or not the texture is blocking during loading.
  55281. */
  55282. set: function (value) {
  55283. this._isBlocking = value;
  55284. },
  55285. enumerable: true,
  55286. configurable: true
  55287. });
  55288. Object.defineProperty(HDRCubeTexture.prototype, "rotationY", {
  55289. /**
  55290. * Gets texture matrix rotation angle around Y axis radians.
  55291. */
  55292. get: function () {
  55293. return this._rotationY;
  55294. },
  55295. /**
  55296. * Sets texture matrix rotation angle around Y axis in radians.
  55297. */
  55298. set: function (value) {
  55299. this._rotationY = value;
  55300. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationY(this._rotationY));
  55301. },
  55302. enumerable: true,
  55303. configurable: true
  55304. });
  55305. Object.defineProperty(HDRCubeTexture.prototype, "boundingBoxSize", {
  55306. get: function () {
  55307. return this._boundingBoxSize;
  55308. },
  55309. /**
  55310. * Gets or sets the size of the bounding box associated with the cube texture
  55311. * When defined, the cubemap will switch to local mode
  55312. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55313. * @example https://www.babylonjs-playground.com/#RNASML
  55314. */
  55315. set: function (value) {
  55316. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  55317. return;
  55318. }
  55319. this._boundingBoxSize = value;
  55320. var scene = this.getScene();
  55321. if (scene) {
  55322. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag);
  55323. }
  55324. },
  55325. enumerable: true,
  55326. configurable: true
  55327. });
  55328. /**
  55329. * Get the current class name of the texture useful for serialization or dynamic coding.
  55330. * @returns "HDRCubeTexture"
  55331. */
  55332. HDRCubeTexture.prototype.getClassName = function () {
  55333. return "HDRCubeTexture";
  55334. };
  55335. /**
  55336. * Occurs when the file is raw .hdr file.
  55337. */
  55338. HDRCubeTexture.prototype.loadTexture = function () {
  55339. var _this = this;
  55340. var callback = function (buffer) {
  55341. _this.lodGenerationOffset = 0.0;
  55342. _this.lodGenerationScale = 0.8;
  55343. var scene = _this.getScene();
  55344. if (!scene) {
  55345. return null;
  55346. }
  55347. // Extract the raw linear data.
  55348. var data = _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__["HDRTools"].GetCubeMapTextureData(buffer, _this._size);
  55349. // Generate harmonics if needed.
  55350. if (_this._generateHarmonics) {
  55351. var sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial(data);
  55352. _this.sphericalPolynomial = sphericalPolynomial;
  55353. }
  55354. var results = [];
  55355. var byteArray = null;
  55356. // Push each faces.
  55357. for (var j = 0; j < 6; j++) {
  55358. // Create uintarray fallback.
  55359. if (!scene.getEngine().getCaps().textureFloat) {
  55360. // 3 channels of 1 bytes per pixel in bytes.
  55361. var byteBuffer = new ArrayBuffer(_this._size * _this._size * 3);
  55362. byteArray = new Uint8Array(byteBuffer);
  55363. }
  55364. var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
  55365. // If special cases.
  55366. if (_this.gammaSpace || byteArray) {
  55367. for (var i = 0; i < _this._size * _this._size; i++) {
  55368. // Put in gamma space if requested.
  55369. if (_this.gammaSpace) {
  55370. dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  55371. dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  55372. dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  55373. }
  55374. // Convert to int texture for fallback.
  55375. if (byteArray) {
  55376. var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
  55377. var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
  55378. var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
  55379. // May use luminance instead if the result is not accurate.
  55380. var max = Math.max(Math.max(r, g), b);
  55381. if (max > 255) {
  55382. var scale = 255 / max;
  55383. r *= scale;
  55384. g *= scale;
  55385. b *= scale;
  55386. }
  55387. byteArray[(i * 3) + 0] = r;
  55388. byteArray[(i * 3) + 1] = g;
  55389. byteArray[(i * 3) + 2] = b;
  55390. }
  55391. }
  55392. }
  55393. if (byteArray) {
  55394. results.push(byteArray);
  55395. }
  55396. else {
  55397. results.push(dataFace);
  55398. }
  55399. }
  55400. return results;
  55401. };
  55402. var scene = this.getScene();
  55403. if (scene) {
  55404. 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);
  55405. }
  55406. };
  55407. HDRCubeTexture.prototype.clone = function () {
  55408. var scene = this.getScene();
  55409. if (!scene) {
  55410. return this;
  55411. }
  55412. var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
  55413. // Base texture
  55414. newTexture.level = this.level;
  55415. newTexture.wrapU = this.wrapU;
  55416. newTexture.wrapV = this.wrapV;
  55417. newTexture.coordinatesIndex = this.coordinatesIndex;
  55418. newTexture.coordinatesMode = this.coordinatesMode;
  55419. return newTexture;
  55420. };
  55421. // Methods
  55422. HDRCubeTexture.prototype.delayLoad = function () {
  55423. if (this.delayLoadState !== _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED) {
  55424. return;
  55425. }
  55426. this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_LOADED;
  55427. this._texture = this._getFromCache(this.url, this._noMipmap);
  55428. if (!this._texture) {
  55429. this.loadTexture();
  55430. }
  55431. };
  55432. /**
  55433. * Get the texture reflection matrix used to rotate/transform the reflection.
  55434. * @returns the reflection matrix
  55435. */
  55436. HDRCubeTexture.prototype.getReflectionTextureMatrix = function () {
  55437. return this._textureMatrix;
  55438. };
  55439. /**
  55440. * Set the texture reflection matrix used to rotate/transform the reflection.
  55441. * @param value Define the reflection matrix to set
  55442. */
  55443. HDRCubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  55444. var _this = this;
  55445. this._textureMatrix = value;
  55446. if (value.updateFlag === this._textureMatrix.updateFlag) {
  55447. return;
  55448. }
  55449. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  55450. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  55451. }
  55452. };
  55453. /**
  55454. * Parses a JSON representation of an HDR Texture in order to create the texture
  55455. * @param parsedTexture Define the JSON representation
  55456. * @param scene Define the scene the texture should be created in
  55457. * @param rootUrl Define the root url in case we need to load relative dependencies
  55458. * @returns the newly created texture after parsing
  55459. */
  55460. HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  55461. var texture = null;
  55462. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  55463. texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
  55464. texture.name = parsedTexture.name;
  55465. texture.hasAlpha = parsedTexture.hasAlpha;
  55466. texture.level = parsedTexture.level;
  55467. texture.coordinatesMode = parsedTexture.coordinatesMode;
  55468. texture.isBlocking = parsedTexture.isBlocking;
  55469. }
  55470. if (texture) {
  55471. if (parsedTexture.boundingBoxPosition) {
  55472. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  55473. }
  55474. if (parsedTexture.boundingBoxSize) {
  55475. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  55476. }
  55477. if (parsedTexture.rotationY) {
  55478. texture.rotationY = parsedTexture.rotationY;
  55479. }
  55480. }
  55481. return texture;
  55482. };
  55483. HDRCubeTexture.prototype.serialize = function () {
  55484. if (!this.name) {
  55485. return null;
  55486. }
  55487. var serializationObject = {};
  55488. serializationObject.name = this.name;
  55489. serializationObject.hasAlpha = this.hasAlpha;
  55490. serializationObject.isCube = true;
  55491. serializationObject.level = this.level;
  55492. serializationObject.size = this._size;
  55493. serializationObject.coordinatesMode = this.coordinatesMode;
  55494. serializationObject.useInGammaSpace = this.gammaSpace;
  55495. serializationObject.generateHarmonics = this._generateHarmonics;
  55496. serializationObject.customType = "BABYLON.HDRCubeTexture";
  55497. serializationObject.noMipmap = this._noMipmap;
  55498. serializationObject.isBlocking = this._isBlocking;
  55499. serializationObject.rotationY = this._rotationY;
  55500. return serializationObject;
  55501. };
  55502. HDRCubeTexture._facesMapping = [
  55503. "right",
  55504. "left",
  55505. "up",
  55506. "down",
  55507. "front",
  55508. "back"
  55509. ];
  55510. return HDRCubeTexture;
  55511. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  55512. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.HDRCubeTexture"] = HDRCubeTexture;
  55513. /***/ }),
  55514. /***/ "./Materials/Textures/index.ts":
  55515. /*!*************************************!*\
  55516. !*** ./Materials/Textures/index.ts ***!
  55517. \*************************************/
  55518. /*! 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 */
  55519. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55520. "use strict";
  55521. __webpack_require__.r(__webpack_exports__);
  55522. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  55523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _baseTexture__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  55524. /* harmony import */ var _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorGradingTexture */ "./Materials/Textures/colorGradingTexture.ts");
  55525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__["ColorGradingTexture"]; });
  55526. /* harmony import */ var _cubeTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  55527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _cubeTexture__WEBPACK_IMPORTED_MODULE_2__["CubeTexture"]; });
  55528. /* harmony import */ var _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  55529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__["DynamicTexture"]; });
  55530. /* harmony import */ var _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  55531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_4__["HDRCubeTexture"]; });
  55532. /* harmony import */ var _internalTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./internalTexture */ "./Materials/Textures/internalTexture.ts");
  55533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _internalTexture__WEBPACK_IMPORTED_MODULE_5__["InternalTexture"]; });
  55534. /* harmony import */ var _internalTextureTracker__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  55535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _internalTextureTracker__WEBPACK_IMPORTED_MODULE_6__["DummyInternalTextureTracker"]; });
  55536. /* harmony import */ var _Loaders_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Loaders/index */ "./Materials/Textures/Loaders/index.ts");
  55537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_DDSTextureLoader"]; });
  55538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_ENVTextureLoader"]; });
  55539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_KTXTextureLoader"]; });
  55540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_TGATextureLoader"]; });
  55541. /* harmony import */ var _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  55542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__["MirrorTexture"]; });
  55543. /* harmony import */ var _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  55544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__["MultiRenderTarget"]; });
  55545. /* harmony import */ var _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Procedurals/index */ "./Materials/Textures/Procedurals/index.ts");
  55546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTexture"]; });
  55547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["CustomProceduralTexture"]; });
  55548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["NoiseProceduralTexture"]; });
  55549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTextureSceneComponent"]; });
  55550. /* harmony import */ var _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./rawCubeTexture */ "./Materials/Textures/rawCubeTexture.ts");
  55551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__["RawCubeTexture"]; });
  55552. /* harmony import */ var _rawTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./rawTexture */ "./Materials/Textures/rawTexture.ts");
  55553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _rawTexture__WEBPACK_IMPORTED_MODULE_12__["RawTexture"]; });
  55554. /* harmony import */ var _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./rawTexture3D */ "./Materials/Textures/rawTexture3D.ts");
  55555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  55556. /* harmony import */ var _refractionTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./refractionTexture */ "./Materials/Textures/refractionTexture.ts");
  55557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _refractionTexture__WEBPACK_IMPORTED_MODULE_14__["RefractionTexture"]; });
  55558. /* harmony import */ var _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  55559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__["RenderTargetTexture"]; });
  55560. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  55561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _texture__WEBPACK_IMPORTED_MODULE_16__["Texture"]; });
  55562. /* harmony import */ var _videoTexture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./videoTexture */ "./Materials/Textures/videoTexture.ts");
  55563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _videoTexture__WEBPACK_IMPORTED_MODULE_17__["VideoTexture"]; });
  55564. /***/ }),
  55565. /***/ "./Materials/Textures/internalTexture.ts":
  55566. /*!***********************************************!*\
  55567. !*** ./Materials/Textures/internalTexture.ts ***!
  55568. \***********************************************/
  55569. /*! exports provided: InternalTexture */
  55570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55571. "use strict";
  55572. __webpack_require__.r(__webpack_exports__);
  55573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return InternalTexture; });
  55574. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  55575. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  55576. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55577. /**
  55578. * Class used to store data associated with WebGL texture data for the engine
  55579. * This class should not be used directly
  55580. */
  55581. var InternalTexture = /** @class */ (function () {
  55582. /**
  55583. * Creates a new InternalTexture
  55584. * @param engine defines the engine to use
  55585. * @param dataSource defines the type of data that will be used
  55586. * @param delayAllocation if the texture allocation should be delayed (default: false)
  55587. */
  55588. function InternalTexture(engine, dataSource, delayAllocation) {
  55589. if (delayAllocation === void 0) { delayAllocation = false; }
  55590. /**
  55591. * Observable called when the texture is loaded
  55592. */
  55593. this.onLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  55594. /**
  55595. * Gets or set the previous tracker in the list
  55596. */
  55597. this.previous = null;
  55598. /**
  55599. * Gets or set the next tracker in the list
  55600. */
  55601. this.next = null;
  55602. // Private
  55603. /** @hidden */
  55604. this._invertVScale = false;
  55605. /** @hidden */
  55606. this._initialSlot = -1;
  55607. /** @hidden */
  55608. this._designatedSlot = -1;
  55609. /** @hidden */
  55610. this._dataSource = InternalTexture.DATASOURCE_UNKNOWN;
  55611. /** @hidden */
  55612. this._comparisonFunction = 0;
  55613. /** @hidden */
  55614. this._sphericalPolynomial = null;
  55615. /** @hidden */
  55616. this._lodGenerationScale = 0;
  55617. /** @hidden */
  55618. this._lodGenerationOffset = 0;
  55619. /** @hidden */
  55620. this._isRGBD = false;
  55621. /** @hidden */
  55622. this._references = 1;
  55623. this._engine = engine;
  55624. this._dataSource = dataSource;
  55625. if (!delayAllocation) {
  55626. this._webGLTexture = engine._createTexture();
  55627. }
  55628. }
  55629. /**
  55630. * Gets the Engine the texture belongs to.
  55631. * @returns The babylon engine
  55632. */
  55633. InternalTexture.prototype.getEngine = function () {
  55634. return this._engine;
  55635. };
  55636. Object.defineProperty(InternalTexture.prototype, "dataSource", {
  55637. /**
  55638. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  55639. */
  55640. get: function () {
  55641. return this._dataSource;
  55642. },
  55643. enumerable: true,
  55644. configurable: true
  55645. });
  55646. /**
  55647. * Increments the number of references (ie. the number of Texture that point to it)
  55648. */
  55649. InternalTexture.prototype.incrementReferences = function () {
  55650. this._references++;
  55651. };
  55652. /**
  55653. * Change the size of the texture (not the size of the content)
  55654. * @param width defines the new width
  55655. * @param height defines the new height
  55656. * @param depth defines the new depth (1 by default)
  55657. */
  55658. InternalTexture.prototype.updateSize = function (width, height, depth) {
  55659. if (depth === void 0) { depth = 1; }
  55660. this.width = width;
  55661. this.height = height;
  55662. this.depth = depth;
  55663. this.baseWidth = width;
  55664. this.baseHeight = height;
  55665. this.baseDepth = depth;
  55666. this._size = width * height * depth;
  55667. };
  55668. /** @hidden */
  55669. InternalTexture.prototype._rebuild = function () {
  55670. var _this = this;
  55671. var proxy;
  55672. this.isReady = false;
  55673. this._cachedCoordinatesMode = null;
  55674. this._cachedWrapU = null;
  55675. this._cachedWrapV = null;
  55676. this._cachedAnisotropicFilteringLevel = null;
  55677. switch (this._dataSource) {
  55678. case InternalTexture.DATASOURCE_TEMP:
  55679. return;
  55680. case InternalTexture.DATASOURCE_URL:
  55681. proxy = this._engine.createTexture(this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function () {
  55682. proxy._swapAndDie(_this);
  55683. _this.isReady = true;
  55684. }, null, this._buffer, undefined, this.format);
  55685. return;
  55686. case InternalTexture.DATASOURCE_RAW:
  55687. proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  55688. proxy._swapAndDie(this);
  55689. this.isReady = true;
  55690. return;
  55691. case InternalTexture.DATASOURCE_RAW3D:
  55692. proxy = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  55693. proxy._swapAndDie(this);
  55694. this.isReady = true;
  55695. return;
  55696. case InternalTexture.DATASOURCE_DYNAMIC:
  55697. proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
  55698. proxy._swapAndDie(this);
  55699. this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, undefined, undefined, true);
  55700. // The engine will make sure to update content so no need to flag it as isReady = true
  55701. return;
  55702. case InternalTexture.DATASOURCE_RENDERTARGET:
  55703. var options = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__["RenderTargetCreationOptions"]();
  55704. options.generateDepthBuffer = this._generateDepthBuffer;
  55705. options.generateMipMaps = this.generateMipMaps;
  55706. options.generateStencilBuffer = this._generateStencilBuffer;
  55707. options.samplingMode = this.samplingMode;
  55708. options.type = this.type;
  55709. if (this.isCube) {
  55710. proxy = this._engine.createRenderTargetCubeTexture(this.width, options);
  55711. }
  55712. else {
  55713. var size = {
  55714. width: this.width,
  55715. height: this.height
  55716. };
  55717. proxy = this._engine.createRenderTargetTexture(size, options);
  55718. }
  55719. proxy._swapAndDie(this);
  55720. this.isReady = true;
  55721. return;
  55722. case InternalTexture.DATASOURCE_DEPTHTEXTURE:
  55723. var depthTextureOptions = {
  55724. bilinearFiltering: this.samplingMode !== _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  55725. comparisonFunction: this._comparisonFunction,
  55726. generateStencil: this._generateStencilBuffer,
  55727. isCube: this.isCube
  55728. };
  55729. proxy = this._engine.createDepthStencilTexture({ width: this.width, height: this.height }, depthTextureOptions);
  55730. proxy._swapAndDie(this);
  55731. this.isReady = true;
  55732. return;
  55733. case InternalTexture.DATASOURCE_CUBE:
  55734. proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
  55735. proxy._swapAndDie(_this);
  55736. _this.isReady = true;
  55737. }, null, this.format, this._extension);
  55738. return;
  55739. case InternalTexture.DATASOURCE_CUBERAW:
  55740. proxy = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  55741. proxy._swapAndDie(this);
  55742. this.isReady = true;
  55743. return;
  55744. case InternalTexture.DATASOURCE_CUBERAW_RGBD:
  55745. proxy = this._engine.createRawCubeTexture(null, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  55746. InternalTexture._UpdateRGBDAsync(proxy, this._bufferViewArrayArray, this._sphericalPolynomial, this._lodGenerationScale, this._lodGenerationOffset).then(function () {
  55747. proxy._swapAndDie(_this);
  55748. _this.isReady = true;
  55749. });
  55750. return;
  55751. case InternalTexture.DATASOURCE_CUBEPREFILTERED:
  55752. proxy = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function (proxy) {
  55753. if (proxy) {
  55754. proxy._swapAndDie(_this);
  55755. }
  55756. _this.isReady = true;
  55757. }, null, this.format, this._extension);
  55758. proxy._sphericalPolynomial = this._sphericalPolynomial;
  55759. return;
  55760. }
  55761. };
  55762. /** @hidden */
  55763. InternalTexture.prototype._swapAndDie = function (target) {
  55764. target._webGLTexture = this._webGLTexture;
  55765. if (this._framebuffer) {
  55766. target._framebuffer = this._framebuffer;
  55767. }
  55768. if (this._depthStencilBuffer) {
  55769. target._depthStencilBuffer = this._depthStencilBuffer;
  55770. }
  55771. if (this._lodTextureHigh) {
  55772. if (target._lodTextureHigh) {
  55773. target._lodTextureHigh.dispose();
  55774. }
  55775. target._lodTextureHigh = this._lodTextureHigh;
  55776. }
  55777. if (this._lodTextureMid) {
  55778. if (target._lodTextureMid) {
  55779. target._lodTextureMid.dispose();
  55780. }
  55781. target._lodTextureMid = this._lodTextureMid;
  55782. }
  55783. if (this._lodTextureLow) {
  55784. if (target._lodTextureLow) {
  55785. target._lodTextureLow.dispose();
  55786. }
  55787. target._lodTextureLow = this._lodTextureLow;
  55788. }
  55789. var cache = this._engine.getLoadedTexturesCache();
  55790. var index = cache.indexOf(this);
  55791. if (index !== -1) {
  55792. cache.splice(index, 1);
  55793. }
  55794. };
  55795. /**
  55796. * Dispose the current allocated resources
  55797. */
  55798. InternalTexture.prototype.dispose = function () {
  55799. if (!this._webGLTexture) {
  55800. return;
  55801. }
  55802. this._references--;
  55803. if (this._references === 0) {
  55804. this._engine._releaseTexture(this);
  55805. this._webGLTexture = null;
  55806. this.previous = null;
  55807. this.next = null;
  55808. }
  55809. };
  55810. /** hidden */
  55811. InternalTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  55812. throw "environmentTextureTools needs to be imported before rebuilding RGBD textures.";
  55813. };
  55814. /**
  55815. * The source of the texture data is unknown
  55816. */
  55817. InternalTexture.DATASOURCE_UNKNOWN = 0;
  55818. /**
  55819. * Texture data comes from an URL
  55820. */
  55821. InternalTexture.DATASOURCE_URL = 1;
  55822. /**
  55823. * Texture data is only used for temporary storage
  55824. */
  55825. InternalTexture.DATASOURCE_TEMP = 2;
  55826. /**
  55827. * Texture data comes from raw data (ArrayBuffer)
  55828. */
  55829. InternalTexture.DATASOURCE_RAW = 3;
  55830. /**
  55831. * Texture content is dynamic (video or dynamic texture)
  55832. */
  55833. InternalTexture.DATASOURCE_DYNAMIC = 4;
  55834. /**
  55835. * Texture content is generated by rendering to it
  55836. */
  55837. InternalTexture.DATASOURCE_RENDERTARGET = 5;
  55838. /**
  55839. * Texture content is part of a multi render target process
  55840. */
  55841. InternalTexture.DATASOURCE_MULTIRENDERTARGET = 6;
  55842. /**
  55843. * Texture data comes from a cube data file
  55844. */
  55845. InternalTexture.DATASOURCE_CUBE = 7;
  55846. /**
  55847. * Texture data comes from a raw cube data
  55848. */
  55849. InternalTexture.DATASOURCE_CUBERAW = 8;
  55850. /**
  55851. * Texture data come from a prefiltered cube data file
  55852. */
  55853. InternalTexture.DATASOURCE_CUBEPREFILTERED = 9;
  55854. /**
  55855. * Texture content is raw 3D data
  55856. */
  55857. InternalTexture.DATASOURCE_RAW3D = 10;
  55858. /**
  55859. * Texture content is a depth texture
  55860. */
  55861. InternalTexture.DATASOURCE_DEPTHTEXTURE = 11;
  55862. /**
  55863. * Texture data comes from a raw cube data encoded with RGBD
  55864. */
  55865. InternalTexture.DATASOURCE_CUBERAW_RGBD = 12;
  55866. return InternalTexture;
  55867. }());
  55868. /***/ }),
  55869. /***/ "./Materials/Textures/internalTextureTracker.ts":
  55870. /*!******************************************************!*\
  55871. !*** ./Materials/Textures/internalTextureTracker.ts ***!
  55872. \******************************************************/
  55873. /*! exports provided: DummyInternalTextureTracker */
  55874. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55875. "use strict";
  55876. __webpack_require__.r(__webpack_exports__);
  55877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return DummyInternalTextureTracker; });
  55878. /**
  55879. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  55880. */
  55881. var DummyInternalTextureTracker = /** @class */ (function () {
  55882. function DummyInternalTextureTracker() {
  55883. /**
  55884. * Gets or set the previous tracker in the list
  55885. */
  55886. this.previous = null;
  55887. /**
  55888. * Gets or set the next tracker in the list
  55889. */
  55890. this.next = null;
  55891. }
  55892. return DummyInternalTextureTracker;
  55893. }());
  55894. /***/ }),
  55895. /***/ "./Materials/Textures/mirrorTexture.ts":
  55896. /*!*********************************************!*\
  55897. !*** ./Materials/Textures/mirrorTexture.ts ***!
  55898. \*********************************************/
  55899. /*! exports provided: MirrorTexture */
  55900. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55901. "use strict";
  55902. __webpack_require__.r(__webpack_exports__);
  55903. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return MirrorTexture; });
  55904. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55905. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55906. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55907. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  55908. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  55909. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55910. /**
  55911. * Mirror texture can be used to simulate the view from a mirror in a scene.
  55912. * It will dynamically be rendered every frame to adapt to the camera point of view.
  55913. * You can then easily use it as a reflectionTexture on a flat surface.
  55914. * In case the surface is not a plane, please consider relying on reflection probes.
  55915. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  55916. */
  55917. var MirrorTexture = /** @class */ (function (_super) {
  55918. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MirrorTexture, _super);
  55919. /**
  55920. * Instantiates a Mirror Texture.
  55921. * Mirror texture can be used to simulate the view from a mirror in a scene.
  55922. * It will dynamically be rendered every frame to adapt to the camera point of view.
  55923. * You can then easily use it as a reflectionTexture on a flat surface.
  55924. * In case the surface is not a plane, please consider relying on reflection probes.
  55925. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  55926. * @param name
  55927. * @param size
  55928. * @param scene
  55929. * @param generateMipMaps
  55930. * @param type
  55931. * @param samplingMode
  55932. * @param generateDepthBuffer
  55933. */
  55934. function MirrorTexture(name, size, scene, generateMipMaps, type, samplingMode, generateDepthBuffer) {
  55935. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  55936. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  55937. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  55938. var _this = _super.call(this, name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer) || this;
  55939. _this.scene = scene;
  55940. /**
  55941. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  55942. * 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.
  55943. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  55944. */
  55945. _this.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  55946. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  55947. _this._mirrorMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  55948. _this._adaptiveBlurKernel = 0;
  55949. _this._blurKernelX = 0;
  55950. _this._blurKernelY = 0;
  55951. _this._blurRatio = 1.0;
  55952. _this.ignoreCameraViewport = true;
  55953. _this._updateGammaSpace();
  55954. _this._imageProcessingConfigChangeObserver = scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  55955. _this._updateGammaSpace;
  55956. });
  55957. _this.onBeforeRenderObservable.add(function () {
  55958. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ReflectionToRef(_this.mirrorPlane, _this._mirrorMatrix);
  55959. _this._savedViewMatrix = scene.getViewMatrix();
  55960. _this._mirrorMatrix.multiplyToRef(_this._savedViewMatrix, _this._transformMatrix);
  55961. scene.setTransformMatrix(_this._transformMatrix, scene.getProjectionMatrix());
  55962. scene.clipPlane = _this.mirrorPlane;
  55963. scene.getEngine().cullBackFaces = false;
  55964. scene._mirroredCameraPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(scene.activeCamera.globalPosition, _this._mirrorMatrix);
  55965. });
  55966. _this.onAfterRenderObservable.add(function () {
  55967. scene.setTransformMatrix(_this._savedViewMatrix, scene.getProjectionMatrix());
  55968. scene.getEngine().cullBackFaces = true;
  55969. scene._mirroredCameraPosition = null;
  55970. delete scene.clipPlane;
  55971. });
  55972. return _this;
  55973. }
  55974. Object.defineProperty(MirrorTexture.prototype, "blurRatio", {
  55975. get: function () {
  55976. return this._blurRatio;
  55977. },
  55978. /**
  55979. * Define the blur ratio used to blur the reflection if needed.
  55980. */
  55981. set: function (value) {
  55982. if (this._blurRatio === value) {
  55983. return;
  55984. }
  55985. this._blurRatio = value;
  55986. this._preparePostProcesses();
  55987. },
  55988. enumerable: true,
  55989. configurable: true
  55990. });
  55991. Object.defineProperty(MirrorTexture.prototype, "adaptiveBlurKernel", {
  55992. /**
  55993. * Define the adaptive blur kernel used to blur the reflection if needed.
  55994. * This will autocompute the closest best match for the `blurKernel`
  55995. */
  55996. set: function (value) {
  55997. this._adaptiveBlurKernel = value;
  55998. this._autoComputeBlurKernel();
  55999. },
  56000. enumerable: true,
  56001. configurable: true
  56002. });
  56003. Object.defineProperty(MirrorTexture.prototype, "blurKernel", {
  56004. /**
  56005. * Define the blur kernel used to blur the reflection if needed.
  56006. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  56007. */
  56008. set: function (value) {
  56009. this.blurKernelX = value;
  56010. this.blurKernelY = value;
  56011. },
  56012. enumerable: true,
  56013. configurable: true
  56014. });
  56015. Object.defineProperty(MirrorTexture.prototype, "blurKernelX", {
  56016. get: function () {
  56017. return this._blurKernelX;
  56018. },
  56019. /**
  56020. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  56021. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  56022. */
  56023. set: function (value) {
  56024. if (this._blurKernelX === value) {
  56025. return;
  56026. }
  56027. this._blurKernelX = value;
  56028. this._preparePostProcesses();
  56029. },
  56030. enumerable: true,
  56031. configurable: true
  56032. });
  56033. Object.defineProperty(MirrorTexture.prototype, "blurKernelY", {
  56034. get: function () {
  56035. return this._blurKernelY;
  56036. },
  56037. /**
  56038. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  56039. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  56040. */
  56041. set: function (value) {
  56042. if (this._blurKernelY === value) {
  56043. return;
  56044. }
  56045. this._blurKernelY = value;
  56046. this._preparePostProcesses();
  56047. },
  56048. enumerable: true,
  56049. configurable: true
  56050. });
  56051. MirrorTexture.prototype._autoComputeBlurKernel = function () {
  56052. var engine = this.getScene().getEngine();
  56053. var dw = this.getRenderWidth() / engine.getRenderWidth();
  56054. var dh = this.getRenderHeight() / engine.getRenderHeight();
  56055. this.blurKernelX = this._adaptiveBlurKernel * dw;
  56056. this.blurKernelY = this._adaptiveBlurKernel * dh;
  56057. };
  56058. MirrorTexture.prototype._onRatioRescale = function () {
  56059. if (this._sizeRatio) {
  56060. this.resize(this._initialSizeParameter);
  56061. if (!this._adaptiveBlurKernel) {
  56062. this._preparePostProcesses();
  56063. }
  56064. }
  56065. if (this._adaptiveBlurKernel) {
  56066. this._autoComputeBlurKernel();
  56067. }
  56068. };
  56069. MirrorTexture.prototype._updateGammaSpace = function () {
  56070. this.gammaSpace = !this.scene.imageProcessingConfiguration.isEnabled || !this.scene.imageProcessingConfiguration.applyByPostProcess;
  56071. };
  56072. MirrorTexture.prototype._preparePostProcesses = function () {
  56073. this.clearPostProcesses(true);
  56074. if (this._blurKernelX && this._blurKernelY) {
  56075. var engine = this.getScene().getEngine();
  56076. var textureType = engine.getCaps().textureFloatRender ? _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT : _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_HALF_FLOAT;
  56077. 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);
  56078. this._blurX.autoClear = false;
  56079. if (this._blurRatio === 1 && this.samples < 2 && this._texture) {
  56080. this._blurX.inputTexture = this._texture;
  56081. }
  56082. else {
  56083. this._blurX.alwaysForcePOT = true;
  56084. }
  56085. 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);
  56086. this._blurY.autoClear = false;
  56087. this._blurY.alwaysForcePOT = this._blurRatio !== 1;
  56088. this.addPostProcess(this._blurX);
  56089. this.addPostProcess(this._blurY);
  56090. }
  56091. else {
  56092. if (this._blurY) {
  56093. this.removePostProcess(this._blurY);
  56094. this._blurY.dispose();
  56095. this._blurY = null;
  56096. }
  56097. if (this._blurX) {
  56098. this.removePostProcess(this._blurX);
  56099. this._blurX.dispose();
  56100. this._blurX = null;
  56101. }
  56102. }
  56103. };
  56104. /**
  56105. * Clone the mirror texture.
  56106. * @returns the cloned texture
  56107. */
  56108. MirrorTexture.prototype.clone = function () {
  56109. var scene = this.getScene();
  56110. if (!scene) {
  56111. return this;
  56112. }
  56113. var textureSize = this.getSize();
  56114. var newTexture = new MirrorTexture(this.name, textureSize.width, scene, this._renderTargetOptions.generateMipMaps, this._renderTargetOptions.type, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer);
  56115. // Base texture
  56116. newTexture.hasAlpha = this.hasAlpha;
  56117. newTexture.level = this.level;
  56118. // Mirror Texture
  56119. newTexture.mirrorPlane = this.mirrorPlane.clone();
  56120. if (this.renderList) {
  56121. newTexture.renderList = this.renderList.slice(0);
  56122. }
  56123. return newTexture;
  56124. };
  56125. /**
  56126. * Serialize the texture to a JSON representation you could use in Parse later on
  56127. * @returns the serialized JSON representation
  56128. */
  56129. MirrorTexture.prototype.serialize = function () {
  56130. if (!this.name) {
  56131. return null;
  56132. }
  56133. var serializationObject = _super.prototype.serialize.call(this);
  56134. serializationObject.mirrorPlane = this.mirrorPlane.asArray();
  56135. return serializationObject;
  56136. };
  56137. /**
  56138. * Dispose the texture and release its associated resources.
  56139. */
  56140. MirrorTexture.prototype.dispose = function () {
  56141. _super.prototype.dispose.call(this);
  56142. this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver);
  56143. };
  56144. return MirrorTexture;
  56145. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]));
  56146. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  56147. return new MirrorTexture(name, renderTargetSize, scene, generateMipMaps);
  56148. };
  56149. /***/ }),
  56150. /***/ "./Materials/Textures/multiRenderTarget.ts":
  56151. /*!*************************************************!*\
  56152. !*** ./Materials/Textures/multiRenderTarget.ts ***!
  56153. \*************************************************/
  56154. /*! exports provided: MultiRenderTarget */
  56155. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56156. "use strict";
  56157. __webpack_require__.r(__webpack_exports__);
  56158. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return MultiRenderTarget; });
  56159. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56160. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56161. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56162. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56163. /**
  56164. * A multi render target, like a render target provides the ability to render to a texture.
  56165. * Unlike the render target, it can render to several draw buffers in one draw.
  56166. * This is specially interesting in deferred rendering or for any effects requiring more than
  56167. * just one color from a single pass.
  56168. */
  56169. var MultiRenderTarget = /** @class */ (function (_super) {
  56170. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiRenderTarget, _super);
  56171. /**
  56172. * Instantiate a new multi render target texture.
  56173. * A multi render target, like a render target provides the ability to render to a texture.
  56174. * Unlike the render target, it can render to several draw buffers in one draw.
  56175. * This is specially interesting in deferred rendering or for any effects requiring more than
  56176. * just one color from a single pass.
  56177. * @param name Define the name of the texture
  56178. * @param size Define the size of the buffers to render to
  56179. * @param count Define the number of target we are rendering into
  56180. * @param scene Define the scene the texture belongs to
  56181. * @param options Define the options used to create the multi render target
  56182. */
  56183. function MultiRenderTarget(name, size, count, scene, options) {
  56184. var _this = this;
  56185. var generateMipMaps = options && options.generateMipMaps ? options.generateMipMaps : false;
  56186. var generateDepthTexture = options && options.generateDepthTexture ? options.generateDepthTexture : false;
  56187. var doNotChangeAspectRatio = !options || options.doNotChangeAspectRatio === undefined ? true : options.doNotChangeAspectRatio;
  56188. _this = _super.call(this, name, size, scene, generateMipMaps, doNotChangeAspectRatio) || this;
  56189. _this._engine = scene.getEngine();
  56190. if (!_this.isSupported) {
  56191. _this.dispose();
  56192. return;
  56193. }
  56194. var types = [];
  56195. var samplingModes = [];
  56196. for (var i = 0; i < count; i++) {
  56197. if (options && options.types && options.types[i] !== undefined) {
  56198. types.push(options.types[i]);
  56199. }
  56200. else {
  56201. types.push(options && options.defaultType ? options.defaultType : _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  56202. }
  56203. if (options && options.samplingModes && options.samplingModes[i] !== undefined) {
  56204. samplingModes.push(options.samplingModes[i]);
  56205. }
  56206. else {
  56207. samplingModes.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE);
  56208. }
  56209. }
  56210. var generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  56211. var generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  56212. _this._size = size;
  56213. _this._multiRenderTargetOptions = {
  56214. samplingModes: samplingModes,
  56215. generateMipMaps: generateMipMaps,
  56216. generateDepthBuffer: generateDepthBuffer,
  56217. generateStencilBuffer: generateStencilBuffer,
  56218. generateDepthTexture: generateDepthTexture,
  56219. types: types,
  56220. textureCount: count
  56221. };
  56222. _this._createInternalTextures();
  56223. _this._createTextures();
  56224. return _this;
  56225. }
  56226. Object.defineProperty(MultiRenderTarget.prototype, "isSupported", {
  56227. /**
  56228. * Get if draw buffers are currently supported by the used hardware and browser.
  56229. */
  56230. get: function () {
  56231. return this._engine.webGLVersion > 1 || this._engine.getCaps().drawBuffersExtension;
  56232. },
  56233. enumerable: true,
  56234. configurable: true
  56235. });
  56236. Object.defineProperty(MultiRenderTarget.prototype, "textures", {
  56237. /**
  56238. * Get the list of textures generated by the multi render target.
  56239. */
  56240. get: function () {
  56241. return this._textures;
  56242. },
  56243. enumerable: true,
  56244. configurable: true
  56245. });
  56246. Object.defineProperty(MultiRenderTarget.prototype, "depthTexture", {
  56247. /**
  56248. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  56249. */
  56250. get: function () {
  56251. return this._textures[this._textures.length - 1];
  56252. },
  56253. enumerable: true,
  56254. configurable: true
  56255. });
  56256. Object.defineProperty(MultiRenderTarget.prototype, "wrapU", {
  56257. /**
  56258. * Set the wrapping mode on U of all the textures we are rendering to.
  56259. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  56260. */
  56261. set: function (wrap) {
  56262. if (this._textures) {
  56263. for (var i = 0; i < this._textures.length; i++) {
  56264. this._textures[i].wrapU = wrap;
  56265. }
  56266. }
  56267. },
  56268. enumerable: true,
  56269. configurable: true
  56270. });
  56271. Object.defineProperty(MultiRenderTarget.prototype, "wrapV", {
  56272. /**
  56273. * Set the wrapping mode on V of all the textures we are rendering to.
  56274. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  56275. */
  56276. set: function (wrap) {
  56277. if (this._textures) {
  56278. for (var i = 0; i < this._textures.length; i++) {
  56279. this._textures[i].wrapV = wrap;
  56280. }
  56281. }
  56282. },
  56283. enumerable: true,
  56284. configurable: true
  56285. });
  56286. /** @hidden */
  56287. MultiRenderTarget.prototype._rebuild = function () {
  56288. this.releaseInternalTextures();
  56289. this._createInternalTextures();
  56290. for (var i = 0; i < this._internalTextures.length; i++) {
  56291. var texture = this._textures[i];
  56292. texture._texture = this._internalTextures[i];
  56293. }
  56294. // Keeps references to frame buffer and stencil/depth buffer
  56295. this._texture = this._internalTextures[0];
  56296. };
  56297. MultiRenderTarget.prototype._createInternalTextures = function () {
  56298. this._internalTextures = this._engine.createMultipleRenderTarget(this._size, this._multiRenderTargetOptions);
  56299. };
  56300. MultiRenderTarget.prototype._createTextures = function () {
  56301. this._textures = [];
  56302. for (var i = 0; i < this._internalTextures.length; i++) {
  56303. var texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](null, this.getScene());
  56304. texture._texture = this._internalTextures[i];
  56305. this._textures.push(texture);
  56306. }
  56307. // Keeps references to frame buffer and stencil/depth buffer
  56308. this._texture = this._internalTextures[0];
  56309. };
  56310. Object.defineProperty(MultiRenderTarget.prototype, "samples", {
  56311. /**
  56312. * Define the number of samples used if MSAA is enabled.
  56313. */
  56314. get: function () {
  56315. return this._samples;
  56316. },
  56317. set: function (value) {
  56318. if (this._samples === value) {
  56319. return;
  56320. }
  56321. this._samples = this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures, value);
  56322. },
  56323. enumerable: true,
  56324. configurable: true
  56325. });
  56326. /**
  56327. * Resize all the textures in the multi render target.
  56328. * Be carrefull as it will recreate all the data in the new texture.
  56329. * @param size Define the new size
  56330. */
  56331. MultiRenderTarget.prototype.resize = function (size) {
  56332. this.releaseInternalTextures();
  56333. this._internalTextures = this._engine.createMultipleRenderTarget(size, this._multiRenderTargetOptions);
  56334. this._createInternalTextures();
  56335. };
  56336. MultiRenderTarget.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  56337. var _this = this;
  56338. engine.unBindMultiColorAttachmentFramebuffer(this._internalTextures, this.isCube, function () {
  56339. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  56340. });
  56341. };
  56342. /**
  56343. * Dispose the render targets and their associated resources
  56344. */
  56345. MultiRenderTarget.prototype.dispose = function () {
  56346. this.releaseInternalTextures();
  56347. _super.prototype.dispose.call(this);
  56348. };
  56349. /**
  56350. * Release all the underlying texture used as draw buffers.
  56351. */
  56352. MultiRenderTarget.prototype.releaseInternalTextures = function () {
  56353. if (!this._internalTextures) {
  56354. return;
  56355. }
  56356. for (var i = this._internalTextures.length - 1; i >= 0; i--) {
  56357. if (this._internalTextures[i] !== undefined) {
  56358. this._internalTextures[i].dispose();
  56359. this._internalTextures.splice(i, 1);
  56360. }
  56361. }
  56362. };
  56363. return MultiRenderTarget;
  56364. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  56365. /***/ }),
  56366. /***/ "./Materials/Textures/rawCubeTexture.ts":
  56367. /*!**********************************************!*\
  56368. !*** ./Materials/Textures/rawCubeTexture.ts ***!
  56369. \**********************************************/
  56370. /*! exports provided: RawCubeTexture */
  56371. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56372. "use strict";
  56373. __webpack_require__.r(__webpack_exports__);
  56374. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return RawCubeTexture; });
  56375. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56376. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  56377. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  56378. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  56379. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  56380. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56381. /**
  56382. * Raw cube texture where the raw buffers are passed in
  56383. */
  56384. var RawCubeTexture = /** @class */ (function (_super) {
  56385. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawCubeTexture, _super);
  56386. /**
  56387. * Creates a cube texture where the raw buffers are passed in.
  56388. * @param scene defines the scene the texture is attached to
  56389. * @param data defines the array of data to use to create each face
  56390. * @param size defines the size of the textures
  56391. * @param format defines the format of the data
  56392. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56393. * @param generateMipMaps defines if the engine should generate the mip levels
  56394. * @param invertY defines if data must be stored with Y axis inverted
  56395. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56396. * @param compression defines the compression used (null by default)
  56397. */
  56398. function RawCubeTexture(scene, data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  56399. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTUREFORMAT_RGBA; }
  56400. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56401. if (generateMipMaps === void 0) { generateMipMaps = false; }
  56402. if (invertY === void 0) { invertY = false; }
  56403. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56404. if (compression === void 0) { compression = null; }
  56405. var _this = _super.call(this, "", scene) || this;
  56406. _this._texture = scene.getEngine().createRawCubeTexture(data, size, format, type, generateMipMaps, invertY, samplingMode, compression);
  56407. return _this;
  56408. }
  56409. /**
  56410. * Updates the raw cube texture.
  56411. * @param data defines the data to store
  56412. * @param format defines the data format
  56413. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56414. * @param invertY defines if data must be stored with Y axis inverted
  56415. * @param compression defines the compression used (null by default)
  56416. * @param level defines which level of the texture to update
  56417. */
  56418. RawCubeTexture.prototype.update = function (data, format, type, invertY, compression) {
  56419. if (compression === void 0) { compression = null; }
  56420. this._texture.getEngine().updateRawCubeTexture(this._texture, data, format, type, invertY, compression);
  56421. };
  56422. /**
  56423. * Updates a raw cube texture with RGBD encoded data.
  56424. * @param data defines the array of data [mipmap][face] to use to create each face
  56425. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56426. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56427. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56428. * @returns a promsie that resolves when the operation is complete
  56429. */
  56430. RawCubeTexture.prototype.updateRGBDAsync = function (data, sphericalPolynomial, lodScale, lodOffset) {
  56431. if (sphericalPolynomial === void 0) { sphericalPolynomial = null; }
  56432. if (lodScale === void 0) { lodScale = 0.8; }
  56433. if (lodOffset === void 0) { lodOffset = 0; }
  56434. return RawCubeTexture._UpdateRGBDAsync(this._texture, data, sphericalPolynomial, lodScale, lodOffset);
  56435. };
  56436. /**
  56437. * Clones the raw cube texture.
  56438. * @return a new cube texture
  56439. */
  56440. RawCubeTexture.prototype.clone = function () {
  56441. var _this = this;
  56442. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  56443. var scene = _this.getScene();
  56444. var internalTexture = _this._texture;
  56445. var texture = new RawCubeTexture(scene, internalTexture._bufferViewArray, internalTexture.width, internalTexture.format, internalTexture.type, internalTexture.generateMipMaps, internalTexture.invertY, internalTexture.samplingMode, internalTexture._compression);
  56446. if (internalTexture.dataSource === _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD) {
  56447. texture.updateRGBDAsync(internalTexture._bufferViewArrayArray, internalTexture._sphericalPolynomial, internalTexture._lodGenerationScale, internalTexture._lodGenerationOffset);
  56448. }
  56449. return texture;
  56450. }, this);
  56451. };
  56452. /** @hidden */
  56453. RawCubeTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  56454. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  56455. internalTexture._bufferViewArrayArray = data;
  56456. internalTexture._lodGenerationScale = lodScale;
  56457. internalTexture._lodGenerationOffset = lodOffset;
  56458. internalTexture._sphericalPolynomial = sphericalPolynomial;
  56459. return _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__["EnvironmentTextureTools"].UploadLevelsAsync(internalTexture, data).then(function () {
  56460. internalTexture.isReady = true;
  56461. });
  56462. };
  56463. return RawCubeTexture;
  56464. }(_Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__["CubeTexture"]));
  56465. /***/ }),
  56466. /***/ "./Materials/Textures/rawTexture.ts":
  56467. /*!******************************************!*\
  56468. !*** ./Materials/Textures/rawTexture.ts ***!
  56469. \******************************************/
  56470. /*! exports provided: RawTexture */
  56471. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56472. "use strict";
  56473. __webpack_require__.r(__webpack_exports__);
  56474. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return RawTexture; });
  56475. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56476. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56477. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56478. /**
  56479. * Raw texture can help creating a texture directly from an array of data.
  56480. * This can be super useful if you either get the data from an uncompressed source or
  56481. * if you wish to create your texture pixel by pixel.
  56482. */
  56483. var RawTexture = /** @class */ (function (_super) {
  56484. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture, _super);
  56485. /**
  56486. * Instantiates a new RawTexture.
  56487. * Raw texture can help creating a texture directly from an array of data.
  56488. * This can be super useful if you either get the data from an uncompressed source or
  56489. * if you wish to create your texture pixel by pixel.
  56490. * @param data define the array of data to use to create the texture
  56491. * @param width define the width of the texture
  56492. * @param height define the height of the texture
  56493. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  56494. * @param scene define the scene the texture belongs to
  56495. * @param generateMipMaps define whether mip maps should be generated or not
  56496. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  56497. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  56498. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  56499. */
  56500. function RawTexture(data, width, height,
  56501. /**
  56502. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  56503. */
  56504. format, scene, generateMipMaps, invertY, samplingMode, type) {
  56505. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56506. if (invertY === void 0) { invertY = false; }
  56507. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56508. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56509. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  56510. _this.format = format;
  56511. _this._engine = scene.getEngine();
  56512. _this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type);
  56513. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  56514. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  56515. return _this;
  56516. }
  56517. /**
  56518. * Updates the texture underlying data.
  56519. * @param data Define the new data of the texture
  56520. */
  56521. RawTexture.prototype.update = function (data) {
  56522. this._engine.updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  56523. };
  56524. /**
  56525. * Creates a luminance texture from some data.
  56526. * @param data Define the texture data
  56527. * @param width Define the width of the texture
  56528. * @param height Define the height of the texture
  56529. * @param scene Define the scene the texture belongs to
  56530. * @param generateMipMaps Define whether or not to create mip maps for the texture
  56531. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  56532. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  56533. * @returns the luminance texture
  56534. */
  56535. RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  56536. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56537. if (invertY === void 0) { invertY = false; }
  56538. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56539. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE, scene, generateMipMaps, invertY, samplingMode);
  56540. };
  56541. /**
  56542. * Creates a luminance alpha texture from some data.
  56543. * @param data Define the texture data
  56544. * @param width Define the width of the texture
  56545. * @param height Define the height of the texture
  56546. * @param scene Define the scene the texture belongs to
  56547. * @param generateMipMaps Define whether or not to create mip maps for the texture
  56548. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  56549. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  56550. * @returns the luminance alpha texture
  56551. */
  56552. RawTexture.CreateLuminanceAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  56553. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56554. if (invertY === void 0) { invertY = false; }
  56555. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56556. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  56557. };
  56558. /**
  56559. * Creates an alpha texture from some data.
  56560. * @param data Define the texture data
  56561. * @param width Define the width of the texture
  56562. * @param height Define the height of the texture
  56563. * @param scene Define the scene the texture belongs to
  56564. * @param generateMipMaps Define whether or not to create mip maps for the texture
  56565. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  56566. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  56567. * @returns the alpha texture
  56568. */
  56569. RawTexture.CreateAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  56570. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56571. if (invertY === void 0) { invertY = false; }
  56572. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56573. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  56574. };
  56575. /**
  56576. * Creates a RGB texture from some data.
  56577. * @param data Define the texture data
  56578. * @param width Define the width of the texture
  56579. * @param height Define the height of the texture
  56580. * @param scene Define the scene the texture belongs to
  56581. * @param generateMipMaps Define whether or not to create mip maps for the texture
  56582. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  56583. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  56584. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  56585. * @returns the RGB alpha texture
  56586. */
  56587. RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  56588. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56589. if (invertY === void 0) { invertY = false; }
  56590. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56591. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56592. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode, type);
  56593. };
  56594. /**
  56595. * Creates a RGBA texture from some data.
  56596. * @param data Define the texture data
  56597. * @param width Define the width of the texture
  56598. * @param height Define the height of the texture
  56599. * @param scene Define the scene the texture belongs to
  56600. * @param generateMipMaps Define whether or not to create mip maps for the texture
  56601. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  56602. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  56603. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  56604. * @returns the RGBA texture
  56605. */
  56606. RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  56607. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56608. if (invertY === void 0) { invertY = false; }
  56609. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56610. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56611. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);
  56612. };
  56613. /**
  56614. * Creates a R texture from some data.
  56615. * @param data Define the texture data
  56616. * @param width Define the width of the texture
  56617. * @param height Define the height of the texture
  56618. * @param scene Define the scene the texture belongs to
  56619. * @param generateMipMaps Define whether or not to create mip maps for the texture
  56620. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  56621. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  56622. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  56623. * @returns the R texture
  56624. */
  56625. RawTexture.CreateRTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  56626. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56627. if (invertY === void 0) { invertY = false; }
  56628. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  56629. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT; }
  56630. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_R, scene, generateMipMaps, invertY, samplingMode, type);
  56631. };
  56632. return RawTexture;
  56633. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  56634. /***/ }),
  56635. /***/ "./Materials/Textures/rawTexture3D.ts":
  56636. /*!********************************************!*\
  56637. !*** ./Materials/Textures/rawTexture3D.ts ***!
  56638. \********************************************/
  56639. /*! exports provided: RawTexture3D */
  56640. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56641. "use strict";
  56642. __webpack_require__.r(__webpack_exports__);
  56643. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return RawTexture3D; });
  56644. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56645. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56646. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56647. /**
  56648. * Class used to store 3D textures containing user data
  56649. */
  56650. var RawTexture3D = /** @class */ (function (_super) {
  56651. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture3D, _super);
  56652. /**
  56653. * Create a new RawTexture3D
  56654. * @param data defines the data of the texture
  56655. * @param width defines the width of the texture
  56656. * @param height defines the height of the texture
  56657. * @param depth defines the depth of the texture
  56658. * @param format defines the texture format to use
  56659. * @param scene defines the hosting scene
  56660. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56661. * @param invertY defines if texture must be stored with Y axis inverted
  56662. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56663. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56664. */
  56665. function RawTexture3D(data, width, height, depth,
  56666. /** Gets or sets the texture format to use */
  56667. format, scene, generateMipMaps, invertY, samplingMode, textureType) {
  56668. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56669. if (invertY === void 0) { invertY = false; }
  56670. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  56671. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56672. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  56673. _this.format = format;
  56674. _this._engine = scene.getEngine();
  56675. _this._texture = scene.getEngine().createRawTexture3D(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, undefined, textureType);
  56676. _this.is3D = true;
  56677. return _this;
  56678. }
  56679. /**
  56680. * Update the texture with new data
  56681. * @param data defines the data to store in the texture
  56682. */
  56683. RawTexture3D.prototype.update = function (data) {
  56684. if (!this._texture) {
  56685. return;
  56686. }
  56687. this._engine.updateRawTexture3D(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  56688. };
  56689. return RawTexture3D;
  56690. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  56691. /***/ }),
  56692. /***/ "./Materials/Textures/refractionTexture.ts":
  56693. /*!*************************************************!*\
  56694. !*** ./Materials/Textures/refractionTexture.ts ***!
  56695. \*************************************************/
  56696. /*! exports provided: RefractionTexture */
  56697. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56698. "use strict";
  56699. __webpack_require__.r(__webpack_exports__);
  56700. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return RefractionTexture; });
  56701. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56702. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56703. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56704. /**
  56705. * Creates a refraction texture used by refraction channel of the standard material.
  56706. * It is like a mirror but to see through a material.
  56707. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56708. */
  56709. var RefractionTexture = /** @class */ (function (_super) {
  56710. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionTexture, _super);
  56711. /**
  56712. * Creates a refraction texture used by refraction channel of the standard material.
  56713. * It is like a mirror but to see through a material.
  56714. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56715. * @param name Define the texture name
  56716. * @param size Define the size of the underlying texture
  56717. * @param scene Define the scene the refraction belongs to
  56718. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56719. */
  56720. function RefractionTexture(name, size, scene, generateMipMaps) {
  56721. var _this = _super.call(this, name, size, scene, generateMipMaps, true) || this;
  56722. /**
  56723. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56724. * 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.
  56725. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56726. */
  56727. _this.refractionPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  56728. /**
  56729. * Define how deep under the surface we should see.
  56730. */
  56731. _this.depth = 2.0;
  56732. _this.onBeforeRenderObservable.add(function () {
  56733. scene.clipPlane = _this.refractionPlane;
  56734. });
  56735. _this.onAfterRenderObservable.add(function () {
  56736. delete scene.clipPlane;
  56737. });
  56738. return _this;
  56739. }
  56740. /**
  56741. * Clone the refraction texture.
  56742. * @returns the cloned texture
  56743. */
  56744. RefractionTexture.prototype.clone = function () {
  56745. var scene = this.getScene();
  56746. if (!scene) {
  56747. return this;
  56748. }
  56749. var textureSize = this.getSize();
  56750. var newTexture = new RefractionTexture(this.name, textureSize.width, scene, this._generateMipMaps);
  56751. // Base texture
  56752. newTexture.hasAlpha = this.hasAlpha;
  56753. newTexture.level = this.level;
  56754. // Refraction Texture
  56755. newTexture.refractionPlane = this.refractionPlane.clone();
  56756. if (this.renderList) {
  56757. newTexture.renderList = this.renderList.slice(0);
  56758. }
  56759. newTexture.depth = this.depth;
  56760. return newTexture;
  56761. };
  56762. /**
  56763. * Serialize the texture to a JSON representation you could use in Parse later on
  56764. * @returns the serialized JSON representation
  56765. */
  56766. RefractionTexture.prototype.serialize = function () {
  56767. if (!this.name) {
  56768. return null;
  56769. }
  56770. var serializationObject = _super.prototype.serialize.call(this);
  56771. serializationObject.mirrorPlane = this.refractionPlane.asArray();
  56772. serializationObject.depth = this.depth;
  56773. return serializationObject;
  56774. };
  56775. return RefractionTexture;
  56776. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  56777. /***/ }),
  56778. /***/ "./Materials/Textures/renderTargetCreationOptions.ts":
  56779. /*!***********************************************************!*\
  56780. !*** ./Materials/Textures/renderTargetCreationOptions.ts ***!
  56781. \***********************************************************/
  56782. /*! exports provided: RenderTargetCreationOptions */
  56783. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56784. "use strict";
  56785. __webpack_require__.r(__webpack_exports__);
  56786. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetCreationOptions", function() { return RenderTargetCreationOptions; });
  56787. /**
  56788. * Define options used to create a render target texture
  56789. */
  56790. var RenderTargetCreationOptions = /** @class */ (function () {
  56791. function RenderTargetCreationOptions() {
  56792. }
  56793. return RenderTargetCreationOptions;
  56794. }());
  56795. /***/ }),
  56796. /***/ "./Materials/Textures/renderTargetTexture.ts":
  56797. /*!***************************************************!*\
  56798. !*** ./Materials/Textures/renderTargetTexture.ts ***!
  56799. \***************************************************/
  56800. /*! exports provided: RenderTargetTexture */
  56801. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56802. "use strict";
  56803. __webpack_require__.r(__webpack_exports__);
  56804. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return RenderTargetTexture; });
  56805. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56806. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  56807. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  56808. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56809. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56810. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  56811. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  56812. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56813. /**
  56814. * This Helps creating a texture that will be created from a camera in your scene.
  56815. * It is basically a dynamic texture that could be used to create special effects for instance.
  56816. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  56817. */
  56818. var RenderTargetTexture = /** @class */ (function (_super) {
  56819. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetTexture, _super);
  56820. /**
  56821. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  56822. * or used a shadow, depth texture...
  56823. * @param name The friendly name of the texture
  56824. * @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)
  56825. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  56826. * @param generateMipMaps True if mip maps need to be generated after render.
  56827. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  56828. * @param type The type of the buffer in the RTT (int, half float, float...)
  56829. * @param isCube True if a cube texture needs to be created
  56830. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  56831. * @param generateDepthBuffer True to generate a depth buffer
  56832. * @param generateStencilBuffer True to generate a stencil buffer
  56833. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  56834. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  56835. * @param delayAllocation if the texture allocation should be delayed (default: false)
  56836. */
  56837. function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube, samplingMode, generateDepthBuffer, generateStencilBuffer, isMulti, format, delayAllocation) {
  56838. if (doNotChangeAspectRatio === void 0) { doNotChangeAspectRatio = true; }
  56839. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  56840. if (isCube === void 0) { isCube = false; }
  56841. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  56842. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  56843. if (generateStencilBuffer === void 0) { generateStencilBuffer = false; }
  56844. if (isMulti === void 0) { isMulti = false; }
  56845. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA; }
  56846. if (delayAllocation === void 0) { delayAllocation = false; }
  56847. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  56848. _this.isCube = isCube;
  56849. /**
  56850. * Define if particles should be rendered in your texture.
  56851. */
  56852. _this.renderParticles = true;
  56853. /**
  56854. * Define if sprites should be rendered in your texture.
  56855. */
  56856. _this.renderSprites = false;
  56857. /**
  56858. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  56859. */
  56860. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].PROJECTION_MODE;
  56861. /**
  56862. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  56863. */
  56864. _this.ignoreCameraViewport = false;
  56865. /**
  56866. * An event triggered when the texture is unbind.
  56867. */
  56868. _this.onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  56869. /**
  56870. * An event triggered when the texture is unbind.
  56871. */
  56872. _this.onAfterUnbindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  56873. /**
  56874. * An event triggered before rendering the texture
  56875. */
  56876. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  56877. /**
  56878. * An event triggered after rendering the texture
  56879. */
  56880. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  56881. /**
  56882. * An event triggered after the texture clear
  56883. */
  56884. _this.onClearObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  56885. _this._currentRefreshId = -1;
  56886. _this._refreshRate = 1;
  56887. _this._samples = 1;
  56888. /**
  56889. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  56890. * It must define where the camera used to render the texture is set
  56891. */
  56892. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  56893. scene = _this.getScene();
  56894. if (!scene) {
  56895. return _this;
  56896. }
  56897. _this.renderList = new Array();
  56898. _this._engine = scene.getEngine();
  56899. _this.name = name;
  56900. _this.isRenderTarget = true;
  56901. _this._initialSizeParameter = size;
  56902. _this._processSizeParameter(size);
  56903. _this._resizeObserver = _this.getScene().getEngine().onResizeObservable.add(function () {
  56904. });
  56905. _this._generateMipMaps = generateMipMaps ? true : false;
  56906. _this._doNotChangeAspectRatio = doNotChangeAspectRatio;
  56907. // Rendering groups
  56908. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__["RenderingManager"](scene);
  56909. _this._renderingManager._useSceneAutoClearSetup = true;
  56910. if (isMulti) {
  56911. return _this;
  56912. }
  56913. _this._renderTargetOptions = {
  56914. generateMipMaps: generateMipMaps,
  56915. type: type,
  56916. format: format,
  56917. samplingMode: samplingMode,
  56918. generateDepthBuffer: generateDepthBuffer,
  56919. generateStencilBuffer: generateStencilBuffer
  56920. };
  56921. if (samplingMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].NEAREST_SAMPLINGMODE) {
  56922. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  56923. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  56924. }
  56925. if (!delayAllocation) {
  56926. if (isCube) {
  56927. _this._texture = scene.getEngine().createRenderTargetCubeTexture(_this.getRenderSize(), _this._renderTargetOptions);
  56928. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].INVCUBIC_MODE;
  56929. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  56930. }
  56931. else {
  56932. _this._texture = scene.getEngine().createRenderTargetTexture(_this._size, _this._renderTargetOptions);
  56933. }
  56934. }
  56935. return _this;
  56936. }
  56937. Object.defineProperty(RenderTargetTexture.prototype, "renderList", {
  56938. /**
  56939. * Use this list to define the list of mesh you want to render.
  56940. */
  56941. get: function () {
  56942. return this._renderList;
  56943. },
  56944. set: function (value) {
  56945. this._renderList = value;
  56946. if (this._renderList) {
  56947. this._hookArray(this._renderList);
  56948. }
  56949. },
  56950. enumerable: true,
  56951. configurable: true
  56952. });
  56953. RenderTargetTexture.prototype._hookArray = function (array) {
  56954. var _this = this;
  56955. var oldPush = array.push;
  56956. array.push = function () {
  56957. var items = [];
  56958. for (var _i = 0; _i < arguments.length; _i++) {
  56959. items[_i] = arguments[_i];
  56960. }
  56961. var wasEmpty = array.length === 0;
  56962. var result = oldPush.apply(array, items);
  56963. if (wasEmpty) {
  56964. _this.getScene().meshes.forEach(function (mesh) {
  56965. mesh._markSubMeshesAsLightDirty();
  56966. });
  56967. }
  56968. return result;
  56969. };
  56970. var oldSplice = array.splice;
  56971. array.splice = function (index, deleteCount) {
  56972. var deleted = oldSplice.apply(array, [index, deleteCount]);
  56973. if (array.length === 0) {
  56974. _this.getScene().meshes.forEach(function (mesh) {
  56975. mesh._markSubMeshesAsLightDirty();
  56976. });
  56977. }
  56978. return deleted;
  56979. };
  56980. };
  56981. Object.defineProperty(RenderTargetTexture.prototype, "onAfterUnbind", {
  56982. /**
  56983. * Set a after unbind callback in the texture.
  56984. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  56985. */
  56986. set: function (callback) {
  56987. if (this._onAfterUnbindObserver) {
  56988. this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver);
  56989. }
  56990. this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(callback);
  56991. },
  56992. enumerable: true,
  56993. configurable: true
  56994. });
  56995. Object.defineProperty(RenderTargetTexture.prototype, "onBeforeRender", {
  56996. /**
  56997. * Set a before render callback in the texture.
  56998. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  56999. */
  57000. set: function (callback) {
  57001. if (this._onBeforeRenderObserver) {
  57002. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  57003. }
  57004. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  57005. },
  57006. enumerable: true,
  57007. configurable: true
  57008. });
  57009. Object.defineProperty(RenderTargetTexture.prototype, "onAfterRender", {
  57010. /**
  57011. * Set a after render callback in the texture.
  57012. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  57013. */
  57014. set: function (callback) {
  57015. if (this._onAfterRenderObserver) {
  57016. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  57017. }
  57018. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  57019. },
  57020. enumerable: true,
  57021. configurable: true
  57022. });
  57023. Object.defineProperty(RenderTargetTexture.prototype, "onClear", {
  57024. /**
  57025. * Set a clear callback in the texture.
  57026. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  57027. */
  57028. set: function (callback) {
  57029. if (this._onClearObserver) {
  57030. this.onClearObservable.remove(this._onClearObserver);
  57031. }
  57032. this._onClearObserver = this.onClearObservable.add(callback);
  57033. },
  57034. enumerable: true,
  57035. configurable: true
  57036. });
  57037. Object.defineProperty(RenderTargetTexture.prototype, "renderTargetOptions", {
  57038. /**
  57039. * Gets render target creation options that were used.
  57040. */
  57041. get: function () {
  57042. return this._renderTargetOptions;
  57043. },
  57044. enumerable: true,
  57045. configurable: true
  57046. });
  57047. RenderTargetTexture.prototype._onRatioRescale = function () {
  57048. if (this._sizeRatio) {
  57049. this.resize(this._initialSizeParameter);
  57050. }
  57051. };
  57052. Object.defineProperty(RenderTargetTexture.prototype, "boundingBoxSize", {
  57053. get: function () {
  57054. return this._boundingBoxSize;
  57055. },
  57056. /**
  57057. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  57058. * When defined, the cubemap will switch to local mode
  57059. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57060. * @example https://www.babylonjs-playground.com/#RNASML
  57061. */
  57062. set: function (value) {
  57063. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  57064. return;
  57065. }
  57066. this._boundingBoxSize = value;
  57067. var scene = this.getScene();
  57068. if (scene) {
  57069. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  57070. }
  57071. },
  57072. enumerable: true,
  57073. configurable: true
  57074. });
  57075. /**
  57076. * Creates a depth stencil texture.
  57077. * This is only available in WebGL 2 or with the depth texture extension available.
  57078. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  57079. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  57080. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  57081. */
  57082. RenderTargetTexture.prototype.createDepthStencilTexture = function (comparisonFunction, bilinearFiltering, generateStencil) {
  57083. if (comparisonFunction === void 0) { comparisonFunction = 0; }
  57084. if (bilinearFiltering === void 0) { bilinearFiltering = true; }
  57085. if (generateStencil === void 0) { generateStencil = false; }
  57086. if (!this.getScene()) {
  57087. return;
  57088. }
  57089. var engine = this.getScene().getEngine();
  57090. this.depthStencilTexture = engine.createDepthStencilTexture(this._size, {
  57091. bilinearFiltering: bilinearFiltering,
  57092. comparisonFunction: comparisonFunction,
  57093. generateStencil: generateStencil,
  57094. isCube: this.isCube
  57095. });
  57096. engine.setFrameBufferDepthStencilTexture(this);
  57097. };
  57098. RenderTargetTexture.prototype._processSizeParameter = function (size) {
  57099. if (size.ratio) {
  57100. this._sizeRatio = size.ratio;
  57101. this._size = {
  57102. width: this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(), this._sizeRatio),
  57103. height: this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(), this._sizeRatio)
  57104. };
  57105. }
  57106. else {
  57107. this._size = size;
  57108. }
  57109. };
  57110. Object.defineProperty(RenderTargetTexture.prototype, "samples", {
  57111. /**
  57112. * Define the number of samples to use in case of MSAA.
  57113. * It defaults to one meaning no MSAA has been enabled.
  57114. */
  57115. get: function () {
  57116. return this._samples;
  57117. },
  57118. set: function (value) {
  57119. if (this._samples === value) {
  57120. return;
  57121. }
  57122. var scene = this.getScene();
  57123. if (!scene) {
  57124. return;
  57125. }
  57126. this._samples = scene.getEngine().updateRenderTargetTextureSampleCount(this._texture, value);
  57127. },
  57128. enumerable: true,
  57129. configurable: true
  57130. });
  57131. /**
  57132. * Resets the refresh counter of the texture and start bak from scratch.
  57133. * Could be useful to regenerate the texture if it is setup to render only once.
  57134. */
  57135. RenderTargetTexture.prototype.resetRefreshCounter = function () {
  57136. this._currentRefreshId = -1;
  57137. };
  57138. Object.defineProperty(RenderTargetTexture.prototype, "refreshRate", {
  57139. /**
  57140. * Define the refresh rate of the texture or the rendering frequency.
  57141. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  57142. */
  57143. get: function () {
  57144. return this._refreshRate;
  57145. },
  57146. set: function (value) {
  57147. this._refreshRate = value;
  57148. this.resetRefreshCounter();
  57149. },
  57150. enumerable: true,
  57151. configurable: true
  57152. });
  57153. /**
  57154. * Adds a post process to the render target rendering passes.
  57155. * @param postProcess define the post process to add
  57156. */
  57157. RenderTargetTexture.prototype.addPostProcess = function (postProcess) {
  57158. if (!this._postProcessManager) {
  57159. var scene = this.getScene();
  57160. if (!scene) {
  57161. return;
  57162. }
  57163. this._postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__["PostProcessManager"](scene);
  57164. this._postProcesses = new Array();
  57165. }
  57166. this._postProcesses.push(postProcess);
  57167. this._postProcesses[0].autoClear = false;
  57168. };
  57169. /**
  57170. * Clear all the post processes attached to the render target
  57171. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  57172. */
  57173. RenderTargetTexture.prototype.clearPostProcesses = function (dispose) {
  57174. if (dispose === void 0) { dispose = false; }
  57175. if (!this._postProcesses) {
  57176. return;
  57177. }
  57178. if (dispose) {
  57179. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  57180. var postProcess = _a[_i];
  57181. postProcess.dispose();
  57182. }
  57183. }
  57184. this._postProcesses = [];
  57185. };
  57186. /**
  57187. * Remove one of the post process from the list of attached post processes to the texture
  57188. * @param postProcess define the post process to remove from the list
  57189. */
  57190. RenderTargetTexture.prototype.removePostProcess = function (postProcess) {
  57191. if (!this._postProcesses) {
  57192. return;
  57193. }
  57194. var index = this._postProcesses.indexOf(postProcess);
  57195. if (index === -1) {
  57196. return;
  57197. }
  57198. this._postProcesses.splice(index, 1);
  57199. if (this._postProcesses.length > 0) {
  57200. this._postProcesses[0].autoClear = false;
  57201. }
  57202. };
  57203. /** @hidden */
  57204. RenderTargetTexture.prototype._shouldRender = function () {
  57205. if (this._currentRefreshId === -1) { // At least render once
  57206. this._currentRefreshId = 1;
  57207. return true;
  57208. }
  57209. if (this.refreshRate === this._currentRefreshId) {
  57210. this._currentRefreshId = 1;
  57211. return true;
  57212. }
  57213. this._currentRefreshId++;
  57214. return false;
  57215. };
  57216. /**
  57217. * Gets the actual render size of the texture.
  57218. * @returns the width of the render size
  57219. */
  57220. RenderTargetTexture.prototype.getRenderSize = function () {
  57221. return this.getRenderWidth();
  57222. };
  57223. /**
  57224. * Gets the actual render width of the texture.
  57225. * @returns the width of the render size
  57226. */
  57227. RenderTargetTexture.prototype.getRenderWidth = function () {
  57228. if (this._size.width) {
  57229. return this._size.width;
  57230. }
  57231. return this._size;
  57232. };
  57233. /**
  57234. * Gets the actual render height of the texture.
  57235. * @returns the height of the render size
  57236. */
  57237. RenderTargetTexture.prototype.getRenderHeight = function () {
  57238. if (this._size.width) {
  57239. return this._size.height;
  57240. }
  57241. return this._size;
  57242. };
  57243. Object.defineProperty(RenderTargetTexture.prototype, "canRescale", {
  57244. /**
  57245. * Get if the texture can be rescaled or not.
  57246. */
  57247. get: function () {
  57248. return true;
  57249. },
  57250. enumerable: true,
  57251. configurable: true
  57252. });
  57253. /**
  57254. * Resize the texture using a ratio.
  57255. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  57256. */
  57257. RenderTargetTexture.prototype.scale = function (ratio) {
  57258. var newSize = this.getRenderSize() * ratio;
  57259. this.resize(newSize);
  57260. };
  57261. /**
  57262. * Get the texture reflection matrix used to rotate/transform the reflection.
  57263. * @returns the reflection matrix
  57264. */
  57265. RenderTargetTexture.prototype.getReflectionTextureMatrix = function () {
  57266. if (this.isCube) {
  57267. return this._textureMatrix;
  57268. }
  57269. return _super.prototype.getReflectionTextureMatrix.call(this);
  57270. };
  57271. /**
  57272. * Resize the texture to a new desired size.
  57273. * Be carrefull as it will recreate all the data in the new texture.
  57274. * @param size Define the new size. It can be:
  57275. * - a number for squared texture,
  57276. * - an object containing { width: number, height: number }
  57277. * - or an object containing a ratio { ratio: number }
  57278. */
  57279. RenderTargetTexture.prototype.resize = function (size) {
  57280. this.releaseInternalTexture();
  57281. var scene = this.getScene();
  57282. if (!scene) {
  57283. return;
  57284. }
  57285. this._processSizeParameter(size);
  57286. if (this.isCube) {
  57287. this._texture = scene.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions);
  57288. }
  57289. else {
  57290. this._texture = scene.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions);
  57291. }
  57292. };
  57293. /**
  57294. * Renders all the objects from the render list into the texture.
  57295. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  57296. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  57297. */
  57298. RenderTargetTexture.prototype.render = function (useCameraPostProcess, dumpForDebug) {
  57299. if (useCameraPostProcess === void 0) { useCameraPostProcess = false; }
  57300. if (dumpForDebug === void 0) { dumpForDebug = false; }
  57301. var scene = this.getScene();
  57302. if (!scene) {
  57303. return;
  57304. }
  57305. var engine = scene.getEngine();
  57306. if (this.useCameraPostProcesses !== undefined) {
  57307. useCameraPostProcess = this.useCameraPostProcesses;
  57308. }
  57309. if (this._waitingRenderList) {
  57310. this.renderList = [];
  57311. for (var index = 0; index < this._waitingRenderList.length; index++) {
  57312. var id = this._waitingRenderList[index];
  57313. var mesh_1 = scene.getMeshByID(id);
  57314. if (mesh_1) {
  57315. this.renderList.push(mesh_1);
  57316. }
  57317. }
  57318. delete this._waitingRenderList;
  57319. }
  57320. // Is predicate defined?
  57321. if (this.renderListPredicate) {
  57322. if (this.renderList) {
  57323. this.renderList.length = 0; // Clear previous renderList
  57324. }
  57325. else {
  57326. this.renderList = [];
  57327. }
  57328. var scene = this.getScene();
  57329. if (!scene) {
  57330. return;
  57331. }
  57332. var sceneMeshes = scene.meshes;
  57333. for (var index = 0; index < sceneMeshes.length; index++) {
  57334. var mesh = sceneMeshes[index];
  57335. if (this.renderListPredicate(mesh)) {
  57336. this.renderList.push(mesh);
  57337. }
  57338. }
  57339. }
  57340. this.onBeforeBindObservable.notifyObservers(this);
  57341. // Set custom projection.
  57342. // Needs to be before binding to prevent changing the aspect ratio.
  57343. var camera;
  57344. if (this.activeCamera) {
  57345. camera = this.activeCamera;
  57346. engine.setViewport(this.activeCamera.viewport, this.getRenderWidth(), this.getRenderHeight());
  57347. if (this.activeCamera !== scene.activeCamera) {
  57348. scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
  57349. }
  57350. }
  57351. else {
  57352. camera = scene.activeCamera;
  57353. if (camera) {
  57354. engine.setViewport(camera.viewport, this.getRenderWidth(), this.getRenderHeight());
  57355. }
  57356. }
  57357. // Prepare renderingManager
  57358. this._renderingManager.reset();
  57359. var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
  57360. var currentRenderListLength = this.renderList ? this.renderList.length : scene.getActiveMeshes().length;
  57361. var sceneRenderId = scene.getRenderId();
  57362. for (var meshIndex = 0; meshIndex < currentRenderListLength; meshIndex++) {
  57363. var mesh = currentRenderList[meshIndex];
  57364. if (mesh) {
  57365. if (!mesh.isReady(this.refreshRate === 0)) {
  57366. this.resetRefreshCounter();
  57367. continue;
  57368. }
  57369. mesh._preActivateForIntermediateRendering(sceneRenderId);
  57370. var isMasked = void 0;
  57371. if (!this.renderList && camera) {
  57372. isMasked = ((mesh.layerMask & camera.layerMask) === 0);
  57373. }
  57374. else {
  57375. isMasked = false;
  57376. }
  57377. if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && !isMasked) {
  57378. mesh._activate(sceneRenderId);
  57379. for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  57380. var subMesh = mesh.subMeshes[subIndex];
  57381. scene._activeIndices.addCount(subMesh.indexCount, false);
  57382. this._renderingManager.dispatch(subMesh, mesh);
  57383. }
  57384. }
  57385. }
  57386. }
  57387. for (var particleIndex = 0; particleIndex < scene.particleSystems.length; particleIndex++) {
  57388. var particleSystem = scene.particleSystems[particleIndex];
  57389. var emitter = particleSystem.emitter;
  57390. if (!particleSystem.isStarted() || !emitter || !emitter.position || !emitter.isEnabled()) {
  57391. continue;
  57392. }
  57393. if (currentRenderList.indexOf(emitter) >= 0) {
  57394. this._renderingManager.dispatchParticles(particleSystem);
  57395. }
  57396. }
  57397. if (this.isCube) {
  57398. for (var face = 0; face < 6; face++) {
  57399. this.renderToTarget(face, currentRenderList, useCameraPostProcess, dumpForDebug);
  57400. scene.incrementRenderId();
  57401. scene.resetCachedMaterial();
  57402. }
  57403. }
  57404. else {
  57405. this.renderToTarget(0, currentRenderList, useCameraPostProcess, dumpForDebug);
  57406. }
  57407. this.onAfterUnbindObservable.notifyObservers(this);
  57408. if (scene.activeCamera) {
  57409. if (this.activeCamera && this.activeCamera !== scene.activeCamera) {
  57410. scene.setTransformMatrix(scene.activeCamera.getViewMatrix(), scene.activeCamera.getProjectionMatrix(true));
  57411. }
  57412. engine.setViewport(scene.activeCamera.viewport);
  57413. }
  57414. scene.resetCachedMaterial();
  57415. };
  57416. RenderTargetTexture.prototype._bestReflectionRenderTargetDimension = function (renderDimension, scale) {
  57417. var minimum = 128;
  57418. var x = renderDimension * scale;
  57419. var curved = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].NearestPOT(x + (minimum * minimum / (minimum + x)));
  57420. // Ensure we don't exceed the render dimension (while staying POT)
  57421. return Math.min(_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].FloorPOT(renderDimension), curved);
  57422. };
  57423. RenderTargetTexture.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  57424. var _this = this;
  57425. if (!this._texture) {
  57426. return;
  57427. }
  57428. engine.unBindFramebuffer(this._texture, this.isCube, function () {
  57429. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  57430. });
  57431. };
  57432. RenderTargetTexture.prototype.renderToTarget = function (faceIndex, currentRenderList, useCameraPostProcess, dumpForDebug) {
  57433. var scene = this.getScene();
  57434. if (!scene) {
  57435. return;
  57436. }
  57437. var engine = scene.getEngine();
  57438. if (!this._texture) {
  57439. return;
  57440. }
  57441. // Bind
  57442. if (this._postProcessManager) {
  57443. this._postProcessManager._prepareFrame(this._texture, this._postProcesses);
  57444. }
  57445. else if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
  57446. if (this._texture) {
  57447. engine.bindFramebuffer(this._texture, this.isCube ? faceIndex : undefined, undefined, undefined, this.ignoreCameraViewport, this.depthStencilTexture ? this.depthStencilTexture : undefined);
  57448. }
  57449. }
  57450. this.onBeforeRenderObservable.notifyObservers(faceIndex);
  57451. // Clear
  57452. if (this.onClearObservable.hasObservers()) {
  57453. this.onClearObservable.notifyObservers(engine);
  57454. }
  57455. else {
  57456. engine.clear(this.clearColor || scene.clearColor, true, true, true);
  57457. }
  57458. if (!this._doNotChangeAspectRatio) {
  57459. scene.updateTransformMatrix(true);
  57460. }
  57461. // Before Camera Draw
  57462. for (var _i = 0, _a = scene._beforeRenderTargetDrawStage; _i < _a.length; _i++) {
  57463. var step = _a[_i];
  57464. step.action(this);
  57465. }
  57466. // Render
  57467. this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
  57468. // After Camera Draw
  57469. for (var _b = 0, _c = scene._afterRenderTargetDrawStage; _b < _c.length; _b++) {
  57470. var step = _c[_b];
  57471. step.action(this);
  57472. }
  57473. if (this._postProcessManager) {
  57474. this._postProcessManager._finalizeFrame(false, this._texture, faceIndex, this._postProcesses, this.ignoreCameraViewport);
  57475. }
  57476. else if (useCameraPostProcess) {
  57477. scene.postProcessManager._finalizeFrame(false, this._texture, faceIndex);
  57478. }
  57479. if (!this._doNotChangeAspectRatio) {
  57480. scene.updateTransformMatrix(true);
  57481. }
  57482. // Dump ?
  57483. if (dumpForDebug) {
  57484. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), engine);
  57485. }
  57486. // Unbind
  57487. if (!this.isCube || faceIndex === 5) {
  57488. if (this.isCube) {
  57489. if (faceIndex === 5) {
  57490. engine.generateMipMapsForCubemap(this._texture);
  57491. }
  57492. }
  57493. this.unbindFrameBuffer(engine, faceIndex);
  57494. }
  57495. else {
  57496. this.onAfterRenderObservable.notifyObservers(faceIndex);
  57497. }
  57498. };
  57499. /**
  57500. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  57501. * This allowed control for front to back rendering or reversly depending of the special needs.
  57502. *
  57503. * @param renderingGroupId The rendering group id corresponding to its index
  57504. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  57505. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  57506. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  57507. */
  57508. RenderTargetTexture.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  57509. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  57510. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  57511. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  57512. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  57513. };
  57514. /**
  57515. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  57516. *
  57517. * @param renderingGroupId The rendering group id corresponding to its index
  57518. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  57519. */
  57520. RenderTargetTexture.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  57521. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  57522. this._renderingManager._useSceneAutoClearSetup = false;
  57523. };
  57524. /**
  57525. * Clones the texture.
  57526. * @returns the cloned texture
  57527. */
  57528. RenderTargetTexture.prototype.clone = function () {
  57529. var textureSize = this.getSize();
  57530. 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);
  57531. // Base texture
  57532. newTexture.hasAlpha = this.hasAlpha;
  57533. newTexture.level = this.level;
  57534. // RenderTarget Texture
  57535. newTexture.coordinatesMode = this.coordinatesMode;
  57536. if (this.renderList) {
  57537. newTexture.renderList = this.renderList.slice(0);
  57538. }
  57539. return newTexture;
  57540. };
  57541. /**
  57542. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  57543. * @returns The JSON representation of the texture
  57544. */
  57545. RenderTargetTexture.prototype.serialize = function () {
  57546. if (!this.name) {
  57547. return null;
  57548. }
  57549. var serializationObject = _super.prototype.serialize.call(this);
  57550. serializationObject.renderTargetSize = this.getRenderSize();
  57551. serializationObject.renderList = [];
  57552. if (this.renderList) {
  57553. for (var index = 0; index < this.renderList.length; index++) {
  57554. serializationObject.renderList.push(this.renderList[index].id);
  57555. }
  57556. }
  57557. return serializationObject;
  57558. };
  57559. /**
  57560. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  57561. */
  57562. RenderTargetTexture.prototype.disposeFramebufferObjects = function () {
  57563. var objBuffer = this.getInternalTexture();
  57564. var scene = this.getScene();
  57565. if (objBuffer && scene) {
  57566. scene.getEngine()._releaseFramebufferObjects(objBuffer);
  57567. }
  57568. };
  57569. /**
  57570. * Dispose the texture and release its associated resources.
  57571. */
  57572. RenderTargetTexture.prototype.dispose = function () {
  57573. if (this._postProcessManager) {
  57574. this._postProcessManager.dispose();
  57575. this._postProcessManager = null;
  57576. }
  57577. this.clearPostProcesses(true);
  57578. if (this._resizeObserver) {
  57579. this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver);
  57580. this._resizeObserver = null;
  57581. }
  57582. this.renderList = null;
  57583. // Remove from custom render targets
  57584. var scene = this.getScene();
  57585. if (!scene) {
  57586. return;
  57587. }
  57588. var index = scene.customRenderTargets.indexOf(this);
  57589. if (index >= 0) {
  57590. scene.customRenderTargets.splice(index, 1);
  57591. }
  57592. for (var _i = 0, _a = scene.cameras; _i < _a.length; _i++) {
  57593. var camera = _a[_i];
  57594. index = camera.customRenderTargets.indexOf(this);
  57595. if (index >= 0) {
  57596. camera.customRenderTargets.splice(index, 1);
  57597. }
  57598. }
  57599. _super.prototype.dispose.call(this);
  57600. };
  57601. /** @hidden */
  57602. RenderTargetTexture.prototype._rebuild = function () {
  57603. if (this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE) {
  57604. this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
  57605. }
  57606. if (this._postProcessManager) {
  57607. this._postProcessManager._rebuild();
  57608. }
  57609. };
  57610. /**
  57611. * Clear the info related to rendering groups preventing retention point in material dispose.
  57612. */
  57613. RenderTargetTexture.prototype.freeRenderingGroups = function () {
  57614. if (this._renderingManager) {
  57615. this._renderingManager.freeRenderingGroups();
  57616. }
  57617. };
  57618. /**
  57619. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  57620. */
  57621. RenderTargetTexture.REFRESHRATE_RENDER_ONCE = 0;
  57622. /**
  57623. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  57624. */
  57625. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME = 1;
  57626. /**
  57627. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  57628. * the central point of your effect and can save a lot of performances.
  57629. */
  57630. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2;
  57631. return RenderTargetTexture;
  57632. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  57633. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  57634. return new RenderTargetTexture(name, renderTargetSize, scene, generateMipMaps);
  57635. };
  57636. /***/ }),
  57637. /***/ "./Materials/Textures/texture.ts":
  57638. /*!***************************************!*\
  57639. !*** ./Materials/Textures/texture.ts ***!
  57640. \***************************************/
  57641. /*! exports provided: Texture */
  57642. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57643. "use strict";
  57644. __webpack_require__.r(__webpack_exports__);
  57645. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return Texture; });
  57646. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57647. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  57648. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  57649. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  57650. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57651. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  57652. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57653. /**
  57654. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  57655. * @see http://doc.babylonjs.com/babylon101/materials#texture
  57656. */
  57657. var Texture = /** @class */ (function (_super) {
  57658. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Texture, _super);
  57659. /**
  57660. * Instantiates a new texture.
  57661. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  57662. * @see http://doc.babylonjs.com/babylon101/materials#texture
  57663. * @param url define the url of the picture to load as a texture
  57664. * @param scene define the scene the texture will belong to
  57665. * @param noMipmap define if the texture will require mip maps or not
  57666. * @param invertY define if the texture needs to be inverted on the y axis during loading
  57667. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  57668. * @param onLoad define a callback triggered when the texture has been loaded
  57669. * @param onError define a callback triggered when an error occurred during the loading session
  57670. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  57671. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  57672. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  57673. */
  57674. function Texture(url, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format) {
  57675. if (noMipmap === void 0) { noMipmap = false; }
  57676. if (invertY === void 0) { invertY = true; }
  57677. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  57678. if (onLoad === void 0) { onLoad = null; }
  57679. if (onError === void 0) { onError = null; }
  57680. if (buffer === void 0) { buffer = null; }
  57681. if (deleteBuffer === void 0) { deleteBuffer = false; }
  57682. var _this = _super.call(this, scene) || this;
  57683. /**
  57684. * Define an offset on the texture to offset the u coordinates of the UVs
  57685. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  57686. */
  57687. _this.uOffset = 0;
  57688. /**
  57689. * Define an offset on the texture to offset the v coordinates of the UVs
  57690. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  57691. */
  57692. _this.vOffset = 0;
  57693. /**
  57694. * Define an offset on the texture to scale the u coordinates of the UVs
  57695. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  57696. */
  57697. _this.uScale = 1.0;
  57698. /**
  57699. * Define an offset on the texture to scale the v coordinates of the UVs
  57700. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  57701. */
  57702. _this.vScale = 1.0;
  57703. /**
  57704. * Define an offset on the texture to rotate around the u coordinates of the UVs
  57705. * @see http://doc.babylonjs.com/how_to/more_materials
  57706. */
  57707. _this.uAng = 0;
  57708. /**
  57709. * Define an offset on the texture to rotate around the v coordinates of the UVs
  57710. * @see http://doc.babylonjs.com/how_to/more_materials
  57711. */
  57712. _this.vAng = 0;
  57713. /**
  57714. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  57715. * @see http://doc.babylonjs.com/how_to/more_materials
  57716. */
  57717. _this.wAng = 0;
  57718. /**
  57719. * Defines the center of rotation (U)
  57720. */
  57721. _this.uRotationCenter = 0.5;
  57722. /**
  57723. * Defines the center of rotation (V)
  57724. */
  57725. _this.vRotationCenter = 0.5;
  57726. /**
  57727. * Defines the center of rotation (W)
  57728. */
  57729. _this.wRotationCenter = 0.5;
  57730. /** @hidden */
  57731. _this._initialSamplingMode = Texture.BILINEAR_SAMPLINGMODE;
  57732. /**
  57733. * Observable triggered once the texture has been loaded.
  57734. */
  57735. _this.onLoadObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  57736. _this._isBlocking = true;
  57737. _this.name = url || "";
  57738. _this.url = url;
  57739. _this._noMipmap = noMipmap;
  57740. _this._invertY = invertY;
  57741. _this._initialSamplingMode = samplingMode;
  57742. _this._buffer = buffer;
  57743. _this._deleteBuffer = deleteBuffer;
  57744. if (format) {
  57745. _this._format = format;
  57746. }
  57747. scene = _this.getScene();
  57748. if (!scene) {
  57749. return _this;
  57750. }
  57751. scene.getEngine().onBeforeTextureInitObservable.notifyObservers(_this);
  57752. var load = function () {
  57753. if (_this._texture && _this._texture._invertVScale) {
  57754. _this.vScale = -1;
  57755. }
  57756. if (_this.onLoadObservable.hasObservers()) {
  57757. _this.onLoadObservable.notifyObservers(_this);
  57758. }
  57759. if (onLoad) {
  57760. onLoad();
  57761. }
  57762. if (!_this.isBlocking && scene) {
  57763. scene.resetCachedMaterial();
  57764. }
  57765. };
  57766. if (!_this.url) {
  57767. _this._delayedOnLoad = load;
  57768. _this._delayedOnError = onError;
  57769. return _this;
  57770. }
  57771. _this._texture = _this._getFromCache(_this.url, noMipmap, samplingMode);
  57772. if (!_this._texture) {
  57773. if (!scene.useDelayedTextureLoading) {
  57774. _this._texture = scene.getEngine().createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format);
  57775. if (deleteBuffer) {
  57776. delete _this._buffer;
  57777. }
  57778. }
  57779. else {
  57780. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  57781. _this._delayedOnLoad = load;
  57782. _this._delayedOnError = onError;
  57783. }
  57784. }
  57785. else {
  57786. if (_this._texture.isReady) {
  57787. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(function () { return load(); });
  57788. }
  57789. else {
  57790. _this._texture.onLoadedObservable.add(load);
  57791. }
  57792. }
  57793. return _this;
  57794. }
  57795. Object.defineProperty(Texture.prototype, "noMipmap", {
  57796. /**
  57797. * Are mip maps generated for this texture or not.
  57798. */
  57799. get: function () {
  57800. return this._noMipmap;
  57801. },
  57802. enumerable: true,
  57803. configurable: true
  57804. });
  57805. Object.defineProperty(Texture.prototype, "isBlocking", {
  57806. get: function () {
  57807. return this._isBlocking;
  57808. },
  57809. /**
  57810. * Is the texture preventing material to render while loading.
  57811. * If false, a default texture will be used instead of the loading one during the preparation step.
  57812. */
  57813. set: function (value) {
  57814. this._isBlocking = value;
  57815. },
  57816. enumerable: true,
  57817. configurable: true
  57818. });
  57819. Object.defineProperty(Texture.prototype, "samplingMode", {
  57820. /**
  57821. * Get the current sampling mode associated with the texture.
  57822. */
  57823. get: function () {
  57824. if (!this._texture) {
  57825. return this._initialSamplingMode;
  57826. }
  57827. return this._texture.samplingMode;
  57828. },
  57829. enumerable: true,
  57830. configurable: true
  57831. });
  57832. Object.defineProperty(Texture.prototype, "invertY", {
  57833. /**
  57834. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  57835. */
  57836. get: function () {
  57837. return this._invertY;
  57838. },
  57839. enumerable: true,
  57840. configurable: true
  57841. });
  57842. /**
  57843. * Update the url (and optional buffer) of this texture if url was null during construction.
  57844. * @param url the url of the texture
  57845. * @param buffer the buffer of the texture (defaults to null)
  57846. * @param onLoad callback called when the texture is loaded (defaults to null)
  57847. */
  57848. Texture.prototype.updateURL = function (url, buffer, onLoad) {
  57849. if (buffer === void 0) { buffer = null; }
  57850. if (this.url) {
  57851. this.releaseInternalTexture();
  57852. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  57853. }
  57854. this.url = url;
  57855. this._buffer = buffer;
  57856. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  57857. if (onLoad) {
  57858. this._delayedOnLoad = onLoad;
  57859. }
  57860. this.delayLoad();
  57861. };
  57862. /**
  57863. * Finish the loading sequence of a texture flagged as delayed load.
  57864. * @hidden
  57865. */
  57866. Texture.prototype.delayLoad = function () {
  57867. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  57868. return;
  57869. }
  57870. var scene = this.getScene();
  57871. if (!scene) {
  57872. return;
  57873. }
  57874. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  57875. this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode);
  57876. if (!this._texture) {
  57877. this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format);
  57878. if (this._deleteBuffer) {
  57879. delete this._buffer;
  57880. }
  57881. }
  57882. else {
  57883. if (this._delayedOnLoad) {
  57884. if (this._texture.isReady) {
  57885. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(this._delayedOnLoad);
  57886. }
  57887. else {
  57888. this._texture.onLoadedObservable.add(this._delayedOnLoad);
  57889. }
  57890. }
  57891. }
  57892. this._delayedOnLoad = null;
  57893. this._delayedOnError = null;
  57894. };
  57895. Texture.prototype._prepareRowForTextureGeneration = function (x, y, z, t) {
  57896. x *= this.uScale;
  57897. y *= this.vScale;
  57898. x -= this.uRotationCenter * this.uScale;
  57899. y -= this.vRotationCenter * this.vScale;
  57900. z -= this.wRotationCenter;
  57901. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, this._rowGenerationMatrix, t);
  57902. t.x += this.uRotationCenter * this.uScale + this.uOffset;
  57903. t.y += this.vRotationCenter * this.vScale + this.vOffset;
  57904. t.z += this.wRotationCenter;
  57905. };
  57906. /**
  57907. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  57908. * @returns the transform matrix of the texture.
  57909. */
  57910. Texture.prototype.getTextureMatrix = function () {
  57911. var _this = this;
  57912. if (this.uOffset === this._cachedUOffset &&
  57913. this.vOffset === this._cachedVOffset &&
  57914. this.uScale === this._cachedUScale &&
  57915. this.vScale === this._cachedVScale &&
  57916. this.uAng === this._cachedUAng &&
  57917. this.vAng === this._cachedVAng &&
  57918. this.wAng === this._cachedWAng) {
  57919. return this._cachedTextureMatrix;
  57920. }
  57921. this._cachedUOffset = this.uOffset;
  57922. this._cachedVOffset = this.vOffset;
  57923. this._cachedUScale = this.uScale;
  57924. this._cachedVScale = this.vScale;
  57925. this._cachedUAng = this.uAng;
  57926. this._cachedVAng = this.vAng;
  57927. this._cachedWAng = this.wAng;
  57928. if (!this._cachedTextureMatrix) {
  57929. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  57930. this._rowGenerationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  57931. this._t0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  57932. this._t1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  57933. this._t2 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  57934. }
  57935. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix);
  57936. this._prepareRowForTextureGeneration(0, 0, 0, this._t0);
  57937. this._prepareRowForTextureGeneration(1.0, 0, 0, this._t1);
  57938. this._prepareRowForTextureGeneration(0, 1.0, 0, this._t2);
  57939. this._t1.subtractInPlace(this._t0);
  57940. this._t2.subtractInPlace(this._t0);
  57941. _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);
  57942. var scene = this.getScene();
  57943. if (!scene) {
  57944. return this._cachedTextureMatrix;
  57945. }
  57946. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  57947. return mat.hasTexture(_this);
  57948. });
  57949. return this._cachedTextureMatrix;
  57950. };
  57951. /**
  57952. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  57953. * @returns The reflection texture transform
  57954. */
  57955. Texture.prototype.getReflectionTextureMatrix = function () {
  57956. var _this = this;
  57957. var scene = this.getScene();
  57958. if (!scene) {
  57959. return this._cachedTextureMatrix;
  57960. }
  57961. if (this.uOffset === this._cachedUOffset &&
  57962. this.vOffset === this._cachedVOffset &&
  57963. this.uScale === this._cachedUScale &&
  57964. this.vScale === this._cachedVScale &&
  57965. this.coordinatesMode === this._cachedCoordinatesMode) {
  57966. if (this.coordinatesMode === Texture.PROJECTION_MODE) {
  57967. if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) {
  57968. return this._cachedTextureMatrix;
  57969. }
  57970. }
  57971. else {
  57972. return this._cachedTextureMatrix;
  57973. }
  57974. }
  57975. if (!this._cachedTextureMatrix) {
  57976. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  57977. }
  57978. if (!this._projectionModeMatrix) {
  57979. this._projectionModeMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  57980. }
  57981. this._cachedUOffset = this.uOffset;
  57982. this._cachedVOffset = this.vOffset;
  57983. this._cachedUScale = this.uScale;
  57984. this._cachedVScale = this.vScale;
  57985. this._cachedCoordinatesMode = this.coordinatesMode;
  57986. switch (this.coordinatesMode) {
  57987. case Texture.PLANAR_MODE:
  57988. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  57989. this._cachedTextureMatrix[0] = this.uScale;
  57990. this._cachedTextureMatrix[5] = this.vScale;
  57991. this._cachedTextureMatrix[12] = this.uOffset;
  57992. this._cachedTextureMatrix[13] = this.vOffset;
  57993. break;
  57994. case Texture.PROJECTION_MODE:
  57995. _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);
  57996. var projectionMatrix = scene.getProjectionMatrix();
  57997. this._cachedProjectionMatrixId = projectionMatrix.updateFlag;
  57998. projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
  57999. break;
  58000. default:
  58001. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  58002. break;
  58003. }
  58004. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  58005. return (mat.getActiveTextures().indexOf(_this) !== -1);
  58006. });
  58007. return this._cachedTextureMatrix;
  58008. };
  58009. /**
  58010. * Clones the texture.
  58011. * @returns the cloned texture
  58012. */
  58013. Texture.prototype.clone = function () {
  58014. var _this = this;
  58015. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  58016. return new Texture(_this._texture ? _this._texture.url : null, _this.getScene(), _this._noMipmap, _this._invertY, _this.samplingMode);
  58017. }, this);
  58018. };
  58019. /**
  58020. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  58021. * @returns The JSON representation of the texture
  58022. */
  58023. Texture.prototype.serialize = function () {
  58024. var serializationObject = _super.prototype.serialize.call(this);
  58025. if (typeof this._buffer === "string" && this._buffer.substr(0, 5) === "data:") {
  58026. serializationObject.base64String = this._buffer;
  58027. serializationObject.name = serializationObject.name.replace("data:", "");
  58028. }
  58029. serializationObject.invertY = this._invertY;
  58030. serializationObject.samplingMode = this.samplingMode;
  58031. return serializationObject;
  58032. };
  58033. /**
  58034. * Get the current class name of the texture useful for serialization or dynamic coding.
  58035. * @returns "Texture"
  58036. */
  58037. Texture.prototype.getClassName = function () {
  58038. return "Texture";
  58039. };
  58040. /**
  58041. * Dispose the texture and release its associated resources.
  58042. */
  58043. Texture.prototype.dispose = function () {
  58044. _super.prototype.dispose.call(this);
  58045. this.onLoadObservable.clear();
  58046. this._delayedOnLoad = null;
  58047. this._delayedOnError = null;
  58048. };
  58049. /**
  58050. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  58051. * @param parsedTexture Define the JSON representation of the texture
  58052. * @param scene Define the scene the parsed texture should be instantiated in
  58053. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58054. * @returns The parsed texture if successful
  58055. */
  58056. Texture.Parse = function (parsedTexture, scene, rootUrl) {
  58057. if (parsedTexture.customType) {
  58058. var customTexture = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Instantiate(parsedTexture.customType);
  58059. // Update Sampling Mode
  58060. var parsedCustomTexture = customTexture.Parse(parsedTexture, scene, rootUrl);
  58061. if (parsedTexture.samplingMode && parsedCustomTexture.updateSamplingMode && parsedCustomTexture._samplingMode) {
  58062. if (parsedCustomTexture._samplingMode !== parsedTexture.samplingMode) {
  58063. parsedCustomTexture.updateSamplingMode(parsedTexture.samplingMode);
  58064. }
  58065. }
  58066. return parsedCustomTexture;
  58067. }
  58068. if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
  58069. return Texture._CubeTextureParser(parsedTexture, scene, rootUrl);
  58070. }
  58071. if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
  58072. return null;
  58073. }
  58074. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  58075. var generateMipMaps = true;
  58076. if (parsedTexture.noMipmap) {
  58077. generateMipMaps = false;
  58078. }
  58079. if (parsedTexture.mirrorPlane) {
  58080. var mirrorTexture = Texture._CreateMirror(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  58081. mirrorTexture._waitingRenderList = parsedTexture.renderList;
  58082. mirrorTexture.mirrorPlane = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"].FromArray(parsedTexture.mirrorPlane);
  58083. return mirrorTexture;
  58084. }
  58085. else if (parsedTexture.isRenderTarget) {
  58086. var renderTargetTexture = null;
  58087. if (parsedTexture.isCube) {
  58088. // Search for an existing reflection probe (which contains a cube render target texture)
  58089. if (scene.reflectionProbes) {
  58090. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  58091. var probe = scene.reflectionProbes[index];
  58092. if (probe.name === parsedTexture.name) {
  58093. return probe.cubeTexture;
  58094. }
  58095. }
  58096. }
  58097. }
  58098. else {
  58099. renderTargetTexture = Texture._CreateRenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  58100. renderTargetTexture._waitingRenderList = parsedTexture.renderList;
  58101. }
  58102. return renderTargetTexture;
  58103. }
  58104. else {
  58105. var texture;
  58106. if (parsedTexture.base64String) {
  58107. texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene, !generateMipMaps);
  58108. }
  58109. else {
  58110. var url = rootUrl + parsedTexture.name;
  58111. if (Texture.UseSerializedUrlIfAny && parsedTexture.url) {
  58112. url = parsedTexture.url;
  58113. }
  58114. texture = new Texture(url, scene, !generateMipMaps, parsedTexture.invertY);
  58115. }
  58116. return texture;
  58117. }
  58118. }, parsedTexture, scene);
  58119. // Update Sampling Mode
  58120. if (parsedTexture.samplingMode) {
  58121. var sampling = parsedTexture.samplingMode;
  58122. if (texture && texture.samplingMode !== sampling) {
  58123. texture.updateSamplingMode(sampling);
  58124. }
  58125. }
  58126. // Animations
  58127. if (texture && parsedTexture.animations) {
  58128. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  58129. var parsedAnimation = parsedTexture.animations[animationIndex];
  58130. texture.animations.push(Texture._AnimationParser(parsedAnimation));
  58131. }
  58132. }
  58133. return texture;
  58134. };
  58135. /**
  58136. * Creates a texture from its base 64 representation.
  58137. * @param data Define the base64 payload without the data: prefix
  58138. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  58139. * @param scene Define the scene the texture should belong to
  58140. * @param noMipmap Forces the texture to not create mip map information if true
  58141. * @param invertY define if the texture needs to be inverted on the y axis during loading
  58142. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  58143. * @param onLoad define a callback triggered when the texture has been loaded
  58144. * @param onError define a callback triggered when an error occurred during the loading session
  58145. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  58146. * @returns the created texture
  58147. */
  58148. Texture.CreateFromBase64String = function (data, name, scene, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  58149. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  58150. if (onLoad === void 0) { onLoad = null; }
  58151. if (onError === void 0) { onError = null; }
  58152. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  58153. return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data, false, format);
  58154. };
  58155. /**
  58156. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  58157. * @param data Define the base64 payload without the data: prefix
  58158. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  58159. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  58160. * @param scene Define the scene the texture should belong to
  58161. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  58162. * @param noMipmap Forces the texture to not create mip map information if true
  58163. * @param invertY define if the texture needs to be inverted on the y axis during loading
  58164. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  58165. * @param onLoad define a callback triggered when the texture has been loaded
  58166. * @param onError define a callback triggered when an error occurred during the loading session
  58167. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  58168. * @returns the created texture
  58169. */
  58170. Texture.LoadFromDataString = function (name, buffer, scene, deleteBuffer, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  58171. if (deleteBuffer === void 0) { deleteBuffer = false; }
  58172. if (noMipmap === void 0) { noMipmap = false; }
  58173. if (invertY === void 0) { invertY = true; }
  58174. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  58175. if (onLoad === void 0) { onLoad = null; }
  58176. if (onError === void 0) { onError = null; }
  58177. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  58178. if (name.substr(0, 5) !== "data:") {
  58179. name = "data:" + name;
  58180. }
  58181. return new Texture(name, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format);
  58182. };
  58183. /** @hidden */
  58184. Texture._AnimationParser = function (jsonAnimation) {
  58185. throw "Animation needs to be imported before being deserialized.";
  58186. };
  58187. /** @hidden */
  58188. Texture._CubeTextureParser = function (jsonTexture, scene, rootUrl) {
  58189. throw "CubeTexture needs to be imported before being deserialized.";
  58190. };
  58191. /** @hidden */
  58192. Texture._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  58193. throw "MirrorTexture needs to be imported before being deserialized.";
  58194. };
  58195. /** @hidden */
  58196. Texture._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  58197. throw "RenderTargetTexture needs to be imported before being deserialized.";
  58198. };
  58199. /** nearest is mag = nearest and min = nearest and mip = linear */
  58200. Texture.NEAREST_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  58201. /** nearest is mag = nearest and min = nearest and mip = linear */
  58202. 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
  58203. /** Bilinear is mag = linear and min = linear and mip = nearest */
  58204. Texture.BILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  58205. /** Bilinear is mag = linear and min = linear and mip = nearest */
  58206. 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
  58207. /** Trilinear is mag = linear and min = linear and mip = linear */
  58208. Texture.TRILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  58209. /** Trilinear is mag = linear and min = linear and mip = linear */
  58210. 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
  58211. /** mag = nearest and min = nearest and mip = nearest */
  58212. Texture.NEAREST_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  58213. /** mag = nearest and min = linear and mip = nearest */
  58214. Texture.NEAREST_LINEAR_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  58215. /** mag = nearest and min = linear and mip = linear */
  58216. Texture.NEAREST_LINEAR_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  58217. /** mag = nearest and min = linear and mip = none */
  58218. Texture.NEAREST_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR;
  58219. /** mag = nearest and min = nearest and mip = none */
  58220. Texture.NEAREST_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST;
  58221. /** mag = linear and min = nearest and mip = nearest */
  58222. Texture.LINEAR_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  58223. /** mag = linear and min = nearest and mip = linear */
  58224. Texture.LINEAR_NEAREST_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  58225. /** mag = linear and min = linear and mip = none */
  58226. Texture.LINEAR_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR;
  58227. /** mag = linear and min = nearest and mip = none */
  58228. Texture.LINEAR_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST;
  58229. /** Explicit coordinates mode */
  58230. Texture.EXPLICIT_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EXPLICIT_MODE;
  58231. /** Spherical coordinates mode */
  58232. Texture.SPHERICAL_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SPHERICAL_MODE;
  58233. /** Planar coordinates mode */
  58234. Texture.PLANAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PLANAR_MODE;
  58235. /** Cubic coordinates mode */
  58236. Texture.CUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CUBIC_MODE;
  58237. /** Projection coordinates mode */
  58238. Texture.PROJECTION_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PROJECTION_MODE;
  58239. /** Inverse Cubic coordinates mode */
  58240. Texture.SKYBOX_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SKYBOX_MODE;
  58241. /** Inverse Cubic coordinates mode */
  58242. Texture.INVCUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_INVCUBIC_MODE;
  58243. /** Equirectangular coordinates mode */
  58244. Texture.EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  58245. /** Equirectangular Fixed coordinates mode */
  58246. Texture.FIXED_EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  58247. /** Equirectangular Fixed Mirrored coordinates mode */
  58248. Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  58249. /** Texture is not repeating outside of 0..1 UVs */
  58250. Texture.CLAMP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  58251. /** Texture is repeating outside of 0..1 UVs */
  58252. Texture.WRAP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  58253. /** Texture is repeating and mirrored */
  58254. Texture.MIRROR_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  58255. /**
  58256. * 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
  58257. */
  58258. Texture.UseSerializedUrlIfAny = false;
  58259. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58260. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58261. ], Texture.prototype, "url", void 0);
  58262. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58263. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58264. ], Texture.prototype, "uOffset", void 0);
  58265. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58266. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58267. ], Texture.prototype, "vOffset", void 0);
  58268. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58269. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58270. ], Texture.prototype, "uScale", void 0);
  58271. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58272. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58273. ], Texture.prototype, "vScale", void 0);
  58274. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58275. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58276. ], Texture.prototype, "uAng", void 0);
  58277. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58278. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58279. ], Texture.prototype, "vAng", void 0);
  58280. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58281. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58282. ], Texture.prototype, "wAng", void 0);
  58283. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58284. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58285. ], Texture.prototype, "uRotationCenter", void 0);
  58286. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58288. ], Texture.prototype, "vRotationCenter", void 0);
  58289. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58291. ], Texture.prototype, "wRotationCenter", void 0);
  58292. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58293. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58294. ], Texture.prototype, "isBlocking", null);
  58295. return Texture;
  58296. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]));
  58297. // References the dependencies.
  58298. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._TextureParser = Texture.Parse;
  58299. /***/ }),
  58300. /***/ "./Materials/Textures/videoTexture.ts":
  58301. /*!********************************************!*\
  58302. !*** ./Materials/Textures/videoTexture.ts ***!
  58303. \********************************************/
  58304. /*! exports provided: VideoTexture */
  58305. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58306. "use strict";
  58307. __webpack_require__.r(__webpack_exports__);
  58308. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return VideoTexture; });
  58309. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58310. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  58311. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  58312. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  58313. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58314. /**
  58315. * If you want to display a video in your scene, this is the special texture for that.
  58316. * This special texture works similar to other textures, with the exception of a few parameters.
  58317. * @see https://doc.babylonjs.com/how_to/video_texture
  58318. */
  58319. var VideoTexture = /** @class */ (function (_super) {
  58320. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoTexture, _super);
  58321. /**
  58322. * Creates a video texture.
  58323. * If you want to display a video in your scene, this is the special texture for that.
  58324. * This special texture works similar to other textures, with the exception of a few parameters.
  58325. * @see https://doc.babylonjs.com/how_to/video_texture
  58326. * @param name optional name, will detect from video source, if not defined
  58327. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  58328. * @param scene is obviously the current scene.
  58329. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  58330. * @param invertY is false by default but can be used to invert video on Y axis
  58331. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  58332. * @param settings allows finer control over video usage
  58333. */
  58334. function VideoTexture(name, src, scene, generateMipMaps, invertY, samplingMode, settings) {
  58335. if (generateMipMaps === void 0) { generateMipMaps = false; }
  58336. if (invertY === void 0) { invertY = false; }
  58337. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  58338. if (settings === void 0) { settings = {
  58339. autoPlay: true,
  58340. loop: true,
  58341. autoUpdateTexture: true,
  58342. }; }
  58343. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  58344. _this._onUserActionRequestedObservable = null;
  58345. _this._stillImageCaptured = false;
  58346. _this._displayingPosterTexture = false;
  58347. _this._createInternalTexture = function () {
  58348. if (_this._texture != null) {
  58349. if (_this._displayingPosterTexture) {
  58350. _this._texture.dispose();
  58351. _this._displayingPosterTexture = false;
  58352. }
  58353. else {
  58354. return;
  58355. }
  58356. }
  58357. if (!_this._engine.needPOTTextures ||
  58358. (_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoWidth) && _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoHeight))) {
  58359. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  58360. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  58361. }
  58362. else {
  58363. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  58364. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  58365. _this._generateMipMaps = false;
  58366. }
  58367. _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this.samplingMode);
  58368. if (!_this.video.autoplay && !_this._settings.poster) {
  58369. var oldHandler_1 = _this.video.onplaying;
  58370. var error_1 = false;
  58371. _this.video.onplaying = function () {
  58372. _this.video.onplaying = oldHandler_1;
  58373. _this._texture.isReady = true;
  58374. _this._updateInternalTexture();
  58375. if (!error_1) {
  58376. _this.video.pause();
  58377. }
  58378. if (_this.onLoadObservable.hasObservers()) {
  58379. _this.onLoadObservable.notifyObservers(_this);
  58380. }
  58381. };
  58382. var playing = _this.video.play();
  58383. if (playing) {
  58384. playing.then(function () {
  58385. // Everything is good.
  58386. })
  58387. .catch(function () {
  58388. error_1 = true;
  58389. // On Chrome for instance, new policies might prevent playing without user interaction.
  58390. if (_this._onUserActionRequestedObservable && _this._onUserActionRequestedObservable.hasObservers()) {
  58391. _this._onUserActionRequestedObservable.notifyObservers(_this);
  58392. }
  58393. });
  58394. }
  58395. else {
  58396. _this.video.onplaying = oldHandler_1;
  58397. _this._texture.isReady = true;
  58398. _this._updateInternalTexture();
  58399. if (_this.onLoadObservable.hasObservers()) {
  58400. _this.onLoadObservable.notifyObservers(_this);
  58401. }
  58402. }
  58403. }
  58404. else {
  58405. _this._texture.isReady = true;
  58406. _this._updateInternalTexture();
  58407. if (_this.onLoadObservable.hasObservers()) {
  58408. _this.onLoadObservable.notifyObservers(_this);
  58409. }
  58410. }
  58411. };
  58412. _this.reset = function () {
  58413. if (_this._texture == null) {
  58414. return;
  58415. }
  58416. if (!_this._displayingPosterTexture) {
  58417. _this._texture.dispose();
  58418. _this._texture = null;
  58419. }
  58420. };
  58421. _this._updateInternalTexture = function () {
  58422. if (_this._texture == null || !_this._texture.isReady) {
  58423. return;
  58424. }
  58425. if (_this.video.readyState < _this.video.HAVE_CURRENT_DATA) {
  58426. return;
  58427. }
  58428. if (_this._displayingPosterTexture) {
  58429. return;
  58430. }
  58431. _this._engine.updateVideoTexture(_this._texture, _this.video, _this._invertY);
  58432. };
  58433. _this._engine = _this.getScene().getEngine();
  58434. _this._generateMipMaps = generateMipMaps;
  58435. _this._initialSamplingMode = samplingMode;
  58436. _this.autoUpdateTexture = settings.autoUpdateTexture;
  58437. _this.name = name || _this._getName(src);
  58438. _this.video = _this._getVideo(src);
  58439. _this._settings = settings;
  58440. if (settings.poster) {
  58441. _this.video.poster = settings.poster;
  58442. }
  58443. if (settings.autoPlay !== undefined) {
  58444. _this.video.autoplay = settings.autoPlay;
  58445. }
  58446. if (settings.loop !== undefined) {
  58447. _this.video.loop = settings.loop;
  58448. }
  58449. _this.video.setAttribute("playsinline", "");
  58450. _this.video.addEventListener("paused", _this._updateInternalTexture);
  58451. _this.video.addEventListener("seeked", _this._updateInternalTexture);
  58452. _this.video.addEventListener("emptied", _this.reset);
  58453. _this._createInternalTextureOnEvent = (settings.poster && !settings.autoPlay) ? "play" : "canplay";
  58454. _this.video.addEventListener(_this._createInternalTextureOnEvent, _this._createInternalTexture);
  58455. var videoHasEnoughData = (_this.video.readyState >= _this.video.HAVE_CURRENT_DATA);
  58456. if (settings.poster &&
  58457. (!settings.autoPlay || !videoHasEnoughData)) {
  58458. _this._texture = _this._engine.createTexture(settings.poster, false, true, scene);
  58459. _this._displayingPosterTexture = true;
  58460. }
  58461. else if (videoHasEnoughData) {
  58462. _this._createInternalTexture();
  58463. }
  58464. return _this;
  58465. }
  58466. Object.defineProperty(VideoTexture.prototype, "onUserActionRequestedObservable", {
  58467. /**
  58468. * Event triggerd when a dom action is required by the user to play the video.
  58469. * This happens due to recent changes in browser policies preventing video to auto start.
  58470. */
  58471. get: function () {
  58472. if (!this._onUserActionRequestedObservable) {
  58473. this._onUserActionRequestedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  58474. }
  58475. return this._onUserActionRequestedObservable;
  58476. },
  58477. enumerable: true,
  58478. configurable: true
  58479. });
  58480. VideoTexture.prototype._getName = function (src) {
  58481. if (src instanceof HTMLVideoElement) {
  58482. return src.currentSrc;
  58483. }
  58484. if (typeof src === "object") {
  58485. return src.toString();
  58486. }
  58487. return src;
  58488. };
  58489. VideoTexture.prototype._getVideo = function (src) {
  58490. if (src instanceof HTMLVideoElement) {
  58491. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src.currentSrc, src);
  58492. return src;
  58493. }
  58494. var video = document.createElement("video");
  58495. if (typeof src === "string") {
  58496. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src, video);
  58497. video.src = src;
  58498. }
  58499. else {
  58500. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src[0], video);
  58501. src.forEach(function (url) {
  58502. var source = document.createElement("source");
  58503. source.src = url;
  58504. video.appendChild(source);
  58505. });
  58506. }
  58507. return video;
  58508. };
  58509. /**
  58510. * @hidden Internal method to initiate `update`.
  58511. */
  58512. VideoTexture.prototype._rebuild = function () {
  58513. this.update();
  58514. };
  58515. /**
  58516. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  58517. */
  58518. VideoTexture.prototype.update = function () {
  58519. if (!this.autoUpdateTexture) {
  58520. // Expecting user to call `updateTexture` manually
  58521. return;
  58522. }
  58523. this.updateTexture(true);
  58524. };
  58525. /**
  58526. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  58527. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  58528. */
  58529. VideoTexture.prototype.updateTexture = function (isVisible) {
  58530. if (!isVisible) {
  58531. return;
  58532. }
  58533. if (this.video.paused && this._stillImageCaptured) {
  58534. return;
  58535. }
  58536. this._stillImageCaptured = true;
  58537. this._updateInternalTexture();
  58538. };
  58539. /**
  58540. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  58541. * @param url New url.
  58542. */
  58543. VideoTexture.prototype.updateURL = function (url) {
  58544. this.video.src = url;
  58545. };
  58546. /**
  58547. * Dispose the texture and release its associated resources.
  58548. */
  58549. VideoTexture.prototype.dispose = function () {
  58550. _super.prototype.dispose.call(this);
  58551. if (this._onUserActionRequestedObservable) {
  58552. this._onUserActionRequestedObservable.clear();
  58553. this._onUserActionRequestedObservable = null;
  58554. }
  58555. this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);
  58556. this.video.removeEventListener("paused", this._updateInternalTexture);
  58557. this.video.removeEventListener("seeked", this._updateInternalTexture);
  58558. this.video.removeEventListener("emptied", this.reset);
  58559. this.video.pause();
  58560. };
  58561. /**
  58562. * Creates a video texture straight from your WebCam video feed.
  58563. * @param scene Define the scene the texture should be created in
  58564. * @param onReady Define a callback to triggered once the texture will be ready
  58565. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  58566. */
  58567. VideoTexture.CreateFromWebCam = function (scene, onReady, constraints) {
  58568. var video = document.createElement("video");
  58569. video.setAttribute('autoplay', '');
  58570. video.setAttribute('muted', '');
  58571. video.setAttribute('playsinline', '');
  58572. var constraintsDeviceId;
  58573. if (constraints && constraints.deviceId) {
  58574. constraintsDeviceId = {
  58575. exact: constraints.deviceId,
  58576. };
  58577. }
  58578. window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
  58579. if (navigator.mediaDevices) {
  58580. navigator.mediaDevices.getUserMedia({ video: constraints })
  58581. .then(function (stream) {
  58582. if (video.mozSrcObject !== undefined) {
  58583. // hack for Firefox < 19
  58584. video.mozSrcObject = stream;
  58585. }
  58586. else {
  58587. video.srcObject = stream;
  58588. }
  58589. var onPlaying = function () {
  58590. if (onReady) {
  58591. onReady(new VideoTexture("video", video, scene, true, true));
  58592. }
  58593. video.removeEventListener("playing", onPlaying);
  58594. };
  58595. video.addEventListener("playing", onPlaying);
  58596. video.play();
  58597. })
  58598. .catch(function (err) {
  58599. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(err.name);
  58600. });
  58601. }
  58602. else {
  58603. navigator.getUserMedia =
  58604. navigator.getUserMedia ||
  58605. navigator.webkitGetUserMedia ||
  58606. navigator.mozGetUserMedia ||
  58607. navigator.msGetUserMedia;
  58608. if (navigator.getUserMedia) {
  58609. navigator.getUserMedia({
  58610. video: {
  58611. deviceId: constraintsDeviceId,
  58612. width: {
  58613. min: (constraints && constraints.minWidth) || 256,
  58614. max: (constraints && constraints.maxWidth) || 640,
  58615. },
  58616. height: {
  58617. min: (constraints && constraints.minHeight) || 256,
  58618. max: (constraints && constraints.maxHeight) || 480,
  58619. },
  58620. },
  58621. }, function (stream) {
  58622. if (video.mozSrcObject !== undefined) {
  58623. // hack for Firefox < 19
  58624. video.mozSrcObject = stream;
  58625. }
  58626. else {
  58627. video.src = (window.URL && window.URL.createObjectURL(stream)) || stream;
  58628. }
  58629. video.play();
  58630. if (onReady) {
  58631. onReady(new VideoTexture("video", video, scene, true, true));
  58632. }
  58633. }, function (e) {
  58634. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(e.name);
  58635. });
  58636. }
  58637. }
  58638. };
  58639. return VideoTexture;
  58640. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  58641. /***/ }),
  58642. /***/ "./Materials/colorCurves.ts":
  58643. /*!**********************************!*\
  58644. !*** ./Materials/colorCurves.ts ***!
  58645. \**********************************/
  58646. /*! exports provided: ColorCurves */
  58647. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58648. "use strict";
  58649. __webpack_require__.r(__webpack_exports__);
  58650. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return ColorCurves; });
  58651. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58652. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  58653. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  58654. /**
  58655. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58656. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58657. * 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;
  58658. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58659. */
  58660. var ColorCurves = /** @class */ (function () {
  58661. function ColorCurves() {
  58662. this._dirty = true;
  58663. this._tempColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  58664. this._globalCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  58665. this._highlightsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  58666. this._midtonesCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  58667. this._shadowsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  58668. this._positiveCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  58669. this._negativeCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  58670. this._globalHue = 30;
  58671. this._globalDensity = 0;
  58672. this._globalSaturation = 0;
  58673. this._globalExposure = 0;
  58674. this._highlightsHue = 30;
  58675. this._highlightsDensity = 0;
  58676. this._highlightsSaturation = 0;
  58677. this._highlightsExposure = 0;
  58678. this._midtonesHue = 30;
  58679. this._midtonesDensity = 0;
  58680. this._midtonesSaturation = 0;
  58681. this._midtonesExposure = 0;
  58682. this._shadowsHue = 30;
  58683. this._shadowsDensity = 0;
  58684. this._shadowsSaturation = 0;
  58685. this._shadowsExposure = 0;
  58686. }
  58687. Object.defineProperty(ColorCurves.prototype, "globalHue", {
  58688. /**
  58689. * Gets the global Hue value.
  58690. * 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).
  58691. */
  58692. get: function () {
  58693. return this._globalHue;
  58694. },
  58695. /**
  58696. * Sets the global Hue value.
  58697. * 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).
  58698. */
  58699. set: function (value) {
  58700. this._globalHue = value;
  58701. this._dirty = true;
  58702. },
  58703. enumerable: true,
  58704. configurable: true
  58705. });
  58706. Object.defineProperty(ColorCurves.prototype, "globalDensity", {
  58707. /**
  58708. * Gets the global Density value.
  58709. * 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.
  58710. * Values less than zero provide a filter of opposite hue.
  58711. */
  58712. get: function () {
  58713. return this._globalDensity;
  58714. },
  58715. /**
  58716. * Sets the global Density value.
  58717. * 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.
  58718. * Values less than zero provide a filter of opposite hue.
  58719. */
  58720. set: function (value) {
  58721. this._globalDensity = value;
  58722. this._dirty = true;
  58723. },
  58724. enumerable: true,
  58725. configurable: true
  58726. });
  58727. Object.defineProperty(ColorCurves.prototype, "globalSaturation", {
  58728. /**
  58729. * Gets the global Saturation value.
  58730. * 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.
  58731. */
  58732. get: function () {
  58733. return this._globalSaturation;
  58734. },
  58735. /**
  58736. * Sets the global Saturation value.
  58737. * 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.
  58738. */
  58739. set: function (value) {
  58740. this._globalSaturation = value;
  58741. this._dirty = true;
  58742. },
  58743. enumerable: true,
  58744. configurable: true
  58745. });
  58746. Object.defineProperty(ColorCurves.prototype, "globalExposure", {
  58747. /**
  58748. * Gets the global Exposure value.
  58749. * 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.
  58750. */
  58751. get: function () {
  58752. return this._globalExposure;
  58753. },
  58754. /**
  58755. * Sets the global Exposure value.
  58756. * 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.
  58757. */
  58758. set: function (value) {
  58759. this._globalExposure = value;
  58760. this._dirty = true;
  58761. },
  58762. enumerable: true,
  58763. configurable: true
  58764. });
  58765. Object.defineProperty(ColorCurves.prototype, "highlightsHue", {
  58766. /**
  58767. * Gets the highlights Hue value.
  58768. * 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).
  58769. */
  58770. get: function () {
  58771. return this._highlightsHue;
  58772. },
  58773. /**
  58774. * Sets the highlights Hue value.
  58775. * 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).
  58776. */
  58777. set: function (value) {
  58778. this._highlightsHue = value;
  58779. this._dirty = true;
  58780. },
  58781. enumerable: true,
  58782. configurable: true
  58783. });
  58784. Object.defineProperty(ColorCurves.prototype, "highlightsDensity", {
  58785. /**
  58786. * Gets the highlights Density value.
  58787. * 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.
  58788. * Values less than zero provide a filter of opposite hue.
  58789. */
  58790. get: function () {
  58791. return this._highlightsDensity;
  58792. },
  58793. /**
  58794. * Sets the highlights Density value.
  58795. * 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.
  58796. * Values less than zero provide a filter of opposite hue.
  58797. */
  58798. set: function (value) {
  58799. this._highlightsDensity = value;
  58800. this._dirty = true;
  58801. },
  58802. enumerable: true,
  58803. configurable: true
  58804. });
  58805. Object.defineProperty(ColorCurves.prototype, "highlightsSaturation", {
  58806. /**
  58807. * Gets the highlights Saturation value.
  58808. * 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.
  58809. */
  58810. get: function () {
  58811. return this._highlightsSaturation;
  58812. },
  58813. /**
  58814. * Sets the highlights Saturation value.
  58815. * 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.
  58816. */
  58817. set: function (value) {
  58818. this._highlightsSaturation = value;
  58819. this._dirty = true;
  58820. },
  58821. enumerable: true,
  58822. configurable: true
  58823. });
  58824. Object.defineProperty(ColorCurves.prototype, "highlightsExposure", {
  58825. /**
  58826. * Gets the highlights Exposure value.
  58827. * 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.
  58828. */
  58829. get: function () {
  58830. return this._highlightsExposure;
  58831. },
  58832. /**
  58833. * Sets the highlights Exposure value.
  58834. * 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.
  58835. */
  58836. set: function (value) {
  58837. this._highlightsExposure = value;
  58838. this._dirty = true;
  58839. },
  58840. enumerable: true,
  58841. configurable: true
  58842. });
  58843. Object.defineProperty(ColorCurves.prototype, "midtonesHue", {
  58844. /**
  58845. * Gets the midtones Hue value.
  58846. * 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).
  58847. */
  58848. get: function () {
  58849. return this._midtonesHue;
  58850. },
  58851. /**
  58852. * Sets the midtones Hue value.
  58853. * 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).
  58854. */
  58855. set: function (value) {
  58856. this._midtonesHue = value;
  58857. this._dirty = true;
  58858. },
  58859. enumerable: true,
  58860. configurable: true
  58861. });
  58862. Object.defineProperty(ColorCurves.prototype, "midtonesDensity", {
  58863. /**
  58864. * Gets the midtones Density value.
  58865. * 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.
  58866. * Values less than zero provide a filter of opposite hue.
  58867. */
  58868. get: function () {
  58869. return this._midtonesDensity;
  58870. },
  58871. /**
  58872. * Sets the midtones Density value.
  58873. * 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.
  58874. * Values less than zero provide a filter of opposite hue.
  58875. */
  58876. set: function (value) {
  58877. this._midtonesDensity = value;
  58878. this._dirty = true;
  58879. },
  58880. enumerable: true,
  58881. configurable: true
  58882. });
  58883. Object.defineProperty(ColorCurves.prototype, "midtonesSaturation", {
  58884. /**
  58885. * Gets the midtones Saturation value.
  58886. * 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.
  58887. */
  58888. get: function () {
  58889. return this._midtonesSaturation;
  58890. },
  58891. /**
  58892. * Sets the midtones Saturation value.
  58893. * 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.
  58894. */
  58895. set: function (value) {
  58896. this._midtonesSaturation = value;
  58897. this._dirty = true;
  58898. },
  58899. enumerable: true,
  58900. configurable: true
  58901. });
  58902. Object.defineProperty(ColorCurves.prototype, "midtonesExposure", {
  58903. /**
  58904. * Gets the midtones Exposure value.
  58905. * 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.
  58906. */
  58907. get: function () {
  58908. return this._midtonesExposure;
  58909. },
  58910. /**
  58911. * Sets the midtones Exposure value.
  58912. * 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.
  58913. */
  58914. set: function (value) {
  58915. this._midtonesExposure = value;
  58916. this._dirty = true;
  58917. },
  58918. enumerable: true,
  58919. configurable: true
  58920. });
  58921. Object.defineProperty(ColorCurves.prototype, "shadowsHue", {
  58922. /**
  58923. * Gets the shadows Hue value.
  58924. * 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).
  58925. */
  58926. get: function () {
  58927. return this._shadowsHue;
  58928. },
  58929. /**
  58930. * Sets the shadows Hue value.
  58931. * 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).
  58932. */
  58933. set: function (value) {
  58934. this._shadowsHue = value;
  58935. this._dirty = true;
  58936. },
  58937. enumerable: true,
  58938. configurable: true
  58939. });
  58940. Object.defineProperty(ColorCurves.prototype, "shadowsDensity", {
  58941. /**
  58942. * Gets the shadows Density value.
  58943. * 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.
  58944. * Values less than zero provide a filter of opposite hue.
  58945. */
  58946. get: function () {
  58947. return this._shadowsDensity;
  58948. },
  58949. /**
  58950. * Sets the shadows Density value.
  58951. * 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.
  58952. * Values less than zero provide a filter of opposite hue.
  58953. */
  58954. set: function (value) {
  58955. this._shadowsDensity = value;
  58956. this._dirty = true;
  58957. },
  58958. enumerable: true,
  58959. configurable: true
  58960. });
  58961. Object.defineProperty(ColorCurves.prototype, "shadowsSaturation", {
  58962. /**
  58963. * Gets the shadows Saturation value.
  58964. * 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.
  58965. */
  58966. get: function () {
  58967. return this._shadowsSaturation;
  58968. },
  58969. /**
  58970. * Sets the shadows Saturation value.
  58971. * 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.
  58972. */
  58973. set: function (value) {
  58974. this._shadowsSaturation = value;
  58975. this._dirty = true;
  58976. },
  58977. enumerable: true,
  58978. configurable: true
  58979. });
  58980. Object.defineProperty(ColorCurves.prototype, "shadowsExposure", {
  58981. /**
  58982. * Gets the shadows Exposure value.
  58983. * 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.
  58984. */
  58985. get: function () {
  58986. return this._shadowsExposure;
  58987. },
  58988. /**
  58989. * Sets the shadows Exposure value.
  58990. * 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.
  58991. */
  58992. set: function (value) {
  58993. this._shadowsExposure = value;
  58994. this._dirty = true;
  58995. },
  58996. enumerable: true,
  58997. configurable: true
  58998. });
  58999. /**
  59000. * Returns the class name
  59001. * @returns The class name
  59002. */
  59003. ColorCurves.prototype.getClassName = function () {
  59004. return "ColorCurves";
  59005. };
  59006. /**
  59007. * Binds the color curves to the shader.
  59008. * @param colorCurves The color curve to bind
  59009. * @param effect The effect to bind to
  59010. * @param positiveUniform The positive uniform shader parameter
  59011. * @param neutralUniform The neutral uniform shader parameter
  59012. * @param negativeUniform The negative uniform shader parameter
  59013. */
  59014. ColorCurves.Bind = function (colorCurves, effect, positiveUniform, neutralUniform, negativeUniform) {
  59015. if (positiveUniform === void 0) { positiveUniform = "vCameraColorCurvePositive"; }
  59016. if (neutralUniform === void 0) { neutralUniform = "vCameraColorCurveNeutral"; }
  59017. if (negativeUniform === void 0) { negativeUniform = "vCameraColorCurveNegative"; }
  59018. if (colorCurves._dirty) {
  59019. colorCurves._dirty = false;
  59020. // Fill in global info.
  59021. colorCurves.getColorGradingDataToRef(colorCurves._globalHue, colorCurves._globalDensity, colorCurves._globalSaturation, colorCurves._globalExposure, colorCurves._globalCurve);
  59022. // Compute highlights info.
  59023. colorCurves.getColorGradingDataToRef(colorCurves._highlightsHue, colorCurves._highlightsDensity, colorCurves._highlightsSaturation, colorCurves._highlightsExposure, colorCurves._tempColor);
  59024. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._highlightsCurve);
  59025. // Compute midtones info.
  59026. colorCurves.getColorGradingDataToRef(colorCurves._midtonesHue, colorCurves._midtonesDensity, colorCurves._midtonesSaturation, colorCurves._midtonesExposure, colorCurves._tempColor);
  59027. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._midtonesCurve);
  59028. // Compute shadows info.
  59029. colorCurves.getColorGradingDataToRef(colorCurves._shadowsHue, colorCurves._shadowsDensity, colorCurves._shadowsSaturation, colorCurves._shadowsExposure, colorCurves._tempColor);
  59030. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._shadowsCurve);
  59031. // Compute deltas (neutral is midtones).
  59032. colorCurves._highlightsCurve.subtractToRef(colorCurves._midtonesCurve, colorCurves._positiveCurve);
  59033. colorCurves._midtonesCurve.subtractToRef(colorCurves._shadowsCurve, colorCurves._negativeCurve);
  59034. }
  59035. if (effect) {
  59036. effect.setFloat4(positiveUniform, colorCurves._positiveCurve.r, colorCurves._positiveCurve.g, colorCurves._positiveCurve.b, colorCurves._positiveCurve.a);
  59037. effect.setFloat4(neutralUniform, colorCurves._midtonesCurve.r, colorCurves._midtonesCurve.g, colorCurves._midtonesCurve.b, colorCurves._midtonesCurve.a);
  59038. effect.setFloat4(negativeUniform, colorCurves._negativeCurve.r, colorCurves._negativeCurve.g, colorCurves._negativeCurve.b, colorCurves._negativeCurve.a);
  59039. }
  59040. };
  59041. /**
  59042. * Prepare the list of uniforms associated with the ColorCurves effects.
  59043. * @param uniformsList The list of uniforms used in the effect
  59044. */
  59045. ColorCurves.PrepareUniforms = function (uniformsList) {
  59046. uniformsList.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative");
  59047. };
  59048. /**
  59049. * Returns color grading data based on a hue, density, saturation and exposure value.
  59050. * @param filterHue The hue of the color filter.
  59051. * @param filterDensity The density of the color filter.
  59052. * @param saturation The saturation.
  59053. * @param exposure The exposure.
  59054. * @param result The result data container.
  59055. */
  59056. ColorCurves.prototype.getColorGradingDataToRef = function (hue, density, saturation, exposure, result) {
  59057. if (hue == null) {
  59058. return;
  59059. }
  59060. hue = ColorCurves.clamp(hue, 0, 360);
  59061. density = ColorCurves.clamp(density, -100, 100);
  59062. saturation = ColorCurves.clamp(saturation, -100, 100);
  59063. exposure = ColorCurves.clamp(exposure, -100, 100);
  59064. // Remap the slider/config filter density with non-linear mapping and also scale by half
  59065. // so that the maximum filter density is only 50% control. This provides fine control
  59066. // for small values and reasonable range.
  59067. density = ColorCurves.applyColorGradingSliderNonlinear(density);
  59068. density *= 0.5;
  59069. exposure = ColorCurves.applyColorGradingSliderNonlinear(exposure);
  59070. if (density < 0) {
  59071. density *= -1;
  59072. hue = (hue + 180) % 360;
  59073. }
  59074. ColorCurves.fromHSBToRef(hue, density, 50 + 0.25 * exposure, result);
  59075. result.scaleToRef(2, result);
  59076. result.a = 1 + 0.01 * saturation;
  59077. };
  59078. /**
  59079. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  59080. * @param value The input slider value in range [-100,100].
  59081. * @returns Adjusted value.
  59082. */
  59083. ColorCurves.applyColorGradingSliderNonlinear = function (value) {
  59084. value /= 100;
  59085. var x = Math.abs(value);
  59086. x = Math.pow(x, 2);
  59087. if (value < 0) {
  59088. x *= -1;
  59089. }
  59090. x *= 100;
  59091. return x;
  59092. };
  59093. /**
  59094. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  59095. * @param hue The hue (H) input.
  59096. * @param saturation The saturation (S) input.
  59097. * @param brightness The brightness (B) input.
  59098. * @result An RGBA color represented as Vector4.
  59099. */
  59100. ColorCurves.fromHSBToRef = function (hue, saturation, brightness, result) {
  59101. var h = ColorCurves.clamp(hue, 0, 360);
  59102. var s = ColorCurves.clamp(saturation / 100, 0, 1);
  59103. var v = ColorCurves.clamp(brightness / 100, 0, 1);
  59104. if (s === 0) {
  59105. result.r = v;
  59106. result.g = v;
  59107. result.b = v;
  59108. }
  59109. else {
  59110. // sector 0 to 5
  59111. h /= 60;
  59112. var i = Math.floor(h);
  59113. // fractional part of h
  59114. var f = h - i;
  59115. var p = v * (1 - s);
  59116. var q = v * (1 - s * f);
  59117. var t = v * (1 - s * (1 - f));
  59118. switch (i) {
  59119. case 0:
  59120. result.r = v;
  59121. result.g = t;
  59122. result.b = p;
  59123. break;
  59124. case 1:
  59125. result.r = q;
  59126. result.g = v;
  59127. result.b = p;
  59128. break;
  59129. case 2:
  59130. result.r = p;
  59131. result.g = v;
  59132. result.b = t;
  59133. break;
  59134. case 3:
  59135. result.r = p;
  59136. result.g = q;
  59137. result.b = v;
  59138. break;
  59139. case 4:
  59140. result.r = t;
  59141. result.g = p;
  59142. result.b = v;
  59143. break;
  59144. default: // case 5:
  59145. result.r = v;
  59146. result.g = p;
  59147. result.b = q;
  59148. break;
  59149. }
  59150. }
  59151. result.a = 1;
  59152. };
  59153. /**
  59154. * Returns a value clamped between min and max
  59155. * @param value The value to clamp
  59156. * @param min The minimum of value
  59157. * @param max The maximum of value
  59158. * @returns The clamped value.
  59159. */
  59160. ColorCurves.clamp = function (value, min, max) {
  59161. return Math.min(Math.max(value, min), max);
  59162. };
  59163. /**
  59164. * Clones the current color curve instance.
  59165. * @return The cloned curves
  59166. */
  59167. ColorCurves.prototype.clone = function () {
  59168. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ColorCurves(); }, this);
  59169. };
  59170. /**
  59171. * Serializes the current color curve instance to a json representation.
  59172. * @return a JSON representation
  59173. */
  59174. ColorCurves.prototype.serialize = function () {
  59175. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  59176. };
  59177. /**
  59178. * Parses the color curve from a json representation.
  59179. * @param source the JSON source to parse
  59180. * @return The parsed curves
  59181. */
  59182. ColorCurves.Parse = function (source) {
  59183. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ColorCurves(); }, source, null, null);
  59184. };
  59185. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59186. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59187. ], ColorCurves.prototype, "_globalHue", void 0);
  59188. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59189. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59190. ], ColorCurves.prototype, "_globalDensity", void 0);
  59191. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59192. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59193. ], ColorCurves.prototype, "_globalSaturation", void 0);
  59194. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59195. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59196. ], ColorCurves.prototype, "_globalExposure", void 0);
  59197. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59198. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59199. ], ColorCurves.prototype, "_highlightsHue", void 0);
  59200. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59201. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59202. ], ColorCurves.prototype, "_highlightsDensity", void 0);
  59203. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59204. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59205. ], ColorCurves.prototype, "_highlightsSaturation", void 0);
  59206. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59207. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59208. ], ColorCurves.prototype, "_highlightsExposure", void 0);
  59209. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59210. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59211. ], ColorCurves.prototype, "_midtonesHue", void 0);
  59212. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59213. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59214. ], ColorCurves.prototype, "_midtonesDensity", void 0);
  59215. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59216. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59217. ], ColorCurves.prototype, "_midtonesSaturation", void 0);
  59218. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59219. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59220. ], ColorCurves.prototype, "_midtonesExposure", void 0);
  59221. return ColorCurves;
  59222. }());
  59223. // References the dependencies.
  59224. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ColorCurvesParser = ColorCurves.Parse;
  59225. /***/ }),
  59226. /***/ "./Materials/effect.ts":
  59227. /*!*****************************!*\
  59228. !*** ./Materials/effect.ts ***!
  59229. \*****************************/
  59230. /*! exports provided: EffectFallbacks, EffectCreationOptions, Effect */
  59231. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59232. "use strict";
  59233. __webpack_require__.r(__webpack_exports__);
  59234. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return EffectFallbacks; });
  59235. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return EffectCreationOptions; });
  59236. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return Effect; });
  59237. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  59238. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  59239. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  59240. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  59241. /**
  59242. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  59243. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  59244. */
  59245. var EffectFallbacks = /** @class */ (function () {
  59246. function EffectFallbacks() {
  59247. this._defines = {};
  59248. this._currentRank = 32;
  59249. this._maxRank = -1;
  59250. }
  59251. /**
  59252. * Removes the fallback from the bound mesh.
  59253. */
  59254. EffectFallbacks.prototype.unBindMesh = function () {
  59255. this._mesh = null;
  59256. };
  59257. /**
  59258. * Adds a fallback on the specified property.
  59259. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  59260. * @param define The name of the define in the shader
  59261. */
  59262. EffectFallbacks.prototype.addFallback = function (rank, define) {
  59263. if (!this._defines[rank]) {
  59264. if (rank < this._currentRank) {
  59265. this._currentRank = rank;
  59266. }
  59267. if (rank > this._maxRank) {
  59268. this._maxRank = rank;
  59269. }
  59270. this._defines[rank] = new Array();
  59271. }
  59272. this._defines[rank].push(define);
  59273. };
  59274. /**
  59275. * Sets the mesh to use CPU skinning when needing to fallback.
  59276. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  59277. * @param mesh The mesh to use the fallbacks.
  59278. */
  59279. EffectFallbacks.prototype.addCPUSkinningFallback = function (rank, mesh) {
  59280. this._mesh = mesh;
  59281. if (rank < this._currentRank) {
  59282. this._currentRank = rank;
  59283. }
  59284. if (rank > this._maxRank) {
  59285. this._maxRank = rank;
  59286. }
  59287. };
  59288. Object.defineProperty(EffectFallbacks.prototype, "isMoreFallbacks", {
  59289. /**
  59290. * Checks to see if more fallbacks are still availible.
  59291. */
  59292. get: function () {
  59293. return this._currentRank <= this._maxRank;
  59294. },
  59295. enumerable: true,
  59296. configurable: true
  59297. });
  59298. /**
  59299. * Removes the defines that shoould be removed when falling back.
  59300. * @param currentDefines defines the current define statements for the shader.
  59301. * @param effect defines the current effect we try to compile
  59302. * @returns The resulting defines with defines of the current rank removed.
  59303. */
  59304. EffectFallbacks.prototype.reduce = function (currentDefines, effect) {
  59305. // First we try to switch to CPU skinning
  59306. if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0 && this._mesh.material) {
  59307. this._mesh.computeBonesUsingShaders = false;
  59308. currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
  59309. effect._bonesComputationForcedToCPU = true;
  59310. var scene = this._mesh.getScene();
  59311. for (var index = 0; index < scene.meshes.length; index++) {
  59312. var otherMesh = scene.meshes[index];
  59313. if (!otherMesh.material) {
  59314. continue;
  59315. }
  59316. if (!otherMesh.computeBonesUsingShaders || otherMesh.numBoneInfluencers === 0) {
  59317. continue;
  59318. }
  59319. if (otherMesh.material.getEffect() === effect) {
  59320. otherMesh.computeBonesUsingShaders = false;
  59321. }
  59322. else if (otherMesh.subMeshes) {
  59323. for (var _i = 0, _a = otherMesh.subMeshes; _i < _a.length; _i++) {
  59324. var subMesh = _a[_i];
  59325. var subMeshEffect = subMesh.effect;
  59326. if (subMeshEffect === effect) {
  59327. otherMesh.computeBonesUsingShaders = false;
  59328. break;
  59329. }
  59330. }
  59331. }
  59332. }
  59333. }
  59334. else {
  59335. var currentFallbacks = this._defines[this._currentRank];
  59336. if (currentFallbacks) {
  59337. for (var index = 0; index < currentFallbacks.length; index++) {
  59338. currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
  59339. }
  59340. }
  59341. this._currentRank++;
  59342. }
  59343. return currentDefines;
  59344. };
  59345. return EffectFallbacks;
  59346. }());
  59347. /**
  59348. * Options to be used when creating an effect.
  59349. */
  59350. var EffectCreationOptions = /** @class */ (function () {
  59351. function EffectCreationOptions() {
  59352. }
  59353. return EffectCreationOptions;
  59354. }());
  59355. /**
  59356. * Effect containing vertex and fragment shader that can be executed on an object.
  59357. */
  59358. var Effect = /** @class */ (function () {
  59359. /**
  59360. * Instantiates an effect.
  59361. * An effect can be used to create/manage/execute vertex and fragment shaders.
  59362. * @param baseName Name of the effect.
  59363. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  59364. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  59365. * @param samplers List of sampler variables that will be passed to the shader.
  59366. * @param engine Engine to be used to render the effect
  59367. * @param defines Define statements to be added to the shader.
  59368. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  59369. * @param onCompiled Callback that will be called when the shader is compiled.
  59370. * @param onError Callback that will be called if an error occurs during shader compilation.
  59371. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  59372. */
  59373. function Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, engine, defines, fallbacks, onCompiled, onError, indexParameters) {
  59374. if (samplers === void 0) { samplers = null; }
  59375. if (defines === void 0) { defines = null; }
  59376. if (fallbacks === void 0) { fallbacks = null; }
  59377. if (onCompiled === void 0) { onCompiled = null; }
  59378. if (onError === void 0) { onError = null; }
  59379. var _this = this;
  59380. /**
  59381. * Unique ID of the effect.
  59382. */
  59383. this.uniqueId = 0;
  59384. /**
  59385. * Observable that will be called when the shader is compiled.
  59386. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  59387. */
  59388. this.onCompileObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  59389. /**
  59390. * Observable that will be called if an error occurs during shader compilation.
  59391. */
  59392. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  59393. /** @hidden */
  59394. this._bonesComputationForcedToCPU = false;
  59395. this._uniformBuffersNames = {};
  59396. this._isReady = false;
  59397. this._compilationError = "";
  59398. this.name = baseName;
  59399. if (attributesNamesOrOptions.attributes) {
  59400. var options = attributesNamesOrOptions;
  59401. this._engine = uniformsNamesOrEngine;
  59402. this._attributesNames = options.attributes;
  59403. this._uniformsNames = options.uniformsNames.concat(options.samplers);
  59404. this._samplers = options.samplers.slice();
  59405. this.defines = options.defines;
  59406. this.onError = options.onError;
  59407. this.onCompiled = options.onCompiled;
  59408. this._fallbacks = options.fallbacks;
  59409. this._indexParameters = options.indexParameters;
  59410. this._transformFeedbackVaryings = options.transformFeedbackVaryings;
  59411. if (options.uniformBuffersNames) {
  59412. for (var i = 0; i < options.uniformBuffersNames.length; i++) {
  59413. this._uniformBuffersNames[options.uniformBuffersNames[i]] = i;
  59414. }
  59415. }
  59416. }
  59417. else {
  59418. this._engine = engine;
  59419. this.defines = defines;
  59420. this._uniformsNames = uniformsNamesOrEngine.concat(samplers);
  59421. this._samplers = samplers ? samplers.slice() : [];
  59422. this._attributesNames = attributesNamesOrOptions;
  59423. this.onError = onError;
  59424. this.onCompiled = onCompiled;
  59425. this._indexParameters = indexParameters;
  59426. this._fallbacks = fallbacks;
  59427. }
  59428. this.uniqueId = Effect._uniqueIdSeed++;
  59429. var vertexSource;
  59430. var fragmentSource;
  59431. if (baseName.vertexElement) {
  59432. vertexSource = document.getElementById(baseName.vertexElement);
  59433. if (!vertexSource) {
  59434. vertexSource = baseName.vertexElement;
  59435. }
  59436. }
  59437. else {
  59438. vertexSource = baseName.vertex || baseName;
  59439. }
  59440. if (baseName.fragmentElement) {
  59441. fragmentSource = document.getElementById(baseName.fragmentElement);
  59442. if (!fragmentSource) {
  59443. fragmentSource = baseName.fragmentElement;
  59444. }
  59445. }
  59446. else {
  59447. fragmentSource = baseName.fragment || baseName;
  59448. }
  59449. this._loadVertexShader(vertexSource, function (vertexCode) {
  59450. _this._processIncludes(vertexCode, function (vertexCodeWithIncludes) {
  59451. _this._processShaderConversion(vertexCodeWithIncludes, false, function (migratedVertexCode) {
  59452. _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
  59453. _this._processIncludes(fragmentCode, function (fragmentCodeWithIncludes) {
  59454. _this._processShaderConversion(fragmentCodeWithIncludes, true, function (migratedFragmentCode) {
  59455. if (baseName) {
  59456. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  59457. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  59458. _this._vertexSourceCode = "#define SHADER_NAME vertex:" + vertex + "\n" + migratedVertexCode;
  59459. _this._fragmentSourceCode = "#define SHADER_NAME fragment:" + fragment + "\n" + migratedFragmentCode;
  59460. }
  59461. else {
  59462. _this._vertexSourceCode = migratedVertexCode;
  59463. _this._fragmentSourceCode = migratedFragmentCode;
  59464. }
  59465. _this._prepareEffect();
  59466. });
  59467. });
  59468. });
  59469. });
  59470. });
  59471. });
  59472. }
  59473. Object.defineProperty(Effect.prototype, "onBindObservable", {
  59474. /**
  59475. * Observable that will be called when effect is bound.
  59476. */
  59477. get: function () {
  59478. if (!this._onBindObservable) {
  59479. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  59480. }
  59481. return this._onBindObservable;
  59482. },
  59483. enumerable: true,
  59484. configurable: true
  59485. });
  59486. Object.defineProperty(Effect.prototype, "key", {
  59487. /**
  59488. * Unique key for this effect
  59489. */
  59490. get: function () {
  59491. return this._key;
  59492. },
  59493. enumerable: true,
  59494. configurable: true
  59495. });
  59496. /**
  59497. * If the effect has been compiled and prepared.
  59498. * @returns if the effect is compiled and prepared.
  59499. */
  59500. Effect.prototype.isReady = function () {
  59501. if (!this._isReady && this._program && this._program.isParallelCompiled) {
  59502. return this._engine._isProgramCompiled(this._program);
  59503. }
  59504. return this._isReady;
  59505. };
  59506. /**
  59507. * The engine the effect was initialized with.
  59508. * @returns the engine.
  59509. */
  59510. Effect.prototype.getEngine = function () {
  59511. return this._engine;
  59512. };
  59513. /**
  59514. * The compiled webGL program for the effect
  59515. * @returns the webGL program.
  59516. */
  59517. Effect.prototype.getProgram = function () {
  59518. return this._program;
  59519. };
  59520. /**
  59521. * The set of names of attribute variables for the shader.
  59522. * @returns An array of attribute names.
  59523. */
  59524. Effect.prototype.getAttributesNames = function () {
  59525. return this._attributesNames;
  59526. };
  59527. /**
  59528. * Returns the attribute at the given index.
  59529. * @param index The index of the attribute.
  59530. * @returns The location of the attribute.
  59531. */
  59532. Effect.prototype.getAttributeLocation = function (index) {
  59533. return this._attributes[index];
  59534. };
  59535. /**
  59536. * Returns the attribute based on the name of the variable.
  59537. * @param name of the attribute to look up.
  59538. * @returns the attribute location.
  59539. */
  59540. Effect.prototype.getAttributeLocationByName = function (name) {
  59541. var index = this._attributesNames.indexOf(name);
  59542. return this._attributes[index];
  59543. };
  59544. /**
  59545. * The number of attributes.
  59546. * @returns the numnber of attributes.
  59547. */
  59548. Effect.prototype.getAttributesCount = function () {
  59549. return this._attributes.length;
  59550. };
  59551. /**
  59552. * Gets the index of a uniform variable.
  59553. * @param uniformName of the uniform to look up.
  59554. * @returns the index.
  59555. */
  59556. Effect.prototype.getUniformIndex = function (uniformName) {
  59557. return this._uniformsNames.indexOf(uniformName);
  59558. };
  59559. /**
  59560. * Returns the attribute based on the name of the variable.
  59561. * @param uniformName of the uniform to look up.
  59562. * @returns the location of the uniform.
  59563. */
  59564. Effect.prototype.getUniform = function (uniformName) {
  59565. return this._uniforms[this._uniformsNames.indexOf(uniformName)];
  59566. };
  59567. /**
  59568. * Returns an array of sampler variable names
  59569. * @returns The array of sampler variable neames.
  59570. */
  59571. Effect.prototype.getSamplers = function () {
  59572. return this._samplers;
  59573. };
  59574. /**
  59575. * The error from the last compilation.
  59576. * @returns the error string.
  59577. */
  59578. Effect.prototype.getCompilationError = function () {
  59579. return this._compilationError;
  59580. };
  59581. /**
  59582. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  59583. * @param func The callback to be used.
  59584. */
  59585. Effect.prototype.executeWhenCompiled = function (func) {
  59586. var _this = this;
  59587. if (this.isReady()) {
  59588. func(this);
  59589. return;
  59590. }
  59591. this.onCompileObservable.add(function (effect) {
  59592. func(effect);
  59593. });
  59594. if (!this._program || this._program.isParallelCompiled) {
  59595. setTimeout(function () {
  59596. _this._checkIsReady();
  59597. }, 16);
  59598. }
  59599. };
  59600. Effect.prototype._checkIsReady = function () {
  59601. var _this = this;
  59602. if (this.isReady()) {
  59603. return;
  59604. }
  59605. setTimeout(function () {
  59606. _this._checkIsReady();
  59607. }, 16);
  59608. };
  59609. /** @hidden */
  59610. Effect.prototype._loadVertexShader = function (vertex, callback) {
  59611. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  59612. // DOM element ?
  59613. if (vertex instanceof HTMLElement) {
  59614. var vertexCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(vertex);
  59615. callback(vertexCode);
  59616. return;
  59617. }
  59618. }
  59619. // Base64 encoded ?
  59620. if (vertex.substr(0, 7) === "base64:") {
  59621. var vertexBinary = window.atob(vertex.substr(7));
  59622. callback(vertexBinary);
  59623. return;
  59624. }
  59625. // Is in local store ?
  59626. if (Effect.ShadersStore[vertex + "VertexShader"]) {
  59627. callback(Effect.ShadersStore[vertex + "VertexShader"]);
  59628. return;
  59629. }
  59630. var vertexShaderUrl;
  59631. if (vertex[0] === "." || vertex[0] === "/" || vertex.indexOf("http") > -1) {
  59632. vertexShaderUrl = vertex;
  59633. }
  59634. else {
  59635. vertexShaderUrl = Effect.ShadersRepository + vertex;
  59636. }
  59637. // Vertex shader
  59638. this._engine._loadFile(vertexShaderUrl + ".vertex.fx", callback);
  59639. };
  59640. /** @hidden */
  59641. Effect.prototype._loadFragmentShader = function (fragment, callback) {
  59642. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  59643. // DOM element ?
  59644. if (fragment instanceof HTMLElement) {
  59645. var fragmentCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(fragment);
  59646. callback(fragmentCode);
  59647. return;
  59648. }
  59649. }
  59650. // Base64 encoded ?
  59651. if (fragment.substr(0, 7) === "base64:") {
  59652. var fragmentBinary = window.atob(fragment.substr(7));
  59653. callback(fragmentBinary);
  59654. return;
  59655. }
  59656. // Is in local store ?
  59657. if (Effect.ShadersStore[fragment + "PixelShader"]) {
  59658. callback(Effect.ShadersStore[fragment + "PixelShader"]);
  59659. return;
  59660. }
  59661. if (Effect.ShadersStore[fragment + "FragmentShader"]) {
  59662. callback(Effect.ShadersStore[fragment + "FragmentShader"]);
  59663. return;
  59664. }
  59665. var fragmentShaderUrl;
  59666. if (fragment[0] === "." || fragment[0] === "/" || fragment.indexOf("http") > -1) {
  59667. fragmentShaderUrl = fragment;
  59668. }
  59669. else {
  59670. fragmentShaderUrl = Effect.ShadersRepository + fragment;
  59671. }
  59672. // Fragment shader
  59673. this._engine._loadFile(fragmentShaderUrl + ".fragment.fx", callback);
  59674. };
  59675. /** @hidden */
  59676. Effect.prototype._dumpShadersSource = function (vertexCode, fragmentCode, defines) {
  59677. // Rebuild shaders source code
  59678. var shaderVersion = (this._engine.webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  59679. var prefix = shaderVersion + (defines ? defines + "\n" : "");
  59680. vertexCode = prefix + vertexCode;
  59681. fragmentCode = prefix + fragmentCode;
  59682. // Number lines of shaders source code
  59683. var i = 2;
  59684. var regex = /\n/gm;
  59685. var formattedVertexCode = "\n1\t" + vertexCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  59686. i = 2;
  59687. var formattedFragmentCode = "\n1\t" + fragmentCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  59688. // Dump shaders name and formatted source code
  59689. if (this.name.vertexElement) {
  59690. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertexElement + formattedVertexCode);
  59691. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragmentElement + formattedFragmentCode);
  59692. }
  59693. else if (this.name.vertex) {
  59694. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertex + formattedVertexCode);
  59695. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragment + formattedFragmentCode);
  59696. }
  59697. else {
  59698. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name + formattedVertexCode);
  59699. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name + formattedFragmentCode);
  59700. }
  59701. };
  59702. Effect.prototype._processShaderConversion = function (sourceCode, isFragment, callback) {
  59703. var preparedSourceCode = this._processPrecision(sourceCode);
  59704. if (this._engine.webGLVersion == 1) {
  59705. callback(preparedSourceCode);
  59706. return;
  59707. }
  59708. // Already converted
  59709. if (preparedSourceCode.indexOf("#version 3") !== -1) {
  59710. callback(preparedSourceCode.replace("#version 300 es", ""));
  59711. return;
  59712. }
  59713. var hasDrawBuffersExtension = preparedSourceCode.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
  59714. // Remove extensions
  59715. // #extension GL_OES_standard_derivatives : enable
  59716. // #extension GL_EXT_shader_texture_lod : enable
  59717. // #extension GL_EXT_frag_depth : enable
  59718. // #extension GL_EXT_draw_buffers : require
  59719. var regex = /#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
  59720. var result = preparedSourceCode.replace(regex, "");
  59721. // Migrate to GLSL v300
  59722. result = result.replace(/varying(?![\n\r])\s/g, isFragment ? "in " : "out ");
  59723. result = result.replace(/attribute[ \t]/g, "in ");
  59724. result = result.replace(/[ \t]attribute/g, " in");
  59725. result = result.replace(/texture2D\s*\(/g, "texture(");
  59726. if (isFragment) {
  59727. result = result.replace(/texture2DLodEXT\s*\(/g, "textureLod(");
  59728. result = result.replace(/textureCubeLodEXT\s*\(/g, "textureLod(");
  59729. result = result.replace(/textureCube\s*\(/g, "texture(");
  59730. result = result.replace(/gl_FragDepthEXT/g, "gl_FragDepth");
  59731. result = result.replace(/gl_FragColor/g, "glFragColor");
  59732. result = result.replace(/gl_FragData/g, "glFragData");
  59733. result = result.replace(/void\s+?main\s*\(/g, (hasDrawBuffersExtension ? "" : "out vec4 glFragColor;\n") + "void main(");
  59734. }
  59735. callback(result);
  59736. };
  59737. Effect.prototype._processIncludes = function (sourceCode, callback) {
  59738. var _this = this;
  59739. var regex = /#include<(.+)>(\((.*)\))*(\[(.*)\])*/g;
  59740. var match = regex.exec(sourceCode);
  59741. var returnValue = new String(sourceCode);
  59742. while (match != null) {
  59743. var includeFile = match[1];
  59744. // Uniform declaration
  59745. if (includeFile.indexOf("__decl__") !== -1) {
  59746. includeFile = includeFile.replace(/__decl__/, "");
  59747. if (this._engine.supportsUniformBuffers) {
  59748. includeFile = includeFile.replace(/Vertex/, "Ubo");
  59749. includeFile = includeFile.replace(/Fragment/, "Ubo");
  59750. }
  59751. includeFile = includeFile + "Declaration";
  59752. }
  59753. if (Effect.IncludesShadersStore[includeFile]) {
  59754. // Substitution
  59755. var includeContent = Effect.IncludesShadersStore[includeFile];
  59756. if (match[2]) {
  59757. var splits = match[3].split(",");
  59758. for (var index = 0; index < splits.length; index += 2) {
  59759. var source = new RegExp(splits[index], "g");
  59760. var dest = splits[index + 1];
  59761. includeContent = includeContent.replace(source, dest);
  59762. }
  59763. }
  59764. if (match[4]) {
  59765. var indexString = match[5];
  59766. if (indexString.indexOf("..") !== -1) {
  59767. var indexSplits = indexString.split("..");
  59768. var minIndex = parseInt(indexSplits[0]);
  59769. var maxIndex = parseInt(indexSplits[1]);
  59770. var sourceIncludeContent = includeContent.slice(0);
  59771. includeContent = "";
  59772. if (isNaN(maxIndex)) {
  59773. maxIndex = this._indexParameters[indexSplits[1]];
  59774. }
  59775. for (var i = minIndex; i < maxIndex; i++) {
  59776. if (!this._engine.supportsUniformBuffers) {
  59777. // Ubo replacement
  59778. sourceIncludeContent = sourceIncludeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  59779. return p1 + "{X}";
  59780. });
  59781. }
  59782. includeContent += sourceIncludeContent.replace(/\{X\}/g, i.toString()) + "\n";
  59783. }
  59784. }
  59785. else {
  59786. if (!this._engine.supportsUniformBuffers) {
  59787. // Ubo replacement
  59788. includeContent = includeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  59789. return p1 + "{X}";
  59790. });
  59791. }
  59792. includeContent = includeContent.replace(/\{X\}/g, indexString);
  59793. }
  59794. }
  59795. // Replace
  59796. returnValue = returnValue.replace(match[0], includeContent);
  59797. }
  59798. else {
  59799. var includeShaderUrl = Effect.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
  59800. this._engine._loadFile(includeShaderUrl, function (fileContent) {
  59801. Effect.IncludesShadersStore[includeFile] = fileContent;
  59802. _this._processIncludes(returnValue, callback);
  59803. });
  59804. return;
  59805. }
  59806. match = regex.exec(sourceCode);
  59807. }
  59808. callback(returnValue);
  59809. };
  59810. Effect.prototype._processPrecision = function (source) {
  59811. if (source.indexOf("precision highp float") === -1) {
  59812. if (!this._engine.getCaps().highPrecisionShaderSupported) {
  59813. source = "precision mediump float;\n" + source;
  59814. }
  59815. else {
  59816. source = "precision highp float;\n" + source;
  59817. }
  59818. }
  59819. else {
  59820. if (!this._engine.getCaps().highPrecisionShaderSupported) { // Moving highp to mediump
  59821. source = source.replace("precision highp float", "precision mediump float");
  59822. }
  59823. }
  59824. return source;
  59825. };
  59826. /**
  59827. * Recompiles the webGL program
  59828. * @param vertexSourceCode The source code for the vertex shader.
  59829. * @param fragmentSourceCode The source code for the fragment shader.
  59830. * @param onCompiled Callback called when completed.
  59831. * @param onError Callback called on error.
  59832. * @hidden
  59833. */
  59834. Effect.prototype._rebuildProgram = function (vertexSourceCode, fragmentSourceCode, onCompiled, onError) {
  59835. var _this = this;
  59836. this._isReady = false;
  59837. this._vertexSourceCodeOverride = vertexSourceCode;
  59838. this._fragmentSourceCodeOverride = fragmentSourceCode;
  59839. this.onError = function (effect, error) {
  59840. if (onError) {
  59841. onError(error);
  59842. }
  59843. };
  59844. this.onCompiled = function () {
  59845. var scenes = _this.getEngine().scenes;
  59846. for (var i = 0; i < scenes.length; i++) {
  59847. scenes[i].markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  59848. }
  59849. if (onCompiled) {
  59850. onCompiled(_this._program);
  59851. }
  59852. };
  59853. this._fallbacks = null;
  59854. this._prepareEffect();
  59855. };
  59856. /**
  59857. * Gets the uniform locations of the the specified variable names
  59858. * @param names THe names of the variables to lookup.
  59859. * @returns Array of locations in the same order as variable names.
  59860. */
  59861. Effect.prototype.getSpecificUniformLocations = function (names) {
  59862. var engine = this._engine;
  59863. return engine.getUniforms(this._program, names);
  59864. };
  59865. /**
  59866. * Prepares the effect
  59867. * @hidden
  59868. */
  59869. Effect.prototype._prepareEffect = function () {
  59870. var _this = this;
  59871. var attributesNames = this._attributesNames;
  59872. var defines = this.defines;
  59873. var fallbacks = this._fallbacks;
  59874. this._valueCache = {};
  59875. var previousProgram = this._program;
  59876. try {
  59877. var engine_1 = this._engine;
  59878. if (this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride) {
  59879. this._program = engine_1.createRawShaderProgram(this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, undefined, this._transformFeedbackVaryings);
  59880. }
  59881. else {
  59882. this._program = engine_1.createShaderProgram(this._vertexSourceCode, this._fragmentSourceCode, defines, undefined, this._transformFeedbackVaryings);
  59883. }
  59884. this._program.__SPECTOR_rebuildProgram = this._rebuildProgram.bind(this);
  59885. engine_1._executeWhenProgramIsCompiled(this._program, function () {
  59886. if (engine_1.supportsUniformBuffers) {
  59887. for (var name in _this._uniformBuffersNames) {
  59888. _this.bindUniformBlock(name, _this._uniformBuffersNames[name]);
  59889. }
  59890. }
  59891. _this._uniforms = engine_1.getUniforms(_this._program, _this._uniformsNames);
  59892. _this._attributes = engine_1.getAttributes(_this._program, attributesNames);
  59893. var index;
  59894. for (index = 0; index < _this._samplers.length; index++) {
  59895. var sampler = _this.getUniform(_this._samplers[index]);
  59896. if (sampler == null) {
  59897. _this._samplers.splice(index, 1);
  59898. index--;
  59899. }
  59900. }
  59901. engine_1.bindSamplers(_this);
  59902. _this._compilationError = "";
  59903. _this._isReady = true;
  59904. if (_this.onCompiled) {
  59905. _this.onCompiled(_this);
  59906. }
  59907. _this.onCompileObservable.notifyObservers(_this);
  59908. _this.onCompileObservable.clear();
  59909. // Unbind mesh reference in fallbacks
  59910. if (_this._fallbacks) {
  59911. _this._fallbacks.unBindMesh();
  59912. }
  59913. if (previousProgram) {
  59914. _this.getEngine()._deleteProgram(previousProgram);
  59915. }
  59916. });
  59917. if (this._program.isParallelCompiled) {
  59918. this._checkIsReady();
  59919. }
  59920. }
  59921. catch (e) {
  59922. this._compilationError = e.message;
  59923. // Let's go through fallbacks then
  59924. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Unable to compile effect:");
  59925. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Uniforms: " + this._uniformsNames.map(function (uniform) {
  59926. return " " + uniform;
  59927. }));
  59928. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Attributes: " + attributesNames.map(function (attribute) {
  59929. return " " + attribute;
  59930. }));
  59931. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Error: " + this._compilationError);
  59932. if (previousProgram) {
  59933. this._program = previousProgram;
  59934. this._isReady = true;
  59935. if (this.onError) {
  59936. this.onError(this, this._compilationError);
  59937. }
  59938. this.onErrorObservable.notifyObservers(this);
  59939. }
  59940. if (fallbacks && fallbacks.isMoreFallbacks) {
  59941. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Trying next fallback.");
  59942. this.defines = fallbacks.reduce(this.defines, this);
  59943. this._prepareEffect();
  59944. }
  59945. else { // Sorry we did everything we can
  59946. if (this.onError) {
  59947. this.onError(this, this._compilationError);
  59948. }
  59949. this.onErrorObservable.notifyObservers(this);
  59950. this.onErrorObservable.clear();
  59951. // Unbind mesh reference in fallbacks
  59952. if (this._fallbacks) {
  59953. this._fallbacks.unBindMesh();
  59954. }
  59955. }
  59956. }
  59957. };
  59958. Object.defineProperty(Effect.prototype, "isSupported", {
  59959. /**
  59960. * Checks if the effect is supported. (Must be called after compilation)
  59961. */
  59962. get: function () {
  59963. return this._compilationError === "";
  59964. },
  59965. enumerable: true,
  59966. configurable: true
  59967. });
  59968. /**
  59969. * Binds a texture to the engine to be used as output of the shader.
  59970. * @param channel Name of the output variable.
  59971. * @param texture Texture to bind.
  59972. * @hidden
  59973. */
  59974. Effect.prototype._bindTexture = function (channel, texture) {
  59975. this._engine._bindTexture(this._samplers.indexOf(channel), texture);
  59976. };
  59977. /**
  59978. * Sets a texture on the engine to be used in the shader.
  59979. * @param channel Name of the sampler variable.
  59980. * @param texture Texture to set.
  59981. */
  59982. Effect.prototype.setTexture = function (channel, texture) {
  59983. this._engine.setTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  59984. };
  59985. /**
  59986. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  59987. * @param channel Name of the sampler variable.
  59988. * @param texture Texture to set.
  59989. */
  59990. Effect.prototype.setDepthStencilTexture = function (channel, texture) {
  59991. this._engine.setDepthStencilTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  59992. };
  59993. /**
  59994. * Sets an array of textures on the engine to be used in the shader.
  59995. * @param channel Name of the variable.
  59996. * @param textures Textures to set.
  59997. */
  59998. Effect.prototype.setTextureArray = function (channel, textures) {
  59999. if (this._samplers.indexOf(channel + "Ex") === -1) {
  60000. var initialPos = this._samplers.indexOf(channel);
  60001. for (var index = 1; index < textures.length; index++) {
  60002. this._samplers.splice(initialPos + index, 0, channel + "Ex");
  60003. }
  60004. }
  60005. this._engine.setTextureArray(this._samplers.indexOf(channel), this.getUniform(channel), textures);
  60006. };
  60007. /**
  60008. * 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)
  60009. * @param channel Name of the sampler variable.
  60010. * @param postProcess Post process to get the input texture from.
  60011. */
  60012. Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  60013. this._engine.setTextureFromPostProcess(this._samplers.indexOf(channel), postProcess);
  60014. };
  60015. /**
  60016. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  60017. * 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)
  60018. * @param channel Name of the sampler variable.
  60019. * @param postProcess Post process to get the output texture from.
  60020. */
  60021. Effect.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  60022. this._engine.setTextureFromPostProcessOutput(this._samplers.indexOf(channel), postProcess);
  60023. };
  60024. /** @hidden */
  60025. Effect.prototype._cacheMatrix = function (uniformName, matrix) {
  60026. var cache = this._valueCache[uniformName];
  60027. var flag = matrix.updateFlag;
  60028. if (cache !== undefined && cache === flag) {
  60029. return false;
  60030. }
  60031. this._valueCache[uniformName] = flag;
  60032. return true;
  60033. };
  60034. /** @hidden */
  60035. Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
  60036. var cache = this._valueCache[uniformName];
  60037. if (!cache) {
  60038. cache = [x, y];
  60039. this._valueCache[uniformName] = cache;
  60040. return true;
  60041. }
  60042. var changed = false;
  60043. if (cache[0] !== x) {
  60044. cache[0] = x;
  60045. changed = true;
  60046. }
  60047. if (cache[1] !== y) {
  60048. cache[1] = y;
  60049. changed = true;
  60050. }
  60051. return changed;
  60052. };
  60053. /** @hidden */
  60054. Effect.prototype._cacheFloat3 = function (uniformName, x, y, z) {
  60055. var cache = this._valueCache[uniformName];
  60056. if (!cache) {
  60057. cache = [x, y, z];
  60058. this._valueCache[uniformName] = cache;
  60059. return true;
  60060. }
  60061. var changed = false;
  60062. if (cache[0] !== x) {
  60063. cache[0] = x;
  60064. changed = true;
  60065. }
  60066. if (cache[1] !== y) {
  60067. cache[1] = y;
  60068. changed = true;
  60069. }
  60070. if (cache[2] !== z) {
  60071. cache[2] = z;
  60072. changed = true;
  60073. }
  60074. return changed;
  60075. };
  60076. /** @hidden */
  60077. Effect.prototype._cacheFloat4 = function (uniformName, x, y, z, w) {
  60078. var cache = this._valueCache[uniformName];
  60079. if (!cache) {
  60080. cache = [x, y, z, w];
  60081. this._valueCache[uniformName] = cache;
  60082. return true;
  60083. }
  60084. var changed = false;
  60085. if (cache[0] !== x) {
  60086. cache[0] = x;
  60087. changed = true;
  60088. }
  60089. if (cache[1] !== y) {
  60090. cache[1] = y;
  60091. changed = true;
  60092. }
  60093. if (cache[2] !== z) {
  60094. cache[2] = z;
  60095. changed = true;
  60096. }
  60097. if (cache[3] !== w) {
  60098. cache[3] = w;
  60099. changed = true;
  60100. }
  60101. return changed;
  60102. };
  60103. /**
  60104. * Binds a buffer to a uniform.
  60105. * @param buffer Buffer to bind.
  60106. * @param name Name of the uniform variable to bind to.
  60107. */
  60108. Effect.prototype.bindUniformBuffer = function (buffer, name) {
  60109. var bufferName = this._uniformBuffersNames[name];
  60110. if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {
  60111. return;
  60112. }
  60113. Effect._baseCache[bufferName] = buffer;
  60114. this._engine.bindUniformBufferBase(buffer, bufferName);
  60115. };
  60116. /**
  60117. * Binds block to a uniform.
  60118. * @param blockName Name of the block to bind.
  60119. * @param index Index to bind.
  60120. */
  60121. Effect.prototype.bindUniformBlock = function (blockName, index) {
  60122. this._engine.bindUniformBlock(this._program, blockName, index);
  60123. };
  60124. /**
  60125. * Sets an interger value on a uniform variable.
  60126. * @param uniformName Name of the variable.
  60127. * @param value Value to be set.
  60128. * @returns this effect.
  60129. */
  60130. Effect.prototype.setInt = function (uniformName, value) {
  60131. var cache = this._valueCache[uniformName];
  60132. if (cache !== undefined && cache === value) {
  60133. return this;
  60134. }
  60135. this._valueCache[uniformName] = value;
  60136. this._engine.setInt(this.getUniform(uniformName), value);
  60137. return this;
  60138. };
  60139. /**
  60140. * Sets an int array on a uniform variable.
  60141. * @param uniformName Name of the variable.
  60142. * @param array array to be set.
  60143. * @returns this effect.
  60144. */
  60145. Effect.prototype.setIntArray = function (uniformName, array) {
  60146. this._valueCache[uniformName] = null;
  60147. this._engine.setIntArray(this.getUniform(uniformName), array);
  60148. return this;
  60149. };
  60150. /**
  60151. * 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)
  60152. * @param uniformName Name of the variable.
  60153. * @param array array to be set.
  60154. * @returns this effect.
  60155. */
  60156. Effect.prototype.setIntArray2 = function (uniformName, array) {
  60157. this._valueCache[uniformName] = null;
  60158. this._engine.setIntArray2(this.getUniform(uniformName), array);
  60159. return this;
  60160. };
  60161. /**
  60162. * 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)
  60163. * @param uniformName Name of the variable.
  60164. * @param array array to be set.
  60165. * @returns this effect.
  60166. */
  60167. Effect.prototype.setIntArray3 = function (uniformName, array) {
  60168. this._valueCache[uniformName] = null;
  60169. this._engine.setIntArray3(this.getUniform(uniformName), array);
  60170. return this;
  60171. };
  60172. /**
  60173. * 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)
  60174. * @param uniformName Name of the variable.
  60175. * @param array array to be set.
  60176. * @returns this effect.
  60177. */
  60178. Effect.prototype.setIntArray4 = function (uniformName, array) {
  60179. this._valueCache[uniformName] = null;
  60180. this._engine.setIntArray4(this.getUniform(uniformName), array);
  60181. return this;
  60182. };
  60183. /**
  60184. * Sets an float array on a uniform variable.
  60185. * @param uniformName Name of the variable.
  60186. * @param array array to be set.
  60187. * @returns this effect.
  60188. */
  60189. Effect.prototype.setFloatArray = function (uniformName, array) {
  60190. this._valueCache[uniformName] = null;
  60191. this._engine.setFloatArray(this.getUniform(uniformName), array);
  60192. return this;
  60193. };
  60194. /**
  60195. * 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)
  60196. * @param uniformName Name of the variable.
  60197. * @param array array to be set.
  60198. * @returns this effect.
  60199. */
  60200. Effect.prototype.setFloatArray2 = function (uniformName, array) {
  60201. this._valueCache[uniformName] = null;
  60202. this._engine.setFloatArray2(this.getUniform(uniformName), array);
  60203. return this;
  60204. };
  60205. /**
  60206. * 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)
  60207. * @param uniformName Name of the variable.
  60208. * @param array array to be set.
  60209. * @returns this effect.
  60210. */
  60211. Effect.prototype.setFloatArray3 = function (uniformName, array) {
  60212. this._valueCache[uniformName] = null;
  60213. this._engine.setFloatArray3(this.getUniform(uniformName), array);
  60214. return this;
  60215. };
  60216. /**
  60217. * 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)
  60218. * @param uniformName Name of the variable.
  60219. * @param array array to be set.
  60220. * @returns this effect.
  60221. */
  60222. Effect.prototype.setFloatArray4 = function (uniformName, array) {
  60223. this._valueCache[uniformName] = null;
  60224. this._engine.setFloatArray4(this.getUniform(uniformName), array);
  60225. return this;
  60226. };
  60227. /**
  60228. * Sets an array on a uniform variable.
  60229. * @param uniformName Name of the variable.
  60230. * @param array array to be set.
  60231. * @returns this effect.
  60232. */
  60233. Effect.prototype.setArray = function (uniformName, array) {
  60234. this._valueCache[uniformName] = null;
  60235. this._engine.setArray(this.getUniform(uniformName), array);
  60236. return this;
  60237. };
  60238. /**
  60239. * 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)
  60240. * @param uniformName Name of the variable.
  60241. * @param array array to be set.
  60242. * @returns this effect.
  60243. */
  60244. Effect.prototype.setArray2 = function (uniformName, array) {
  60245. this._valueCache[uniformName] = null;
  60246. this._engine.setArray2(this.getUniform(uniformName), array);
  60247. return this;
  60248. };
  60249. /**
  60250. * 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)
  60251. * @param uniformName Name of the variable.
  60252. * @param array array to be set.
  60253. * @returns this effect.
  60254. */
  60255. Effect.prototype.setArray3 = function (uniformName, array) {
  60256. this._valueCache[uniformName] = null;
  60257. this._engine.setArray3(this.getUniform(uniformName), array);
  60258. return this;
  60259. };
  60260. /**
  60261. * 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)
  60262. * @param uniformName Name of the variable.
  60263. * @param array array to be set.
  60264. * @returns this effect.
  60265. */
  60266. Effect.prototype.setArray4 = function (uniformName, array) {
  60267. this._valueCache[uniformName] = null;
  60268. this._engine.setArray4(this.getUniform(uniformName), array);
  60269. return this;
  60270. };
  60271. /**
  60272. * Sets matrices on a uniform variable.
  60273. * @param uniformName Name of the variable.
  60274. * @param matrices matrices to be set.
  60275. * @returns this effect.
  60276. */
  60277. Effect.prototype.setMatrices = function (uniformName, matrices) {
  60278. if (!matrices) {
  60279. return this;
  60280. }
  60281. this._valueCache[uniformName] = null;
  60282. this._engine.setMatrices(this.getUniform(uniformName), matrices);
  60283. return this;
  60284. };
  60285. /**
  60286. * Sets matrix on a uniform variable.
  60287. * @param uniformName Name of the variable.
  60288. * @param matrix matrix to be set.
  60289. * @returns this effect.
  60290. */
  60291. Effect.prototype.setMatrix = function (uniformName, matrix) {
  60292. if (this._cacheMatrix(uniformName, matrix)) {
  60293. this._engine.setMatrix(this.getUniform(uniformName), matrix);
  60294. }
  60295. return this;
  60296. };
  60297. /**
  60298. * 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)
  60299. * @param uniformName Name of the variable.
  60300. * @param matrix matrix to be set.
  60301. * @returns this effect.
  60302. */
  60303. Effect.prototype.setMatrix3x3 = function (uniformName, matrix) {
  60304. this._valueCache[uniformName] = null;
  60305. this._engine.setMatrix3x3(this.getUniform(uniformName), matrix);
  60306. return this;
  60307. };
  60308. /**
  60309. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  60310. * @param uniformName Name of the variable.
  60311. * @param matrix matrix to be set.
  60312. * @returns this effect.
  60313. */
  60314. Effect.prototype.setMatrix2x2 = function (uniformName, matrix) {
  60315. this._valueCache[uniformName] = null;
  60316. this._engine.setMatrix2x2(this.getUniform(uniformName), matrix);
  60317. return this;
  60318. };
  60319. /**
  60320. * Sets a float on a uniform variable.
  60321. * @param uniformName Name of the variable.
  60322. * @param value value to be set.
  60323. * @returns this effect.
  60324. */
  60325. Effect.prototype.setFloat = function (uniformName, value) {
  60326. var cache = this._valueCache[uniformName];
  60327. if (cache !== undefined && cache === value) {
  60328. return this;
  60329. }
  60330. this._valueCache[uniformName] = value;
  60331. this._engine.setFloat(this.getUniform(uniformName), value);
  60332. return this;
  60333. };
  60334. /**
  60335. * Sets a boolean on a uniform variable.
  60336. * @param uniformName Name of the variable.
  60337. * @param bool value to be set.
  60338. * @returns this effect.
  60339. */
  60340. Effect.prototype.setBool = function (uniformName, bool) {
  60341. var cache = this._valueCache[uniformName];
  60342. if (cache !== undefined && cache === bool) {
  60343. return this;
  60344. }
  60345. this._valueCache[uniformName] = bool;
  60346. this._engine.setBool(this.getUniform(uniformName), bool ? 1 : 0);
  60347. return this;
  60348. };
  60349. /**
  60350. * Sets a Vector2 on a uniform variable.
  60351. * @param uniformName Name of the variable.
  60352. * @param vector2 vector2 to be set.
  60353. * @returns this effect.
  60354. */
  60355. Effect.prototype.setVector2 = function (uniformName, vector2) {
  60356. if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {
  60357. this._engine.setFloat2(this.getUniform(uniformName), vector2.x, vector2.y);
  60358. }
  60359. return this;
  60360. };
  60361. /**
  60362. * Sets a float2 on a uniform variable.
  60363. * @param uniformName Name of the variable.
  60364. * @param x First float in float2.
  60365. * @param y Second float in float2.
  60366. * @returns this effect.
  60367. */
  60368. Effect.prototype.setFloat2 = function (uniformName, x, y) {
  60369. if (this._cacheFloat2(uniformName, x, y)) {
  60370. this._engine.setFloat2(this.getUniform(uniformName), x, y);
  60371. }
  60372. return this;
  60373. };
  60374. /**
  60375. * Sets a Vector3 on a uniform variable.
  60376. * @param uniformName Name of the variable.
  60377. * @param vector3 Value to be set.
  60378. * @returns this effect.
  60379. */
  60380. Effect.prototype.setVector3 = function (uniformName, vector3) {
  60381. if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {
  60382. this._engine.setFloat3(this.getUniform(uniformName), vector3.x, vector3.y, vector3.z);
  60383. }
  60384. return this;
  60385. };
  60386. /**
  60387. * Sets a float3 on a uniform variable.
  60388. * @param uniformName Name of the variable.
  60389. * @param x First float in float3.
  60390. * @param y Second float in float3.
  60391. * @param z Third float in float3.
  60392. * @returns this effect.
  60393. */
  60394. Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
  60395. if (this._cacheFloat3(uniformName, x, y, z)) {
  60396. this._engine.setFloat3(this.getUniform(uniformName), x, y, z);
  60397. }
  60398. return this;
  60399. };
  60400. /**
  60401. * Sets a Vector4 on a uniform variable.
  60402. * @param uniformName Name of the variable.
  60403. * @param vector4 Value to be set.
  60404. * @returns this effect.
  60405. */
  60406. Effect.prototype.setVector4 = function (uniformName, vector4) {
  60407. if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {
  60408. this._engine.setFloat4(this.getUniform(uniformName), vector4.x, vector4.y, vector4.z, vector4.w);
  60409. }
  60410. return this;
  60411. };
  60412. /**
  60413. * Sets a float4 on a uniform variable.
  60414. * @param uniformName Name of the variable.
  60415. * @param x First float in float4.
  60416. * @param y Second float in float4.
  60417. * @param z Third float in float4.
  60418. * @param w Fourth float in float4.
  60419. * @returns this effect.
  60420. */
  60421. Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
  60422. if (this._cacheFloat4(uniformName, x, y, z, w)) {
  60423. this._engine.setFloat4(this.getUniform(uniformName), x, y, z, w);
  60424. }
  60425. return this;
  60426. };
  60427. /**
  60428. * Sets a Color3 on a uniform variable.
  60429. * @param uniformName Name of the variable.
  60430. * @param color3 Value to be set.
  60431. * @returns this effect.
  60432. */
  60433. Effect.prototype.setColor3 = function (uniformName, color3) {
  60434. if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {
  60435. this._engine.setColor3(this.getUniform(uniformName), color3);
  60436. }
  60437. return this;
  60438. };
  60439. /**
  60440. * Sets a Color4 on a uniform variable.
  60441. * @param uniformName Name of the variable.
  60442. * @param color3 Value to be set.
  60443. * @param alpha Alpha value to be set.
  60444. * @returns this effect.
  60445. */
  60446. Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
  60447. if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {
  60448. this._engine.setColor4(this.getUniform(uniformName), color3, alpha);
  60449. }
  60450. return this;
  60451. };
  60452. /**
  60453. * Sets a Color4 on a uniform variable
  60454. * @param uniformName defines the name of the variable
  60455. * @param color4 defines the value to be set
  60456. * @returns this effect.
  60457. */
  60458. Effect.prototype.setDirectColor4 = function (uniformName, color4) {
  60459. if (this._cacheFloat4(uniformName, color4.r, color4.g, color4.b, color4.a)) {
  60460. this._engine.setDirectColor4(this.getUniform(uniformName), color4);
  60461. }
  60462. return this;
  60463. };
  60464. /**
  60465. * This function will add a new shader to the shader store
  60466. * @param name the name of the shader
  60467. * @param pixelShader optional pixel shader content
  60468. * @param vertexShader optional vertex shader content
  60469. */
  60470. Effect.RegisterShader = function (name, pixelShader, vertexShader) {
  60471. if (pixelShader) {
  60472. Effect.ShadersStore[name + "PixelShader"] = pixelShader;
  60473. }
  60474. if (vertexShader) {
  60475. Effect.ShadersStore[name + "VertexShader"] = vertexShader;
  60476. }
  60477. };
  60478. /**
  60479. * Resets the cache of effects.
  60480. */
  60481. Effect.ResetCache = function () {
  60482. Effect._baseCache = {};
  60483. };
  60484. /**
  60485. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  60486. */
  60487. Effect.ShadersRepository = "src/Shaders/";
  60488. Effect._uniqueIdSeed = 0;
  60489. Effect._baseCache = {};
  60490. /**
  60491. * Store of each shader (The can be looked up using effect.key)
  60492. */
  60493. Effect.ShadersStore = {};
  60494. /**
  60495. * Store of each included file for a shader (The can be looked up using effect.key)
  60496. */
  60497. Effect.IncludesShadersStore = {};
  60498. return Effect;
  60499. }());
  60500. /***/ }),
  60501. /***/ "./Materials/fresnelParameters.ts":
  60502. /*!****************************************!*\
  60503. !*** ./Materials/fresnelParameters.ts ***!
  60504. \****************************************/
  60505. /*! exports provided: FresnelParameters */
  60506. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60507. "use strict";
  60508. __webpack_require__.r(__webpack_exports__);
  60509. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return FresnelParameters; });
  60510. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  60511. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  60512. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  60513. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  60514. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  60515. /**
  60516. * This represents all the required information to add a fresnel effect on a material:
  60517. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  60518. */
  60519. var FresnelParameters = /** @class */ (function () {
  60520. function FresnelParameters() {
  60521. this._isEnabled = true;
  60522. /**
  60523. * Define the color used on edges (grazing angle)
  60524. */
  60525. this.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  60526. /**
  60527. * Define the color used on center
  60528. */
  60529. this.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  60530. /**
  60531. * Define bias applied to computed fresnel term
  60532. */
  60533. this.bias = 0;
  60534. /**
  60535. * Defined the power exponent applied to fresnel term
  60536. */
  60537. this.power = 1;
  60538. }
  60539. Object.defineProperty(FresnelParameters.prototype, "isEnabled", {
  60540. /**
  60541. * Define if the fresnel effect is enable or not.
  60542. */
  60543. get: function () {
  60544. return this._isEnabled;
  60545. },
  60546. set: function (value) {
  60547. if (this._isEnabled === value) {
  60548. return;
  60549. }
  60550. this._isEnabled = value;
  60551. _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);
  60552. },
  60553. enumerable: true,
  60554. configurable: true
  60555. });
  60556. /**
  60557. * Clones the current fresnel and its valuues
  60558. * @returns a clone fresnel configuration
  60559. */
  60560. FresnelParameters.prototype.clone = function () {
  60561. var newFresnelParameters = new FresnelParameters();
  60562. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newFresnelParameters);
  60563. return newFresnelParameters;
  60564. };
  60565. /**
  60566. * Serializes the current fresnel parameters to a JSON representation.
  60567. * @return the JSON serialization
  60568. */
  60569. FresnelParameters.prototype.serialize = function () {
  60570. var serializationObject = {};
  60571. serializationObject.isEnabled = this.isEnabled;
  60572. serializationObject.leftColor = this.leftColor.asArray();
  60573. serializationObject.rightColor = this.rightColor.asArray();
  60574. serializationObject.bias = this.bias;
  60575. serializationObject.power = this.power;
  60576. return serializationObject;
  60577. };
  60578. /**
  60579. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  60580. * @param parsedFresnelParameters Define the JSON representation
  60581. * @returns the parsed parameters
  60582. */
  60583. FresnelParameters.Parse = function (parsedFresnelParameters) {
  60584. var fresnelParameters = new FresnelParameters();
  60585. fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
  60586. fresnelParameters.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.leftColor);
  60587. fresnelParameters.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.rightColor);
  60588. fresnelParameters.bias = parsedFresnelParameters.bias;
  60589. fresnelParameters.power = parsedFresnelParameters.power || 1.0;
  60590. return fresnelParameters;
  60591. };
  60592. return FresnelParameters;
  60593. }());
  60594. // References the dependencies.
  60595. _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]._FresnelParametersParser = FresnelParameters.Parse;
  60596. /***/ }),
  60597. /***/ "./Materials/imageProcessingConfiguration.ts":
  60598. /*!***************************************************!*\
  60599. !*** ./Materials/imageProcessingConfiguration.ts ***!
  60600. \***************************************************/
  60601. /*! exports provided: ImageProcessingConfigurationDefines, ImageProcessingConfiguration */
  60602. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60603. "use strict";
  60604. __webpack_require__.r(__webpack_exports__);
  60605. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return ImageProcessingConfigurationDefines; });
  60606. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return ImageProcessingConfiguration; });
  60607. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60608. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  60609. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  60610. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  60611. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  60612. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  60613. /* harmony import */ var _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/colorCurves */ "./Materials/colorCurves.ts");
  60614. /**
  60615. * @hidden
  60616. */
  60617. var ImageProcessingConfigurationDefines = /** @class */ (function (_super) {
  60618. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingConfigurationDefines, _super);
  60619. function ImageProcessingConfigurationDefines() {
  60620. var _this = _super.call(this) || this;
  60621. _this.IMAGEPROCESSING = false;
  60622. _this.VIGNETTE = false;
  60623. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  60624. _this.VIGNETTEBLENDMODEOPAQUE = false;
  60625. _this.TONEMAPPING = false;
  60626. _this.TONEMAPPING_ACES = false;
  60627. _this.CONTRAST = false;
  60628. _this.COLORCURVES = false;
  60629. _this.COLORGRADING = false;
  60630. _this.COLORGRADING3D = false;
  60631. _this.SAMPLER3DGREENDEPTH = false;
  60632. _this.SAMPLER3DBGRMAP = false;
  60633. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  60634. _this.EXPOSURE = false;
  60635. _this.rebuild();
  60636. return _this;
  60637. }
  60638. return ImageProcessingConfigurationDefines;
  60639. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__["MaterialDefines"]));
  60640. /**
  60641. * This groups together the common properties used for image processing either in direct forward pass
  60642. * or through post processing effect depending on the use of the image processing pipeline in your scene
  60643. * or not.
  60644. */
  60645. var ImageProcessingConfiguration = /** @class */ (function () {
  60646. function ImageProcessingConfiguration() {
  60647. /**
  60648. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  60649. */
  60650. this.colorCurves = new _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"]();
  60651. this._colorCurvesEnabled = false;
  60652. this._colorGradingEnabled = false;
  60653. this._colorGradingWithGreenDepth = true;
  60654. this._colorGradingBGR = true;
  60655. /** @hidden */
  60656. this._exposure = 1.0;
  60657. this._toneMappingEnabled = false;
  60658. this._toneMappingType = ImageProcessingConfiguration.TONEMAPPING_STANDARD;
  60659. this._contrast = 1.0;
  60660. /**
  60661. * Vignette stretch size.
  60662. */
  60663. this.vignetteStretch = 0;
  60664. /**
  60665. * Vignette centre X Offset.
  60666. */
  60667. this.vignetteCentreX = 0;
  60668. /**
  60669. * Vignette centre Y Offset.
  60670. */
  60671. this.vignetteCentreY = 0;
  60672. /**
  60673. * Vignette weight or intensity of the vignette effect.
  60674. */
  60675. this.vignetteWeight = 1.5;
  60676. /**
  60677. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  60678. * if vignetteEnabled is set to true.
  60679. */
  60680. this.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  60681. /**
  60682. * Camera field of view used by the Vignette effect.
  60683. */
  60684. this.vignetteCameraFov = 0.5;
  60685. this._vignetteBlendMode = ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;
  60686. this._vignetteEnabled = false;
  60687. this._applyByPostProcess = false;
  60688. this._isEnabled = true;
  60689. /**
  60690. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  60691. */
  60692. this.onUpdateParameters = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  60693. }
  60694. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorCurvesEnabled", {
  60695. /**
  60696. * Gets wether the color curves effect is enabled.
  60697. */
  60698. get: function () {
  60699. return this._colorCurvesEnabled;
  60700. },
  60701. /**
  60702. * Sets wether the color curves effect is enabled.
  60703. */
  60704. set: function (value) {
  60705. if (this._colorCurvesEnabled === value) {
  60706. return;
  60707. }
  60708. this._colorCurvesEnabled = value;
  60709. this._updateParameters();
  60710. },
  60711. enumerable: true,
  60712. configurable: true
  60713. });
  60714. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingTexture", {
  60715. /**
  60716. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  60717. */
  60718. get: function () {
  60719. return this._colorGradingTexture;
  60720. },
  60721. /**
  60722. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  60723. */
  60724. set: function (value) {
  60725. if (this._colorGradingTexture === value) {
  60726. return;
  60727. }
  60728. this._colorGradingTexture = value;
  60729. this._updateParameters();
  60730. },
  60731. enumerable: true,
  60732. configurable: true
  60733. });
  60734. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingEnabled", {
  60735. /**
  60736. * Gets wether the color grading effect is enabled.
  60737. */
  60738. get: function () {
  60739. return this._colorGradingEnabled;
  60740. },
  60741. /**
  60742. * Sets wether the color grading effect is enabled.
  60743. */
  60744. set: function (value) {
  60745. if (this._colorGradingEnabled === value) {
  60746. return;
  60747. }
  60748. this._colorGradingEnabled = value;
  60749. this._updateParameters();
  60750. },
  60751. enumerable: true,
  60752. configurable: true
  60753. });
  60754. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingWithGreenDepth", {
  60755. /**
  60756. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  60757. */
  60758. get: function () {
  60759. return this._colorGradingWithGreenDepth;
  60760. },
  60761. /**
  60762. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  60763. */
  60764. set: function (value) {
  60765. if (this._colorGradingWithGreenDepth === value) {
  60766. return;
  60767. }
  60768. this._colorGradingWithGreenDepth = value;
  60769. this._updateParameters();
  60770. },
  60771. enumerable: true,
  60772. configurable: true
  60773. });
  60774. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingBGR", {
  60775. /**
  60776. * Gets wether the color grading texture contains BGR values.
  60777. */
  60778. get: function () {
  60779. return this._colorGradingBGR;
  60780. },
  60781. /**
  60782. * Sets wether the color grading texture contains BGR values.
  60783. */
  60784. set: function (value) {
  60785. if (this._colorGradingBGR === value) {
  60786. return;
  60787. }
  60788. this._colorGradingBGR = value;
  60789. this._updateParameters();
  60790. },
  60791. enumerable: true,
  60792. configurable: true
  60793. });
  60794. Object.defineProperty(ImageProcessingConfiguration.prototype, "exposure", {
  60795. /**
  60796. * Gets the Exposure used in the effect.
  60797. */
  60798. get: function () {
  60799. return this._exposure;
  60800. },
  60801. /**
  60802. * Sets the Exposure used in the effect.
  60803. */
  60804. set: function (value) {
  60805. if (this._exposure === value) {
  60806. return;
  60807. }
  60808. this._exposure = value;
  60809. this._updateParameters();
  60810. },
  60811. enumerable: true,
  60812. configurable: true
  60813. });
  60814. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingEnabled", {
  60815. /**
  60816. * Gets wether the tone mapping effect is enabled.
  60817. */
  60818. get: function () {
  60819. return this._toneMappingEnabled;
  60820. },
  60821. /**
  60822. * Sets wether the tone mapping effect is enabled.
  60823. */
  60824. set: function (value) {
  60825. if (this._toneMappingEnabled === value) {
  60826. return;
  60827. }
  60828. this._toneMappingEnabled = value;
  60829. this._updateParameters();
  60830. },
  60831. enumerable: true,
  60832. configurable: true
  60833. });
  60834. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingType", {
  60835. /**
  60836. * Gets the type of tone mapping effect.
  60837. */
  60838. get: function () {
  60839. return this._toneMappingType;
  60840. },
  60841. /**
  60842. * Sets the type of tone mapping effect used in BabylonJS.
  60843. */
  60844. set: function (value) {
  60845. if (this._toneMappingType === value) {
  60846. return;
  60847. }
  60848. this._toneMappingType = value;
  60849. this._updateParameters();
  60850. },
  60851. enumerable: true,
  60852. configurable: true
  60853. });
  60854. Object.defineProperty(ImageProcessingConfiguration.prototype, "contrast", {
  60855. /**
  60856. * Gets the contrast used in the effect.
  60857. */
  60858. get: function () {
  60859. return this._contrast;
  60860. },
  60861. /**
  60862. * Sets the contrast used in the effect.
  60863. */
  60864. set: function (value) {
  60865. if (this._contrast === value) {
  60866. return;
  60867. }
  60868. this._contrast = value;
  60869. this._updateParameters();
  60870. },
  60871. enumerable: true,
  60872. configurable: true
  60873. });
  60874. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteBlendMode", {
  60875. /**
  60876. * Gets the vignette blend mode allowing different kind of effect.
  60877. */
  60878. get: function () {
  60879. return this._vignetteBlendMode;
  60880. },
  60881. /**
  60882. * Sets the vignette blend mode allowing different kind of effect.
  60883. */
  60884. set: function (value) {
  60885. if (this._vignetteBlendMode === value) {
  60886. return;
  60887. }
  60888. this._vignetteBlendMode = value;
  60889. this._updateParameters();
  60890. },
  60891. enumerable: true,
  60892. configurable: true
  60893. });
  60894. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteEnabled", {
  60895. /**
  60896. * Gets wether the vignette effect is enabled.
  60897. */
  60898. get: function () {
  60899. return this._vignetteEnabled;
  60900. },
  60901. /**
  60902. * Sets wether the vignette effect is enabled.
  60903. */
  60904. set: function (value) {
  60905. if (this._vignetteEnabled === value) {
  60906. return;
  60907. }
  60908. this._vignetteEnabled = value;
  60909. this._updateParameters();
  60910. },
  60911. enumerable: true,
  60912. configurable: true
  60913. });
  60914. Object.defineProperty(ImageProcessingConfiguration.prototype, "applyByPostProcess", {
  60915. /**
  60916. * Gets wether the image processing is applied through a post process or not.
  60917. */
  60918. get: function () {
  60919. return this._applyByPostProcess;
  60920. },
  60921. /**
  60922. * Sets wether the image processing is applied through a post process or not.
  60923. */
  60924. set: function (value) {
  60925. if (this._applyByPostProcess === value) {
  60926. return;
  60927. }
  60928. this._applyByPostProcess = value;
  60929. this._updateParameters();
  60930. },
  60931. enumerable: true,
  60932. configurable: true
  60933. });
  60934. Object.defineProperty(ImageProcessingConfiguration.prototype, "isEnabled", {
  60935. /**
  60936. * Gets wether the image processing is enabled or not.
  60937. */
  60938. get: function () {
  60939. return this._isEnabled;
  60940. },
  60941. /**
  60942. * Sets wether the image processing is enabled or not.
  60943. */
  60944. set: function (value) {
  60945. if (this._isEnabled === value) {
  60946. return;
  60947. }
  60948. this._isEnabled = value;
  60949. this._updateParameters();
  60950. },
  60951. enumerable: true,
  60952. configurable: true
  60953. });
  60954. /**
  60955. * Method called each time the image processing information changes requires to recompile the effect.
  60956. */
  60957. ImageProcessingConfiguration.prototype._updateParameters = function () {
  60958. this.onUpdateParameters.notifyObservers(this);
  60959. };
  60960. /**
  60961. * Gets the current class name.
  60962. * @return "ImageProcessingConfiguration"
  60963. */
  60964. ImageProcessingConfiguration.prototype.getClassName = function () {
  60965. return "ImageProcessingConfiguration";
  60966. };
  60967. /**
  60968. * Prepare the list of uniforms associated with the Image Processing effects.
  60969. * @param uniforms The list of uniforms used in the effect
  60970. * @param defines the list of defines currently in use
  60971. */
  60972. ImageProcessingConfiguration.PrepareUniforms = function (uniforms, defines) {
  60973. if (defines.EXPOSURE) {
  60974. uniforms.push("exposureLinear");
  60975. }
  60976. if (defines.CONTRAST) {
  60977. uniforms.push("contrast");
  60978. }
  60979. if (defines.COLORGRADING) {
  60980. uniforms.push("colorTransformSettings");
  60981. }
  60982. if (defines.VIGNETTE) {
  60983. uniforms.push("vInverseScreenSize");
  60984. uniforms.push("vignetteSettings1");
  60985. uniforms.push("vignetteSettings2");
  60986. }
  60987. if (defines.COLORCURVES) {
  60988. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].PrepareUniforms(uniforms);
  60989. }
  60990. };
  60991. /**
  60992. * Prepare the list of samplers associated with the Image Processing effects.
  60993. * @param samplersList The list of uniforms used in the effect
  60994. * @param defines the list of defines currently in use
  60995. */
  60996. ImageProcessingConfiguration.PrepareSamplers = function (samplersList, defines) {
  60997. if (defines.COLORGRADING) {
  60998. samplersList.push("txColorTransform");
  60999. }
  61000. };
  61001. /**
  61002. * Prepare the list of defines associated to the shader.
  61003. * @param defines the list of defines to complete
  61004. * @param forPostProcess Define if we are currently in post process mode or not
  61005. */
  61006. ImageProcessingConfiguration.prototype.prepareDefines = function (defines, forPostProcess) {
  61007. if (forPostProcess === void 0) { forPostProcess = false; }
  61008. if (forPostProcess !== this.applyByPostProcess || !this._isEnabled) {
  61009. defines.VIGNETTE = false;
  61010. defines.TONEMAPPING = false;
  61011. defines.TONEMAPPING_ACES = false;
  61012. defines.CONTRAST = false;
  61013. defines.EXPOSURE = false;
  61014. defines.COLORCURVES = false;
  61015. defines.COLORGRADING = false;
  61016. defines.COLORGRADING3D = false;
  61017. defines.IMAGEPROCESSING = false;
  61018. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled;
  61019. return;
  61020. }
  61021. defines.VIGNETTE = this.vignetteEnabled;
  61022. defines.VIGNETTEBLENDMODEMULTIPLY = (this.vignetteBlendMode === ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY);
  61023. defines.VIGNETTEBLENDMODEOPAQUE = !defines.VIGNETTEBLENDMODEMULTIPLY;
  61024. defines.TONEMAPPING = this.toneMappingEnabled;
  61025. switch (this._toneMappingType) {
  61026. case ImageProcessingConfiguration.TONEMAPPING_ACES:
  61027. defines.TONEMAPPING_ACES = true;
  61028. break;
  61029. default:
  61030. defines.TONEMAPPING_ACES = false;
  61031. break;
  61032. }
  61033. defines.CONTRAST = (this.contrast !== 1.0);
  61034. defines.EXPOSURE = (this.exposure !== 1.0);
  61035. defines.COLORCURVES = (this.colorCurvesEnabled && !!this.colorCurves);
  61036. defines.COLORGRADING = (this.colorGradingEnabled && !!this.colorGradingTexture);
  61037. if (defines.COLORGRADING) {
  61038. defines.COLORGRADING3D = this.colorGradingTexture.is3D;
  61039. }
  61040. else {
  61041. defines.COLORGRADING3D = false;
  61042. }
  61043. defines.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth;
  61044. defines.SAMPLER3DBGRMAP = this.colorGradingBGR;
  61045. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess;
  61046. defines.IMAGEPROCESSING = defines.VIGNETTE || defines.TONEMAPPING || defines.CONTRAST || defines.EXPOSURE || defines.COLORCURVES || defines.COLORGRADING;
  61047. };
  61048. /**
  61049. * Returns true if all the image processing information are ready.
  61050. * @returns True if ready, otherwise, false
  61051. */
  61052. ImageProcessingConfiguration.prototype.isReady = function () {
  61053. // Color Grading texure can not be none blocking.
  61054. return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady();
  61055. };
  61056. /**
  61057. * Binds the image processing to the shader.
  61058. * @param effect The effect to bind to
  61059. * @param aspectRatio Define the current aspect ratio of the effect
  61060. */
  61061. ImageProcessingConfiguration.prototype.bind = function (effect, aspectRatio) {
  61062. if (aspectRatio === void 0) { aspectRatio = 1; }
  61063. // Color Curves
  61064. if (this._colorCurvesEnabled && this.colorCurves) {
  61065. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].Bind(this.colorCurves, effect);
  61066. }
  61067. // Vignette
  61068. if (this._vignetteEnabled) {
  61069. var inverseWidth = 1 / effect.getEngine().getRenderWidth();
  61070. var inverseHeight = 1 / effect.getEngine().getRenderHeight();
  61071. effect.setFloat2("vInverseScreenSize", inverseWidth, inverseHeight);
  61072. var vignetteScaleY = Math.tan(this.vignetteCameraFov * 0.5);
  61073. var vignetteScaleX = vignetteScaleY * aspectRatio;
  61074. var vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY);
  61075. vignetteScaleX = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch);
  61076. vignetteScaleY = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch);
  61077. effect.setFloat4("vignetteSettings1", vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY);
  61078. var vignettePower = -2.0 * this.vignetteWeight;
  61079. effect.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower);
  61080. }
  61081. // Exposure
  61082. effect.setFloat("exposureLinear", this.exposure);
  61083. // Contrast
  61084. effect.setFloat("contrast", this.contrast);
  61085. // Color transform settings
  61086. if (this.colorGradingTexture) {
  61087. effect.setTexture("txColorTransform", this.colorGradingTexture);
  61088. var textureSize = this.colorGradingTexture.getSize().height;
  61089. effect.setFloat4("colorTransformSettings", (textureSize - 1) / textureSize, // textureScale
  61090. 0.5 / textureSize, // textureOffset
  61091. textureSize, // textureSize
  61092. this.colorGradingTexture.level // weight
  61093. );
  61094. }
  61095. };
  61096. /**
  61097. * Clones the current image processing instance.
  61098. * @return The cloned image processing
  61099. */
  61100. ImageProcessingConfiguration.prototype.clone = function () {
  61101. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ImageProcessingConfiguration(); }, this);
  61102. };
  61103. /**
  61104. * Serializes the current image processing instance to a json representation.
  61105. * @return a JSON representation
  61106. */
  61107. ImageProcessingConfiguration.prototype.serialize = function () {
  61108. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  61109. };
  61110. /**
  61111. * Parses the image processing from a json representation.
  61112. * @param source the JSON source to parse
  61113. * @return The parsed image processing
  61114. */
  61115. ImageProcessingConfiguration.Parse = function (source) {
  61116. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ImageProcessingConfiguration(); }, source, null, null);
  61117. };
  61118. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_MULTIPLY", {
  61119. /**
  61120. * Used to apply the vignette as a mix with the pixel color.
  61121. */
  61122. get: function () {
  61123. return this._VIGNETTEMODE_MULTIPLY;
  61124. },
  61125. enumerable: true,
  61126. configurable: true
  61127. });
  61128. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_OPAQUE", {
  61129. /**
  61130. * Used to apply the vignette as a replacement of the pixel color.
  61131. */
  61132. get: function () {
  61133. return this._VIGNETTEMODE_OPAQUE;
  61134. },
  61135. enumerable: true,
  61136. configurable: true
  61137. });
  61138. /**
  61139. * Default tone mapping applied in BabylonJS.
  61140. */
  61141. ImageProcessingConfiguration.TONEMAPPING_STANDARD = 0;
  61142. /**
  61143. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  61144. * to other engines rendering to increase portability.
  61145. */
  61146. ImageProcessingConfiguration.TONEMAPPING_ACES = 1;
  61147. // Static constants associated to the image processing.
  61148. ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY = 0;
  61149. ImageProcessingConfiguration._VIGNETTEMODE_OPAQUE = 1;
  61150. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61151. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColorCurves"])()
  61152. ], ImageProcessingConfiguration.prototype, "colorCurves", void 0);
  61153. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61154. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61155. ], ImageProcessingConfiguration.prototype, "_colorCurvesEnabled", void 0);
  61156. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61157. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("colorGradingTexture")
  61158. ], ImageProcessingConfiguration.prototype, "_colorGradingTexture", void 0);
  61159. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61160. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61161. ], ImageProcessingConfiguration.prototype, "_colorGradingEnabled", void 0);
  61162. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61163. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61164. ], ImageProcessingConfiguration.prototype, "_colorGradingWithGreenDepth", void 0);
  61165. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61166. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61167. ], ImageProcessingConfiguration.prototype, "_colorGradingBGR", void 0);
  61168. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61169. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61170. ], ImageProcessingConfiguration.prototype, "_exposure", void 0);
  61171. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61172. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61173. ], ImageProcessingConfiguration.prototype, "_toneMappingEnabled", void 0);
  61174. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61175. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61176. ], ImageProcessingConfiguration.prototype, "_toneMappingType", void 0);
  61177. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61178. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61179. ], ImageProcessingConfiguration.prototype, "_contrast", void 0);
  61180. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61181. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61182. ], ImageProcessingConfiguration.prototype, "vignetteStretch", void 0);
  61183. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61184. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61185. ], ImageProcessingConfiguration.prototype, "vignetteCentreX", void 0);
  61186. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61187. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61188. ], ImageProcessingConfiguration.prototype, "vignetteCentreY", void 0);
  61189. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61190. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61191. ], ImageProcessingConfiguration.prototype, "vignetteWeight", void 0);
  61192. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61193. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  61194. ], ImageProcessingConfiguration.prototype, "vignetteColor", void 0);
  61195. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61196. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61197. ], ImageProcessingConfiguration.prototype, "vignetteCameraFov", void 0);
  61198. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61199. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61200. ], ImageProcessingConfiguration.prototype, "_vignetteBlendMode", void 0);
  61201. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61202. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61203. ], ImageProcessingConfiguration.prototype, "_vignetteEnabled", void 0);
  61204. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61205. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61206. ], ImageProcessingConfiguration.prototype, "_applyByPostProcess", void 0);
  61207. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  61208. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  61209. ], ImageProcessingConfiguration.prototype, "_isEnabled", void 0);
  61210. return ImageProcessingConfiguration;
  61211. }());
  61212. // References the dependencies.
  61213. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ImageProcessingConfigurationParser = ImageProcessingConfiguration.Parse;
  61214. /***/ }),
  61215. /***/ "./Materials/index.ts":
  61216. /*!****************************!*\
  61217. !*** ./Materials/index.ts ***!
  61218. \****************************/
  61219. /*! 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 */
  61220. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61221. "use strict";
  61222. __webpack_require__.r(__webpack_exports__);
  61223. /* harmony import */ var _Background_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Background/index */ "./Materials/Background/index.ts");
  61224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Background_index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  61225. /* harmony import */ var _colorCurves__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorCurves */ "./Materials/colorCurves.ts");
  61226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _colorCurves__WEBPACK_IMPORTED_MODULE_1__["ColorCurves"]; });
  61227. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  61228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectFallbacks"]; });
  61229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectCreationOptions"]; });
  61230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["Effect"]; });
  61231. /* harmony import */ var _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fresnelParameters */ "./Materials/fresnelParameters.ts");
  61232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__["FresnelParameters"]; });
  61233. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  61234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfigurationDefines"]; });
  61235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfiguration"]; });
  61236. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  61237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _material__WEBPACK_IMPORTED_MODULE_5__["Material"]; });
  61238. /* harmony import */ var _materialDefines__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./materialDefines */ "./Materials/materialDefines.ts");
  61239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _materialDefines__WEBPACK_IMPORTED_MODULE_6__["MaterialDefines"]; });
  61240. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  61241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"]; });
  61242. /* harmony import */ var _multiMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./multiMaterial */ "./Materials/multiMaterial.ts");
  61243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _multiMaterial__WEBPACK_IMPORTED_MODULE_8__["MultiMaterial"]; });
  61244. /* harmony import */ var _PBR_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./PBR/index */ "./Materials/PBR/index.ts");
  61245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseMaterial"]; });
  61246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseSimpleMaterial"]; });
  61247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterial"]; });
  61248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMetallicRoughnessMaterial"]; });
  61249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRSpecularGlossinessMaterial"]; });
  61250. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  61251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _pushMaterial__WEBPACK_IMPORTED_MODULE_10__["PushMaterial"]; });
  61252. /* harmony import */ var _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shaderMaterial */ "./Materials/shaderMaterial.ts");
  61253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__["ShaderMaterial"]; });
  61254. /* harmony import */ var _standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./standardMaterial */ "./Materials/standardMaterial.ts");
  61255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterialDefines"]; });
  61256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]; });
  61257. /* harmony import */ var _Textures_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Textures/index */ "./Materials/Textures/index.ts");
  61258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["BaseTexture"]; });
  61259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CubeTexture"]; });
  61260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["HDRCubeTexture"]; });
  61261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["InternalTexture"]; });
  61262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DummyInternalTextureTracker"]; });
  61263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MirrorTexture"]; });
  61264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MultiRenderTarget"]; });
  61265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture"]; });
  61266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RenderTargetTexture"]; });
  61267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["Texture"]; });
  61268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ColorGradingTexture"]; });
  61269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DynamicTexture"]; });
  61270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTexture"]; });
  61271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawCubeTexture"]; });
  61272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  61273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RefractionTexture"]; });
  61274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["VideoTexture"]; });
  61275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_DDSTextureLoader"]; });
  61276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_ENVTextureLoader"]; });
  61277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_KTXTextureLoader"]; });
  61278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_TGATextureLoader"]; });
  61279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CustomProceduralTexture"]; });
  61280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["NoiseProceduralTexture"]; });
  61281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTextureSceneComponent"]; });
  61282. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  61283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__["UniformBuffer"]; });
  61284. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  61285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _materialFlags__WEBPACK_IMPORTED_MODULE_15__["MaterialFlags"]; });
  61286. /***/ }),
  61287. /***/ "./Materials/material.ts":
  61288. /*!*******************************!*\
  61289. !*** ./Materials/material.ts ***!
  61290. \*******************************/
  61291. /*! exports provided: Material */
  61292. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61293. "use strict";
  61294. __webpack_require__.r(__webpack_exports__);
  61295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return Material; });
  61296. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61297. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  61298. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  61299. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  61300. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  61301. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  61302. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  61303. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  61304. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  61305. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  61306. /**
  61307. * Base class for the main features of a material in Babylon.js
  61308. */
  61309. var Material = /** @class */ (function () {
  61310. /**
  61311. * Creates a material instance
  61312. * @param name defines the name of the material
  61313. * @param scene defines the scene to reference
  61314. * @param doNotAdd specifies if the material should be added to the scene
  61315. */
  61316. function Material(name, scene, doNotAdd) {
  61317. /**
  61318. * Gets or sets user defined metadata
  61319. */
  61320. this.metadata = null;
  61321. /**
  61322. * For internal use only. Please do not use.
  61323. */
  61324. this.reservedDataStore = null;
  61325. /**
  61326. * Specifies if the ready state should be checked on each call
  61327. */
  61328. this.checkReadyOnEveryCall = false;
  61329. /**
  61330. * Specifies if the ready state should be checked once
  61331. */
  61332. this.checkReadyOnlyOnce = false;
  61333. /**
  61334. * The state of the material
  61335. */
  61336. this.state = "";
  61337. /**
  61338. * The alpha value of the material
  61339. */
  61340. this._alpha = 1.0;
  61341. /**
  61342. * Specifies if back face culling is enabled
  61343. */
  61344. this._backFaceCulling = true;
  61345. /**
  61346. * Specifies if the material should be serialized
  61347. */
  61348. this.doNotSerialize = false;
  61349. /**
  61350. * @hidden
  61351. */
  61352. this._storeEffectOnSubMeshes = false;
  61353. /**
  61354. * An event triggered when the material is disposed
  61355. */
  61356. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  61357. /**
  61358. * Stores the value of the alpha mode
  61359. */
  61360. this._alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  61361. /**
  61362. * Stores the state of the need depth pre-pass value
  61363. */
  61364. this._needDepthPrePass = false;
  61365. /**
  61366. * Specifies if depth writing should be disabled
  61367. */
  61368. this.disableDepthWrite = false;
  61369. /**
  61370. * Specifies if depth writing should be forced
  61371. */
  61372. this.forceDepthWrite = false;
  61373. /**
  61374. * Specifies if there should be a separate pass for culling
  61375. */
  61376. this.separateCullingPass = false;
  61377. /**
  61378. * Stores the state specifing if fog should be enabled
  61379. */
  61380. this._fogEnabled = true;
  61381. /**
  61382. * Stores the size of points
  61383. */
  61384. this.pointSize = 1.0;
  61385. /**
  61386. * Stores the z offset value
  61387. */
  61388. this.zOffset = 0;
  61389. /**
  61390. * @hidden
  61391. * Specifies if the material was previously ready
  61392. */
  61393. this._wasPreviouslyReady = false;
  61394. /**
  61395. * Stores the fill mode state
  61396. */
  61397. this._fillMode = Material.TriangleFillMode;
  61398. /** @hidden */
  61399. this._indexInSceneMaterialArray = -1;
  61400. this.name = name;
  61401. this.id = name || _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RandomId();
  61402. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  61403. this.uniqueId = this._scene.getUniqueId();
  61404. if (this._scene.useRightHandedSystem) {
  61405. this.sideOrientation = Material.ClockWiseSideOrientation;
  61406. }
  61407. else {
  61408. this.sideOrientation = Material.CounterClockWiseSideOrientation;
  61409. }
  61410. this._uniformBuffer = new _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__["UniformBuffer"](this._scene.getEngine());
  61411. this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
  61412. if (!doNotAdd) {
  61413. this._scene.addMaterial(this);
  61414. }
  61415. if (this._scene.useMaterialMeshMap) {
  61416. this.meshMap = {};
  61417. }
  61418. }
  61419. Object.defineProperty(Material.prototype, "alpha", {
  61420. /**
  61421. * Gets the alpha value of the material
  61422. */
  61423. get: function () {
  61424. return this._alpha;
  61425. },
  61426. /**
  61427. * Sets the alpha value of the material
  61428. */
  61429. set: function (value) {
  61430. if (this._alpha === value) {
  61431. return;
  61432. }
  61433. this._alpha = value;
  61434. this.markAsDirty(Material.MiscDirtyFlag);
  61435. },
  61436. enumerable: true,
  61437. configurable: true
  61438. });
  61439. Object.defineProperty(Material.prototype, "backFaceCulling", {
  61440. /**
  61441. * Gets the back-face culling state
  61442. */
  61443. get: function () {
  61444. return this._backFaceCulling;
  61445. },
  61446. /**
  61447. * Sets the back-face culling state
  61448. */
  61449. set: function (value) {
  61450. if (this._backFaceCulling === value) {
  61451. return;
  61452. }
  61453. this._backFaceCulling = value;
  61454. this.markAsDirty(Material.TextureDirtyFlag);
  61455. },
  61456. enumerable: true,
  61457. configurable: true
  61458. });
  61459. Object.defineProperty(Material.prototype, "hasRenderTargetTextures", {
  61460. /**
  61461. * Gets a boolean indicating that current material needs to register RTT
  61462. */
  61463. get: function () {
  61464. return false;
  61465. },
  61466. enumerable: true,
  61467. configurable: true
  61468. });
  61469. Object.defineProperty(Material.prototype, "onDispose", {
  61470. /**
  61471. * Called during a dispose event
  61472. */
  61473. set: function (callback) {
  61474. if (this._onDisposeObserver) {
  61475. this.onDisposeObservable.remove(this._onDisposeObserver);
  61476. }
  61477. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  61478. },
  61479. enumerable: true,
  61480. configurable: true
  61481. });
  61482. Object.defineProperty(Material.prototype, "onBindObservable", {
  61483. /**
  61484. * An event triggered when the material is bound
  61485. */
  61486. get: function () {
  61487. if (!this._onBindObservable) {
  61488. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  61489. }
  61490. return this._onBindObservable;
  61491. },
  61492. enumerable: true,
  61493. configurable: true
  61494. });
  61495. Object.defineProperty(Material.prototype, "onBind", {
  61496. /**
  61497. * Called during a bind event
  61498. */
  61499. set: function (callback) {
  61500. if (this._onBindObserver) {
  61501. this.onBindObservable.remove(this._onBindObserver);
  61502. }
  61503. this._onBindObserver = this.onBindObservable.add(callback);
  61504. },
  61505. enumerable: true,
  61506. configurable: true
  61507. });
  61508. Object.defineProperty(Material.prototype, "onUnBindObservable", {
  61509. /**
  61510. * An event triggered when the material is unbound
  61511. */
  61512. get: function () {
  61513. if (!this._onUnBindObservable) {
  61514. this._onUnBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  61515. }
  61516. return this._onUnBindObservable;
  61517. },
  61518. enumerable: true,
  61519. configurable: true
  61520. });
  61521. Object.defineProperty(Material.prototype, "alphaMode", {
  61522. /**
  61523. * Gets the value of the alpha mode
  61524. */
  61525. get: function () {
  61526. return this._alphaMode;
  61527. },
  61528. /**
  61529. * Sets the value of the alpha mode.
  61530. *
  61531. * | Value | Type | Description |
  61532. * | --- | --- | --- |
  61533. * | 0 | ALPHA_DISABLE | |
  61534. * | 1 | ALPHA_ADD | |
  61535. * | 2 | ALPHA_COMBINE | |
  61536. * | 3 | ALPHA_SUBTRACT | |
  61537. * | 4 | ALPHA_MULTIPLY | |
  61538. * | 5 | ALPHA_MAXIMIZED | |
  61539. * | 6 | ALPHA_ONEONE | |
  61540. * | 7 | ALPHA_PREMULTIPLIED | |
  61541. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  61542. * | 9 | ALPHA_INTERPOLATE | |
  61543. * | 10 | ALPHA_SCREENMODE | |
  61544. *
  61545. */
  61546. set: function (value) {
  61547. if (this._alphaMode === value) {
  61548. return;
  61549. }
  61550. this._alphaMode = value;
  61551. this.markAsDirty(Material.TextureDirtyFlag);
  61552. },
  61553. enumerable: true,
  61554. configurable: true
  61555. });
  61556. Object.defineProperty(Material.prototype, "needDepthPrePass", {
  61557. /**
  61558. * Gets the depth pre-pass value
  61559. */
  61560. get: function () {
  61561. return this._needDepthPrePass;
  61562. },
  61563. /**
  61564. * Sets the need depth pre-pass value
  61565. */
  61566. set: function (value) {
  61567. if (this._needDepthPrePass === value) {
  61568. return;
  61569. }
  61570. this._needDepthPrePass = value;
  61571. if (this._needDepthPrePass) {
  61572. this.checkReadyOnEveryCall = true;
  61573. }
  61574. },
  61575. enumerable: true,
  61576. configurable: true
  61577. });
  61578. Object.defineProperty(Material.prototype, "fogEnabled", {
  61579. /**
  61580. * Gets the value of the fog enabled state
  61581. */
  61582. get: function () {
  61583. return this._fogEnabled;
  61584. },
  61585. /**
  61586. * Sets the state for enabling fog
  61587. */
  61588. set: function (value) {
  61589. if (this._fogEnabled === value) {
  61590. return;
  61591. }
  61592. this._fogEnabled = value;
  61593. this.markAsDirty(Material.MiscDirtyFlag);
  61594. },
  61595. enumerable: true,
  61596. configurable: true
  61597. });
  61598. Object.defineProperty(Material.prototype, "wireframe", {
  61599. /**
  61600. * Gets a value specifying if wireframe mode is enabled
  61601. */
  61602. get: function () {
  61603. switch (this._fillMode) {
  61604. case Material.WireFrameFillMode:
  61605. case Material.LineListDrawMode:
  61606. case Material.LineLoopDrawMode:
  61607. case Material.LineStripDrawMode:
  61608. return true;
  61609. }
  61610. return this._scene.forceWireframe;
  61611. },
  61612. /**
  61613. * Sets the state of wireframe mode
  61614. */
  61615. set: function (value) {
  61616. this.fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
  61617. },
  61618. enumerable: true,
  61619. configurable: true
  61620. });
  61621. Object.defineProperty(Material.prototype, "pointsCloud", {
  61622. /**
  61623. * Gets the value specifying if point clouds are enabled
  61624. */
  61625. get: function () {
  61626. switch (this._fillMode) {
  61627. case Material.PointFillMode:
  61628. case Material.PointListDrawMode:
  61629. return true;
  61630. }
  61631. return this._scene.forcePointsCloud;
  61632. },
  61633. /**
  61634. * Sets the state of point cloud mode
  61635. */
  61636. set: function (value) {
  61637. this.fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
  61638. },
  61639. enumerable: true,
  61640. configurable: true
  61641. });
  61642. Object.defineProperty(Material.prototype, "fillMode", {
  61643. /**
  61644. * Gets the material fill mode
  61645. */
  61646. get: function () {
  61647. return this._fillMode;
  61648. },
  61649. /**
  61650. * Sets the material fill mode
  61651. */
  61652. set: function (value) {
  61653. if (this._fillMode === value) {
  61654. return;
  61655. }
  61656. this._fillMode = value;
  61657. this.markAsDirty(Material.MiscDirtyFlag);
  61658. },
  61659. enumerable: true,
  61660. configurable: true
  61661. });
  61662. /**
  61663. * Returns a string representation of the current material
  61664. * @param fullDetails defines a boolean indicating which levels of logging is desired
  61665. * @returns a string with material information
  61666. */
  61667. Material.prototype.toString = function (fullDetails) {
  61668. var ret = "Name: " + this.name;
  61669. if (fullDetails) {
  61670. }
  61671. return ret;
  61672. };
  61673. /**
  61674. * Gets the class name of the material
  61675. * @returns a string with the class name of the material
  61676. */
  61677. Material.prototype.getClassName = function () {
  61678. return "Material";
  61679. };
  61680. Object.defineProperty(Material.prototype, "isFrozen", {
  61681. /**
  61682. * Specifies if updates for the material been locked
  61683. */
  61684. get: function () {
  61685. return this.checkReadyOnlyOnce;
  61686. },
  61687. enumerable: true,
  61688. configurable: true
  61689. });
  61690. /**
  61691. * Locks updates for the material
  61692. */
  61693. Material.prototype.freeze = function () {
  61694. this.checkReadyOnlyOnce = true;
  61695. };
  61696. /**
  61697. * Unlocks updates for the material
  61698. */
  61699. Material.prototype.unfreeze = function () {
  61700. this.checkReadyOnlyOnce = false;
  61701. };
  61702. /**
  61703. * Specifies if the material is ready to be used
  61704. * @param mesh defines the mesh to check
  61705. * @param useInstances specifies if instances should be used
  61706. * @returns a boolean indicating if the material is ready to be used
  61707. */
  61708. Material.prototype.isReady = function (mesh, useInstances) {
  61709. return true;
  61710. };
  61711. /**
  61712. * Specifies that the submesh is ready to be used
  61713. * @param mesh defines the mesh to check
  61714. * @param subMesh defines which submesh to check
  61715. * @param useInstances specifies that instances should be used
  61716. * @returns a boolean indicating that the submesh is ready or not
  61717. */
  61718. Material.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  61719. return false;
  61720. };
  61721. /**
  61722. * Returns the material effect
  61723. * @returns the effect associated with the material
  61724. */
  61725. Material.prototype.getEffect = function () {
  61726. return this._effect;
  61727. };
  61728. /**
  61729. * Returns the current scene
  61730. * @returns a Scene
  61731. */
  61732. Material.prototype.getScene = function () {
  61733. return this._scene;
  61734. };
  61735. /**
  61736. * Specifies if the material will require alpha blending
  61737. * @returns a boolean specifying if alpha blending is needed
  61738. */
  61739. Material.prototype.needAlphaBlending = function () {
  61740. return (this.alpha < 1.0);
  61741. };
  61742. /**
  61743. * Specifies if the mesh will require alpha blending
  61744. * @param mesh defines the mesh to check
  61745. * @returns a boolean specifying if alpha blending is needed for the mesh
  61746. */
  61747. Material.prototype.needAlphaBlendingForMesh = function (mesh) {
  61748. return this.needAlphaBlending() || (mesh.visibility < 1.0) || mesh.hasVertexAlpha;
  61749. };
  61750. /**
  61751. * Specifies if this material should be rendered in alpha test mode
  61752. * @returns a boolean specifying if an alpha test is needed.
  61753. */
  61754. Material.prototype.needAlphaTesting = function () {
  61755. return false;
  61756. };
  61757. /**
  61758. * Gets the texture used for the alpha test
  61759. * @returns the texture to use for alpha testing
  61760. */
  61761. Material.prototype.getAlphaTestTexture = function () {
  61762. return null;
  61763. };
  61764. /**
  61765. * Marks the material to indicate that it needs to be re-calculated
  61766. */
  61767. Material.prototype.markDirty = function () {
  61768. this._wasPreviouslyReady = false;
  61769. };
  61770. /** @hidden */
  61771. Material.prototype._preBind = function (effect, overrideOrientation) {
  61772. if (overrideOrientation === void 0) { overrideOrientation = null; }
  61773. var engine = this._scene.getEngine();
  61774. var orientation = (overrideOrientation == null) ? this.sideOrientation : overrideOrientation;
  61775. var reverse = orientation === Material.ClockWiseSideOrientation;
  61776. engine.enableEffect(effect ? effect : this._effect);
  61777. engine.setState(this.backFaceCulling, this.zOffset, false, reverse);
  61778. return reverse;
  61779. };
  61780. /**
  61781. * Binds the material to the mesh
  61782. * @param world defines the world transformation matrix
  61783. * @param mesh defines the mesh to bind the material to
  61784. */
  61785. Material.prototype.bind = function (world, mesh) {
  61786. };
  61787. /**
  61788. * Binds the submesh to the material
  61789. * @param world defines the world transformation matrix
  61790. * @param mesh defines the mesh containing the submesh
  61791. * @param subMesh defines the submesh to bind the material to
  61792. */
  61793. Material.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  61794. };
  61795. /**
  61796. * Binds the world matrix to the material
  61797. * @param world defines the world transformation matrix
  61798. */
  61799. Material.prototype.bindOnlyWorldMatrix = function (world) {
  61800. };
  61801. /**
  61802. * Binds the scene's uniform buffer to the effect.
  61803. * @param effect defines the effect to bind to the scene uniform buffer
  61804. * @param sceneUbo defines the uniform buffer storing scene data
  61805. */
  61806. Material.prototype.bindSceneUniformBuffer = function (effect, sceneUbo) {
  61807. sceneUbo.bindToEffect(effect, "Scene");
  61808. };
  61809. /**
  61810. * Binds the view matrix to the effect
  61811. * @param effect defines the effect to bind the view matrix to
  61812. */
  61813. Material.prototype.bindView = function (effect) {
  61814. if (!this._useUBO) {
  61815. effect.setMatrix("view", this.getScene().getViewMatrix());
  61816. }
  61817. else {
  61818. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  61819. }
  61820. };
  61821. /**
  61822. * Binds the view projection matrix to the effect
  61823. * @param effect defines the effect to bind the view projection matrix to
  61824. */
  61825. Material.prototype.bindViewProjection = function (effect) {
  61826. if (!this._useUBO) {
  61827. effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  61828. }
  61829. else {
  61830. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  61831. }
  61832. };
  61833. /**
  61834. * Specifies if material alpha testing should be turned on for the mesh
  61835. * @param mesh defines the mesh to check
  61836. */
  61837. Material.prototype._shouldTurnAlphaTestOn = function (mesh) {
  61838. return (!this.needAlphaBlendingForMesh(mesh) && this.needAlphaTesting());
  61839. };
  61840. /**
  61841. * Processes to execute after binding the material to a mesh
  61842. * @param mesh defines the rendered mesh
  61843. */
  61844. Material.prototype._afterBind = function (mesh) {
  61845. this._scene._cachedMaterial = this;
  61846. if (mesh) {
  61847. this._scene._cachedVisibility = mesh.visibility;
  61848. }
  61849. else {
  61850. this._scene._cachedVisibility = 1;
  61851. }
  61852. if (this._onBindObservable && mesh) {
  61853. this._onBindObservable.notifyObservers(mesh);
  61854. }
  61855. if (this.disableDepthWrite) {
  61856. var engine = this._scene.getEngine();
  61857. this._cachedDepthWriteState = engine.getDepthWrite();
  61858. engine.setDepthWrite(false);
  61859. }
  61860. };
  61861. /**
  61862. * Unbinds the material from the mesh
  61863. */
  61864. Material.prototype.unbind = function () {
  61865. if (this._onUnBindObservable) {
  61866. this._onUnBindObservable.notifyObservers(this);
  61867. }
  61868. if (this.disableDepthWrite) {
  61869. var engine = this._scene.getEngine();
  61870. engine.setDepthWrite(this._cachedDepthWriteState);
  61871. }
  61872. };
  61873. /**
  61874. * Gets the active textures from the material
  61875. * @returns an array of textures
  61876. */
  61877. Material.prototype.getActiveTextures = function () {
  61878. return [];
  61879. };
  61880. /**
  61881. * Specifies if the material uses a texture
  61882. * @param texture defines the texture to check against the material
  61883. * @returns a boolean specifying if the material uses the texture
  61884. */
  61885. Material.prototype.hasTexture = function (texture) {
  61886. return false;
  61887. };
  61888. /**
  61889. * Makes a duplicate of the material, and gives it a new name
  61890. * @param name defines the new name for the duplicated material
  61891. * @returns the cloned material
  61892. */
  61893. Material.prototype.clone = function (name) {
  61894. return null;
  61895. };
  61896. /**
  61897. * Gets the meshes bound to the material
  61898. * @returns an array of meshes bound to the material
  61899. */
  61900. Material.prototype.getBindedMeshes = function () {
  61901. var _this = this;
  61902. if (this.meshMap) {
  61903. var result = new Array();
  61904. for (var meshId in this.meshMap) {
  61905. var mesh = this.meshMap[meshId];
  61906. if (mesh) {
  61907. result.push(mesh);
  61908. }
  61909. }
  61910. return result;
  61911. }
  61912. else {
  61913. var meshes = this._scene.meshes;
  61914. return meshes.filter(function (mesh) { return mesh.material === _this; });
  61915. }
  61916. };
  61917. /**
  61918. * Force shader compilation
  61919. * @param mesh defines the mesh associated with this material
  61920. * @param onCompiled defines a function to execute once the material is compiled
  61921. * @param options defines the options to configure the compilation
  61922. */
  61923. Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
  61924. var _this = this;
  61925. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  61926. var subMesh = new _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__["BaseSubMesh"]();
  61927. var scene = this.getScene();
  61928. var checkReady = function () {
  61929. if (!_this._scene || !_this._scene.getEngine()) {
  61930. return;
  61931. }
  61932. if (subMesh._materialDefines) {
  61933. subMesh._materialDefines._renderId = -1;
  61934. }
  61935. var clipPlaneState = scene.clipPlane;
  61936. if (localOptions.clipPlane) {
  61937. scene.clipPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"](0, 0, 0, 1);
  61938. }
  61939. if (_this._storeEffectOnSubMeshes) {
  61940. if (_this.isReadyForSubMesh(mesh, subMesh)) {
  61941. if (onCompiled) {
  61942. onCompiled(_this);
  61943. }
  61944. }
  61945. else {
  61946. setTimeout(checkReady, 16);
  61947. }
  61948. }
  61949. else {
  61950. if (_this.isReady()) {
  61951. if (onCompiled) {
  61952. onCompiled(_this);
  61953. }
  61954. }
  61955. else {
  61956. setTimeout(checkReady, 16);
  61957. }
  61958. }
  61959. if (localOptions.clipPlane) {
  61960. scene.clipPlane = clipPlaneState;
  61961. }
  61962. };
  61963. checkReady();
  61964. };
  61965. /**
  61966. * Force shader compilation
  61967. * @param mesh defines the mesh that will use this material
  61968. * @param options defines additional options for compiling the shaders
  61969. * @returns a promise that resolves when the compilation completes
  61970. */
  61971. Material.prototype.forceCompilationAsync = function (mesh, options) {
  61972. var _this = this;
  61973. return new Promise(function (resolve) {
  61974. _this.forceCompilation(mesh, function () {
  61975. resolve();
  61976. }, options);
  61977. });
  61978. };
  61979. /**
  61980. * Marks a define in the material to indicate that it needs to be re-computed
  61981. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  61982. */
  61983. Material.prototype.markAsDirty = function (flag) {
  61984. if (this.getScene().blockMaterialDirtyMechanism) {
  61985. return;
  61986. }
  61987. Material._DirtyCallbackArray.length = 0;
  61988. if (flag & Material.TextureDirtyFlag) {
  61989. Material._DirtyCallbackArray.push(Material._TextureDirtyCallBack);
  61990. }
  61991. if (flag & Material.LightDirtyFlag) {
  61992. Material._DirtyCallbackArray.push(Material._LightsDirtyCallBack);
  61993. }
  61994. if (flag & Material.FresnelDirtyFlag) {
  61995. Material._DirtyCallbackArray.push(Material._FresnelDirtyCallBack);
  61996. }
  61997. if (flag & Material.AttributesDirtyFlag) {
  61998. Material._DirtyCallbackArray.push(Material._AttributeDirtyCallBack);
  61999. }
  62000. if (flag & Material.MiscDirtyFlag) {
  62001. Material._DirtyCallbackArray.push(Material._MiscDirtyCallBack);
  62002. }
  62003. if (Material._DirtyCallbackArray.length) {
  62004. this._markAllSubMeshesAsDirty(Material._RunDirtyCallBacks);
  62005. }
  62006. this.getScene().resetCachedMaterial();
  62007. };
  62008. /**
  62009. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  62010. * @param func defines a function which checks material defines against the submeshes
  62011. */
  62012. Material.prototype._markAllSubMeshesAsDirty = function (func) {
  62013. if (this.getScene().blockMaterialDirtyMechanism) {
  62014. return;
  62015. }
  62016. var meshes = this.getScene().meshes;
  62017. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  62018. var mesh = meshes_1[_i];
  62019. if (!mesh.subMeshes) {
  62020. continue;
  62021. }
  62022. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  62023. var subMesh = _b[_a];
  62024. if (subMesh.getMaterial() !== this) {
  62025. continue;
  62026. }
  62027. if (!subMesh._materialDefines) {
  62028. continue;
  62029. }
  62030. func(subMesh._materialDefines);
  62031. }
  62032. }
  62033. };
  62034. /**
  62035. * Indicates that image processing needs to be re-calculated for all submeshes
  62036. */
  62037. Material.prototype._markAllSubMeshesAsImageProcessingDirty = function () {
  62038. this._markAllSubMeshesAsDirty(Material._ImageProcessingDirtyCallBack);
  62039. };
  62040. /**
  62041. * Indicates that textures need to be re-calculated for all submeshes
  62042. */
  62043. Material.prototype._markAllSubMeshesAsTexturesDirty = function () {
  62044. this._markAllSubMeshesAsDirty(Material._TextureDirtyCallBack);
  62045. };
  62046. /**
  62047. * Indicates that fresnel needs to be re-calculated for all submeshes
  62048. */
  62049. Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
  62050. this._markAllSubMeshesAsDirty(Material._FresnelDirtyCallBack);
  62051. };
  62052. /**
  62053. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  62054. */
  62055. Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
  62056. this._markAllSubMeshesAsDirty(Material._FresnelAndMiscDirtyCallBack);
  62057. };
  62058. /**
  62059. * Indicates that lights need to be re-calculated for all submeshes
  62060. */
  62061. Material.prototype._markAllSubMeshesAsLightsDirty = function () {
  62062. this._markAllSubMeshesAsDirty(Material._LightsDirtyCallBack);
  62063. };
  62064. /**
  62065. * Indicates that attributes need to be re-calculated for all submeshes
  62066. */
  62067. Material.prototype._markAllSubMeshesAsAttributesDirty = function () {
  62068. this._markAllSubMeshesAsDirty(Material._AttributeDirtyCallBack);
  62069. };
  62070. /**
  62071. * Indicates that misc needs to be re-calculated for all submeshes
  62072. */
  62073. Material.prototype._markAllSubMeshesAsMiscDirty = function () {
  62074. this._markAllSubMeshesAsDirty(Material._MiscDirtyCallBack);
  62075. };
  62076. /**
  62077. * Indicates that textures and misc need to be re-calculated for all submeshes
  62078. */
  62079. Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
  62080. this._markAllSubMeshesAsDirty(Material._TextureAndMiscDirtyCallBack);
  62081. };
  62082. /**
  62083. * Disposes the material
  62084. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  62085. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  62086. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  62087. */
  62088. Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  62089. var scene = this.getScene();
  62090. // Animations
  62091. scene.stopAnimation(this);
  62092. scene.freeProcessedMaterials();
  62093. // Remove from scene
  62094. scene.removeMaterial(this);
  62095. if (notBoundToMesh !== true) {
  62096. // Remove from meshes
  62097. if (this.meshMap) {
  62098. for (var meshId in this.meshMap) {
  62099. var mesh = this.meshMap[meshId];
  62100. if (mesh) {
  62101. mesh.material = null; // will set the entry in the map to undefined
  62102. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  62103. }
  62104. }
  62105. }
  62106. else {
  62107. var meshes = scene.meshes;
  62108. for (var _i = 0, meshes_2 = meshes; _i < meshes_2.length; _i++) {
  62109. var mesh = meshes_2[_i];
  62110. if (mesh.material === this) {
  62111. mesh.material = null;
  62112. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  62113. }
  62114. }
  62115. }
  62116. }
  62117. this._uniformBuffer.dispose();
  62118. // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
  62119. if (forceDisposeEffect && this._effect) {
  62120. if (!this._storeEffectOnSubMeshes) {
  62121. scene.getEngine()._releaseEffect(this._effect);
  62122. }
  62123. this._effect = null;
  62124. }
  62125. // Callback
  62126. this.onDisposeObservable.notifyObservers(this);
  62127. this.onDisposeObservable.clear();
  62128. if (this._onBindObservable) {
  62129. this._onBindObservable.clear();
  62130. }
  62131. if (this._onUnBindObservable) {
  62132. this._onUnBindObservable.clear();
  62133. }
  62134. };
  62135. /** @hidden */
  62136. Material.prototype.releaseVertexArrayObject = function (mesh, forceDisposeEffect) {
  62137. if (mesh.geometry) {
  62138. var geometry = (mesh.geometry);
  62139. var scene = this.getScene();
  62140. if (this._storeEffectOnSubMeshes) {
  62141. for (var _i = 0, _a = mesh.subMeshes; _i < _a.length; _i++) {
  62142. var subMesh = _a[_i];
  62143. geometry._releaseVertexArrayObject(subMesh._materialEffect);
  62144. if (forceDisposeEffect && subMesh._materialEffect) {
  62145. scene.getEngine()._releaseEffect(subMesh._materialEffect);
  62146. }
  62147. }
  62148. }
  62149. else {
  62150. geometry._releaseVertexArrayObject(this._effect);
  62151. }
  62152. }
  62153. };
  62154. /**
  62155. * Serializes this material
  62156. * @returns the serialized material object
  62157. */
  62158. Material.prototype.serialize = function () {
  62159. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  62160. };
  62161. /**
  62162. * Creates a material from parsed material data
  62163. * @param parsedMaterial defines parsed material data
  62164. * @param scene defines the hosting scene
  62165. * @param rootUrl defines the root URL to use to load textures
  62166. * @returns a new material
  62167. */
  62168. Material.Parse = function (parsedMaterial, scene, rootUrl) {
  62169. if (!parsedMaterial.customType) {
  62170. parsedMaterial.customType = "BABYLON.StandardMaterial";
  62171. }
  62172. else if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
  62173. parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
  62174. if (!BABYLON.LegacyPBRMaterial) {
  62175. _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.");
  62176. return;
  62177. }
  62178. }
  62179. var materialType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedMaterial.customType);
  62180. return materialType.Parse(parsedMaterial, scene, rootUrl);
  62181. };
  62182. /**
  62183. * Returns the triangle fill mode
  62184. */
  62185. Material.TriangleFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFillMode;
  62186. /**
  62187. * Returns the wireframe mode
  62188. */
  62189. Material.WireFrameFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_WireFrameFillMode;
  62190. /**
  62191. * Returns the point fill mode
  62192. */
  62193. Material.PointFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointFillMode;
  62194. /**
  62195. * Returns the point list draw mode
  62196. */
  62197. Material.PointListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointListDrawMode;
  62198. /**
  62199. * Returns the line list draw mode
  62200. */
  62201. Material.LineListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineListDrawMode;
  62202. /**
  62203. * Returns the line loop draw mode
  62204. */
  62205. Material.LineLoopDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineLoopDrawMode;
  62206. /**
  62207. * Returns the line strip draw mode
  62208. */
  62209. Material.LineStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineStripDrawMode;
  62210. /**
  62211. * Returns the triangle strip draw mode
  62212. */
  62213. Material.TriangleStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleStripDrawMode;
  62214. /**
  62215. * Returns the triangle fan draw mode
  62216. */
  62217. Material.TriangleFanDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFanDrawMode;
  62218. /**
  62219. * Stores the clock-wise side orientation
  62220. */
  62221. Material.ClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_ClockWiseSideOrientation;
  62222. /**
  62223. * Stores the counter clock-wise side orientation
  62224. */
  62225. Material.CounterClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_CounterClockWiseSideOrientation;
  62226. /**
  62227. * The dirty texture flag value
  62228. */
  62229. Material.TextureDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TextureDirtyFlag;
  62230. /**
  62231. * The dirty light flag value
  62232. */
  62233. Material.LightDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LightDirtyFlag;
  62234. /**
  62235. * The dirty fresnel flag value
  62236. */
  62237. Material.FresnelDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_FresnelDirtyFlag;
  62238. /**
  62239. * The dirty attribute flag value
  62240. */
  62241. Material.AttributesDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AttributesDirtyFlag;
  62242. /**
  62243. * The dirty misc flag value
  62244. */
  62245. Material.MiscDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_MiscDirtyFlag;
  62246. /**
  62247. * The all dirty flag value
  62248. */
  62249. Material.AllDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AllDirtyFlag;
  62250. Material._ImageProcessingDirtyCallBack = function (defines) { return defines.markAsImageProcessingDirty(); };
  62251. Material._TextureDirtyCallBack = function (defines) { return defines.markAsTexturesDirty(); };
  62252. Material._FresnelDirtyCallBack = function (defines) { return defines.markAsFresnelDirty(); };
  62253. Material._MiscDirtyCallBack = function (defines) { return defines.markAsMiscDirty(); };
  62254. Material._LightsDirtyCallBack = function (defines) { return defines.markAsLightDirty(); };
  62255. Material._AttributeDirtyCallBack = function (defines) { return defines.markAsAttributesDirty(); };
  62256. Material._FresnelAndMiscDirtyCallBack = function (defines) {
  62257. Material._FresnelDirtyCallBack(defines);
  62258. Material._MiscDirtyCallBack(defines);
  62259. };
  62260. Material._TextureAndMiscDirtyCallBack = function (defines) {
  62261. Material._TextureDirtyCallBack(defines);
  62262. Material._MiscDirtyCallBack(defines);
  62263. };
  62264. Material._DirtyCallbackArray = [];
  62265. Material._RunDirtyCallBacks = function (defines) {
  62266. for (var _i = 0, _a = Material._DirtyCallbackArray; _i < _a.length; _i++) {
  62267. var cb = _a[_i];
  62268. cb(defines);
  62269. }
  62270. };
  62271. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62272. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62273. ], Material.prototype, "id", void 0);
  62274. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62275. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62276. ], Material.prototype, "uniqueId", void 0);
  62277. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62278. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62279. ], Material.prototype, "name", void 0);
  62280. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62281. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62282. ], Material.prototype, "checkReadyOnEveryCall", void 0);
  62283. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62284. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62285. ], Material.prototype, "checkReadyOnlyOnce", void 0);
  62286. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62288. ], Material.prototype, "state", void 0);
  62289. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alpha")
  62291. ], Material.prototype, "_alpha", void 0);
  62292. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62293. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("backFaceCulling")
  62294. ], Material.prototype, "_backFaceCulling", void 0);
  62295. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62296. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62297. ], Material.prototype, "sideOrientation", void 0);
  62298. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62299. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alphaMode")
  62300. ], Material.prototype, "_alphaMode", void 0);
  62301. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62302. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62303. ], Material.prototype, "_needDepthPrePass", void 0);
  62304. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62305. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62306. ], Material.prototype, "disableDepthWrite", void 0);
  62307. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62308. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62309. ], Material.prototype, "forceDepthWrite", void 0);
  62310. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62311. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62312. ], Material.prototype, "separateCullingPass", void 0);
  62313. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62314. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("fogEnabled")
  62315. ], Material.prototype, "_fogEnabled", void 0);
  62316. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62317. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62318. ], Material.prototype, "pointSize", void 0);
  62319. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62320. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62321. ], Material.prototype, "zOffset", void 0);
  62322. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62323. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62324. ], Material.prototype, "wireframe", null);
  62325. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62326. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62327. ], Material.prototype, "pointsCloud", null);
  62328. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62329. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62330. ], Material.prototype, "fillMode", null);
  62331. return Material;
  62332. }());
  62333. /***/ }),
  62334. /***/ "./Materials/materialDefines.ts":
  62335. /*!**************************************!*\
  62336. !*** ./Materials/materialDefines.ts ***!
  62337. \**************************************/
  62338. /*! exports provided: MaterialDefines */
  62339. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62340. "use strict";
  62341. __webpack_require__.r(__webpack_exports__);
  62342. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return MaterialDefines; });
  62343. /**
  62344. * Manages the defines for the Material
  62345. */
  62346. var MaterialDefines = /** @class */ (function () {
  62347. function MaterialDefines() {
  62348. this._isDirty = true;
  62349. /** @hidden */
  62350. this._areLightsDirty = true;
  62351. /** @hidden */
  62352. this._areAttributesDirty = true;
  62353. /** @hidden */
  62354. this._areTexturesDirty = true;
  62355. /** @hidden */
  62356. this._areFresnelDirty = true;
  62357. /** @hidden */
  62358. this._areMiscDirty = true;
  62359. /** @hidden */
  62360. this._areImageProcessingDirty = true;
  62361. /** @hidden */
  62362. this._normals = false;
  62363. /** @hidden */
  62364. this._uvs = false;
  62365. /** @hidden */
  62366. this._needNormals = false;
  62367. /** @hidden */
  62368. this._needUVs = false;
  62369. }
  62370. Object.defineProperty(MaterialDefines.prototype, "isDirty", {
  62371. /**
  62372. * Specifies if the material needs to be re-calculated
  62373. */
  62374. get: function () {
  62375. return this._isDirty;
  62376. },
  62377. enumerable: true,
  62378. configurable: true
  62379. });
  62380. /**
  62381. * Marks the material to indicate that it has been re-calculated
  62382. */
  62383. MaterialDefines.prototype.markAsProcessed = function () {
  62384. this._isDirty = false;
  62385. this._areAttributesDirty = false;
  62386. this._areTexturesDirty = false;
  62387. this._areFresnelDirty = false;
  62388. this._areLightsDirty = false;
  62389. this._areMiscDirty = false;
  62390. this._areImageProcessingDirty = false;
  62391. };
  62392. /**
  62393. * Marks the material to indicate that it needs to be re-calculated
  62394. */
  62395. MaterialDefines.prototype.markAsUnprocessed = function () {
  62396. this._isDirty = true;
  62397. };
  62398. /**
  62399. * Marks the material to indicate all of its defines need to be re-calculated
  62400. */
  62401. MaterialDefines.prototype.markAllAsDirty = function () {
  62402. this._areTexturesDirty = true;
  62403. this._areAttributesDirty = true;
  62404. this._areLightsDirty = true;
  62405. this._areFresnelDirty = true;
  62406. this._areMiscDirty = true;
  62407. this._areImageProcessingDirty = true;
  62408. this._isDirty = true;
  62409. };
  62410. /**
  62411. * Marks the material to indicate that image processing needs to be re-calculated
  62412. */
  62413. MaterialDefines.prototype.markAsImageProcessingDirty = function () {
  62414. this._areImageProcessingDirty = true;
  62415. this._isDirty = true;
  62416. };
  62417. /**
  62418. * Marks the material to indicate the lights need to be re-calculated
  62419. */
  62420. MaterialDefines.prototype.markAsLightDirty = function () {
  62421. this._areLightsDirty = true;
  62422. this._isDirty = true;
  62423. };
  62424. /**
  62425. * Marks the attribute state as changed
  62426. */
  62427. MaterialDefines.prototype.markAsAttributesDirty = function () {
  62428. this._areAttributesDirty = true;
  62429. this._isDirty = true;
  62430. };
  62431. /**
  62432. * Marks the texture state as changed
  62433. */
  62434. MaterialDefines.prototype.markAsTexturesDirty = function () {
  62435. this._areTexturesDirty = true;
  62436. this._isDirty = true;
  62437. };
  62438. /**
  62439. * Marks the fresnel state as changed
  62440. */
  62441. MaterialDefines.prototype.markAsFresnelDirty = function () {
  62442. this._areFresnelDirty = true;
  62443. this._isDirty = true;
  62444. };
  62445. /**
  62446. * Marks the misc state as changed
  62447. */
  62448. MaterialDefines.prototype.markAsMiscDirty = function () {
  62449. this._areMiscDirty = true;
  62450. this._isDirty = true;
  62451. };
  62452. /**
  62453. * Rebuilds the material defines
  62454. */
  62455. MaterialDefines.prototype.rebuild = function () {
  62456. if (this._keys) {
  62457. delete this._keys;
  62458. }
  62459. this._keys = [];
  62460. for (var _i = 0, _a = Object.keys(this); _i < _a.length; _i++) {
  62461. var key = _a[_i];
  62462. if (key[0] === "_") {
  62463. continue;
  62464. }
  62465. this._keys.push(key);
  62466. }
  62467. };
  62468. /**
  62469. * Specifies if two material defines are equal
  62470. * @param other - A material define instance to compare to
  62471. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  62472. */
  62473. MaterialDefines.prototype.isEqual = function (other) {
  62474. if (this._keys.length !== other._keys.length) {
  62475. return false;
  62476. }
  62477. for (var index = 0; index < this._keys.length; index++) {
  62478. var prop = this._keys[index];
  62479. if (this[prop] !== other[prop]) {
  62480. return false;
  62481. }
  62482. }
  62483. return true;
  62484. };
  62485. /**
  62486. * Clones this instance's defines to another instance
  62487. * @param other - material defines to clone values to
  62488. */
  62489. MaterialDefines.prototype.cloneTo = function (other) {
  62490. if (this._keys.length !== other._keys.length) {
  62491. other._keys = this._keys.slice(0);
  62492. }
  62493. for (var index = 0; index < this._keys.length; index++) {
  62494. var prop = this._keys[index];
  62495. other[prop] = this[prop];
  62496. }
  62497. };
  62498. /**
  62499. * Resets the material define values
  62500. */
  62501. MaterialDefines.prototype.reset = function () {
  62502. for (var index = 0; index < this._keys.length; index++) {
  62503. var prop = this._keys[index];
  62504. var type = typeof this[prop];
  62505. switch (type) {
  62506. case "number":
  62507. this[prop] = 0;
  62508. break;
  62509. case "string":
  62510. this[prop] = "";
  62511. break;
  62512. default:
  62513. this[prop] = false;
  62514. break;
  62515. }
  62516. }
  62517. };
  62518. /**
  62519. * Converts the material define values to a string
  62520. * @returns - String of material define information
  62521. */
  62522. MaterialDefines.prototype.toString = function () {
  62523. var result = "";
  62524. for (var index = 0; index < this._keys.length; index++) {
  62525. var prop = this._keys[index];
  62526. var value = this[prop];
  62527. var type = typeof value;
  62528. switch (type) {
  62529. case "number":
  62530. case "string":
  62531. result += "#define " + prop + " " + value + "\n";
  62532. break;
  62533. default:
  62534. if (value) {
  62535. result += "#define " + prop + "\n";
  62536. }
  62537. break;
  62538. }
  62539. }
  62540. return result;
  62541. };
  62542. return MaterialDefines;
  62543. }());
  62544. /***/ }),
  62545. /***/ "./Materials/materialFlags.ts":
  62546. /*!************************************!*\
  62547. !*** ./Materials/materialFlags.ts ***!
  62548. \************************************/
  62549. /*! exports provided: MaterialFlags */
  62550. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62551. "use strict";
  62552. __webpack_require__.r(__webpack_exports__);
  62553. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return MaterialFlags; });
  62554. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  62555. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  62556. /**
  62557. * This groups all the flags used to control the materials channel.
  62558. */
  62559. var MaterialFlags = /** @class */ (function () {
  62560. function MaterialFlags() {
  62561. }
  62562. Object.defineProperty(MaterialFlags, "DiffuseTextureEnabled", {
  62563. /**
  62564. * Are diffuse textures enabled in the application.
  62565. */
  62566. get: function () {
  62567. return this._DiffuseTextureEnabled;
  62568. },
  62569. set: function (value) {
  62570. if (this._DiffuseTextureEnabled === value) {
  62571. return;
  62572. }
  62573. this._DiffuseTextureEnabled = value;
  62574. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62575. },
  62576. enumerable: true,
  62577. configurable: true
  62578. });
  62579. Object.defineProperty(MaterialFlags, "AmbientTextureEnabled", {
  62580. /**
  62581. * Are ambient textures enabled in the application.
  62582. */
  62583. get: function () {
  62584. return this._AmbientTextureEnabled;
  62585. },
  62586. set: function (value) {
  62587. if (this._AmbientTextureEnabled === value) {
  62588. return;
  62589. }
  62590. this._AmbientTextureEnabled = value;
  62591. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62592. },
  62593. enumerable: true,
  62594. configurable: true
  62595. });
  62596. Object.defineProperty(MaterialFlags, "OpacityTextureEnabled", {
  62597. /**
  62598. * Are opacity textures enabled in the application.
  62599. */
  62600. get: function () {
  62601. return this._OpacityTextureEnabled;
  62602. },
  62603. set: function (value) {
  62604. if (this._OpacityTextureEnabled === value) {
  62605. return;
  62606. }
  62607. this._OpacityTextureEnabled = value;
  62608. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62609. },
  62610. enumerable: true,
  62611. configurable: true
  62612. });
  62613. Object.defineProperty(MaterialFlags, "ReflectionTextureEnabled", {
  62614. /**
  62615. * Are reflection textures enabled in the application.
  62616. */
  62617. get: function () {
  62618. return this._ReflectionTextureEnabled;
  62619. },
  62620. set: function (value) {
  62621. if (this._ReflectionTextureEnabled === value) {
  62622. return;
  62623. }
  62624. this._ReflectionTextureEnabled = value;
  62625. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62626. },
  62627. enumerable: true,
  62628. configurable: true
  62629. });
  62630. Object.defineProperty(MaterialFlags, "EmissiveTextureEnabled", {
  62631. /**
  62632. * Are emissive textures enabled in the application.
  62633. */
  62634. get: function () {
  62635. return this._EmissiveTextureEnabled;
  62636. },
  62637. set: function (value) {
  62638. if (this._EmissiveTextureEnabled === value) {
  62639. return;
  62640. }
  62641. this._EmissiveTextureEnabled = value;
  62642. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62643. },
  62644. enumerable: true,
  62645. configurable: true
  62646. });
  62647. Object.defineProperty(MaterialFlags, "SpecularTextureEnabled", {
  62648. /**
  62649. * Are specular textures enabled in the application.
  62650. */
  62651. get: function () {
  62652. return this._SpecularTextureEnabled;
  62653. },
  62654. set: function (value) {
  62655. if (this._SpecularTextureEnabled === value) {
  62656. return;
  62657. }
  62658. this._SpecularTextureEnabled = value;
  62659. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62660. },
  62661. enumerable: true,
  62662. configurable: true
  62663. });
  62664. Object.defineProperty(MaterialFlags, "BumpTextureEnabled", {
  62665. /**
  62666. * Are bump textures enabled in the application.
  62667. */
  62668. get: function () {
  62669. return this._BumpTextureEnabled;
  62670. },
  62671. set: function (value) {
  62672. if (this._BumpTextureEnabled === value) {
  62673. return;
  62674. }
  62675. this._BumpTextureEnabled = value;
  62676. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62677. },
  62678. enumerable: true,
  62679. configurable: true
  62680. });
  62681. Object.defineProperty(MaterialFlags, "LightmapTextureEnabled", {
  62682. /**
  62683. * Are lightmap textures enabled in the application.
  62684. */
  62685. get: function () {
  62686. return this._LightmapTextureEnabled;
  62687. },
  62688. set: function (value) {
  62689. if (this._LightmapTextureEnabled === value) {
  62690. return;
  62691. }
  62692. this._LightmapTextureEnabled = value;
  62693. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62694. },
  62695. enumerable: true,
  62696. configurable: true
  62697. });
  62698. Object.defineProperty(MaterialFlags, "RefractionTextureEnabled", {
  62699. /**
  62700. * Are refraction textures enabled in the application.
  62701. */
  62702. get: function () {
  62703. return this._RefractionTextureEnabled;
  62704. },
  62705. set: function (value) {
  62706. if (this._RefractionTextureEnabled === value) {
  62707. return;
  62708. }
  62709. this._RefractionTextureEnabled = value;
  62710. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62711. },
  62712. enumerable: true,
  62713. configurable: true
  62714. });
  62715. Object.defineProperty(MaterialFlags, "ColorGradingTextureEnabled", {
  62716. /**
  62717. * Are color grading textures enabled in the application.
  62718. */
  62719. get: function () {
  62720. return this._ColorGradingTextureEnabled;
  62721. },
  62722. set: function (value) {
  62723. if (this._ColorGradingTextureEnabled === value) {
  62724. return;
  62725. }
  62726. this._ColorGradingTextureEnabled = value;
  62727. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  62728. },
  62729. enumerable: true,
  62730. configurable: true
  62731. });
  62732. Object.defineProperty(MaterialFlags, "FresnelEnabled", {
  62733. /**
  62734. * Are fresnels enabled in the application.
  62735. */
  62736. get: function () {
  62737. return this._FresnelEnabled;
  62738. },
  62739. set: function (value) {
  62740. if (this._FresnelEnabled === value) {
  62741. return;
  62742. }
  62743. this._FresnelEnabled = value;
  62744. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_FresnelDirtyFlag);
  62745. },
  62746. enumerable: true,
  62747. configurable: true
  62748. });
  62749. // Flags used to enable or disable a type of texture for all Standard Materials
  62750. MaterialFlags._DiffuseTextureEnabled = true;
  62751. MaterialFlags._AmbientTextureEnabled = true;
  62752. MaterialFlags._OpacityTextureEnabled = true;
  62753. MaterialFlags._ReflectionTextureEnabled = true;
  62754. MaterialFlags._EmissiveTextureEnabled = true;
  62755. MaterialFlags._SpecularTextureEnabled = true;
  62756. MaterialFlags._BumpTextureEnabled = true;
  62757. MaterialFlags._LightmapTextureEnabled = true;
  62758. MaterialFlags._RefractionTextureEnabled = true;
  62759. MaterialFlags._ColorGradingTextureEnabled = true;
  62760. MaterialFlags._FresnelEnabled = true;
  62761. return MaterialFlags;
  62762. }());
  62763. /***/ }),
  62764. /***/ "./Materials/materialHelper.ts":
  62765. /*!*************************************!*\
  62766. !*** ./Materials/materialHelper.ts ***!
  62767. \*************************************/
  62768. /*! exports provided: MaterialHelper */
  62769. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62770. "use strict";
  62771. __webpack_require__.r(__webpack_exports__);
  62772. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return MaterialHelper; });
  62773. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  62774. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  62775. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  62776. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  62777. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  62778. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Lights/light */ "./Lights/light.ts");
  62779. /**
  62780. * "Static Class" containing the most commonly used helper while dealing with material for
  62781. * rendering purpose.
  62782. *
  62783. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  62784. *
  62785. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  62786. */
  62787. var MaterialHelper = /** @class */ (function () {
  62788. function MaterialHelper() {
  62789. }
  62790. /**
  62791. * Bind the current view position to an effect.
  62792. * @param effect The effect to be bound
  62793. * @param scene The scene the eyes position is used from
  62794. */
  62795. MaterialHelper.BindEyePosition = function (effect, scene) {
  62796. if (scene._forcedViewPosition) {
  62797. effect.setVector3("vEyePosition", scene._forcedViewPosition);
  62798. return;
  62799. }
  62800. effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  62801. };
  62802. /**
  62803. * Helps preparing the defines values about the UVs in used in the effect.
  62804. * UVs are shared as much as we can accross channels in the shaders.
  62805. * @param texture The texture we are preparing the UVs for
  62806. * @param defines The defines to update
  62807. * @param key The channel key "diffuse", "specular"... used in the shader
  62808. */
  62809. MaterialHelper.PrepareDefinesForMergedUV = function (texture, defines, key) {
  62810. defines._needUVs = true;
  62811. defines[key] = true;
  62812. if (texture.getTextureMatrix().isIdentityAs3x2()) {
  62813. defines[key + "DIRECTUV"] = texture.coordinatesIndex + 1;
  62814. if (texture.coordinatesIndex === 0) {
  62815. defines["MAINUV1"] = true;
  62816. }
  62817. else {
  62818. defines["MAINUV2"] = true;
  62819. }
  62820. }
  62821. else {
  62822. defines[key + "DIRECTUV"] = 0;
  62823. }
  62824. };
  62825. /**
  62826. * Binds a texture matrix value to its corrsponding uniform
  62827. * @param texture The texture to bind the matrix for
  62828. * @param uniformBuffer The uniform buffer receivin the data
  62829. * @param key The channel key "diffuse", "specular"... used in the shader
  62830. */
  62831. MaterialHelper.BindTextureMatrix = function (texture, uniformBuffer, key) {
  62832. var matrix = texture.getTextureMatrix();
  62833. if (!matrix.isIdentityAs3x2()) {
  62834. uniformBuffer.updateMatrix(key + "Matrix", matrix);
  62835. }
  62836. };
  62837. /**
  62838. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  62839. * @param mesh defines the current mesh
  62840. * @param scene defines the current scene
  62841. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  62842. * @param pointsCloud defines if point cloud rendering has to be turned on
  62843. * @param fogEnabled defines if fog has to be turned on
  62844. * @param alphaTest defines if alpha testing has to be turned on
  62845. * @param defines defines the current list of defines
  62846. */
  62847. MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
  62848. if (defines._areMiscDirty) {
  62849. defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
  62850. defines["POINTSIZE"] = pointsCloud;
  62851. defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE && fogEnabled);
  62852. defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
  62853. defines["ALPHATEST"] = alphaTest;
  62854. }
  62855. };
  62856. /**
  62857. * Helper used to prepare the list of defines associated with frame values for shader compilation
  62858. * @param scene defines the current scene
  62859. * @param engine defines the current engine
  62860. * @param defines specifies the list of active defines
  62861. * @param useInstances defines if instances have to be turned on
  62862. * @param useClipPlane defines if clip plane have to be turned on
  62863. */
  62864. MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, useClipPlane) {
  62865. if (useClipPlane === void 0) { useClipPlane = null; }
  62866. var changed = false;
  62867. var useClipPlane1 = false;
  62868. var useClipPlane2 = false;
  62869. var useClipPlane3 = false;
  62870. var useClipPlane4 = false;
  62871. useClipPlane1 = useClipPlane == null ? (scene.clipPlane !== undefined && scene.clipPlane !== null) : useClipPlane;
  62872. useClipPlane2 = useClipPlane == null ? (scene.clipPlane2 !== undefined && scene.clipPlane2 !== null) : useClipPlane;
  62873. useClipPlane3 = useClipPlane == null ? (scene.clipPlane3 !== undefined && scene.clipPlane3 !== null) : useClipPlane;
  62874. useClipPlane4 = useClipPlane == null ? (scene.clipPlane4 !== undefined && scene.clipPlane4 !== null) : useClipPlane;
  62875. if (defines["CLIPPLANE"] !== useClipPlane1) {
  62876. defines["CLIPPLANE"] = useClipPlane1;
  62877. changed = true;
  62878. }
  62879. if (defines["CLIPPLANE2"] !== useClipPlane2) {
  62880. defines["CLIPPLANE2"] = useClipPlane2;
  62881. changed = true;
  62882. }
  62883. if (defines["CLIPPLANE3"] !== useClipPlane3) {
  62884. defines["CLIPPLANE3"] = useClipPlane3;
  62885. changed = true;
  62886. }
  62887. if (defines["CLIPPLANE4"] !== useClipPlane4) {
  62888. defines["CLIPPLANE4"] = useClipPlane4;
  62889. changed = true;
  62890. }
  62891. if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
  62892. defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
  62893. changed = true;
  62894. }
  62895. if (defines["INSTANCES"] !== useInstances) {
  62896. defines["INSTANCES"] = useInstances;
  62897. changed = true;
  62898. }
  62899. if (changed) {
  62900. defines.markAsUnprocessed();
  62901. }
  62902. };
  62903. /**
  62904. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  62905. * @param mesh The mesh containing the geometry data we will draw
  62906. * @param defines The defines to update
  62907. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  62908. * @param useBones Precise whether bones should be used or not (override mesh info)
  62909. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  62910. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  62911. * @returns false if defines are considered not dirty and have not been checked
  62912. */
  62913. MaterialHelper.PrepareDefinesForAttributes = function (mesh, defines, useVertexColor, useBones, useMorphTargets, useVertexAlpha) {
  62914. if (useMorphTargets === void 0) { useMorphTargets = false; }
  62915. if (useVertexAlpha === void 0) { useVertexAlpha = true; }
  62916. if (!defines._areAttributesDirty && defines._needNormals === defines._normals && defines._needUVs === defines._uvs) {
  62917. return false;
  62918. }
  62919. defines._normals = defines._needNormals;
  62920. defines._uvs = defines._needUVs;
  62921. defines["NORMAL"] = (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind));
  62922. if (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind)) {
  62923. defines["TANGENT"] = true;
  62924. }
  62925. if (defines._needUVs) {
  62926. defines["UV1"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  62927. defines["UV2"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  62928. }
  62929. else {
  62930. defines["UV1"] = false;
  62931. defines["UV2"] = false;
  62932. }
  62933. if (useVertexColor) {
  62934. var hasVertexColors = mesh.useVertexColors && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  62935. defines["VERTEXCOLOR"] = hasVertexColors;
  62936. defines["VERTEXALPHA"] = mesh.hasVertexAlpha && hasVertexColors && useVertexAlpha;
  62937. }
  62938. if (useBones) {
  62939. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  62940. defines["NUM_BONE_INFLUENCERS"] = mesh.numBoneInfluencers;
  62941. var materialSupportsBoneTexture = defines["BONETEXTURE"] !== undefined;
  62942. if (mesh.skeleton.isUsingTextureForMatrices && materialSupportsBoneTexture) {
  62943. defines["BONETEXTURE"] = true;
  62944. }
  62945. else {
  62946. defines["BonesPerMesh"] = (mesh.skeleton.bones.length + 1);
  62947. defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
  62948. }
  62949. }
  62950. else {
  62951. defines["NUM_BONE_INFLUENCERS"] = 0;
  62952. defines["BonesPerMesh"] = 0;
  62953. }
  62954. }
  62955. if (useMorphTargets) {
  62956. var manager = mesh.morphTargetManager;
  62957. if (manager) {
  62958. defines["MORPHTARGETS_TANGENT"] = manager.supportsTangents && defines["TANGENT"];
  62959. defines["MORPHTARGETS_NORMAL"] = manager.supportsNormals && defines["NORMAL"];
  62960. defines["MORPHTARGETS"] = (manager.numInfluencers > 0);
  62961. defines["NUM_MORPH_INFLUENCERS"] = manager.numInfluencers;
  62962. }
  62963. else {
  62964. defines["MORPHTARGETS_TANGENT"] = false;
  62965. defines["MORPHTARGETS_NORMAL"] = false;
  62966. defines["MORPHTARGETS"] = false;
  62967. defines["NUM_MORPH_INFLUENCERS"] = 0;
  62968. }
  62969. }
  62970. return true;
  62971. };
  62972. /**
  62973. * Prepares the defines related to the light information passed in parameter
  62974. * @param scene The scene we are intending to draw
  62975. * @param mesh The mesh the effect is compiling for
  62976. * @param defines The defines to update
  62977. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  62978. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  62979. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  62980. * @returns true if normals will be required for the rest of the effect
  62981. */
  62982. MaterialHelper.PrepareDefinesForLights = function (scene, mesh, defines, specularSupported, maxSimultaneousLights, disableLighting) {
  62983. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  62984. if (disableLighting === void 0) { disableLighting = false; }
  62985. if (!defines._areLightsDirty) {
  62986. return defines._needNormals;
  62987. }
  62988. var lightIndex = 0;
  62989. var needNormals = false;
  62990. var needRebuild = false;
  62991. var lightmapMode = false;
  62992. var shadowEnabled = false;
  62993. var specularEnabled = false;
  62994. if (scene.lightsEnabled && !disableLighting) {
  62995. for (var _i = 0, _a = mesh._lightSources; _i < _a.length; _i++) {
  62996. var light = _a[_i];
  62997. needNormals = true;
  62998. if (defines["LIGHT" + lightIndex] === undefined) {
  62999. needRebuild = true;
  63000. }
  63001. defines["LIGHT" + lightIndex] = true;
  63002. defines["SPOTLIGHT" + lightIndex] = false;
  63003. defines["HEMILIGHT" + lightIndex] = false;
  63004. defines["POINTLIGHT" + lightIndex] = false;
  63005. defines["DIRLIGHT" + lightIndex] = false;
  63006. light.prepareLightSpecificDefines(defines, lightIndex);
  63007. // FallOff.
  63008. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = false;
  63009. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = false;
  63010. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = false;
  63011. switch (light.falloffType) {
  63012. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_GLTF:
  63013. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = true;
  63014. break;
  63015. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_PHYSICAL:
  63016. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = true;
  63017. break;
  63018. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_STANDARD:
  63019. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = true;
  63020. break;
  63021. }
  63022. // Specular
  63023. if (specularSupported && !light.specular.equalsFloats(0, 0, 0)) {
  63024. specularEnabled = true;
  63025. }
  63026. // Shadows
  63027. defines["SHADOW" + lightIndex] = false;
  63028. defines["SHADOWPCF" + lightIndex] = false;
  63029. defines["SHADOWPCSS" + lightIndex] = false;
  63030. defines["SHADOWPOISSON" + lightIndex] = false;
  63031. defines["SHADOWESM" + lightIndex] = false;
  63032. defines["SHADOWCUBE" + lightIndex] = false;
  63033. defines["SHADOWLOWQUALITY" + lightIndex] = false;
  63034. defines["SHADOWMEDIUMQUALITY" + lightIndex] = false;
  63035. if (mesh && mesh.receiveShadows && scene.shadowsEnabled && light.shadowEnabled) {
  63036. var shadowGenerator = light.getShadowGenerator();
  63037. if (shadowGenerator) {
  63038. var shadowMap = shadowGenerator.getShadowMap();
  63039. if (shadowMap) {
  63040. if (shadowMap.renderList && shadowMap.renderList.length > 0) {
  63041. shadowEnabled = true;
  63042. shadowGenerator.prepareDefines(defines, lightIndex);
  63043. }
  63044. }
  63045. }
  63046. }
  63047. if (light.lightmapMode != _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_DEFAULT) {
  63048. lightmapMode = true;
  63049. defines["LIGHTMAPEXCLUDED" + lightIndex] = true;
  63050. defines["LIGHTMAPNOSPECULAR" + lightIndex] = (light.lightmapMode == _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_SHADOWSONLY);
  63051. }
  63052. else {
  63053. defines["LIGHTMAPEXCLUDED" + lightIndex] = false;
  63054. defines["LIGHTMAPNOSPECULAR" + lightIndex] = false;
  63055. }
  63056. lightIndex++;
  63057. if (lightIndex === maxSimultaneousLights) {
  63058. break;
  63059. }
  63060. }
  63061. }
  63062. defines["SPECULARTERM"] = specularEnabled;
  63063. defines["SHADOWS"] = shadowEnabled;
  63064. // Resetting all other lights if any
  63065. for (var index = lightIndex; index < maxSimultaneousLights; index++) {
  63066. if (defines["LIGHT" + index] !== undefined) {
  63067. defines["LIGHT" + index] = false;
  63068. defines["HEMILIGHT" + lightIndex] = false;
  63069. defines["POINTLIGHT" + lightIndex] = false;
  63070. defines["DIRLIGHT" + lightIndex] = false;
  63071. defines["SPOTLIGHT" + lightIndex] = false;
  63072. defines["SHADOW" + lightIndex] = false;
  63073. }
  63074. }
  63075. var caps = scene.getEngine().getCaps();
  63076. if (defines["SHADOWFLOAT"] === undefined) {
  63077. needRebuild = true;
  63078. }
  63079. defines["SHADOWFLOAT"] = shadowEnabled &&
  63080. ((caps.textureFloatRender && caps.textureFloatLinearFiltering) ||
  63081. (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering));
  63082. defines["LIGHTMAPEXCLUDED"] = lightmapMode;
  63083. if (needRebuild) {
  63084. defines.rebuild();
  63085. }
  63086. return needNormals;
  63087. };
  63088. /**
  63089. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  63090. * that won t be acctive due to defines being turned off.
  63091. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  63092. * @param samplersList The samplers list
  63093. * @param defines The defines helping in the list generation
  63094. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  63095. */
  63096. MaterialHelper.PrepareUniformsAndSamplersList = function (uniformsListOrOptions, samplersList, defines, maxSimultaneousLights) {
  63097. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  63098. var uniformsList;
  63099. var uniformBuffersList = null;
  63100. if (uniformsListOrOptions.uniformsNames) {
  63101. var options = uniformsListOrOptions;
  63102. uniformsList = options.uniformsNames;
  63103. uniformBuffersList = options.uniformBuffersNames;
  63104. samplersList = options.samplers;
  63105. defines = options.defines;
  63106. maxSimultaneousLights = options.maxSimultaneousLights;
  63107. }
  63108. else {
  63109. uniformsList = uniformsListOrOptions;
  63110. if (!samplersList) {
  63111. samplersList = [];
  63112. }
  63113. }
  63114. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  63115. if (!defines["LIGHT" + lightIndex]) {
  63116. break;
  63117. }
  63118. uniformsList.push("vLightData" + lightIndex, "vLightDiffuse" + lightIndex, "vLightSpecular" + lightIndex, "vLightDirection" + lightIndex, "vLightFalloff" + lightIndex, "vLightGround" + lightIndex, "lightMatrix" + lightIndex, "shadowsInfo" + lightIndex, "depthValues" + lightIndex);
  63119. if (uniformBuffersList) {
  63120. uniformBuffersList.push("Light" + lightIndex);
  63121. }
  63122. samplersList.push("shadowSampler" + lightIndex);
  63123. samplersList.push("depthSampler" + lightIndex);
  63124. if (defines["PROJECTEDLIGHTTEXTURE" + lightIndex]) {
  63125. samplersList.push("projectionLightSampler" + lightIndex);
  63126. uniformsList.push("textureProjectionMatrix" + lightIndex);
  63127. }
  63128. }
  63129. if (defines["NUM_MORPH_INFLUENCERS"]) {
  63130. uniformsList.push("morphTargetInfluences");
  63131. }
  63132. };
  63133. /**
  63134. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  63135. * @param defines The defines to update while falling back
  63136. * @param fallbacks The authorized effect fallbacks
  63137. * @param maxSimultaneousLights The maximum number of lights allowed
  63138. * @param rank the current rank of the Effect
  63139. * @returns The newly affected rank
  63140. */
  63141. MaterialHelper.HandleFallbacksForShadows = function (defines, fallbacks, maxSimultaneousLights, rank) {
  63142. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  63143. if (rank === void 0) { rank = 0; }
  63144. var lightFallbackRank = 0;
  63145. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  63146. if (!defines["LIGHT" + lightIndex]) {
  63147. break;
  63148. }
  63149. if (lightIndex > 0) {
  63150. lightFallbackRank = rank + lightIndex;
  63151. fallbacks.addFallback(lightFallbackRank, "LIGHT" + lightIndex);
  63152. }
  63153. if (!defines["SHADOWS"]) {
  63154. if (defines["SHADOW" + lightIndex]) {
  63155. fallbacks.addFallback(rank, "SHADOW" + lightIndex);
  63156. }
  63157. if (defines["SHADOWPCF" + lightIndex]) {
  63158. fallbacks.addFallback(rank, "SHADOWPCF" + lightIndex);
  63159. }
  63160. if (defines["SHADOWPCSS" + lightIndex]) {
  63161. fallbacks.addFallback(rank, "SHADOWPCSS" + lightIndex);
  63162. }
  63163. if (defines["SHADOWPOISSON" + lightIndex]) {
  63164. fallbacks.addFallback(rank, "SHADOWPOISSON" + lightIndex);
  63165. }
  63166. if (defines["SHADOWESM" + lightIndex]) {
  63167. fallbacks.addFallback(rank, "SHADOWESM" + lightIndex);
  63168. }
  63169. }
  63170. }
  63171. return lightFallbackRank++;
  63172. };
  63173. /**
  63174. * Prepares the list of attributes required for morph targets according to the effect defines.
  63175. * @param attribs The current list of supported attribs
  63176. * @param mesh The mesh to prepare the morph targets attributes for
  63177. * @param defines The current Defines of the effect
  63178. */
  63179. MaterialHelper.PrepareAttributesForMorphTargets = function (attribs, mesh, defines) {
  63180. var influencers = defines["NUM_MORPH_INFLUENCERS"];
  63181. if (influencers > 0 && _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine) {
  63182. var maxAttributesCount = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine.getCaps().maxVertexAttribs;
  63183. var manager = mesh.morphTargetManager;
  63184. var normal = manager && manager.supportsNormals && defines["NORMAL"];
  63185. var tangent = manager && manager.supportsTangents && defines["TANGENT"];
  63186. for (var index = 0; index < influencers; index++) {
  63187. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind + index);
  63188. if (normal) {
  63189. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind + index);
  63190. }
  63191. if (tangent) {
  63192. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind + index);
  63193. }
  63194. if (attribs.length > maxAttributesCount) {
  63195. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add more vertex attributes for mesh " + mesh.name);
  63196. }
  63197. }
  63198. }
  63199. };
  63200. /**
  63201. * Prepares the list of attributes required for bones according to the effect defines.
  63202. * @param attribs The current list of supported attribs
  63203. * @param mesh The mesh to prepare the bones attributes for
  63204. * @param defines The current Defines of the effect
  63205. * @param fallbacks The current efffect fallback strategy
  63206. */
  63207. MaterialHelper.PrepareAttributesForBones = function (attribs, mesh, defines, fallbacks) {
  63208. if (defines["NUM_BONE_INFLUENCERS"] > 0) {
  63209. fallbacks.addCPUSkinningFallback(0, mesh);
  63210. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  63211. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  63212. if (defines["NUM_BONE_INFLUENCERS"] > 4) {
  63213. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesExtraKind);
  63214. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsExtraKind);
  63215. }
  63216. }
  63217. };
  63218. /**
  63219. * Prepares the list of attributes required for instances according to the effect defines.
  63220. * @param attribs The current list of supported attribs
  63221. * @param defines The current Defines of the effect
  63222. */
  63223. MaterialHelper.PrepareAttributesForInstances = function (attribs, defines) {
  63224. if (defines["INSTANCES"]) {
  63225. attribs.push("world0");
  63226. attribs.push("world1");
  63227. attribs.push("world2");
  63228. attribs.push("world3");
  63229. }
  63230. };
  63231. /**
  63232. * Binds the light shadow information to the effect for the given mesh.
  63233. * @param light The light containing the generator
  63234. * @param scene The scene the lights belongs to
  63235. * @param mesh The mesh we are binding the information to render
  63236. * @param lightIndex The light index in the effect used to render the mesh
  63237. * @param effect The effect we are binding the data to
  63238. */
  63239. MaterialHelper.BindLightShadow = function (light, mesh, lightIndex, effect) {
  63240. if (light.shadowEnabled && mesh.receiveShadows) {
  63241. var shadowGenerator = light.getShadowGenerator();
  63242. if (shadowGenerator) {
  63243. shadowGenerator.bindShadowLight(lightIndex, effect);
  63244. }
  63245. }
  63246. };
  63247. /**
  63248. * Binds the light information to the effect.
  63249. * @param light The light containing the generator
  63250. * @param effect The effect we are binding the data to
  63251. * @param lightIndex The light index in the effect used to render
  63252. */
  63253. MaterialHelper.BindLightProperties = function (light, effect, lightIndex) {
  63254. light.transferToEffect(effect, lightIndex + "");
  63255. };
  63256. /**
  63257. * Binds the lights information from the scene to the effect for the given mesh.
  63258. * @param scene The scene the lights belongs to
  63259. * @param mesh The mesh we are binding the information to render
  63260. * @param effect The effect we are binding the data to
  63261. * @param defines The generated defines for the effect
  63262. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  63263. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  63264. */
  63265. MaterialHelper.BindLights = function (scene, mesh, effect, defines, maxSimultaneousLights, usePhysicalLightFalloff) {
  63266. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  63267. if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
  63268. var len = Math.min(mesh._lightSources.length, maxSimultaneousLights);
  63269. for (var i = 0; i < len; i++) {
  63270. var light = mesh._lightSources[i];
  63271. var iAsString = i.toString();
  63272. var scaledIntensity = light.getScaledIntensity();
  63273. light._uniformBuffer.bindToEffect(effect, "Light" + i);
  63274. MaterialHelper.BindLightProperties(light, effect, i);
  63275. light.diffuse.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0]);
  63276. light._uniformBuffer.updateColor4("vLightDiffuse", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0], usePhysicalLightFalloff ? light.radius : light.range, iAsString);
  63277. if (defines["SPECULARTERM"]) {
  63278. light.specular.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1]);
  63279. light._uniformBuffer.updateColor3("vLightSpecular", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1], iAsString);
  63280. }
  63281. // Shadows
  63282. if (scene.shadowsEnabled) {
  63283. this.BindLightShadow(light, mesh, iAsString, effect);
  63284. }
  63285. light._uniformBuffer.update();
  63286. }
  63287. };
  63288. /**
  63289. * Binds the fog information from the scene to the effect for the given mesh.
  63290. * @param scene The scene the lights belongs to
  63291. * @param mesh The mesh we are binding the information to render
  63292. * @param effect The effect we are binding the data to
  63293. * @param linearSpace Defines if the fog effect is applied in linear space
  63294. */
  63295. MaterialHelper.BindFogParameters = function (scene, mesh, effect, linearSpace) {
  63296. if (linearSpace === void 0) { linearSpace = false; }
  63297. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
  63298. effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
  63299. // Convert fog color to linear space if used in a linear space computed shader.
  63300. if (linearSpace) {
  63301. scene.fogColor.toLinearSpaceToRef(this._tempFogColor);
  63302. effect.setColor3("vFogColor", this._tempFogColor);
  63303. }
  63304. else {
  63305. effect.setColor3("vFogColor", scene.fogColor);
  63306. }
  63307. }
  63308. };
  63309. /**
  63310. * Binds the bones information from the mesh to the effect.
  63311. * @param mesh The mesh we are binding the information to render
  63312. * @param effect The effect we are binding the data to
  63313. */
  63314. MaterialHelper.BindBonesParameters = function (mesh, effect) {
  63315. if (!effect || !mesh) {
  63316. return;
  63317. }
  63318. if (mesh.computeBonesUsingShaders && effect._bonesComputationForcedToCPU) {
  63319. mesh.computeBonesUsingShaders = false;
  63320. }
  63321. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  63322. var skeleton = mesh.skeleton;
  63323. if (skeleton.isUsingTextureForMatrices && effect.getUniformIndex("boneTextureWidth") > -1) {
  63324. var boneTexture = skeleton.getTransformMatrixTexture();
  63325. effect.setTexture("boneSampler", boneTexture);
  63326. effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  63327. }
  63328. else {
  63329. var matrices = skeleton.getTransformMatrices(mesh);
  63330. if (matrices) {
  63331. effect.setMatrices("mBones", matrices);
  63332. }
  63333. }
  63334. }
  63335. };
  63336. /**
  63337. * Binds the morph targets information from the mesh to the effect.
  63338. * @param abstractMesh The mesh we are binding the information to render
  63339. * @param effect The effect we are binding the data to
  63340. */
  63341. MaterialHelper.BindMorphTargetParameters = function (abstractMesh, effect) {
  63342. var manager = abstractMesh.morphTargetManager;
  63343. if (!abstractMesh || !manager) {
  63344. return;
  63345. }
  63346. effect.setFloatArray("morphTargetInfluences", manager.influences);
  63347. };
  63348. /**
  63349. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  63350. * @param defines The generated defines used in the effect
  63351. * @param effect The effect we are binding the data to
  63352. * @param scene The scene we are willing to render with logarithmic scale for
  63353. */
  63354. MaterialHelper.BindLogDepth = function (defines, effect, scene) {
  63355. if (defines["LOGARITHMICDEPTH"]) {
  63356. effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  63357. }
  63358. };
  63359. /**
  63360. * Binds the clip plane information from the scene to the effect.
  63361. * @param scene The scene the clip plane information are extracted from
  63362. * @param effect The effect we are binding the data to
  63363. */
  63364. MaterialHelper.BindClipPlane = function (effect, scene) {
  63365. if (scene.clipPlane) {
  63366. var clipPlane = scene.clipPlane;
  63367. effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  63368. }
  63369. if (scene.clipPlane2) {
  63370. var clipPlane = scene.clipPlane2;
  63371. effect.setFloat4("vClipPlane2", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  63372. }
  63373. if (scene.clipPlane3) {
  63374. var clipPlane = scene.clipPlane3;
  63375. effect.setFloat4("vClipPlane3", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  63376. }
  63377. if (scene.clipPlane4) {
  63378. var clipPlane = scene.clipPlane4;
  63379. effect.setFloat4("vClipPlane4", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  63380. }
  63381. };
  63382. MaterialHelper._tempFogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  63383. return MaterialHelper;
  63384. }());
  63385. /***/ }),
  63386. /***/ "./Materials/multiMaterial.ts":
  63387. /*!************************************!*\
  63388. !*** ./Materials/multiMaterial.ts ***!
  63389. \************************************/
  63390. /*! exports provided: MultiMaterial */
  63391. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63392. "use strict";
  63393. __webpack_require__.r(__webpack_exports__);
  63394. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return MultiMaterial; });
  63395. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  63396. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  63397. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  63398. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  63399. /**
  63400. * A multi-material is used to apply different materials to different parts of the same object without the need of
  63401. * separate meshes. This can be use to improve performances.
  63402. * @see http://doc.babylonjs.com/how_to/multi_materials
  63403. */
  63404. var MultiMaterial = /** @class */ (function (_super) {
  63405. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiMaterial, _super);
  63406. /**
  63407. * Instantiates a new Multi Material
  63408. * A multi-material is used to apply different materials to different parts of the same object without the need of
  63409. * separate meshes. This can be use to improve performances.
  63410. * @see http://doc.babylonjs.com/how_to/multi_materials
  63411. * @param name Define the name in the scene
  63412. * @param scene Define the scene the material belongs to
  63413. */
  63414. function MultiMaterial(name, scene) {
  63415. var _this = _super.call(this, name, scene, true) || this;
  63416. scene.multiMaterials.push(_this);
  63417. _this.subMaterials = new Array();
  63418. _this._storeEffectOnSubMeshes = true; // multimaterial is considered like a push material
  63419. return _this;
  63420. }
  63421. Object.defineProperty(MultiMaterial.prototype, "subMaterials", {
  63422. /**
  63423. * Gets or Sets the list of Materials used within the multi material.
  63424. * They need to be ordered according to the submeshes order in the associated mesh
  63425. */
  63426. get: function () {
  63427. return this._subMaterials;
  63428. },
  63429. set: function (value) {
  63430. this._subMaterials = value;
  63431. this._hookArray(value);
  63432. },
  63433. enumerable: true,
  63434. configurable: true
  63435. });
  63436. /**
  63437. * Function used to align with Node.getChildren()
  63438. * @returns the list of Materials used within the multi material
  63439. */
  63440. MultiMaterial.prototype.getChildren = function () {
  63441. return this.subMaterials;
  63442. };
  63443. MultiMaterial.prototype._hookArray = function (array) {
  63444. var _this = this;
  63445. var oldPush = array.push;
  63446. array.push = function () {
  63447. var items = [];
  63448. for (var _i = 0; _i < arguments.length; _i++) {
  63449. items[_i] = arguments[_i];
  63450. }
  63451. var result = oldPush.apply(array, items);
  63452. _this._markAllSubMeshesAsTexturesDirty();
  63453. return result;
  63454. };
  63455. var oldSplice = array.splice;
  63456. array.splice = function (index, deleteCount) {
  63457. var deleted = oldSplice.apply(array, [index, deleteCount]);
  63458. _this._markAllSubMeshesAsTexturesDirty();
  63459. return deleted;
  63460. };
  63461. };
  63462. /**
  63463. * Get one of the submaterial by its index in the submaterials array
  63464. * @param index The index to look the sub material at
  63465. * @returns The Material if the index has been defined
  63466. */
  63467. MultiMaterial.prototype.getSubMaterial = function (index) {
  63468. if (index < 0 || index >= this.subMaterials.length) {
  63469. return this.getScene().defaultMaterial;
  63470. }
  63471. return this.subMaterials[index];
  63472. };
  63473. /**
  63474. * Get the list of active textures for the whole sub materials list.
  63475. * @returns All the textures that will be used during the rendering
  63476. */
  63477. MultiMaterial.prototype.getActiveTextures = function () {
  63478. var _a;
  63479. return (_a = _super.prototype.getActiveTextures.call(this)).concat.apply(_a, this.subMaterials.map(function (subMaterial) {
  63480. if (subMaterial) {
  63481. return subMaterial.getActiveTextures();
  63482. }
  63483. else {
  63484. return [];
  63485. }
  63486. }));
  63487. };
  63488. /**
  63489. * Gets the current class name of the material e.g. "MultiMaterial"
  63490. * Mainly use in serialization.
  63491. * @returns the class name
  63492. */
  63493. MultiMaterial.prototype.getClassName = function () {
  63494. return "MultiMaterial";
  63495. };
  63496. /**
  63497. * Checks if the material is ready to render the requested sub mesh
  63498. * @param mesh Define the mesh the submesh belongs to
  63499. * @param subMesh Define the sub mesh to look readyness for
  63500. * @param useInstances Define whether or not the material is used with instances
  63501. * @returns true if ready, otherwise false
  63502. */
  63503. MultiMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  63504. for (var index = 0; index < this.subMaterials.length; index++) {
  63505. var subMaterial = this.subMaterials[index];
  63506. if (subMaterial) {
  63507. if (subMaterial._storeEffectOnSubMeshes) {
  63508. if (!subMaterial.isReadyForSubMesh(mesh, subMesh, useInstances)) {
  63509. return false;
  63510. }
  63511. continue;
  63512. }
  63513. if (!subMaterial.isReady(mesh)) {
  63514. return false;
  63515. }
  63516. }
  63517. }
  63518. return true;
  63519. };
  63520. /**
  63521. * Clones the current material and its related sub materials
  63522. * @param name Define the name of the newly cloned material
  63523. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  63524. * @returns the cloned material
  63525. */
  63526. MultiMaterial.prototype.clone = function (name, cloneChildren) {
  63527. var newMultiMaterial = new MultiMaterial(name, this.getScene());
  63528. for (var index = 0; index < this.subMaterials.length; index++) {
  63529. var subMaterial = null;
  63530. var current = this.subMaterials[index];
  63531. if (cloneChildren && current) {
  63532. subMaterial = current.clone(name + "-" + current.name);
  63533. }
  63534. else {
  63535. subMaterial = this.subMaterials[index];
  63536. }
  63537. newMultiMaterial.subMaterials.push(subMaterial);
  63538. }
  63539. return newMultiMaterial;
  63540. };
  63541. /**
  63542. * Serializes the materials into a JSON representation.
  63543. * @returns the JSON representation
  63544. */
  63545. MultiMaterial.prototype.serialize = function () {
  63546. var serializationObject = {};
  63547. serializationObject.name = this.name;
  63548. serializationObject.id = this.id;
  63549. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  63550. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  63551. }
  63552. serializationObject.materials = [];
  63553. for (var matIndex = 0; matIndex < this.subMaterials.length; matIndex++) {
  63554. var subMat = this.subMaterials[matIndex];
  63555. if (subMat) {
  63556. serializationObject.materials.push(subMat.id);
  63557. }
  63558. else {
  63559. serializationObject.materials.push(null);
  63560. }
  63561. }
  63562. return serializationObject;
  63563. };
  63564. /**
  63565. * Dispose the material and release its associated resources
  63566. * @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)
  63567. * @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)
  63568. * @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)
  63569. */
  63570. MultiMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, forceDisposeChildren) {
  63571. var scene = this.getScene();
  63572. if (!scene) {
  63573. return;
  63574. }
  63575. if (forceDisposeChildren) {
  63576. for (var index = 0; index < this.subMaterials.length; index++) {
  63577. var subMaterial = this.subMaterials[index];
  63578. if (subMaterial) {
  63579. subMaterial.dispose(forceDisposeEffect, forceDisposeTextures);
  63580. }
  63581. }
  63582. }
  63583. var index = scene.multiMaterials.indexOf(this);
  63584. if (index >= 0) {
  63585. scene.multiMaterials.splice(index, 1);
  63586. }
  63587. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  63588. };
  63589. /**
  63590. * Creates a MultiMaterial from parsed MultiMaterial data.
  63591. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  63592. * @param scene defines the hosting scene
  63593. * @returns a new MultiMaterial
  63594. */
  63595. MultiMaterial.ParseMultiMaterial = function (parsedMultiMaterial, scene) {
  63596. var multiMaterial = new MultiMaterial(parsedMultiMaterial.name, scene);
  63597. multiMaterial.id = parsedMultiMaterial.id;
  63598. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  63599. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(multiMaterial, parsedMultiMaterial.tags);
  63600. }
  63601. for (var matIndex = 0; matIndex < parsedMultiMaterial.materials.length; matIndex++) {
  63602. var subMatId = parsedMultiMaterial.materials[matIndex];
  63603. if (subMatId) {
  63604. multiMaterial.subMaterials.push(scene.getMaterialByID(subMatId));
  63605. }
  63606. else {
  63607. multiMaterial.subMaterials.push(null);
  63608. }
  63609. }
  63610. return multiMaterial;
  63611. };
  63612. return MultiMaterial;
  63613. }(_Materials_material__WEBPACK_IMPORTED_MODULE_1__["Material"]));
  63614. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.MultiMaterial"] = MultiMaterial;
  63615. /***/ }),
  63616. /***/ "./Materials/pushMaterial.ts":
  63617. /*!***********************************!*\
  63618. !*** ./Materials/pushMaterial.ts ***!
  63619. \***********************************/
  63620. /*! exports provided: PushMaterial */
  63621. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63622. "use strict";
  63623. __webpack_require__.r(__webpack_exports__);
  63624. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return PushMaterial; });
  63625. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  63626. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  63627. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  63628. /**
  63629. * Base class of materials working in push mode in babylon JS
  63630. * @hidden
  63631. */
  63632. var PushMaterial = /** @class */ (function (_super) {
  63633. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PushMaterial, _super);
  63634. function PushMaterial(name, scene) {
  63635. var _this = _super.call(this, name, scene) || this;
  63636. _this._normalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  63637. /**
  63638. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  63639. * This means that the material can keep using a previous shader while a new one is being compiled.
  63640. * This is mostly used when shader parallel compilation is supported (true by default)
  63641. */
  63642. _this.allowShaderHotSwapping = true;
  63643. _this._storeEffectOnSubMeshes = true;
  63644. return _this;
  63645. }
  63646. PushMaterial.prototype.getEffect = function () {
  63647. return this._activeEffect;
  63648. };
  63649. PushMaterial.prototype.isReady = function (mesh, useInstances) {
  63650. if (!mesh) {
  63651. return false;
  63652. }
  63653. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  63654. return true;
  63655. }
  63656. return this.isReadyForSubMesh(mesh, mesh.subMeshes[0], useInstances);
  63657. };
  63658. /**
  63659. * Binds the given world matrix to the active effect
  63660. *
  63661. * @param world the matrix to bind
  63662. */
  63663. PushMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  63664. this._activeEffect.setMatrix("world", world);
  63665. };
  63666. /**
  63667. * Binds the given normal matrix to the active effect
  63668. *
  63669. * @param normalMatrix the matrix to bind
  63670. */
  63671. PushMaterial.prototype.bindOnlyNormalMatrix = function (normalMatrix) {
  63672. this._activeEffect.setMatrix("normalMatrix", normalMatrix);
  63673. };
  63674. PushMaterial.prototype.bind = function (world, mesh) {
  63675. if (!mesh) {
  63676. return;
  63677. }
  63678. this.bindForSubMesh(world, mesh, mesh.subMeshes[0]);
  63679. };
  63680. PushMaterial.prototype._afterBind = function (mesh, effect) {
  63681. if (effect === void 0) { effect = null; }
  63682. _super.prototype._afterBind.call(this, mesh);
  63683. this.getScene()._cachedEffect = effect;
  63684. };
  63685. PushMaterial.prototype._mustRebind = function (scene, effect, visibility) {
  63686. if (visibility === void 0) { visibility = 1; }
  63687. return scene.isCachedMaterialInvalid(this, effect, visibility);
  63688. };
  63689. return PushMaterial;
  63690. }(_Materials_material__WEBPACK_IMPORTED_MODULE_2__["Material"]));
  63691. /***/ }),
  63692. /***/ "./Materials/shaderMaterial.ts":
  63693. /*!*************************************!*\
  63694. !*** ./Materials/shaderMaterial.ts ***!
  63695. \*************************************/
  63696. /*! exports provided: ShaderMaterial */
  63697. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63698. "use strict";
  63699. __webpack_require__.r(__webpack_exports__);
  63700. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return ShaderMaterial; });
  63701. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  63702. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  63703. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  63704. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  63705. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  63706. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  63707. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  63708. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  63709. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  63710. /**
  63711. * 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.
  63712. *
  63713. * This returned material effects how the mesh will look based on the code in the shaders.
  63714. *
  63715. * @see http://doc.babylonjs.com/how_to/shader_material
  63716. */
  63717. var ShaderMaterial = /** @class */ (function (_super) {
  63718. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderMaterial, _super);
  63719. /**
  63720. * Instantiate a new shader material.
  63721. * 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.
  63722. * This returned material effects how the mesh will look based on the code in the shaders.
  63723. * @see http://doc.babylonjs.com/how_to/shader_material
  63724. * @param name Define the name of the material in the scene
  63725. * @param scene Define the scene the material belongs to
  63726. * @param shaderPath Defines the route to the shader code in one of three ways:
  63727. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  63728. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  63729. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  63730. * @param options Define the options used to create the shader
  63731. */
  63732. function ShaderMaterial(name, scene, shaderPath, options) {
  63733. if (options === void 0) { options = {}; }
  63734. var _this = _super.call(this, name, scene) || this;
  63735. _this._textures = {};
  63736. _this._textureArrays = {};
  63737. _this._floats = {};
  63738. _this._ints = {};
  63739. _this._floatsArrays = {};
  63740. _this._colors3 = {};
  63741. _this._colors3Arrays = {};
  63742. _this._colors4 = {};
  63743. _this._vectors2 = {};
  63744. _this._vectors3 = {};
  63745. _this._vectors4 = {};
  63746. _this._matrices = {};
  63747. _this._matrices3x3 = {};
  63748. _this._matrices2x2 = {};
  63749. _this._vectors2Arrays = {};
  63750. _this._vectors3Arrays = {};
  63751. _this._cachedWorldViewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  63752. _this._shaderPath = shaderPath;
  63753. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ needAlphaBlending: false, needAlphaTesting: false, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection"], uniformBuffers: [], samplers: [], defines: [] }, options);
  63754. return _this;
  63755. }
  63756. /**
  63757. * Gets the current class name of the material e.g. "ShaderMaterial"
  63758. * Mainly use in serialization.
  63759. * @returns the class name
  63760. */
  63761. ShaderMaterial.prototype.getClassName = function () {
  63762. return "ShaderMaterial";
  63763. };
  63764. /**
  63765. * Specifies if the material will require alpha blending
  63766. * @returns a boolean specifying if alpha blending is needed
  63767. */
  63768. ShaderMaterial.prototype.needAlphaBlending = function () {
  63769. return (this.alpha < 1.0) || this._options.needAlphaBlending;
  63770. };
  63771. /**
  63772. * Specifies if this material should be rendered in alpha test mode
  63773. * @returns a boolean specifying if an alpha test is needed.
  63774. */
  63775. ShaderMaterial.prototype.needAlphaTesting = function () {
  63776. return this._options.needAlphaTesting;
  63777. };
  63778. ShaderMaterial.prototype._checkUniform = function (uniformName) {
  63779. if (this._options.uniforms.indexOf(uniformName) === -1) {
  63780. this._options.uniforms.push(uniformName);
  63781. }
  63782. };
  63783. /**
  63784. * Set a texture in the shader.
  63785. * @param name Define the name of the uniform samplers as defined in the shader
  63786. * @param texture Define the texture to bind to this sampler
  63787. * @return the material itself allowing "fluent" like uniform updates
  63788. */
  63789. ShaderMaterial.prototype.setTexture = function (name, texture) {
  63790. if (this._options.samplers.indexOf(name) === -1) {
  63791. this._options.samplers.push(name);
  63792. }
  63793. this._textures[name] = texture;
  63794. return this;
  63795. };
  63796. /**
  63797. * Set a texture array in the shader.
  63798. * @param name Define the name of the uniform sampler array as defined in the shader
  63799. * @param textures Define the list of textures to bind to this sampler
  63800. * @return the material itself allowing "fluent" like uniform updates
  63801. */
  63802. ShaderMaterial.prototype.setTextureArray = function (name, textures) {
  63803. if (this._options.samplers.indexOf(name) === -1) {
  63804. this._options.samplers.push(name);
  63805. }
  63806. this._checkUniform(name);
  63807. this._textureArrays[name] = textures;
  63808. return this;
  63809. };
  63810. /**
  63811. * Set a float in the shader.
  63812. * @param name Define the name of the uniform as defined in the shader
  63813. * @param value Define the value to give to the uniform
  63814. * @return the material itself allowing "fluent" like uniform updates
  63815. */
  63816. ShaderMaterial.prototype.setFloat = function (name, value) {
  63817. this._checkUniform(name);
  63818. this._floats[name] = value;
  63819. return this;
  63820. };
  63821. /**
  63822. * Set a int in the shader.
  63823. * @param name Define the name of the uniform as defined in the shader
  63824. * @param value Define the value to give to the uniform
  63825. * @return the material itself allowing "fluent" like uniform updates
  63826. */
  63827. ShaderMaterial.prototype.setInt = function (name, value) {
  63828. this._checkUniform(name);
  63829. this._ints[name] = value;
  63830. return this;
  63831. };
  63832. /**
  63833. * Set an array of floats in the shader.
  63834. * @param name Define the name of the uniform as defined in the shader
  63835. * @param value Define the value to give to the uniform
  63836. * @return the material itself allowing "fluent" like uniform updates
  63837. */
  63838. ShaderMaterial.prototype.setFloats = function (name, value) {
  63839. this._checkUniform(name);
  63840. this._floatsArrays[name] = value;
  63841. return this;
  63842. };
  63843. /**
  63844. * Set a vec3 in the shader from a Color3.
  63845. * @param name Define the name of the uniform as defined in the shader
  63846. * @param value Define the value to give to the uniform
  63847. * @return the material itself allowing "fluent" like uniform updates
  63848. */
  63849. ShaderMaterial.prototype.setColor3 = function (name, value) {
  63850. this._checkUniform(name);
  63851. this._colors3[name] = value;
  63852. return this;
  63853. };
  63854. /**
  63855. * Set a vec3 array in the shader from a Color3 array.
  63856. * @param name Define the name of the uniform as defined in the shader
  63857. * @param value Define the value to give to the uniform
  63858. * @return the material itself allowing "fluent" like uniform updates
  63859. */
  63860. ShaderMaterial.prototype.setColor3Array = function (name, value) {
  63861. this._checkUniform(name);
  63862. this._colors3Arrays[name] = value.reduce(function (arr, color) {
  63863. color.toArray(arr, arr.length);
  63864. return arr;
  63865. }, []);
  63866. return this;
  63867. };
  63868. /**
  63869. * Set a vec4 in the shader from a Color4.
  63870. * @param name Define the name of the uniform as defined in the shader
  63871. * @param value Define the value to give to the uniform
  63872. * @return the material itself allowing "fluent" like uniform updates
  63873. */
  63874. ShaderMaterial.prototype.setColor4 = function (name, value) {
  63875. this._checkUniform(name);
  63876. this._colors4[name] = value;
  63877. return this;
  63878. };
  63879. /**
  63880. * Set a vec2 in the shader from a Vector2.
  63881. * @param name Define the name of the uniform as defined in the shader
  63882. * @param value Define the value to give to the uniform
  63883. * @return the material itself allowing "fluent" like uniform updates
  63884. */
  63885. ShaderMaterial.prototype.setVector2 = function (name, value) {
  63886. this._checkUniform(name);
  63887. this._vectors2[name] = value;
  63888. return this;
  63889. };
  63890. /**
  63891. * Set a vec3 in the shader from a Vector3.
  63892. * @param name Define the name of the uniform as defined in the shader
  63893. * @param value Define the value to give to the uniform
  63894. * @return the material itself allowing "fluent" like uniform updates
  63895. */
  63896. ShaderMaterial.prototype.setVector3 = function (name, value) {
  63897. this._checkUniform(name);
  63898. this._vectors3[name] = value;
  63899. return this;
  63900. };
  63901. /**
  63902. * Set a vec4 in the shader from a Vector4.
  63903. * @param name Define the name of the uniform as defined in the shader
  63904. * @param value Define the value to give to the uniform
  63905. * @return the material itself allowing "fluent" like uniform updates
  63906. */
  63907. ShaderMaterial.prototype.setVector4 = function (name, value) {
  63908. this._checkUniform(name);
  63909. this._vectors4[name] = value;
  63910. return this;
  63911. };
  63912. /**
  63913. * Set a mat4 in the shader from a Matrix.
  63914. * @param name Define the name of the uniform as defined in the shader
  63915. * @param value Define the value to give to the uniform
  63916. * @return the material itself allowing "fluent" like uniform updates
  63917. */
  63918. ShaderMaterial.prototype.setMatrix = function (name, value) {
  63919. this._checkUniform(name);
  63920. this._matrices[name] = value;
  63921. return this;
  63922. };
  63923. /**
  63924. * Set a mat3 in the shader from a Float32Array.
  63925. * @param name Define the name of the uniform as defined in the shader
  63926. * @param value Define the value to give to the uniform
  63927. * @return the material itself allowing "fluent" like uniform updates
  63928. */
  63929. ShaderMaterial.prototype.setMatrix3x3 = function (name, value) {
  63930. this._checkUniform(name);
  63931. this._matrices3x3[name] = value;
  63932. return this;
  63933. };
  63934. /**
  63935. * Set a mat2 in the shader from a Float32Array.
  63936. * @param name Define the name of the uniform as defined in the shader
  63937. * @param value Define the value to give to the uniform
  63938. * @return the material itself allowing "fluent" like uniform updates
  63939. */
  63940. ShaderMaterial.prototype.setMatrix2x2 = function (name, value) {
  63941. this._checkUniform(name);
  63942. this._matrices2x2[name] = value;
  63943. return this;
  63944. };
  63945. /**
  63946. * Set a vec2 array in the shader from a number array.
  63947. * @param name Define the name of the uniform as defined in the shader
  63948. * @param value Define the value to give to the uniform
  63949. * @return the material itself allowing "fluent" like uniform updates
  63950. */
  63951. ShaderMaterial.prototype.setArray2 = function (name, value) {
  63952. this._checkUniform(name);
  63953. this._vectors2Arrays[name] = value;
  63954. return this;
  63955. };
  63956. /**
  63957. * Set a vec3 array in the shader from a number array.
  63958. * @param name Define the name of the uniform as defined in the shader
  63959. * @param value Define the value to give to the uniform
  63960. * @return the material itself allowing "fluent" like uniform updates
  63961. */
  63962. ShaderMaterial.prototype.setArray3 = function (name, value) {
  63963. this._checkUniform(name);
  63964. this._vectors3Arrays[name] = value;
  63965. return this;
  63966. };
  63967. ShaderMaterial.prototype._checkCache = function (mesh, useInstances) {
  63968. if (!mesh) {
  63969. return true;
  63970. }
  63971. if (this._effect && (this._effect.defines.indexOf("#define INSTANCES") !== -1) !== useInstances) {
  63972. return false;
  63973. }
  63974. return false;
  63975. };
  63976. /**
  63977. * Checks if the material is ready to render the requested mesh
  63978. * @param mesh Define the mesh to render
  63979. * @param useInstances Define whether or not the material is used with instances
  63980. * @returns true if ready, otherwise false
  63981. */
  63982. ShaderMaterial.prototype.isReady = function (mesh, useInstances) {
  63983. var scene = this.getScene();
  63984. var engine = scene.getEngine();
  63985. if (!this.checkReadyOnEveryCall) {
  63986. if (this._renderId === scene.getRenderId()) {
  63987. if (this._checkCache(mesh, useInstances)) {
  63988. return true;
  63989. }
  63990. }
  63991. }
  63992. // Instances
  63993. var defines = [];
  63994. var attribs = [];
  63995. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  63996. for (var index = 0; index < this._options.defines.length; index++) {
  63997. defines.push(this._options.defines[index]);
  63998. }
  63999. for (var index = 0; index < this._options.attributes.length; index++) {
  64000. attribs.push(this._options.attributes[index]);
  64001. }
  64002. if (mesh && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  64003. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  64004. defines.push("#define VERTEXCOLOR");
  64005. }
  64006. if (useInstances) {
  64007. defines.push("#define INSTANCES");
  64008. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  64009. }
  64010. // Bones
  64011. if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  64012. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  64013. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  64014. if (mesh.numBoneInfluencers > 4) {
  64015. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  64016. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind);
  64017. }
  64018. var skeleton = mesh.skeleton;
  64019. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  64020. fallbacks.addCPUSkinningFallback(0, mesh);
  64021. if (skeleton.isUsingTextureForMatrices) {
  64022. defines.push("#define BONETEXTURE");
  64023. if (this._options.uniforms.indexOf("boneTextureWidth") === -1) {
  64024. this._options.uniforms.push("boneTextureWidth");
  64025. }
  64026. if (this._options.samplers.indexOf("boneSampler") === -1) {
  64027. this._options.samplers.push("boneSampler");
  64028. }
  64029. }
  64030. else {
  64031. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  64032. if (this._options.uniforms.indexOf("mBones") === -1) {
  64033. this._options.uniforms.push("mBones");
  64034. }
  64035. }
  64036. }
  64037. else {
  64038. defines.push("#define NUM_BONE_INFLUENCERS 0");
  64039. }
  64040. // Textures
  64041. for (var name in this._textures) {
  64042. if (!this._textures[name].isReady()) {
  64043. return false;
  64044. }
  64045. }
  64046. // Alpha test
  64047. if (mesh && this._shouldTurnAlphaTestOn(mesh)) {
  64048. defines.push("#define ALPHATEST");
  64049. }
  64050. var previousEffect = this._effect;
  64051. var join = defines.join("\n");
  64052. this._effect = engine.createEffect(this._shaderPath, {
  64053. attributes: attribs,
  64054. uniformsNames: this._options.uniforms,
  64055. uniformBuffersNames: this._options.uniformBuffers,
  64056. samplers: this._options.samplers,
  64057. defines: join,
  64058. fallbacks: fallbacks,
  64059. onCompiled: this.onCompiled,
  64060. onError: this.onError
  64061. }, engine);
  64062. if (!this._effect.isReady()) {
  64063. return false;
  64064. }
  64065. if (previousEffect !== this._effect) {
  64066. scene.resetCachedMaterial();
  64067. }
  64068. this._renderId = scene.getRenderId();
  64069. return true;
  64070. };
  64071. /**
  64072. * Binds the world matrix to the material
  64073. * @param world defines the world transformation matrix
  64074. */
  64075. ShaderMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  64076. var scene = this.getScene();
  64077. if (!this._effect) {
  64078. return;
  64079. }
  64080. if (this._options.uniforms.indexOf("world") !== -1) {
  64081. this._effect.setMatrix("world", world);
  64082. }
  64083. if (this._options.uniforms.indexOf("worldView") !== -1) {
  64084. world.multiplyToRef(scene.getViewMatrix(), this._cachedWorldViewMatrix);
  64085. this._effect.setMatrix("worldView", this._cachedWorldViewMatrix);
  64086. }
  64087. if (this._options.uniforms.indexOf("worldViewProjection") !== -1) {
  64088. this._effect.setMatrix("worldViewProjection", world.multiply(scene.getTransformMatrix()));
  64089. }
  64090. };
  64091. /**
  64092. * Binds the material to the mesh
  64093. * @param world defines the world transformation matrix
  64094. * @param mesh defines the mesh to bind the material to
  64095. */
  64096. ShaderMaterial.prototype.bind = function (world, mesh) {
  64097. // Std values
  64098. this.bindOnlyWorldMatrix(world);
  64099. if (this._effect && this.getScene().getCachedMaterial() !== this) {
  64100. if (this._options.uniforms.indexOf("view") !== -1) {
  64101. this._effect.setMatrix("view", this.getScene().getViewMatrix());
  64102. }
  64103. if (this._options.uniforms.indexOf("projection") !== -1) {
  64104. this._effect.setMatrix("projection", this.getScene().getProjectionMatrix());
  64105. }
  64106. if (this._options.uniforms.indexOf("viewProjection") !== -1) {
  64107. this._effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  64108. }
  64109. // Bones
  64110. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindBonesParameters(mesh, this._effect);
  64111. var name;
  64112. // Texture
  64113. for (name in this._textures) {
  64114. this._effect.setTexture(name, this._textures[name]);
  64115. }
  64116. // Texture arrays
  64117. for (name in this._textureArrays) {
  64118. this._effect.setTextureArray(name, this._textureArrays[name]);
  64119. }
  64120. // Int
  64121. for (name in this._ints) {
  64122. this._effect.setInt(name, this._ints[name]);
  64123. }
  64124. // Float
  64125. for (name in this._floats) {
  64126. this._effect.setFloat(name, this._floats[name]);
  64127. }
  64128. // Floats
  64129. for (name in this._floatsArrays) {
  64130. this._effect.setArray(name, this._floatsArrays[name]);
  64131. }
  64132. // Color3
  64133. for (name in this._colors3) {
  64134. this._effect.setColor3(name, this._colors3[name]);
  64135. }
  64136. for (name in this._colors3Arrays) {
  64137. this._effect.setArray3(name, this._colors3Arrays[name]);
  64138. }
  64139. // Color4
  64140. for (name in this._colors4) {
  64141. var color = this._colors4[name];
  64142. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  64143. }
  64144. // Vector2
  64145. for (name in this._vectors2) {
  64146. this._effect.setVector2(name, this._vectors2[name]);
  64147. }
  64148. // Vector3
  64149. for (name in this._vectors3) {
  64150. this._effect.setVector3(name, this._vectors3[name]);
  64151. }
  64152. // Vector4
  64153. for (name in this._vectors4) {
  64154. this._effect.setVector4(name, this._vectors4[name]);
  64155. }
  64156. // Matrix
  64157. for (name in this._matrices) {
  64158. this._effect.setMatrix(name, this._matrices[name]);
  64159. }
  64160. // Matrix 3x3
  64161. for (name in this._matrices3x3) {
  64162. this._effect.setMatrix3x3(name, this._matrices3x3[name]);
  64163. }
  64164. // Matrix 2x2
  64165. for (name in this._matrices2x2) {
  64166. this._effect.setMatrix2x2(name, this._matrices2x2[name]);
  64167. }
  64168. // Vector2Array
  64169. for (name in this._vectors2Arrays) {
  64170. this._effect.setArray2(name, this._vectors2Arrays[name]);
  64171. }
  64172. // Vector3Array
  64173. for (name in this._vectors3Arrays) {
  64174. this._effect.setArray3(name, this._vectors3Arrays[name]);
  64175. }
  64176. }
  64177. this._afterBind(mesh);
  64178. };
  64179. /**
  64180. * Gets the active textures from the material
  64181. * @returns an array of textures
  64182. */
  64183. ShaderMaterial.prototype.getActiveTextures = function () {
  64184. var activeTextures = _super.prototype.getActiveTextures.call(this);
  64185. for (var name in this._textures) {
  64186. activeTextures.push(this._textures[name]);
  64187. }
  64188. for (var name in this._textureArrays) {
  64189. var array = this._textureArrays[name];
  64190. for (var index = 0; index < array.length; index++) {
  64191. activeTextures.push(array[index]);
  64192. }
  64193. }
  64194. return activeTextures;
  64195. };
  64196. /**
  64197. * Specifies if the material uses a texture
  64198. * @param texture defines the texture to check against the material
  64199. * @returns a boolean specifying if the material uses the texture
  64200. */
  64201. ShaderMaterial.prototype.hasTexture = function (texture) {
  64202. if (_super.prototype.hasTexture.call(this, texture)) {
  64203. return true;
  64204. }
  64205. for (var name in this._textures) {
  64206. if (this._textures[name] === texture) {
  64207. return true;
  64208. }
  64209. }
  64210. for (var name in this._textureArrays) {
  64211. var array = this._textureArrays[name];
  64212. for (var index = 0; index < array.length; index++) {
  64213. if (array[index] === texture) {
  64214. return true;
  64215. }
  64216. }
  64217. }
  64218. return false;
  64219. };
  64220. /**
  64221. * Makes a duplicate of the material, and gives it a new name
  64222. * @param name defines the new name for the duplicated material
  64223. * @returns the cloned material
  64224. */
  64225. ShaderMaterial.prototype.clone = function (name) {
  64226. var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
  64227. return newShaderMaterial;
  64228. };
  64229. /**
  64230. * Disposes the material
  64231. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  64232. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  64233. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  64234. */
  64235. ShaderMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  64236. if (forceDisposeTextures) {
  64237. var name;
  64238. for (name in this._textures) {
  64239. this._textures[name].dispose();
  64240. }
  64241. for (name in this._textureArrays) {
  64242. var array = this._textureArrays[name];
  64243. for (var index = 0; index < array.length; index++) {
  64244. array[index].dispose();
  64245. }
  64246. }
  64247. }
  64248. this._textures = {};
  64249. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures, notBoundToMesh);
  64250. };
  64251. /**
  64252. * Serializes this material in a JSON representation
  64253. * @returns the serialized material object
  64254. */
  64255. ShaderMaterial.prototype.serialize = function () {
  64256. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  64257. serializationObject.customType = "ShaderMaterial";
  64258. serializationObject.options = this._options;
  64259. serializationObject.shaderPath = this._shaderPath;
  64260. var name;
  64261. // Texture
  64262. serializationObject.textures = {};
  64263. for (name in this._textures) {
  64264. serializationObject.textures[name] = this._textures[name].serialize();
  64265. }
  64266. // Texture arrays
  64267. serializationObject.textureArrays = {};
  64268. for (name in this._textureArrays) {
  64269. serializationObject.textureArrays[name] = [];
  64270. var array = this._textureArrays[name];
  64271. for (var index = 0; index < array.length; index++) {
  64272. serializationObject.textureArrays[name].push(array[index].serialize());
  64273. }
  64274. }
  64275. // Float
  64276. serializationObject.floats = {};
  64277. for (name in this._floats) {
  64278. serializationObject.floats[name] = this._floats[name];
  64279. }
  64280. // Float s
  64281. serializationObject.FloatArrays = {};
  64282. for (name in this._floatsArrays) {
  64283. serializationObject.FloatArrays[name] = this._floatsArrays[name];
  64284. }
  64285. // Color3
  64286. serializationObject.colors3 = {};
  64287. for (name in this._colors3) {
  64288. serializationObject.colors3[name] = this._colors3[name].asArray();
  64289. }
  64290. // Color3 array
  64291. serializationObject.colors3Arrays = {};
  64292. for (name in this._colors3Arrays) {
  64293. serializationObject.colors3Arrays[name] = this._colors3Arrays[name];
  64294. }
  64295. // Color4
  64296. serializationObject.colors4 = {};
  64297. for (name in this._colors4) {
  64298. serializationObject.colors4[name] = this._colors4[name].asArray();
  64299. }
  64300. // Vector2
  64301. serializationObject.vectors2 = {};
  64302. for (name in this._vectors2) {
  64303. serializationObject.vectors2[name] = this._vectors2[name].asArray();
  64304. }
  64305. // Vector3
  64306. serializationObject.vectors3 = {};
  64307. for (name in this._vectors3) {
  64308. serializationObject.vectors3[name] = this._vectors3[name].asArray();
  64309. }
  64310. // Vector4
  64311. serializationObject.vectors4 = {};
  64312. for (name in this._vectors4) {
  64313. serializationObject.vectors4[name] = this._vectors4[name].asArray();
  64314. }
  64315. // Matrix
  64316. serializationObject.matrices = {};
  64317. for (name in this._matrices) {
  64318. serializationObject.matrices[name] = this._matrices[name].asArray();
  64319. }
  64320. // Matrix 3x3
  64321. serializationObject.matrices3x3 = {};
  64322. for (name in this._matrices3x3) {
  64323. serializationObject.matrices3x3[name] = this._matrices3x3[name];
  64324. }
  64325. // Matrix 2x2
  64326. serializationObject.matrices2x2 = {};
  64327. for (name in this._matrices2x2) {
  64328. serializationObject.matrices2x2[name] = this._matrices2x2[name];
  64329. }
  64330. // Vector2Array
  64331. serializationObject.vectors2Arrays = {};
  64332. for (name in this._vectors2Arrays) {
  64333. serializationObject.vectors2Arrays[name] = this._vectors2Arrays[name];
  64334. }
  64335. // Vector3Array
  64336. serializationObject.vectors3Arrays = {};
  64337. for (name in this._vectors3Arrays) {
  64338. serializationObject.vectors3Arrays[name] = this._vectors3Arrays[name];
  64339. }
  64340. return serializationObject;
  64341. };
  64342. /**
  64343. * Creates a shader material from parsed shader material data
  64344. * @param source defines the JSON represnetation of the material
  64345. * @param scene defines the hosting scene
  64346. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  64347. * @returns a new material
  64348. */
  64349. ShaderMaterial.Parse = function (source, scene, rootUrl) {
  64350. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ShaderMaterial(source.name, scene, source.shaderPath, source.options); }, source, scene, rootUrl);
  64351. var name;
  64352. // Texture
  64353. for (name in source.textures) {
  64354. material.setTexture(name, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(source.textures[name], scene, rootUrl));
  64355. }
  64356. // Texture arrays
  64357. for (name in source.textureArrays) {
  64358. var array = source.textureArrays[name];
  64359. var textureArray = new Array();
  64360. for (var index = 0; index < array.length; index++) {
  64361. textureArray.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(array[index], scene, rootUrl));
  64362. }
  64363. material.setTextureArray(name, textureArray);
  64364. }
  64365. // Float
  64366. for (name in source.floats) {
  64367. material.setFloat(name, source.floats[name]);
  64368. }
  64369. // Float s
  64370. for (name in source.floatsArrays) {
  64371. material.setFloats(name, source.floatsArrays[name]);
  64372. }
  64373. // Color3
  64374. for (name in source.colors3) {
  64375. material.setColor3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(source.colors3[name]));
  64376. }
  64377. // Color3 arrays
  64378. for (name in source.colors3Arrays) {
  64379. var colors = source.colors3Arrays[name].reduce(function (arr, num, i) {
  64380. if (i % 3 === 0) {
  64381. arr.push([num]);
  64382. }
  64383. else {
  64384. arr[arr.length - 1].push(num);
  64385. }
  64386. return arr;
  64387. }, []).map(function (color) { return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(color); });
  64388. material.setColor3Array(name, colors);
  64389. }
  64390. // Color4
  64391. for (name in source.colors4) {
  64392. material.setColor4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(source.colors4[name]));
  64393. }
  64394. // Vector2
  64395. for (name in source.vectors2) {
  64396. material.setVector2(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"].FromArray(source.vectors2[name]));
  64397. }
  64398. // Vector3
  64399. for (name in source.vectors3) {
  64400. material.setVector3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(source.vectors3[name]));
  64401. }
  64402. // Vector4
  64403. for (name in source.vectors4) {
  64404. material.setVector4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector4"].FromArray(source.vectors4[name]));
  64405. }
  64406. // Matrix
  64407. for (name in source.matrices) {
  64408. material.setMatrix(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(source.matrices[name]));
  64409. }
  64410. // Matrix 3x3
  64411. for (name in source.matrices3x3) {
  64412. material.setMatrix3x3(name, source.matrices3x3[name]);
  64413. }
  64414. // Matrix 2x2
  64415. for (name in source.matrices2x2) {
  64416. material.setMatrix2x2(name, source.matrices2x2[name]);
  64417. }
  64418. // Vector2Array
  64419. for (name in source.vectors2Arrays) {
  64420. material.setArray2(name, source.vectors2Arrays[name]);
  64421. }
  64422. // Vector3Array
  64423. for (name in source.vectors3Arrays) {
  64424. material.setArray3(name, source.vectors3Arrays[name]);
  64425. }
  64426. return material;
  64427. };
  64428. return ShaderMaterial;
  64429. }(_material__WEBPACK_IMPORTED_MODULE_7__["Material"]));
  64430. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.ShaderMaterial"] = ShaderMaterial;
  64431. /***/ }),
  64432. /***/ "./Materials/standardMaterial.ts":
  64433. /*!***************************************!*\
  64434. !*** ./Materials/standardMaterial.ts ***!
  64435. \***************************************/
  64436. /*! exports provided: StandardMaterialDefines, StandardMaterial */
  64437. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64438. "use strict";
  64439. __webpack_require__.r(__webpack_exports__);
  64440. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return StandardMaterialDefines; });
  64441. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return StandardMaterial; });
  64442. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64443. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  64444. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  64445. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  64446. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64447. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  64448. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  64449. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  64450. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  64451. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  64452. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  64453. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  64454. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  64455. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  64456. /* harmony import */ var _Shaders_default_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/default.fragment */ "./Shaders/default.fragment.ts");
  64457. /* harmony import */ var _Shaders_default_vertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/default.vertex */ "./Shaders/default.vertex.ts");
  64458. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  64459. /** @hidden */
  64460. var StandardMaterialDefines = /** @class */ (function (_super) {
  64461. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterialDefines, _super);
  64462. function StandardMaterialDefines() {
  64463. var _this = _super.call(this) || this;
  64464. _this.MAINUV1 = false;
  64465. _this.MAINUV2 = false;
  64466. _this.DIFFUSE = false;
  64467. _this.DIFFUSEDIRECTUV = 0;
  64468. _this.AMBIENT = false;
  64469. _this.AMBIENTDIRECTUV = 0;
  64470. _this.OPACITY = false;
  64471. _this.OPACITYDIRECTUV = 0;
  64472. _this.OPACITYRGB = false;
  64473. _this.REFLECTION = false;
  64474. _this.EMISSIVE = false;
  64475. _this.EMISSIVEDIRECTUV = 0;
  64476. _this.SPECULAR = false;
  64477. _this.SPECULARDIRECTUV = 0;
  64478. _this.BUMP = false;
  64479. _this.BUMPDIRECTUV = 0;
  64480. _this.PARALLAX = false;
  64481. _this.PARALLAXOCCLUSION = false;
  64482. _this.SPECULAROVERALPHA = false;
  64483. _this.CLIPPLANE = false;
  64484. _this.CLIPPLANE2 = false;
  64485. _this.CLIPPLANE3 = false;
  64486. _this.CLIPPLANE4 = false;
  64487. _this.ALPHATEST = false;
  64488. _this.DEPTHPREPASS = false;
  64489. _this.ALPHAFROMDIFFUSE = false;
  64490. _this.POINTSIZE = false;
  64491. _this.FOG = false;
  64492. _this.SPECULARTERM = false;
  64493. _this.DIFFUSEFRESNEL = false;
  64494. _this.OPACITYFRESNEL = false;
  64495. _this.REFLECTIONFRESNEL = false;
  64496. _this.REFRACTIONFRESNEL = false;
  64497. _this.EMISSIVEFRESNEL = false;
  64498. _this.FRESNEL = false;
  64499. _this.NORMAL = false;
  64500. _this.UV1 = false;
  64501. _this.UV2 = false;
  64502. _this.VERTEXCOLOR = false;
  64503. _this.VERTEXALPHA = false;
  64504. _this.NUM_BONE_INFLUENCERS = 0;
  64505. _this.BonesPerMesh = 0;
  64506. _this.BONETEXTURE = false;
  64507. _this.INSTANCES = false;
  64508. _this.GLOSSINESS = false;
  64509. _this.ROUGHNESS = false;
  64510. _this.EMISSIVEASILLUMINATION = false;
  64511. _this.LINKEMISSIVEWITHDIFFUSE = false;
  64512. _this.REFLECTIONFRESNELFROMSPECULAR = false;
  64513. _this.LIGHTMAP = false;
  64514. _this.LIGHTMAPDIRECTUV = 0;
  64515. _this.OBJECTSPACE_NORMALMAP = false;
  64516. _this.USELIGHTMAPASSHADOWMAP = false;
  64517. _this.REFLECTIONMAP_3D = false;
  64518. _this.REFLECTIONMAP_SPHERICAL = false;
  64519. _this.REFLECTIONMAP_PLANAR = false;
  64520. _this.REFLECTIONMAP_CUBIC = false;
  64521. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  64522. _this.REFLECTIONMAP_PROJECTION = false;
  64523. _this.REFLECTIONMAP_SKYBOX = false;
  64524. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  64525. _this.REFLECTIONMAP_EXPLICIT = false;
  64526. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  64527. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  64528. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  64529. _this.INVERTCUBICMAP = false;
  64530. _this.LOGARITHMICDEPTH = false;
  64531. _this.REFRACTION = false;
  64532. _this.REFRACTIONMAP_3D = false;
  64533. _this.REFLECTIONOVERALPHA = false;
  64534. _this.TWOSIDEDLIGHTING = false;
  64535. _this.SHADOWFLOAT = false;
  64536. _this.MORPHTARGETS = false;
  64537. _this.MORPHTARGETS_NORMAL = false;
  64538. _this.MORPHTARGETS_TANGENT = false;
  64539. _this.NUM_MORPH_INFLUENCERS = 0;
  64540. _this.NONUNIFORMSCALING = false; // https://playground.babylonjs.com#V6DWIH
  64541. _this.PREMULTIPLYALPHA = false; // https://playground.babylonjs.com#LNVJJ7
  64542. _this.IMAGEPROCESSING = false;
  64543. _this.VIGNETTE = false;
  64544. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  64545. _this.VIGNETTEBLENDMODEOPAQUE = false;
  64546. _this.TONEMAPPING = false;
  64547. _this.TONEMAPPING_ACES = false;
  64548. _this.CONTRAST = false;
  64549. _this.COLORCURVES = false;
  64550. _this.COLORGRADING = false;
  64551. _this.COLORGRADING3D = false;
  64552. _this.SAMPLER3DGREENDEPTH = false;
  64553. _this.SAMPLER3DBGRMAP = false;
  64554. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  64555. /**
  64556. * If the reflection texture on this material is in linear color space
  64557. * @hidden
  64558. */
  64559. _this.IS_REFLECTION_LINEAR = false;
  64560. /**
  64561. * If the refraction texture on this material is in linear color space
  64562. * @hidden
  64563. */
  64564. _this.IS_REFRACTION_LINEAR = false;
  64565. _this.EXPOSURE = false;
  64566. _this.rebuild();
  64567. return _this;
  64568. }
  64569. StandardMaterialDefines.prototype.setReflectionMode = function (modeToEnable) {
  64570. var modes = [
  64571. "REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR",
  64572. "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX",
  64573. "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED",
  64574. "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"
  64575. ];
  64576. for (var _i = 0, modes_1 = modes; _i < modes_1.length; _i++) {
  64577. var mode = modes_1[_i];
  64578. this[mode] = (mode === modeToEnable);
  64579. }
  64580. };
  64581. return StandardMaterialDefines;
  64582. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  64583. /**
  64584. * This is the default material used in Babylon. It is the best trade off between quality
  64585. * and performances.
  64586. * @see http://doc.babylonjs.com/babylon101/materials
  64587. */
  64588. var StandardMaterial = /** @class */ (function (_super) {
  64589. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterial, _super);
  64590. /**
  64591. * Instantiates a new standard material.
  64592. * This is the default material used in Babylon. It is the best trade off between quality
  64593. * and performances.
  64594. * @see http://doc.babylonjs.com/babylon101/materials
  64595. * @param name Define the name of the material in the scene
  64596. * @param scene Define the scene the material belong to
  64597. */
  64598. function StandardMaterial(name, scene) {
  64599. var _this = _super.call(this, name, scene) || this;
  64600. /**
  64601. * The color of the material lit by the environmental background lighting.
  64602. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  64603. */
  64604. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  64605. /**
  64606. * The basic color of the material as viewed under a light.
  64607. */
  64608. _this.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  64609. /**
  64610. * Define how the color and intensity of the highlight given by the light in the material.
  64611. */
  64612. _this.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  64613. /**
  64614. * Define the color of the material as if self lit.
  64615. * This will be mixed in the final result even in the absence of light.
  64616. */
  64617. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  64618. /**
  64619. * Defines how sharp are the highlights in the material.
  64620. * The bigger the value the sharper giving a more glossy feeling to the result.
  64621. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  64622. */
  64623. _this.specularPower = 64;
  64624. _this._useAlphaFromDiffuseTexture = false;
  64625. _this._useEmissiveAsIllumination = false;
  64626. _this._linkEmissiveWithDiffuse = false;
  64627. _this._useSpecularOverAlpha = false;
  64628. _this._useReflectionOverAlpha = false;
  64629. _this._disableLighting = false;
  64630. _this._useObjectSpaceNormalMap = false;
  64631. _this._useParallax = false;
  64632. _this._useParallaxOcclusion = false;
  64633. /**
  64634. * 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.
  64635. */
  64636. _this.parallaxScaleBias = 0.05;
  64637. _this._roughness = 0;
  64638. /**
  64639. * In case of refraction, define the value of the indice of refraction.
  64640. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  64641. */
  64642. _this.indexOfRefraction = 0.98;
  64643. /**
  64644. * Invert the refraction texture alongside the y axis.
  64645. * It can be useful with procedural textures or probe for instance.
  64646. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  64647. */
  64648. _this.invertRefractionY = true;
  64649. /**
  64650. * Defines the alpha limits in alpha test mode.
  64651. */
  64652. _this.alphaCutOff = 0.4;
  64653. _this._useLightmapAsShadowmap = false;
  64654. _this._useReflectionFresnelFromSpecular = false;
  64655. _this._useGlossinessFromSpecularMapAlpha = false;
  64656. _this._maxSimultaneousLights = 4;
  64657. _this._invertNormalMapX = false;
  64658. _this._invertNormalMapY = false;
  64659. _this._twoSidedLighting = false;
  64660. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  64661. _this._worldViewProjectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  64662. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  64663. // Setup the default processing configuration to the scene.
  64664. _this._attachImageProcessingConfiguration(null);
  64665. _this.getRenderTargetTextures = function () {
  64666. _this._renderTargets.reset();
  64667. if (StandardMaterial.ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  64668. _this._renderTargets.push(_this._reflectionTexture);
  64669. }
  64670. if (StandardMaterial.RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  64671. _this._renderTargets.push(_this._refractionTexture);
  64672. }
  64673. return _this._renderTargets;
  64674. };
  64675. return _this;
  64676. }
  64677. Object.defineProperty(StandardMaterial.prototype, "imageProcessingConfiguration", {
  64678. /**
  64679. * Gets the image processing configuration used either in this material.
  64680. */
  64681. get: function () {
  64682. return this._imageProcessingConfiguration;
  64683. },
  64684. /**
  64685. * Sets the Default image processing configuration used either in the this material.
  64686. *
  64687. * If sets to null, the scene one is in use.
  64688. */
  64689. set: function (value) {
  64690. this._attachImageProcessingConfiguration(value);
  64691. // Ensure the effect will be rebuilt.
  64692. this._markAllSubMeshesAsTexturesDirty();
  64693. },
  64694. enumerable: true,
  64695. configurable: true
  64696. });
  64697. /**
  64698. * Attaches a new image processing configuration to the Standard Material.
  64699. * @param configuration
  64700. */
  64701. StandardMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  64702. var _this = this;
  64703. if (configuration === this._imageProcessingConfiguration) {
  64704. return;
  64705. }
  64706. // Detaches observer.
  64707. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  64708. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  64709. }
  64710. // Pick the scene configuration if needed.
  64711. if (!configuration) {
  64712. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  64713. }
  64714. else {
  64715. this._imageProcessingConfiguration = configuration;
  64716. }
  64717. // Attaches observer.
  64718. if (this._imageProcessingConfiguration) {
  64719. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  64720. _this._markAllSubMeshesAsImageProcessingDirty();
  64721. });
  64722. }
  64723. };
  64724. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurvesEnabled", {
  64725. /**
  64726. * Gets wether the color curves effect is enabled.
  64727. */
  64728. get: function () {
  64729. return this.imageProcessingConfiguration.colorCurvesEnabled;
  64730. },
  64731. /**
  64732. * Sets wether the color curves effect is enabled.
  64733. */
  64734. set: function (value) {
  64735. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  64736. },
  64737. enumerable: true,
  64738. configurable: true
  64739. });
  64740. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingEnabled", {
  64741. /**
  64742. * Gets wether the color grading effect is enabled.
  64743. */
  64744. get: function () {
  64745. return this.imageProcessingConfiguration.colorGradingEnabled;
  64746. },
  64747. /**
  64748. * Gets wether the color grading effect is enabled.
  64749. */
  64750. set: function (value) {
  64751. this.imageProcessingConfiguration.colorGradingEnabled = value;
  64752. },
  64753. enumerable: true,
  64754. configurable: true
  64755. });
  64756. Object.defineProperty(StandardMaterial.prototype, "cameraToneMappingEnabled", {
  64757. /**
  64758. * Gets wether tonemapping is enabled or not.
  64759. */
  64760. get: function () {
  64761. return this._imageProcessingConfiguration.toneMappingEnabled;
  64762. },
  64763. /**
  64764. * Sets wether tonemapping is enabled or not
  64765. */
  64766. set: function (value) {
  64767. this._imageProcessingConfiguration.toneMappingEnabled = value;
  64768. },
  64769. enumerable: true,
  64770. configurable: true
  64771. });
  64772. Object.defineProperty(StandardMaterial.prototype, "cameraExposure", {
  64773. /**
  64774. * The camera exposure used on this material.
  64775. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  64776. * This corresponds to a photographic exposure.
  64777. */
  64778. get: function () {
  64779. return this._imageProcessingConfiguration.exposure;
  64780. },
  64781. /**
  64782. * The camera exposure used on this material.
  64783. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  64784. * This corresponds to a photographic exposure.
  64785. */
  64786. set: function (value) {
  64787. this._imageProcessingConfiguration.exposure = value;
  64788. },
  64789. enumerable: true,
  64790. configurable: true
  64791. });
  64792. Object.defineProperty(StandardMaterial.prototype, "cameraContrast", {
  64793. /**
  64794. * Gets The camera contrast used on this material.
  64795. */
  64796. get: function () {
  64797. return this._imageProcessingConfiguration.contrast;
  64798. },
  64799. /**
  64800. * Sets The camera contrast used on this material.
  64801. */
  64802. set: function (value) {
  64803. this._imageProcessingConfiguration.contrast = value;
  64804. },
  64805. enumerable: true,
  64806. configurable: true
  64807. });
  64808. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingTexture", {
  64809. /**
  64810. * Gets the Color Grading 2D Lookup Texture.
  64811. */
  64812. get: function () {
  64813. return this._imageProcessingConfiguration.colorGradingTexture;
  64814. },
  64815. /**
  64816. * Sets the Color Grading 2D Lookup Texture.
  64817. */
  64818. set: function (value) {
  64819. this._imageProcessingConfiguration.colorGradingTexture = value;
  64820. },
  64821. enumerable: true,
  64822. configurable: true
  64823. });
  64824. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurves", {
  64825. /**
  64826. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  64827. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  64828. * 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;
  64829. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  64830. */
  64831. get: function () {
  64832. return this._imageProcessingConfiguration.colorCurves;
  64833. },
  64834. /**
  64835. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  64836. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  64837. * 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;
  64838. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  64839. */
  64840. set: function (value) {
  64841. this._imageProcessingConfiguration.colorCurves = value;
  64842. },
  64843. enumerable: true,
  64844. configurable: true
  64845. });
  64846. Object.defineProperty(StandardMaterial.prototype, "hasRenderTargetTextures", {
  64847. /**
  64848. * Gets a boolean indicating that current material needs to register RTT
  64849. */
  64850. get: function () {
  64851. if (StandardMaterial.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  64852. return true;
  64853. }
  64854. if (StandardMaterial.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  64855. return true;
  64856. }
  64857. return false;
  64858. },
  64859. enumerable: true,
  64860. configurable: true
  64861. });
  64862. /**
  64863. * Gets the current class name of the material e.g. "StandardMaterial"
  64864. * Mainly use in serialization.
  64865. * @returns the class name
  64866. */
  64867. StandardMaterial.prototype.getClassName = function () {
  64868. return "StandardMaterial";
  64869. };
  64870. Object.defineProperty(StandardMaterial.prototype, "useLogarithmicDepth", {
  64871. /**
  64872. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  64873. * You can try switching to logarithmic depth.
  64874. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  64875. */
  64876. get: function () {
  64877. return this._useLogarithmicDepth;
  64878. },
  64879. set: function (value) {
  64880. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  64881. this._markAllSubMeshesAsMiscDirty();
  64882. },
  64883. enumerable: true,
  64884. configurable: true
  64885. });
  64886. /**
  64887. * Specifies if the material will require alpha blending
  64888. * @returns a boolean specifying if alpha blending is needed
  64889. */
  64890. StandardMaterial.prototype.needAlphaBlending = function () {
  64891. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled;
  64892. };
  64893. /**
  64894. * Specifies if this material should be rendered in alpha test mode
  64895. * @returns a boolean specifying if an alpha test is needed.
  64896. */
  64897. StandardMaterial.prototype.needAlphaTesting = function () {
  64898. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha;
  64899. };
  64900. StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
  64901. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture;
  64902. };
  64903. /**
  64904. * Get the texture used for alpha test purpose.
  64905. * @returns the diffuse texture in case of the standard material.
  64906. */
  64907. StandardMaterial.prototype.getAlphaTestTexture = function () {
  64908. return this._diffuseTexture;
  64909. };
  64910. /**
  64911. * Get if the submesh is ready to be used and all its information available.
  64912. * Child classes can use it to update shaders
  64913. * @param mesh defines the mesh to check
  64914. * @param subMesh defines which submesh to check
  64915. * @param useInstances specifies that instances should be used
  64916. * @returns a boolean indicating that the submesh is ready or not
  64917. */
  64918. StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  64919. if (useInstances === void 0) { useInstances = false; }
  64920. if (subMesh.effect && this.isFrozen) {
  64921. if (this._wasPreviouslyReady) {
  64922. return true;
  64923. }
  64924. }
  64925. if (!subMesh._materialDefines) {
  64926. subMesh._materialDefines = new StandardMaterialDefines();
  64927. }
  64928. var scene = this.getScene();
  64929. var defines = subMesh._materialDefines;
  64930. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  64931. if (defines._renderId === scene.getRenderId()) {
  64932. return true;
  64933. }
  64934. }
  64935. var engine = scene.getEngine();
  64936. // Lights
  64937. defines._needNormals = _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  64938. // Textures
  64939. if (defines._areTexturesDirty) {
  64940. defines._needUVs = false;
  64941. defines.MAINUV1 = false;
  64942. defines.MAINUV2 = false;
  64943. if (scene.texturesEnabled) {
  64944. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  64945. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  64946. return false;
  64947. }
  64948. else {
  64949. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  64950. }
  64951. }
  64952. else {
  64953. defines.DIFFUSE = false;
  64954. }
  64955. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  64956. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  64957. return false;
  64958. }
  64959. else {
  64960. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  64961. }
  64962. }
  64963. else {
  64964. defines.AMBIENT = false;
  64965. }
  64966. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  64967. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  64968. return false;
  64969. }
  64970. else {
  64971. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  64972. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  64973. }
  64974. }
  64975. else {
  64976. defines.OPACITY = false;
  64977. }
  64978. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  64979. if (!this._reflectionTexture.isReadyOrNotBlocking()) {
  64980. return false;
  64981. }
  64982. else {
  64983. defines._needNormals = true;
  64984. defines.REFLECTION = true;
  64985. defines.ROUGHNESS = (this._roughness > 0);
  64986. defines.REFLECTIONOVERALPHA = this._useReflectionOverAlpha;
  64987. defines.INVERTCUBICMAP = (this._reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE);
  64988. defines.REFLECTIONMAP_3D = this._reflectionTexture.isCube;
  64989. switch (this._reflectionTexture.coordinatesMode) {
  64990. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  64991. defines.setReflectionMode("REFLECTIONMAP_EXPLICIT");
  64992. break;
  64993. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  64994. defines.setReflectionMode("REFLECTIONMAP_PLANAR");
  64995. break;
  64996. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  64997. defines.setReflectionMode("REFLECTIONMAP_PROJECTION");
  64998. break;
  64999. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  65000. defines.setReflectionMode("REFLECTIONMAP_SKYBOX");
  65001. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !this._reflectionTexture.getReflectionTextureMatrix().isIdentity();
  65002. break;
  65003. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  65004. defines.setReflectionMode("REFLECTIONMAP_SPHERICAL");
  65005. break;
  65006. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  65007. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
  65008. break;
  65009. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  65010. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
  65011. break;
  65012. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  65013. defines.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
  65014. break;
  65015. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  65016. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  65017. default:
  65018. defines.setReflectionMode("REFLECTIONMAP_CUBIC");
  65019. break;
  65020. }
  65021. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = this._reflectionTexture.boundingBoxSize ? true : false;
  65022. }
  65023. }
  65024. else {
  65025. defines.REFLECTION = false;
  65026. }
  65027. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  65028. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  65029. return false;
  65030. }
  65031. else {
  65032. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  65033. }
  65034. }
  65035. else {
  65036. defines.EMISSIVE = false;
  65037. }
  65038. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  65039. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  65040. return false;
  65041. }
  65042. else {
  65043. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  65044. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  65045. }
  65046. }
  65047. else {
  65048. defines.LIGHTMAP = false;
  65049. }
  65050. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  65051. if (!this._specularTexture.isReadyOrNotBlocking()) {
  65052. return false;
  65053. }
  65054. else {
  65055. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._specularTexture, defines, "SPECULAR");
  65056. defines.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
  65057. }
  65058. }
  65059. else {
  65060. defines.SPECULAR = false;
  65061. }
  65062. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && StandardMaterial.BumpTextureEnabled) {
  65063. // Bump texure can not be not blocking.
  65064. if (!this._bumpTexture.isReady()) {
  65065. return false;
  65066. }
  65067. else {
  65068. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  65069. defines.PARALLAX = this._useParallax;
  65070. defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
  65071. }
  65072. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  65073. }
  65074. else {
  65075. defines.BUMP = false;
  65076. }
  65077. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  65078. if (!this._refractionTexture.isReadyOrNotBlocking()) {
  65079. return false;
  65080. }
  65081. else {
  65082. defines._needUVs = true;
  65083. defines.REFRACTION = true;
  65084. defines.REFRACTIONMAP_3D = this._refractionTexture.isCube;
  65085. }
  65086. }
  65087. else {
  65088. defines.REFRACTION = false;
  65089. }
  65090. defines.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting;
  65091. }
  65092. else {
  65093. defines.DIFFUSE = false;
  65094. defines.AMBIENT = false;
  65095. defines.OPACITY = false;
  65096. defines.REFLECTION = false;
  65097. defines.EMISSIVE = false;
  65098. defines.LIGHTMAP = false;
  65099. defines.BUMP = false;
  65100. defines.REFRACTION = false;
  65101. }
  65102. defines.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture();
  65103. defines.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination;
  65104. defines.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse;
  65105. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  65106. 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);
  65107. }
  65108. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  65109. if (!this._imageProcessingConfiguration.isReady()) {
  65110. return false;
  65111. }
  65112. this._imageProcessingConfiguration.prepareDefines(defines);
  65113. defines.IS_REFLECTION_LINEAR = (this.reflectionTexture != null && !this.reflectionTexture.gammaSpace);
  65114. defines.IS_REFRACTION_LINEAR = (this.refractionTexture != null && !this.refractionTexture.gammaSpace);
  65115. }
  65116. if (defines._areFresnelDirty) {
  65117. if (StandardMaterial.FresnelEnabled) {
  65118. // Fresnel
  65119. if (this._diffuseFresnelParameters || this._opacityFresnelParameters ||
  65120. this._emissiveFresnelParameters || this._refractionFresnelParameters ||
  65121. this._reflectionFresnelParameters) {
  65122. defines.DIFFUSEFRESNEL = (this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled);
  65123. defines.OPACITYFRESNEL = (this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled);
  65124. defines.REFLECTIONFRESNEL = (this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled);
  65125. defines.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular;
  65126. defines.REFRACTIONFRESNEL = (this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled);
  65127. defines.EMISSIVEFRESNEL = (this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled);
  65128. defines._needNormals = true;
  65129. defines.FRESNEL = true;
  65130. }
  65131. }
  65132. else {
  65133. defines.FRESNEL = false;
  65134. }
  65135. }
  65136. // Misc.
  65137. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  65138. // Attribs
  65139. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true);
  65140. // Values that need to be evaluated on every frame
  65141. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  65142. // Get correct effect
  65143. if (defines.isDirty) {
  65144. defines.markAsProcessed();
  65145. // Fallbacks
  65146. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_7__["EffectFallbacks"]();
  65147. if (defines.REFLECTION) {
  65148. fallbacks.addFallback(0, "REFLECTION");
  65149. }
  65150. if (defines.SPECULAR) {
  65151. fallbacks.addFallback(0, "SPECULAR");
  65152. }
  65153. if (defines.BUMP) {
  65154. fallbacks.addFallback(0, "BUMP");
  65155. }
  65156. if (defines.PARALLAX) {
  65157. fallbacks.addFallback(1, "PARALLAX");
  65158. }
  65159. if (defines.PARALLAXOCCLUSION) {
  65160. fallbacks.addFallback(0, "PARALLAXOCCLUSION");
  65161. }
  65162. if (defines.SPECULAROVERALPHA) {
  65163. fallbacks.addFallback(0, "SPECULAROVERALPHA");
  65164. }
  65165. if (defines.FOG) {
  65166. fallbacks.addFallback(1, "FOG");
  65167. }
  65168. if (defines.POINTSIZE) {
  65169. fallbacks.addFallback(0, "POINTSIZE");
  65170. }
  65171. if (defines.LOGARITHMICDEPTH) {
  65172. fallbacks.addFallback(0, "LOGARITHMICDEPTH");
  65173. }
  65174. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  65175. if (defines.SPECULARTERM) {
  65176. fallbacks.addFallback(0, "SPECULARTERM");
  65177. }
  65178. if (defines.DIFFUSEFRESNEL) {
  65179. fallbacks.addFallback(1, "DIFFUSEFRESNEL");
  65180. }
  65181. if (defines.OPACITYFRESNEL) {
  65182. fallbacks.addFallback(2, "OPACITYFRESNEL");
  65183. }
  65184. if (defines.REFLECTIONFRESNEL) {
  65185. fallbacks.addFallback(3, "REFLECTIONFRESNEL");
  65186. }
  65187. if (defines.EMISSIVEFRESNEL) {
  65188. fallbacks.addFallback(4, "EMISSIVEFRESNEL");
  65189. }
  65190. if (defines.FRESNEL) {
  65191. fallbacks.addFallback(4, "FRESNEL");
  65192. }
  65193. //Attributes
  65194. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  65195. if (defines.NORMAL) {
  65196. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  65197. }
  65198. if (defines.UV1) {
  65199. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  65200. }
  65201. if (defines.UV2) {
  65202. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  65203. }
  65204. if (defines.VERTEXCOLOR) {
  65205. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind);
  65206. }
  65207. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  65208. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  65209. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  65210. var shaderName = "default";
  65211. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor",
  65212. "vFogInfos", "vFogColor", "pointSize",
  65213. "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  65214. "mBones",
  65215. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix",
  65216. "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
  65217. "vReflectionPosition", "vReflectionSize",
  65218. "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth"
  65219. ];
  65220. var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler",
  65221. "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler",
  65222. "refractionCubeSampler", "refraction2DSampler", "boneSampler"];
  65223. var uniformBuffers = ["Material", "Scene"];
  65224. if (_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"]) {
  65225. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  65226. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  65227. }
  65228. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareUniformsAndSamplersList({
  65229. uniformsNames: uniforms,
  65230. uniformBuffersNames: uniformBuffers,
  65231. samplers: samplers,
  65232. defines: defines,
  65233. maxSimultaneousLights: this._maxSimultaneousLights
  65234. });
  65235. if (this.customShaderNameResolve) {
  65236. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  65237. }
  65238. var join = defines.toString();
  65239. var previousEffect = subMesh.effect;
  65240. var effect = scene.getEngine().createEffect(shaderName, {
  65241. attributes: attribs,
  65242. uniformsNames: uniforms,
  65243. uniformBuffersNames: uniformBuffers,
  65244. samplers: samplers,
  65245. defines: join,
  65246. fallbacks: fallbacks,
  65247. onCompiled: this.onCompiled,
  65248. onError: this.onError,
  65249. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  65250. }, engine);
  65251. if (effect) {
  65252. // Use previous effect while new one is compiling
  65253. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  65254. effect = previousEffect;
  65255. defines.markAsUnprocessed();
  65256. }
  65257. else {
  65258. scene.resetCachedMaterial();
  65259. subMesh.setEffect(effect, defines);
  65260. this.buildUniformLayout();
  65261. }
  65262. }
  65263. }
  65264. if (!subMesh.effect || !subMesh.effect.isReady()) {
  65265. return false;
  65266. }
  65267. defines._renderId = scene.getRenderId();
  65268. this._wasPreviouslyReady = true;
  65269. return true;
  65270. };
  65271. /**
  65272. * Builds the material UBO layouts.
  65273. * Used internally during the effect preparation.
  65274. */
  65275. StandardMaterial.prototype.buildUniformLayout = function () {
  65276. // Order is important !
  65277. this._uniformBuffer.addUniform("diffuseLeftColor", 4);
  65278. this._uniformBuffer.addUniform("diffuseRightColor", 4);
  65279. this._uniformBuffer.addUniform("opacityParts", 4);
  65280. this._uniformBuffer.addUniform("reflectionLeftColor", 4);
  65281. this._uniformBuffer.addUniform("reflectionRightColor", 4);
  65282. this._uniformBuffer.addUniform("refractionLeftColor", 4);
  65283. this._uniformBuffer.addUniform("refractionRightColor", 4);
  65284. this._uniformBuffer.addUniform("emissiveLeftColor", 4);
  65285. this._uniformBuffer.addUniform("emissiveRightColor", 4);
  65286. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  65287. this._uniformBuffer.addUniform("vAmbientInfos", 2);
  65288. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  65289. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  65290. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  65291. this._uniformBuffer.addUniform("vReflectionSize", 3);
  65292. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  65293. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  65294. this._uniformBuffer.addUniform("vSpecularInfos", 2);
  65295. this._uniformBuffer.addUniform("vBumpInfos", 3);
  65296. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  65297. this._uniformBuffer.addUniform("ambientMatrix", 16);
  65298. this._uniformBuffer.addUniform("opacityMatrix", 16);
  65299. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  65300. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  65301. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  65302. this._uniformBuffer.addUniform("specularMatrix", 16);
  65303. this._uniformBuffer.addUniform("bumpMatrix", 16);
  65304. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  65305. this._uniformBuffer.addUniform("refractionMatrix", 16);
  65306. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  65307. this._uniformBuffer.addUniform("vSpecularColor", 4);
  65308. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  65309. this._uniformBuffer.addUniform("vDiffuseColor", 4);
  65310. this._uniformBuffer.addUniform("pointSize", 1);
  65311. this._uniformBuffer.create();
  65312. };
  65313. /**
  65314. * Unbinds the material from the mesh
  65315. */
  65316. StandardMaterial.prototype.unbind = function () {
  65317. if (this._activeEffect) {
  65318. var needFlag = false;
  65319. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  65320. this._activeEffect.setTexture("reflection2DSampler", null);
  65321. needFlag = true;
  65322. }
  65323. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  65324. this._activeEffect.setTexture("refraction2DSampler", null);
  65325. needFlag = true;
  65326. }
  65327. if (needFlag) {
  65328. this._markAllSubMeshesAsTexturesDirty();
  65329. }
  65330. }
  65331. _super.prototype.unbind.call(this);
  65332. };
  65333. /**
  65334. * Binds the submesh to this material by preparing the effect and shader to draw
  65335. * @param world defines the world transformation matrix
  65336. * @param mesh defines the mesh containing the submesh
  65337. * @param subMesh defines the submesh to bind the material to
  65338. */
  65339. StandardMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  65340. var scene = this.getScene();
  65341. var defines = subMesh._materialDefines;
  65342. if (!defines) {
  65343. return;
  65344. }
  65345. var effect = subMesh.effect;
  65346. if (!effect) {
  65347. return;
  65348. }
  65349. this._activeEffect = effect;
  65350. // Matrices
  65351. this.bindOnlyWorldMatrix(world);
  65352. // Normal Matrix
  65353. if (defines.OBJECTSPACE_NORMALMAP) {
  65354. world.toNormalMatrix(this._normalMatrix);
  65355. this.bindOnlyNormalMatrix(this._normalMatrix);
  65356. }
  65357. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  65358. // Bones
  65359. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindBonesParameters(mesh, effect);
  65360. if (mustRebind) {
  65361. this._uniformBuffer.bindToEffect(effect, "Material");
  65362. this.bindViewProjection(effect);
  65363. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  65364. if (StandardMaterial.FresnelEnabled && defines.FRESNEL) {
  65365. // Fresnel
  65366. if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled) {
  65367. this._uniformBuffer.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power);
  65368. this._uniformBuffer.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias);
  65369. }
  65370. if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
  65371. 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);
  65372. }
  65373. if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
  65374. this._uniformBuffer.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power);
  65375. this._uniformBuffer.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias);
  65376. }
  65377. if (this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled) {
  65378. this._uniformBuffer.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power);
  65379. this._uniformBuffer.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias);
  65380. }
  65381. if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) {
  65382. this._uniformBuffer.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power);
  65383. this._uniformBuffer.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias);
  65384. }
  65385. }
  65386. // Textures
  65387. if (scene.texturesEnabled) {
  65388. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  65389. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  65390. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  65391. if (this._diffuseTexture.hasAlpha) {
  65392. effect.setFloat("alphaCutOff", this.alphaCutOff);
  65393. }
  65394. }
  65395. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  65396. this._uniformBuffer.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level);
  65397. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  65398. }
  65399. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  65400. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  65401. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  65402. }
  65403. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  65404. this._uniformBuffer.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness);
  65405. this._uniformBuffer.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix());
  65406. if (this._reflectionTexture.boundingBoxSize) {
  65407. var cubeTexture = this._reflectionTexture;
  65408. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  65409. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  65410. }
  65411. }
  65412. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  65413. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  65414. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  65415. }
  65416. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  65417. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  65418. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  65419. }
  65420. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  65421. this._uniformBuffer.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level);
  65422. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._specularTexture, this._uniformBuffer, "specular");
  65423. }
  65424. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  65425. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
  65426. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  65427. if (scene._mirroredCameraPosition) {
  65428. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  65429. }
  65430. else {
  65431. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  65432. }
  65433. }
  65434. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  65435. var depth = 1.0;
  65436. if (!this._refractionTexture.isCube) {
  65437. this._uniformBuffer.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix());
  65438. if (this._refractionTexture.depth) {
  65439. depth = this._refractionTexture.depth;
  65440. }
  65441. }
  65442. this._uniformBuffer.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1);
  65443. }
  65444. }
  65445. // Point size
  65446. if (this.pointsCloud) {
  65447. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  65448. }
  65449. if (defines.SPECULARTERM) {
  65450. this._uniformBuffer.updateColor4("vSpecularColor", this.specularColor, this.specularPower);
  65451. }
  65452. this._uniformBuffer.updateColor3("vEmissiveColor", StandardMaterial.EmissiveTextureEnabled ? this.emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].BlackReadOnly);
  65453. // Diffuse
  65454. this._uniformBuffer.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  65455. }
  65456. // Textures
  65457. if (scene.texturesEnabled) {
  65458. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  65459. effect.setTexture("diffuseSampler", this._diffuseTexture);
  65460. }
  65461. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  65462. effect.setTexture("ambientSampler", this._ambientTexture);
  65463. }
  65464. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  65465. effect.setTexture("opacitySampler", this._opacityTexture);
  65466. }
  65467. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  65468. if (this._reflectionTexture.isCube) {
  65469. effect.setTexture("reflectionCubeSampler", this._reflectionTexture);
  65470. }
  65471. else {
  65472. effect.setTexture("reflection2DSampler", this._reflectionTexture);
  65473. }
  65474. }
  65475. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  65476. effect.setTexture("emissiveSampler", this._emissiveTexture);
  65477. }
  65478. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  65479. effect.setTexture("lightmapSampler", this._lightmapTexture);
  65480. }
  65481. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  65482. effect.setTexture("specularSampler", this._specularTexture);
  65483. }
  65484. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  65485. effect.setTexture("bumpSampler", this._bumpTexture);
  65486. }
  65487. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  65488. var depth = 1.0;
  65489. if (this._refractionTexture.isCube) {
  65490. effect.setTexture("refractionCubeSampler", this._refractionTexture);
  65491. }
  65492. else {
  65493. effect.setTexture("refraction2DSampler", this._refractionTexture);
  65494. }
  65495. }
  65496. }
  65497. // Clip plane
  65498. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindClipPlane(effect, scene);
  65499. // Colors
  65500. scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
  65501. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindEyePosition(effect, scene);
  65502. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  65503. }
  65504. if (mustRebind || !this.isFrozen) {
  65505. // Lights
  65506. if (scene.lightsEnabled && !this._disableLighting) {
  65507. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLights(scene, mesh, effect, defines, this._maxSimultaneousLights);
  65508. }
  65509. // View
  65510. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].FOGMODE_NONE || this._reflectionTexture || this._refractionTexture) {
  65511. this.bindView(effect);
  65512. }
  65513. // Fog
  65514. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindFogParameters(scene, mesh, effect);
  65515. // Morph targets
  65516. if (defines.NUM_MORPH_INFLUENCERS) {
  65517. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, effect);
  65518. }
  65519. // Log. depth
  65520. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLogDepth(defines, effect, scene);
  65521. // image processing
  65522. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  65523. this._imageProcessingConfiguration.bind(this._activeEffect);
  65524. }
  65525. }
  65526. this._uniformBuffer.update();
  65527. this._afterBind(mesh, this._activeEffect);
  65528. };
  65529. /**
  65530. * Get the list of animatables in the material.
  65531. * @returns the list of animatables object used in the material
  65532. */
  65533. StandardMaterial.prototype.getAnimatables = function () {
  65534. var results = [];
  65535. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  65536. results.push(this._diffuseTexture);
  65537. }
  65538. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  65539. results.push(this._ambientTexture);
  65540. }
  65541. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  65542. results.push(this._opacityTexture);
  65543. }
  65544. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  65545. results.push(this._reflectionTexture);
  65546. }
  65547. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  65548. results.push(this._emissiveTexture);
  65549. }
  65550. if (this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0) {
  65551. results.push(this._specularTexture);
  65552. }
  65553. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  65554. results.push(this._bumpTexture);
  65555. }
  65556. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  65557. results.push(this._lightmapTexture);
  65558. }
  65559. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  65560. results.push(this._refractionTexture);
  65561. }
  65562. return results;
  65563. };
  65564. /**
  65565. * Gets the active textures from the material
  65566. * @returns an array of textures
  65567. */
  65568. StandardMaterial.prototype.getActiveTextures = function () {
  65569. var activeTextures = _super.prototype.getActiveTextures.call(this);
  65570. if (this._diffuseTexture) {
  65571. activeTextures.push(this._diffuseTexture);
  65572. }
  65573. if (this._ambientTexture) {
  65574. activeTextures.push(this._ambientTexture);
  65575. }
  65576. if (this._opacityTexture) {
  65577. activeTextures.push(this._opacityTexture);
  65578. }
  65579. if (this._reflectionTexture) {
  65580. activeTextures.push(this._reflectionTexture);
  65581. }
  65582. if (this._emissiveTexture) {
  65583. activeTextures.push(this._emissiveTexture);
  65584. }
  65585. if (this._specularTexture) {
  65586. activeTextures.push(this._specularTexture);
  65587. }
  65588. if (this._bumpTexture) {
  65589. activeTextures.push(this._bumpTexture);
  65590. }
  65591. if (this._lightmapTexture) {
  65592. activeTextures.push(this._lightmapTexture);
  65593. }
  65594. if (this._refractionTexture) {
  65595. activeTextures.push(this._refractionTexture);
  65596. }
  65597. return activeTextures;
  65598. };
  65599. /**
  65600. * Specifies if the material uses a texture
  65601. * @param texture defines the texture to check against the material
  65602. * @returns a boolean specifying if the material uses the texture
  65603. */
  65604. StandardMaterial.prototype.hasTexture = function (texture) {
  65605. if (_super.prototype.hasTexture.call(this, texture)) {
  65606. return true;
  65607. }
  65608. if (this._diffuseTexture === texture) {
  65609. return true;
  65610. }
  65611. if (this._ambientTexture === texture) {
  65612. return true;
  65613. }
  65614. if (this._opacityTexture === texture) {
  65615. return true;
  65616. }
  65617. if (this._reflectionTexture === texture) {
  65618. return true;
  65619. }
  65620. if (this._emissiveTexture === texture) {
  65621. return true;
  65622. }
  65623. if (this._specularTexture === texture) {
  65624. return true;
  65625. }
  65626. if (this._bumpTexture === texture) {
  65627. return true;
  65628. }
  65629. if (this._lightmapTexture === texture) {
  65630. return true;
  65631. }
  65632. if (this._refractionTexture === texture) {
  65633. return true;
  65634. }
  65635. return false;
  65636. };
  65637. /**
  65638. * Disposes the material
  65639. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  65640. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  65641. */
  65642. StandardMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  65643. if (forceDisposeTextures) {
  65644. if (this._diffuseTexture) {
  65645. this._diffuseTexture.dispose();
  65646. }
  65647. if (this._ambientTexture) {
  65648. this._ambientTexture.dispose();
  65649. }
  65650. if (this._opacityTexture) {
  65651. this._opacityTexture.dispose();
  65652. }
  65653. if (this._reflectionTexture) {
  65654. this._reflectionTexture.dispose();
  65655. }
  65656. if (this._emissiveTexture) {
  65657. this._emissiveTexture.dispose();
  65658. }
  65659. if (this._specularTexture) {
  65660. this._specularTexture.dispose();
  65661. }
  65662. if (this._bumpTexture) {
  65663. this._bumpTexture.dispose();
  65664. }
  65665. if (this._lightmapTexture) {
  65666. this._lightmapTexture.dispose();
  65667. }
  65668. if (this._refractionTexture) {
  65669. this._refractionTexture.dispose();
  65670. }
  65671. }
  65672. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  65673. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  65674. }
  65675. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  65676. };
  65677. /**
  65678. * Makes a duplicate of the material, and gives it a new name
  65679. * @param name defines the new name for the duplicated material
  65680. * @returns the cloned material
  65681. */
  65682. StandardMaterial.prototype.clone = function (name) {
  65683. var _this = this;
  65684. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new StandardMaterial(name, _this.getScene()); }, this);
  65685. result.name = name;
  65686. result.id = name;
  65687. return result;
  65688. };
  65689. /**
  65690. * Serializes this material in a JSON representation
  65691. * @returns the serialized material object
  65692. */
  65693. StandardMaterial.prototype.serialize = function () {
  65694. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  65695. };
  65696. /**
  65697. * Creates a standard material from parsed material data
  65698. * @param source defines the JSON representation of the material
  65699. * @param scene defines the hosting scene
  65700. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  65701. * @returns a new standard material
  65702. */
  65703. StandardMaterial.Parse = function (source, scene, rootUrl) {
  65704. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardMaterial(source.name, scene); }, source, scene, rootUrl);
  65705. };
  65706. Object.defineProperty(StandardMaterial, "DiffuseTextureEnabled", {
  65707. // Flags used to enable or disable a type of texture for all Standard Materials
  65708. /**
  65709. * Are diffuse textures enabled in the application.
  65710. */
  65711. get: function () {
  65712. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled;
  65713. },
  65714. set: function (value) {
  65715. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled = value;
  65716. },
  65717. enumerable: true,
  65718. configurable: true
  65719. });
  65720. Object.defineProperty(StandardMaterial, "AmbientTextureEnabled", {
  65721. /**
  65722. * Are ambient textures enabled in the application.
  65723. */
  65724. get: function () {
  65725. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled;
  65726. },
  65727. set: function (value) {
  65728. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled = value;
  65729. },
  65730. enumerable: true,
  65731. configurable: true
  65732. });
  65733. Object.defineProperty(StandardMaterial, "OpacityTextureEnabled", {
  65734. /**
  65735. * Are opacity textures enabled in the application.
  65736. */
  65737. get: function () {
  65738. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled;
  65739. },
  65740. set: function (value) {
  65741. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled = value;
  65742. },
  65743. enumerable: true,
  65744. configurable: true
  65745. });
  65746. Object.defineProperty(StandardMaterial, "ReflectionTextureEnabled", {
  65747. /**
  65748. * Are reflection textures enabled in the application.
  65749. */
  65750. get: function () {
  65751. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled;
  65752. },
  65753. set: function (value) {
  65754. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled = value;
  65755. },
  65756. enumerable: true,
  65757. configurable: true
  65758. });
  65759. Object.defineProperty(StandardMaterial, "EmissiveTextureEnabled", {
  65760. /**
  65761. * Are emissive textures enabled in the application.
  65762. */
  65763. get: function () {
  65764. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled;
  65765. },
  65766. set: function (value) {
  65767. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled = value;
  65768. },
  65769. enumerable: true,
  65770. configurable: true
  65771. });
  65772. Object.defineProperty(StandardMaterial, "SpecularTextureEnabled", {
  65773. /**
  65774. * Are specular textures enabled in the application.
  65775. */
  65776. get: function () {
  65777. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled;
  65778. },
  65779. set: function (value) {
  65780. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled = value;
  65781. },
  65782. enumerable: true,
  65783. configurable: true
  65784. });
  65785. Object.defineProperty(StandardMaterial, "BumpTextureEnabled", {
  65786. /**
  65787. * Are bump textures enabled in the application.
  65788. */
  65789. get: function () {
  65790. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled;
  65791. },
  65792. set: function (value) {
  65793. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled = value;
  65794. },
  65795. enumerable: true,
  65796. configurable: true
  65797. });
  65798. Object.defineProperty(StandardMaterial, "LightmapTextureEnabled", {
  65799. /**
  65800. * Are lightmap textures enabled in the application.
  65801. */
  65802. get: function () {
  65803. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled;
  65804. },
  65805. set: function (value) {
  65806. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled = value;
  65807. },
  65808. enumerable: true,
  65809. configurable: true
  65810. });
  65811. Object.defineProperty(StandardMaterial, "RefractionTextureEnabled", {
  65812. /**
  65813. * Are refraction textures enabled in the application.
  65814. */
  65815. get: function () {
  65816. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled;
  65817. },
  65818. set: function (value) {
  65819. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled = value;
  65820. },
  65821. enumerable: true,
  65822. configurable: true
  65823. });
  65824. Object.defineProperty(StandardMaterial, "ColorGradingTextureEnabled", {
  65825. /**
  65826. * Are color grading textures enabled in the application.
  65827. */
  65828. get: function () {
  65829. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled;
  65830. },
  65831. set: function (value) {
  65832. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled = value;
  65833. },
  65834. enumerable: true,
  65835. configurable: true
  65836. });
  65837. Object.defineProperty(StandardMaterial, "FresnelEnabled", {
  65838. /**
  65839. * Are fresnels enabled in the application.
  65840. */
  65841. get: function () {
  65842. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled;
  65843. },
  65844. set: function (value) {
  65845. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled = value;
  65846. },
  65847. enumerable: true,
  65848. configurable: true
  65849. });
  65850. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65851. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
  65852. ], StandardMaterial.prototype, "_diffuseTexture", void 0);
  65853. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65854. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  65855. ], StandardMaterial.prototype, "diffuseTexture", void 0);
  65856. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65857. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("ambientTexture")
  65858. ], StandardMaterial.prototype, "_ambientTexture", void 0);
  65859. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65860. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65861. ], StandardMaterial.prototype, "ambientTexture", void 0);
  65862. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65863. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("opacityTexture")
  65864. ], StandardMaterial.prototype, "_opacityTexture", void 0);
  65865. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65866. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  65867. ], StandardMaterial.prototype, "opacityTexture", void 0);
  65868. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65869. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("reflectionTexture")
  65870. ], StandardMaterial.prototype, "_reflectionTexture", void 0);
  65871. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65872. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65873. ], StandardMaterial.prototype, "reflectionTexture", void 0);
  65874. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65875. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("emissiveTexture")
  65876. ], StandardMaterial.prototype, "_emissiveTexture", void 0);
  65877. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65878. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65879. ], StandardMaterial.prototype, "emissiveTexture", void 0);
  65880. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65881. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("specularTexture")
  65882. ], StandardMaterial.prototype, "_specularTexture", void 0);
  65883. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65884. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65885. ], StandardMaterial.prototype, "specularTexture", void 0);
  65886. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65887. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture")
  65888. ], StandardMaterial.prototype, "_bumpTexture", void 0);
  65889. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65890. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65891. ], StandardMaterial.prototype, "bumpTexture", void 0);
  65892. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65893. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lightmapTexture")
  65894. ], StandardMaterial.prototype, "_lightmapTexture", void 0);
  65895. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65896. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65897. ], StandardMaterial.prototype, "lightmapTexture", void 0);
  65898. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65899. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("refractionTexture")
  65900. ], StandardMaterial.prototype, "_refractionTexture", void 0);
  65901. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65902. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65903. ], StandardMaterial.prototype, "refractionTexture", void 0);
  65904. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65905. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient")
  65906. ], StandardMaterial.prototype, "ambientColor", void 0);
  65907. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65908. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse")
  65909. ], StandardMaterial.prototype, "diffuseColor", void 0);
  65910. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65911. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular")
  65912. ], StandardMaterial.prototype, "specularColor", void 0);
  65913. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65914. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive")
  65915. ], StandardMaterial.prototype, "emissiveColor", void 0);
  65916. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65917. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65918. ], StandardMaterial.prototype, "specularPower", void 0);
  65919. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65920. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useAlphaFromDiffuseTexture")
  65921. ], StandardMaterial.prototype, "_useAlphaFromDiffuseTexture", void 0);
  65922. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65923. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65924. ], StandardMaterial.prototype, "useAlphaFromDiffuseTexture", void 0);
  65925. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65926. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useEmissiveAsIllumination")
  65927. ], StandardMaterial.prototype, "_useEmissiveAsIllumination", void 0);
  65928. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65929. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65930. ], StandardMaterial.prototype, "useEmissiveAsIllumination", void 0);
  65931. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65932. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("linkEmissiveWithDiffuse")
  65933. ], StandardMaterial.prototype, "_linkEmissiveWithDiffuse", void 0);
  65934. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65935. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65936. ], StandardMaterial.prototype, "linkEmissiveWithDiffuse", void 0);
  65937. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65938. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useSpecularOverAlpha")
  65939. ], StandardMaterial.prototype, "_useSpecularOverAlpha", void 0);
  65940. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65941. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65942. ], StandardMaterial.prototype, "useSpecularOverAlpha", void 0);
  65943. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65944. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionOverAlpha")
  65945. ], StandardMaterial.prototype, "_useReflectionOverAlpha", void 0);
  65946. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65947. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65948. ], StandardMaterial.prototype, "useReflectionOverAlpha", void 0);
  65949. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65950. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
  65951. ], StandardMaterial.prototype, "_disableLighting", void 0);
  65952. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65953. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  65954. ], StandardMaterial.prototype, "disableLighting", void 0);
  65955. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65956. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useObjectSpaceNormalMap")
  65957. ], StandardMaterial.prototype, "_useObjectSpaceNormalMap", void 0);
  65958. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65959. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65960. ], StandardMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  65961. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65962. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallax")
  65963. ], StandardMaterial.prototype, "_useParallax", void 0);
  65964. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65965. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65966. ], StandardMaterial.prototype, "useParallax", void 0);
  65967. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65968. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallaxOcclusion")
  65969. ], StandardMaterial.prototype, "_useParallaxOcclusion", void 0);
  65970. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65971. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65972. ], StandardMaterial.prototype, "useParallaxOcclusion", void 0);
  65973. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65974. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65975. ], StandardMaterial.prototype, "parallaxScaleBias", void 0);
  65976. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65977. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("roughness")
  65978. ], StandardMaterial.prototype, "_roughness", void 0);
  65979. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65980. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65981. ], StandardMaterial.prototype, "roughness", void 0);
  65982. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65983. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65984. ], StandardMaterial.prototype, "indexOfRefraction", void 0);
  65985. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65986. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65987. ], StandardMaterial.prototype, "invertRefractionY", void 0);
  65988. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65989. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65990. ], StandardMaterial.prototype, "alphaCutOff", void 0);
  65991. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65992. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useLightmapAsShadowmap")
  65993. ], StandardMaterial.prototype, "_useLightmapAsShadowmap", void 0);
  65994. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65995. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  65996. ], StandardMaterial.prototype, "useLightmapAsShadowmap", void 0);
  65997. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65998. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("diffuseFresnelParameters")
  65999. ], StandardMaterial.prototype, "_diffuseFresnelParameters", void 0);
  66000. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66001. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66002. ], StandardMaterial.prototype, "diffuseFresnelParameters", void 0);
  66003. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66004. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("opacityFresnelParameters")
  66005. ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
  66006. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66007. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelAndMiscDirty")
  66008. ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
  66009. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66010. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("reflectionFresnelParameters")
  66011. ], StandardMaterial.prototype, "_reflectionFresnelParameters", void 0);
  66012. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66013. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66014. ], StandardMaterial.prototype, "reflectionFresnelParameters", void 0);
  66015. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66016. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("refractionFresnelParameters")
  66017. ], StandardMaterial.prototype, "_refractionFresnelParameters", void 0);
  66018. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66019. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66020. ], StandardMaterial.prototype, "refractionFresnelParameters", void 0);
  66021. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66022. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("emissiveFresnelParameters")
  66023. ], StandardMaterial.prototype, "_emissiveFresnelParameters", void 0);
  66024. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66025. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66026. ], StandardMaterial.prototype, "emissiveFresnelParameters", void 0);
  66027. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66028. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionFresnelFromSpecular")
  66029. ], StandardMaterial.prototype, "_useReflectionFresnelFromSpecular", void 0);
  66030. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66031. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  66032. ], StandardMaterial.prototype, "useReflectionFresnelFromSpecular", void 0);
  66033. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66034. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useGlossinessFromSpecularMapAlpha")
  66035. ], StandardMaterial.prototype, "_useGlossinessFromSpecularMapAlpha", void 0);
  66036. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66037. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66038. ], StandardMaterial.prototype, "useGlossinessFromSpecularMapAlpha", void 0);
  66039. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66040. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
  66041. ], StandardMaterial.prototype, "_maxSimultaneousLights", void 0);
  66042. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66043. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  66044. ], StandardMaterial.prototype, "maxSimultaneousLights", void 0);
  66045. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66046. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapX")
  66047. ], StandardMaterial.prototype, "_invertNormalMapX", void 0);
  66048. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66049. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66050. ], StandardMaterial.prototype, "invertNormalMapX", void 0);
  66051. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66052. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapY")
  66053. ], StandardMaterial.prototype, "_invertNormalMapY", void 0);
  66054. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66055. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66056. ], StandardMaterial.prototype, "invertNormalMapY", void 0);
  66057. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66058. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("twoSidedLighting")
  66059. ], StandardMaterial.prototype, "_twoSidedLighting", void 0);
  66060. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66061. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  66062. ], StandardMaterial.prototype, "twoSidedLighting", void 0);
  66063. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66064. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66065. ], StandardMaterial.prototype, "useLogarithmicDepth", null);
  66066. return StandardMaterial;
  66067. }(_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  66068. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardMaterial"] = StandardMaterial;
  66069. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].DefaultMaterialFactory = function (scene) {
  66070. return new StandardMaterial("default material", scene);
  66071. };
  66072. /***/ }),
  66073. /***/ "./Materials/uniformBuffer.ts":
  66074. /*!************************************!*\
  66075. !*** ./Materials/uniformBuffer.ts ***!
  66076. \************************************/
  66077. /*! exports provided: UniformBuffer */
  66078. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66079. "use strict";
  66080. __webpack_require__.r(__webpack_exports__);
  66081. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return UniformBuffer; });
  66082. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  66083. /**
  66084. * Uniform buffer objects.
  66085. *
  66086. * Handles blocks of uniform on the GPU.
  66087. *
  66088. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  66089. *
  66090. * For more information, please refer to :
  66091. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  66092. */
  66093. var UniformBuffer = /** @class */ (function () {
  66094. /**
  66095. * Instantiates a new Uniform buffer objects.
  66096. *
  66097. * Handles blocks of uniform on the GPU.
  66098. *
  66099. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  66100. *
  66101. * For more information, please refer to :
  66102. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  66103. * @param engine Define the engine the buffer is associated with
  66104. * @param data Define the data contained in the buffer
  66105. * @param dynamic Define if the buffer is updatable
  66106. */
  66107. function UniformBuffer(engine, data, dynamic) {
  66108. this._engine = engine;
  66109. this._noUBO = !engine.supportsUniformBuffers;
  66110. this._dynamic = dynamic;
  66111. this._data = data || [];
  66112. this._uniformLocations = {};
  66113. this._uniformSizes = {};
  66114. this._uniformLocationPointer = 0;
  66115. this._needSync = false;
  66116. if (this._noUBO) {
  66117. this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;
  66118. this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;
  66119. this.updateFloat = this._updateFloatForEffect;
  66120. this.updateFloat2 = this._updateFloat2ForEffect;
  66121. this.updateFloat3 = this._updateFloat3ForEffect;
  66122. this.updateFloat4 = this._updateFloat4ForEffect;
  66123. this.updateMatrix = this._updateMatrixForEffect;
  66124. this.updateVector3 = this._updateVector3ForEffect;
  66125. this.updateVector4 = this._updateVector4ForEffect;
  66126. this.updateColor3 = this._updateColor3ForEffect;
  66127. this.updateColor4 = this._updateColor4ForEffect;
  66128. }
  66129. else {
  66130. this._engine._uniformBuffers.push(this);
  66131. this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
  66132. this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
  66133. this.updateFloat = this._updateFloatForUniform;
  66134. this.updateFloat2 = this._updateFloat2ForUniform;
  66135. this.updateFloat3 = this._updateFloat3ForUniform;
  66136. this.updateFloat4 = this._updateFloat4ForUniform;
  66137. this.updateMatrix = this._updateMatrixForUniform;
  66138. this.updateVector3 = this._updateVector3ForUniform;
  66139. this.updateVector4 = this._updateVector4ForUniform;
  66140. this.updateColor3 = this._updateColor3ForUniform;
  66141. this.updateColor4 = this._updateColor4ForUniform;
  66142. }
  66143. }
  66144. Object.defineProperty(UniformBuffer.prototype, "useUbo", {
  66145. /**
  66146. * Indicates if the buffer is using the WebGL2 UBO implementation,
  66147. * or just falling back on setUniformXXX calls.
  66148. */
  66149. get: function () {
  66150. return !this._noUBO;
  66151. },
  66152. enumerable: true,
  66153. configurable: true
  66154. });
  66155. Object.defineProperty(UniformBuffer.prototype, "isSync", {
  66156. /**
  66157. * Indicates if the WebGL underlying uniform buffer is in sync
  66158. * with the javascript cache data.
  66159. */
  66160. get: function () {
  66161. return !this._needSync;
  66162. },
  66163. enumerable: true,
  66164. configurable: true
  66165. });
  66166. /**
  66167. * Indicates if the WebGL underlying uniform buffer is dynamic.
  66168. * Also, a dynamic UniformBuffer will disable cache verification and always
  66169. * update the underlying WebGL uniform buffer to the GPU.
  66170. * @returns if Dynamic, otherwise false
  66171. */
  66172. UniformBuffer.prototype.isDynamic = function () {
  66173. return this._dynamic !== undefined;
  66174. };
  66175. /**
  66176. * The data cache on JS side.
  66177. * @returns the underlying data as a float array
  66178. */
  66179. UniformBuffer.prototype.getData = function () {
  66180. return this._bufferData;
  66181. };
  66182. /**
  66183. * The underlying WebGL Uniform buffer.
  66184. * @returns the webgl buffer
  66185. */
  66186. UniformBuffer.prototype.getBuffer = function () {
  66187. return this._buffer;
  66188. };
  66189. /**
  66190. * std140 layout specifies how to align data within an UBO structure.
  66191. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  66192. * for specs.
  66193. */
  66194. UniformBuffer.prototype._fillAlignment = function (size) {
  66195. // This code has been simplified because we only use floats, vectors of 1, 2, 3, 4 components
  66196. // and 4x4 matrices
  66197. // TODO : change if other types are used
  66198. var alignment;
  66199. if (size <= 2) {
  66200. alignment = size;
  66201. }
  66202. else {
  66203. alignment = 4;
  66204. }
  66205. if ((this._uniformLocationPointer % alignment) !== 0) {
  66206. var oldPointer = this._uniformLocationPointer;
  66207. this._uniformLocationPointer += alignment - (this._uniformLocationPointer % alignment);
  66208. var diff = this._uniformLocationPointer - oldPointer;
  66209. for (var i = 0; i < diff; i++) {
  66210. this._data.push(0);
  66211. }
  66212. }
  66213. };
  66214. /**
  66215. * Adds an uniform in the buffer.
  66216. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  66217. * for the layout to be correct !
  66218. * @param name Name of the uniform, as used in the uniform block in the shader.
  66219. * @param size Data size, or data directly.
  66220. */
  66221. UniformBuffer.prototype.addUniform = function (name, size) {
  66222. if (this._noUBO) {
  66223. return;
  66224. }
  66225. if (this._uniformLocations[name] !== undefined) {
  66226. // Already existing uniform
  66227. return;
  66228. }
  66229. // This function must be called in the order of the shader layout !
  66230. // size can be the size of the uniform, or data directly
  66231. var data;
  66232. if (size instanceof Array) {
  66233. data = size;
  66234. size = data.length;
  66235. }
  66236. else {
  66237. size = size;
  66238. data = [];
  66239. // Fill with zeros
  66240. for (var i = 0; i < size; i++) {
  66241. data.push(0);
  66242. }
  66243. }
  66244. this._fillAlignment(size);
  66245. this._uniformSizes[name] = size;
  66246. this._uniformLocations[name] = this._uniformLocationPointer;
  66247. this._uniformLocationPointer += size;
  66248. for (var i = 0; i < size; i++) {
  66249. this._data.push(data[i]);
  66250. }
  66251. this._needSync = true;
  66252. };
  66253. /**
  66254. * Adds a Matrix 4x4 to the uniform buffer.
  66255. * @param name Name of the uniform, as used in the uniform block in the shader.
  66256. * @param mat A 4x4 matrix.
  66257. */
  66258. UniformBuffer.prototype.addMatrix = function (name, mat) {
  66259. this.addUniform(name, Array.prototype.slice.call(mat.toArray()));
  66260. };
  66261. /**
  66262. * Adds a vec2 to the uniform buffer.
  66263. * @param name Name of the uniform, as used in the uniform block in the shader.
  66264. * @param x Define the x component value of the vec2
  66265. * @param y Define the y component value of the vec2
  66266. */
  66267. UniformBuffer.prototype.addFloat2 = function (name, x, y) {
  66268. var temp = [x, y];
  66269. this.addUniform(name, temp);
  66270. };
  66271. /**
  66272. * Adds a vec3 to the uniform buffer.
  66273. * @param name Name of the uniform, as used in the uniform block in the shader.
  66274. * @param x Define the x component value of the vec3
  66275. * @param y Define the y component value of the vec3
  66276. * @param z Define the z component value of the vec3
  66277. */
  66278. UniformBuffer.prototype.addFloat3 = function (name, x, y, z) {
  66279. var temp = [x, y, z];
  66280. this.addUniform(name, temp);
  66281. };
  66282. /**
  66283. * Adds a vec3 to the uniform buffer.
  66284. * @param name Name of the uniform, as used in the uniform block in the shader.
  66285. * @param color Define the vec3 from a Color
  66286. */
  66287. UniformBuffer.prototype.addColor3 = function (name, color) {
  66288. var temp = new Array();
  66289. color.toArray(temp);
  66290. this.addUniform(name, temp);
  66291. };
  66292. /**
  66293. * Adds a vec4 to the uniform buffer.
  66294. * @param name Name of the uniform, as used in the uniform block in the shader.
  66295. * @param color Define the rgb components from a Color
  66296. * @param alpha Define the a component of the vec4
  66297. */
  66298. UniformBuffer.prototype.addColor4 = function (name, color, alpha) {
  66299. var temp = new Array();
  66300. color.toArray(temp);
  66301. temp.push(alpha);
  66302. this.addUniform(name, temp);
  66303. };
  66304. /**
  66305. * Adds a vec3 to the uniform buffer.
  66306. * @param name Name of the uniform, as used in the uniform block in the shader.
  66307. * @param vector Define the vec3 components from a Vector
  66308. */
  66309. UniformBuffer.prototype.addVector3 = function (name, vector) {
  66310. var temp = new Array();
  66311. vector.toArray(temp);
  66312. this.addUniform(name, temp);
  66313. };
  66314. /**
  66315. * Adds a Matrix 3x3 to the uniform buffer.
  66316. * @param name Name of the uniform, as used in the uniform block in the shader.
  66317. */
  66318. UniformBuffer.prototype.addMatrix3x3 = function (name) {
  66319. this.addUniform(name, 12);
  66320. };
  66321. /**
  66322. * Adds a Matrix 2x2 to the uniform buffer.
  66323. * @param name Name of the uniform, as used in the uniform block in the shader.
  66324. */
  66325. UniformBuffer.prototype.addMatrix2x2 = function (name) {
  66326. this.addUniform(name, 8);
  66327. };
  66328. /**
  66329. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  66330. */
  66331. UniformBuffer.prototype.create = function () {
  66332. if (this._noUBO) {
  66333. return;
  66334. }
  66335. if (this._buffer) {
  66336. return; // nothing to do
  66337. }
  66338. // See spec, alignment must be filled as a vec4
  66339. this._fillAlignment(4);
  66340. this._bufferData = new Float32Array(this._data);
  66341. this._rebuild();
  66342. this._needSync = true;
  66343. };
  66344. /** @hidden */
  66345. UniformBuffer.prototype._rebuild = function () {
  66346. if (this._noUBO) {
  66347. return;
  66348. }
  66349. if (this._dynamic) {
  66350. this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData);
  66351. }
  66352. else {
  66353. this._buffer = this._engine.createUniformBuffer(this._bufferData);
  66354. }
  66355. };
  66356. /**
  66357. * Updates the WebGL Uniform Buffer on the GPU.
  66358. * If the `dynamic` flag is set to true, no cache comparison is done.
  66359. * Otherwise, the buffer will be updated only if the cache differs.
  66360. */
  66361. UniformBuffer.prototype.update = function () {
  66362. if (!this._buffer) {
  66363. this.create();
  66364. return;
  66365. }
  66366. if (!this._dynamic && !this._needSync) {
  66367. return;
  66368. }
  66369. this._engine.updateUniformBuffer(this._buffer, this._bufferData);
  66370. this._needSync = false;
  66371. };
  66372. /**
  66373. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  66374. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  66375. * @param data Define the flattened data
  66376. * @param size Define the size of the data.
  66377. */
  66378. UniformBuffer.prototype.updateUniform = function (uniformName, data, size) {
  66379. var location = this._uniformLocations[uniformName];
  66380. if (location === undefined) {
  66381. if (this._buffer) {
  66382. // Cannot add an uniform if the buffer is already created
  66383. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add an uniform after UBO has been created.");
  66384. return;
  66385. }
  66386. this.addUniform(uniformName, size);
  66387. location = this._uniformLocations[uniformName];
  66388. }
  66389. if (!this._buffer) {
  66390. this.create();
  66391. }
  66392. if (!this._dynamic) {
  66393. // Cache for static uniform buffers
  66394. var changed = false;
  66395. for (var i = 0; i < size; i++) {
  66396. if (this._bufferData[location + i] !== data[i]) {
  66397. changed = true;
  66398. this._bufferData[location + i] = data[i];
  66399. }
  66400. }
  66401. this._needSync = this._needSync || changed;
  66402. }
  66403. else {
  66404. // No cache for dynamic
  66405. for (var i = 0; i < size; i++) {
  66406. this._bufferData[location + i] = data[i];
  66407. }
  66408. }
  66409. };
  66410. // Update methods
  66411. UniformBuffer.prototype._updateMatrix3x3ForUniform = function (name, matrix) {
  66412. // To match std140, matrix must be realigned
  66413. for (var i = 0; i < 3; i++) {
  66414. UniformBuffer._tempBuffer[i * 4] = matrix[i * 3];
  66415. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 3 + 1];
  66416. UniformBuffer._tempBuffer[i * 4 + 2] = matrix[i * 3 + 2];
  66417. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  66418. }
  66419. this.updateUniform(name, UniformBuffer._tempBuffer, 12);
  66420. };
  66421. UniformBuffer.prototype._updateMatrix3x3ForEffect = function (name, matrix) {
  66422. this._currentEffect.setMatrix3x3(name, matrix);
  66423. };
  66424. UniformBuffer.prototype._updateMatrix2x2ForEffect = function (name, matrix) {
  66425. this._currentEffect.setMatrix2x2(name, matrix);
  66426. };
  66427. UniformBuffer.prototype._updateMatrix2x2ForUniform = function (name, matrix) {
  66428. // To match std140, matrix must be realigned
  66429. for (var i = 0; i < 2; i++) {
  66430. UniformBuffer._tempBuffer[i * 4] = matrix[i * 2];
  66431. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 2 + 1];
  66432. UniformBuffer._tempBuffer[i * 4 + 2] = 0.0;
  66433. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  66434. }
  66435. this.updateUniform(name, UniformBuffer._tempBuffer, 8);
  66436. };
  66437. UniformBuffer.prototype._updateFloatForEffect = function (name, x) {
  66438. this._currentEffect.setFloat(name, x);
  66439. };
  66440. UniformBuffer.prototype._updateFloatForUniform = function (name, x) {
  66441. UniformBuffer._tempBuffer[0] = x;
  66442. this.updateUniform(name, UniformBuffer._tempBuffer, 1);
  66443. };
  66444. UniformBuffer.prototype._updateFloat2ForEffect = function (name, x, y, suffix) {
  66445. if (suffix === void 0) { suffix = ""; }
  66446. this._currentEffect.setFloat2(name + suffix, x, y);
  66447. };
  66448. UniformBuffer.prototype._updateFloat2ForUniform = function (name, x, y) {
  66449. UniformBuffer._tempBuffer[0] = x;
  66450. UniformBuffer._tempBuffer[1] = y;
  66451. this.updateUniform(name, UniformBuffer._tempBuffer, 2);
  66452. };
  66453. UniformBuffer.prototype._updateFloat3ForEffect = function (name, x, y, z, suffix) {
  66454. if (suffix === void 0) { suffix = ""; }
  66455. this._currentEffect.setFloat3(name + suffix, x, y, z);
  66456. };
  66457. UniformBuffer.prototype._updateFloat3ForUniform = function (name, x, y, z) {
  66458. UniformBuffer._tempBuffer[0] = x;
  66459. UniformBuffer._tempBuffer[1] = y;
  66460. UniformBuffer._tempBuffer[2] = z;
  66461. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  66462. };
  66463. UniformBuffer.prototype._updateFloat4ForEffect = function (name, x, y, z, w, suffix) {
  66464. if (suffix === void 0) { suffix = ""; }
  66465. this._currentEffect.setFloat4(name + suffix, x, y, z, w);
  66466. };
  66467. UniformBuffer.prototype._updateFloat4ForUniform = function (name, x, y, z, w) {
  66468. UniformBuffer._tempBuffer[0] = x;
  66469. UniformBuffer._tempBuffer[1] = y;
  66470. UniformBuffer._tempBuffer[2] = z;
  66471. UniformBuffer._tempBuffer[3] = w;
  66472. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  66473. };
  66474. UniformBuffer.prototype._updateMatrixForEffect = function (name, mat) {
  66475. this._currentEffect.setMatrix(name, mat);
  66476. };
  66477. UniformBuffer.prototype._updateMatrixForUniform = function (name, mat) {
  66478. this.updateUniform(name, mat.toArray(), 16);
  66479. };
  66480. UniformBuffer.prototype._updateVector3ForEffect = function (name, vector) {
  66481. this._currentEffect.setVector3(name, vector);
  66482. };
  66483. UniformBuffer.prototype._updateVector3ForUniform = function (name, vector) {
  66484. vector.toArray(UniformBuffer._tempBuffer);
  66485. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  66486. };
  66487. UniformBuffer.prototype._updateVector4ForEffect = function (name, vector) {
  66488. this._currentEffect.setVector4(name, vector);
  66489. };
  66490. UniformBuffer.prototype._updateVector4ForUniform = function (name, vector) {
  66491. vector.toArray(UniformBuffer._tempBuffer);
  66492. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  66493. };
  66494. UniformBuffer.prototype._updateColor3ForEffect = function (name, color, suffix) {
  66495. if (suffix === void 0) { suffix = ""; }
  66496. this._currentEffect.setColor3(name + suffix, color);
  66497. };
  66498. UniformBuffer.prototype._updateColor3ForUniform = function (name, color) {
  66499. color.toArray(UniformBuffer._tempBuffer);
  66500. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  66501. };
  66502. UniformBuffer.prototype._updateColor4ForEffect = function (name, color, alpha, suffix) {
  66503. if (suffix === void 0) { suffix = ""; }
  66504. this._currentEffect.setColor4(name + suffix, color, alpha);
  66505. };
  66506. UniformBuffer.prototype._updateColor4ForUniform = function (name, color, alpha) {
  66507. color.toArray(UniformBuffer._tempBuffer);
  66508. UniformBuffer._tempBuffer[3] = alpha;
  66509. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  66510. };
  66511. /**
  66512. * Sets a sampler uniform on the effect.
  66513. * @param name Define the name of the sampler.
  66514. * @param texture Define the texture to set in the sampler
  66515. */
  66516. UniformBuffer.prototype.setTexture = function (name, texture) {
  66517. this._currentEffect.setTexture(name, texture);
  66518. };
  66519. /**
  66520. * Directly updates the value of the uniform in the cache AND on the GPU.
  66521. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  66522. * @param data Define the flattened data
  66523. */
  66524. UniformBuffer.prototype.updateUniformDirectly = function (uniformName, data) {
  66525. this.updateUniform(uniformName, data, data.length);
  66526. this.update();
  66527. };
  66528. /**
  66529. * Binds this uniform buffer to an effect.
  66530. * @param effect Define the effect to bind the buffer to
  66531. * @param name Name of the uniform block in the shader.
  66532. */
  66533. UniformBuffer.prototype.bindToEffect = function (effect, name) {
  66534. this._currentEffect = effect;
  66535. if (this._noUBO || !this._buffer) {
  66536. return;
  66537. }
  66538. effect.bindUniformBuffer(this._buffer, name);
  66539. };
  66540. /**
  66541. * Disposes the uniform buffer.
  66542. */
  66543. UniformBuffer.prototype.dispose = function () {
  66544. if (this._noUBO) {
  66545. return;
  66546. }
  66547. var uniformBuffers = this._engine._uniformBuffers;
  66548. var index = uniformBuffers.indexOf(this);
  66549. if (index !== -1) {
  66550. uniformBuffers[index] = uniformBuffers[uniformBuffers.length - 1];
  66551. uniformBuffers.pop();
  66552. }
  66553. if (!this._buffer) {
  66554. return;
  66555. }
  66556. if (this._engine._releaseBuffer(this._buffer)) {
  66557. this._buffer = null;
  66558. }
  66559. };
  66560. // Pool for avoiding memory leaks
  66561. UniformBuffer._MAX_UNIFORM_SIZE = 256;
  66562. UniformBuffer._tempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);
  66563. return UniformBuffer;
  66564. }());
  66565. /***/ }),
  66566. /***/ "./Maths/index.ts":
  66567. /*!************************!*\
  66568. !*** ./Maths/index.ts ***!
  66569. \************************/
  66570. /*! 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 */
  66571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66572. "use strict";
  66573. __webpack_require__.r(__webpack_exports__);
  66574. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  66575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  66576. /* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math */ "./Maths/math.ts");
  66577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]; });
  66578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]; });
  66579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]; });
  66580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color3"]; });
  66581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color4"]; });
  66582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]; });
  66583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]; });
  66584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]; });
  66585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Size"]; });
  66586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]; });
  66587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]; });
  66588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Plane"]; });
  66589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Viewport"]; });
  66590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Frustum"]; });
  66591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Space"]; });
  66592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Axis"]; });
  66593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"]; });
  66594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Orientation"]; });
  66595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Angle"]; });
  66596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Arc2"]; });
  66597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path2"]; });
  66598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path3D"]; });
  66599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Curve3"]; });
  66600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalVertex"]; });
  66601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalTextureVertex"]; });
  66602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Tmp"]; });
  66603. /* harmony import */ var _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  66604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"]; });
  66605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]; });
  66606. /***/ }),
  66607. /***/ "./Maths/math.scalar.ts":
  66608. /*!******************************!*\
  66609. !*** ./Maths/math.scalar.ts ***!
  66610. \******************************/
  66611. /*! exports provided: Scalar */
  66612. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66613. "use strict";
  66614. __webpack_require__.r(__webpack_exports__);
  66615. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return Scalar; });
  66616. /**
  66617. * Scalar computation library
  66618. */
  66619. var Scalar = /** @class */ (function () {
  66620. function Scalar() {
  66621. }
  66622. /**
  66623. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66624. * @param a number
  66625. * @param b number
  66626. * @param epsilon (default = 1.401298E-45)
  66627. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66628. */
  66629. Scalar.WithinEpsilon = function (a, b, epsilon) {
  66630. if (epsilon === void 0) { epsilon = 1.401298E-45; }
  66631. var num = a - b;
  66632. return -epsilon <= num && num <= epsilon;
  66633. };
  66634. /**
  66635. * Returns a string : the upper case translation of the number i to hexadecimal.
  66636. * @param i number
  66637. * @returns the upper case translation of the number i to hexadecimal.
  66638. */
  66639. Scalar.ToHex = function (i) {
  66640. var str = i.toString(16);
  66641. if (i <= 15) {
  66642. return ("0" + str).toUpperCase();
  66643. }
  66644. return str.toUpperCase();
  66645. };
  66646. /**
  66647. * Returns -1 if value is negative and +1 is value is positive.
  66648. * @param value the value
  66649. * @returns the value itself if it's equal to zero.
  66650. */
  66651. Scalar.Sign = function (value) {
  66652. value = +value; // convert to a number
  66653. if (value === 0 || isNaN(value)) {
  66654. return value;
  66655. }
  66656. return value > 0 ? 1 : -1;
  66657. };
  66658. /**
  66659. * Returns the value itself if it's between min and max.
  66660. * Returns min if the value is lower than min.
  66661. * Returns max if the value is greater than max.
  66662. * @param value the value to clmap
  66663. * @param min the min value to clamp to (default: 0)
  66664. * @param max the max value to clamp to (default: 1)
  66665. * @returns the clamped value
  66666. */
  66667. Scalar.Clamp = function (value, min, max) {
  66668. if (min === void 0) { min = 0; }
  66669. if (max === void 0) { max = 1; }
  66670. return Math.min(max, Math.max(min, value));
  66671. };
  66672. /**
  66673. * the log2 of value.
  66674. * @param value the value to compute log2 of
  66675. * @returns the log2 of value.
  66676. */
  66677. Scalar.Log2 = function (value) {
  66678. return Math.log(value) * Math.LOG2E;
  66679. };
  66680. /**
  66681. * Loops the value, so that it is never larger than length and never smaller than 0.
  66682. *
  66683. * This is similar to the modulo operator but it works with floating point numbers.
  66684. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  66685. * With t = 5 and length = 2.5, the result would be 0.0.
  66686. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  66687. * @param value the value
  66688. * @param length the length
  66689. * @returns the looped value
  66690. */
  66691. Scalar.Repeat = function (value, length) {
  66692. return value - Math.floor(value / length) * length;
  66693. };
  66694. /**
  66695. * Normalize the value between 0.0 and 1.0 using min and max values
  66696. * @param value value to normalize
  66697. * @param min max to normalize between
  66698. * @param max min to normalize between
  66699. * @returns the normalized value
  66700. */
  66701. Scalar.Normalize = function (value, min, max) {
  66702. return (value - min) / (max - min);
  66703. };
  66704. /**
  66705. * Denormalize the value from 0.0 and 1.0 using min and max values
  66706. * @param normalized value to denormalize
  66707. * @param min max to denormalize between
  66708. * @param max min to denormalize between
  66709. * @returns the denormalized value
  66710. */
  66711. Scalar.Denormalize = function (normalized, min, max) {
  66712. return (normalized * (max - min) + min);
  66713. };
  66714. /**
  66715. * Calculates the shortest difference between two given angles given in degrees.
  66716. * @param current current angle in degrees
  66717. * @param target target angle in degrees
  66718. * @returns the delta
  66719. */
  66720. Scalar.DeltaAngle = function (current, target) {
  66721. var num = Scalar.Repeat(target - current, 360.0);
  66722. if (num > 180.0) {
  66723. num -= 360.0;
  66724. }
  66725. return num;
  66726. };
  66727. /**
  66728. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  66729. * @param tx value
  66730. * @param length length
  66731. * @returns The returned value will move back and forth between 0 and length
  66732. */
  66733. Scalar.PingPong = function (tx, length) {
  66734. var t = Scalar.Repeat(tx, length * 2.0);
  66735. return length - Math.abs(t - length);
  66736. };
  66737. /**
  66738. * Interpolates between min and max with smoothing at the limits.
  66739. *
  66740. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  66741. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  66742. * @param from from
  66743. * @param to to
  66744. * @param tx value
  66745. * @returns the smooth stepped value
  66746. */
  66747. Scalar.SmoothStep = function (from, to, tx) {
  66748. var t = Scalar.Clamp(tx);
  66749. t = -2.0 * t * t * t + 3.0 * t * t;
  66750. return to * t + from * (1.0 - t);
  66751. };
  66752. /**
  66753. * Moves a value current towards target.
  66754. *
  66755. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  66756. * Negative values of maxDelta pushes the value away from target.
  66757. * @param current current value
  66758. * @param target target value
  66759. * @param maxDelta max distance to move
  66760. * @returns resulting value
  66761. */
  66762. Scalar.MoveTowards = function (current, target, maxDelta) {
  66763. var result = 0;
  66764. if (Math.abs(target - current) <= maxDelta) {
  66765. result = target;
  66766. }
  66767. else {
  66768. result = current + Scalar.Sign(target - current) * maxDelta;
  66769. }
  66770. return result;
  66771. };
  66772. /**
  66773. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66774. *
  66775. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  66776. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  66777. * @param current current value
  66778. * @param target target value
  66779. * @param maxDelta max distance to move
  66780. * @returns resulting angle
  66781. */
  66782. Scalar.MoveTowardsAngle = function (current, target, maxDelta) {
  66783. var num = Scalar.DeltaAngle(current, target);
  66784. var result = 0;
  66785. if (-maxDelta < num && num < maxDelta) {
  66786. result = target;
  66787. }
  66788. else {
  66789. target = current + num;
  66790. result = Scalar.MoveTowards(current, target, maxDelta);
  66791. }
  66792. return result;
  66793. };
  66794. /**
  66795. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  66796. * @param start start value
  66797. * @param end target value
  66798. * @param amount amount to lerp between
  66799. * @returns the lerped value
  66800. */
  66801. Scalar.Lerp = function (start, end, amount) {
  66802. return start + ((end - start) * amount);
  66803. };
  66804. /**
  66805. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66806. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  66807. * @param start start value
  66808. * @param end target value
  66809. * @param amount amount to lerp between
  66810. * @returns the lerped value
  66811. */
  66812. Scalar.LerpAngle = function (start, end, amount) {
  66813. var num = Scalar.Repeat(end - start, 360.0);
  66814. if (num > 180.0) {
  66815. num -= 360.0;
  66816. }
  66817. return start + num * Scalar.Clamp(amount);
  66818. };
  66819. /**
  66820. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  66821. * @param a start value
  66822. * @param b target value
  66823. * @param value value between a and b
  66824. * @returns the inverseLerp value
  66825. */
  66826. Scalar.InverseLerp = function (a, b, value) {
  66827. var result = 0;
  66828. if (a != b) {
  66829. result = Scalar.Clamp((value - a) / (b - a));
  66830. }
  66831. else {
  66832. result = 0.0;
  66833. }
  66834. return result;
  66835. };
  66836. /**
  66837. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  66838. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  66839. * @param value1 spline value
  66840. * @param tangent1 spline value
  66841. * @param value2 spline value
  66842. * @param tangent2 spline value
  66843. * @param amount input value
  66844. * @returns hermite result
  66845. */
  66846. Scalar.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  66847. var squared = amount * amount;
  66848. var cubed = amount * squared;
  66849. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  66850. var part2 = (-2.0 * cubed) + (3.0 * squared);
  66851. var part3 = (cubed - (2.0 * squared)) + amount;
  66852. var part4 = cubed - squared;
  66853. return (((value1 * part1) + (value2 * part2)) + (tangent1 * part3)) + (tangent2 * part4);
  66854. };
  66855. /**
  66856. * Returns a random float number between and min and max values
  66857. * @param min min value of random
  66858. * @param max max value of random
  66859. * @returns random value
  66860. */
  66861. Scalar.RandomRange = function (min, max) {
  66862. if (min === max) {
  66863. return min;
  66864. }
  66865. return ((Math.random() * (max - min)) + min);
  66866. };
  66867. /**
  66868. * This function returns percentage of a number in a given range.
  66869. *
  66870. * RangeToPercent(40,20,60) will return 0.5 (50%)
  66871. * RangeToPercent(34,0,100) will return 0.34 (34%)
  66872. * @param number to convert to percentage
  66873. * @param min min range
  66874. * @param max max range
  66875. * @returns the percentage
  66876. */
  66877. Scalar.RangeToPercent = function (number, min, max) {
  66878. return ((number - min) / (max - min));
  66879. };
  66880. /**
  66881. * This function returns number that corresponds to the percentage in a given range.
  66882. *
  66883. * PercentToRange(0.34,0,100) will return 34.
  66884. * @param percent to convert to number
  66885. * @param min min range
  66886. * @param max max range
  66887. * @returns the number
  66888. */
  66889. Scalar.PercentToRange = function (percent, min, max) {
  66890. return ((max - min) * percent + min);
  66891. };
  66892. /**
  66893. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  66894. * @param angle The angle to normalize in radian.
  66895. * @return The converted angle.
  66896. */
  66897. Scalar.NormalizeRadians = function (angle) {
  66898. // More precise but slower version kept for reference.
  66899. // angle = angle % Tools.TwoPi;
  66900. // angle = (angle + Tools.TwoPi) % Tools.TwoPi;
  66901. //if (angle > Math.PI) {
  66902. // angle -= Tools.TwoPi;
  66903. //}
  66904. angle -= (Scalar.TwoPi * Math.floor((angle + Math.PI) / Scalar.TwoPi));
  66905. return angle;
  66906. };
  66907. /**
  66908. * Two pi constants convenient for computation.
  66909. */
  66910. Scalar.TwoPi = Math.PI * 2;
  66911. return Scalar;
  66912. }());
  66913. /***/ }),
  66914. /***/ "./Maths/math.ts":
  66915. /*!***********************!*\
  66916. !*** ./Maths/math.ts ***!
  66917. \***********************/
  66918. /*! 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 */
  66919. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66920. "use strict";
  66921. __webpack_require__.r(__webpack_exports__);
  66922. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return ToGammaSpace; });
  66923. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return ToLinearSpace; });
  66924. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return Epsilon; });
  66925. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return Color3; });
  66926. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return Color4; });
  66927. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return Vector2; });
  66928. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return Vector3; });
  66929. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return Vector4; });
  66930. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return Size; });
  66931. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return Quaternion; });
  66932. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return Matrix; });
  66933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return Plane; });
  66934. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return Viewport; });
  66935. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return Frustum; });
  66936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return Space; });
  66937. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return Axis; });
  66938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return BezierCurve; });
  66939. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return Orientation; });
  66940. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return Angle; });
  66941. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return Arc2; });
  66942. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return Path2; });
  66943. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return Path3D; });
  66944. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return Curve3; });
  66945. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return PositionNormalVertex; });
  66946. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return PositionNormalTextureVertex; });
  66947. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return Tmp; });
  66948. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  66949. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  66950. /**
  66951. * Constant used to convert a value to gamma space
  66952. * @ignorenaming
  66953. */
  66954. var ToGammaSpace = 1 / 2.2;
  66955. /**
  66956. * Constant used to convert a value to linear space
  66957. * @ignorenaming
  66958. */
  66959. var ToLinearSpace = 2.2;
  66960. /**
  66961. * Constant used to define the minimal number value in Babylon.js
  66962. * @ignorenaming
  66963. */
  66964. var Epsilon = 0.001;
  66965. /**
  66966. * Class used to hold a RBG color
  66967. */
  66968. var Color3 = /** @class */ (function () {
  66969. /**
  66970. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  66971. * @param r defines the red component (between 0 and 1, default is 0)
  66972. * @param g defines the green component (between 0 and 1, default is 0)
  66973. * @param b defines the blue component (between 0 and 1, default is 0)
  66974. */
  66975. function Color3(
  66976. /**
  66977. * Defines the red component (between 0 and 1, default is 0)
  66978. */
  66979. r,
  66980. /**
  66981. * Defines the green component (between 0 and 1, default is 0)
  66982. */
  66983. g,
  66984. /**
  66985. * Defines the blue component (between 0 and 1, default is 0)
  66986. */
  66987. b) {
  66988. if (r === void 0) { r = 0; }
  66989. if (g === void 0) { g = 0; }
  66990. if (b === void 0) { b = 0; }
  66991. this.r = r;
  66992. this.g = g;
  66993. this.b = b;
  66994. }
  66995. /**
  66996. * Creates a string with the Color3 current values
  66997. * @returns the string representation of the Color3 object
  66998. */
  66999. Color3.prototype.toString = function () {
  67000. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}";
  67001. };
  67002. /**
  67003. * Returns the string "Color3"
  67004. * @returns "Color3"
  67005. */
  67006. Color3.prototype.getClassName = function () {
  67007. return "Color3";
  67008. };
  67009. /**
  67010. * Compute the Color3 hash code
  67011. * @returns an unique number that can be used to hash Color3 objects
  67012. */
  67013. Color3.prototype.getHashCode = function () {
  67014. var hash = this.r || 0;
  67015. hash = (hash * 397) ^ (this.g || 0);
  67016. hash = (hash * 397) ^ (this.b || 0);
  67017. return hash;
  67018. };
  67019. // Operators
  67020. /**
  67021. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  67022. * @param array defines the array where to store the r,g,b components
  67023. * @param index defines an optional index in the target array to define where to start storing values
  67024. * @returns the current Color3 object
  67025. */
  67026. Color3.prototype.toArray = function (array, index) {
  67027. if (index === void 0) { index = 0; }
  67028. array[index] = this.r;
  67029. array[index + 1] = this.g;
  67030. array[index + 2] = this.b;
  67031. return this;
  67032. };
  67033. /**
  67034. * Returns a new Color4 object from the current Color3 and the given alpha
  67035. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  67036. * @returns a new Color4 object
  67037. */
  67038. Color3.prototype.toColor4 = function (alpha) {
  67039. if (alpha === void 0) { alpha = 1; }
  67040. return new Color4(this.r, this.g, this.b, alpha);
  67041. };
  67042. /**
  67043. * Returns a new array populated with 3 numeric elements : red, green and blue values
  67044. * @returns the new array
  67045. */
  67046. Color3.prototype.asArray = function () {
  67047. var result = new Array();
  67048. this.toArray(result, 0);
  67049. return result;
  67050. };
  67051. /**
  67052. * Returns the luminance value
  67053. * @returns a float value
  67054. */
  67055. Color3.prototype.toLuminance = function () {
  67056. return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
  67057. };
  67058. /**
  67059. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  67060. * @param otherColor defines the second operand
  67061. * @returns the new Color3 object
  67062. */
  67063. Color3.prototype.multiply = function (otherColor) {
  67064. return new Color3(this.r * otherColor.r, this.g * otherColor.g, this.b * otherColor.b);
  67065. };
  67066. /**
  67067. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  67068. * @param otherColor defines the second operand
  67069. * @param result defines the Color3 object where to store the result
  67070. * @returns the current Color3
  67071. */
  67072. Color3.prototype.multiplyToRef = function (otherColor, result) {
  67073. result.r = this.r * otherColor.r;
  67074. result.g = this.g * otherColor.g;
  67075. result.b = this.b * otherColor.b;
  67076. return this;
  67077. };
  67078. /**
  67079. * Determines equality between Color3 objects
  67080. * @param otherColor defines the second operand
  67081. * @returns true if the rgb values are equal to the given ones
  67082. */
  67083. Color3.prototype.equals = function (otherColor) {
  67084. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b;
  67085. };
  67086. /**
  67087. * Determines equality between the current Color3 object and a set of r,b,g values
  67088. * @param r defines the red component to check
  67089. * @param g defines the green component to check
  67090. * @param b defines the blue component to check
  67091. * @returns true if the rgb values are equal to the given ones
  67092. */
  67093. Color3.prototype.equalsFloats = function (r, g, b) {
  67094. return this.r === r && this.g === g && this.b === b;
  67095. };
  67096. /**
  67097. * Multiplies in place each rgb value by scale
  67098. * @param scale defines the scaling factor
  67099. * @returns the updated Color3
  67100. */
  67101. Color3.prototype.scale = function (scale) {
  67102. return new Color3(this.r * scale, this.g * scale, this.b * scale);
  67103. };
  67104. /**
  67105. * Multiplies the rgb values by scale and stores the result into "result"
  67106. * @param scale defines the scaling factor
  67107. * @param result defines the Color3 object where to store the result
  67108. * @returns the unmodified current Color3
  67109. */
  67110. Color3.prototype.scaleToRef = function (scale, result) {
  67111. result.r = this.r * scale;
  67112. result.g = this.g * scale;
  67113. result.b = this.b * scale;
  67114. return this;
  67115. };
  67116. /**
  67117. * Scale the current Color3 values by a factor and add the result to a given Color3
  67118. * @param scale defines the scale factor
  67119. * @param result defines color to store the result into
  67120. * @returns the unmodified current Color3
  67121. */
  67122. Color3.prototype.scaleAndAddToRef = function (scale, result) {
  67123. result.r += this.r * scale;
  67124. result.g += this.g * scale;
  67125. result.b += this.b * scale;
  67126. return this;
  67127. };
  67128. /**
  67129. * Clamps the rgb values by the min and max values and stores the result into "result"
  67130. * @param min defines minimum clamping value (default is 0)
  67131. * @param max defines maximum clamping value (default is 1)
  67132. * @param result defines color to store the result into
  67133. * @returns the original Color3
  67134. */
  67135. Color3.prototype.clampToRef = function (min, max, result) {
  67136. if (min === void 0) { min = 0; }
  67137. if (max === void 0) { max = 1; }
  67138. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  67139. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  67140. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  67141. return this;
  67142. };
  67143. /**
  67144. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  67145. * @param otherColor defines the second operand
  67146. * @returns the new Color3
  67147. */
  67148. Color3.prototype.add = function (otherColor) {
  67149. return new Color3(this.r + otherColor.r, this.g + otherColor.g, this.b + otherColor.b);
  67150. };
  67151. /**
  67152. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  67153. * @param otherColor defines the second operand
  67154. * @param result defines Color3 object to store the result into
  67155. * @returns the unmodified current Color3
  67156. */
  67157. Color3.prototype.addToRef = function (otherColor, result) {
  67158. result.r = this.r + otherColor.r;
  67159. result.g = this.g + otherColor.g;
  67160. result.b = this.b + otherColor.b;
  67161. return this;
  67162. };
  67163. /**
  67164. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  67165. * @param otherColor defines the second operand
  67166. * @returns the new Color3
  67167. */
  67168. Color3.prototype.subtract = function (otherColor) {
  67169. return new Color3(this.r - otherColor.r, this.g - otherColor.g, this.b - otherColor.b);
  67170. };
  67171. /**
  67172. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  67173. * @param otherColor defines the second operand
  67174. * @param result defines Color3 object to store the result into
  67175. * @returns the unmodified current Color3
  67176. */
  67177. Color3.prototype.subtractToRef = function (otherColor, result) {
  67178. result.r = this.r - otherColor.r;
  67179. result.g = this.g - otherColor.g;
  67180. result.b = this.b - otherColor.b;
  67181. return this;
  67182. };
  67183. /**
  67184. * Copy the current object
  67185. * @returns a new Color3 copied the current one
  67186. */
  67187. Color3.prototype.clone = function () {
  67188. return new Color3(this.r, this.g, this.b);
  67189. };
  67190. /**
  67191. * Copies the rgb values from the source in the current Color3
  67192. * @param source defines the source Color3 object
  67193. * @returns the updated Color3 object
  67194. */
  67195. Color3.prototype.copyFrom = function (source) {
  67196. this.r = source.r;
  67197. this.g = source.g;
  67198. this.b = source.b;
  67199. return this;
  67200. };
  67201. /**
  67202. * Updates the Color3 rgb values from the given floats
  67203. * @param r defines the red component to read from
  67204. * @param g defines the green component to read from
  67205. * @param b defines the blue component to read from
  67206. * @returns the current Color3 object
  67207. */
  67208. Color3.prototype.copyFromFloats = function (r, g, b) {
  67209. this.r = r;
  67210. this.g = g;
  67211. this.b = b;
  67212. return this;
  67213. };
  67214. /**
  67215. * Updates the Color3 rgb values from the given floats
  67216. * @param r defines the red component to read from
  67217. * @param g defines the green component to read from
  67218. * @param b defines the blue component to read from
  67219. * @returns the current Color3 object
  67220. */
  67221. Color3.prototype.set = function (r, g, b) {
  67222. return this.copyFromFloats(r, g, b);
  67223. };
  67224. /**
  67225. * Compute the Color3 hexadecimal code as a string
  67226. * @returns a string containing the hexadecimal representation of the Color3 object
  67227. */
  67228. Color3.prototype.toHexString = function () {
  67229. var intR = (this.r * 255) | 0;
  67230. var intG = (this.g * 255) | 0;
  67231. var intB = (this.b * 255) | 0;
  67232. 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);
  67233. };
  67234. /**
  67235. * Computes a new Color3 converted from the current one to linear space
  67236. * @returns a new Color3 object
  67237. */
  67238. Color3.prototype.toLinearSpace = function () {
  67239. var convertedColor = new Color3();
  67240. this.toLinearSpaceToRef(convertedColor);
  67241. return convertedColor;
  67242. };
  67243. /**
  67244. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  67245. * @param convertedColor defines the Color3 object where to store the linear space version
  67246. * @returns the unmodified Color3
  67247. */
  67248. Color3.prototype.toLinearSpaceToRef = function (convertedColor) {
  67249. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  67250. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  67251. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  67252. return this;
  67253. };
  67254. /**
  67255. * Computes a new Color3 converted from the current one to gamma space
  67256. * @returns a new Color3 object
  67257. */
  67258. Color3.prototype.toGammaSpace = function () {
  67259. var convertedColor = new Color3();
  67260. this.toGammaSpaceToRef(convertedColor);
  67261. return convertedColor;
  67262. };
  67263. /**
  67264. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  67265. * @param convertedColor defines the Color3 object where to store the gamma space version
  67266. * @returns the unmodified Color3
  67267. */
  67268. Color3.prototype.toGammaSpaceToRef = function (convertedColor) {
  67269. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  67270. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  67271. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  67272. return this;
  67273. };
  67274. /**
  67275. * Creates a new Color3 from the string containing valid hexadecimal values
  67276. * @param hex defines a string containing valid hexadecimal values
  67277. * @returns a new Color3 object
  67278. */
  67279. Color3.FromHexString = function (hex) {
  67280. if (hex.substring(0, 1) !== "#" || hex.length !== 7) {
  67281. return new Color3(0, 0, 0);
  67282. }
  67283. var r = parseInt(hex.substring(1, 3), 16);
  67284. var g = parseInt(hex.substring(3, 5), 16);
  67285. var b = parseInt(hex.substring(5, 7), 16);
  67286. return Color3.FromInts(r, g, b);
  67287. };
  67288. /**
  67289. * Creates a new Vector3 from the starting index of the given array
  67290. * @param array defines the source array
  67291. * @param offset defines an offset in the source array
  67292. * @returns a new Color3 object
  67293. */
  67294. Color3.FromArray = function (array, offset) {
  67295. if (offset === void 0) { offset = 0; }
  67296. return new Color3(array[offset], array[offset + 1], array[offset + 2]);
  67297. };
  67298. /**
  67299. * Creates a new Color3 from integer values (< 256)
  67300. * @param r defines the red component to read from (value between 0 and 255)
  67301. * @param g defines the green component to read from (value between 0 and 255)
  67302. * @param b defines the blue component to read from (value between 0 and 255)
  67303. * @returns a new Color3 object
  67304. */
  67305. Color3.FromInts = function (r, g, b) {
  67306. return new Color3(r / 255.0, g / 255.0, b / 255.0);
  67307. };
  67308. /**
  67309. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  67310. * @param start defines the start Color3 value
  67311. * @param end defines the end Color3 value
  67312. * @param amount defines the gradient value between start and end
  67313. * @returns a new Color3 object
  67314. */
  67315. Color3.Lerp = function (start, end, amount) {
  67316. var result = new Color3(0.0, 0.0, 0.0);
  67317. Color3.LerpToRef(start, end, amount, result);
  67318. return result;
  67319. };
  67320. /**
  67321. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  67322. * @param left defines the start value
  67323. * @param right defines the end value
  67324. * @param amount defines the gradient factor
  67325. * @param result defines the Color3 object where to store the result
  67326. */
  67327. Color3.LerpToRef = function (left, right, amount, result) {
  67328. result.r = left.r + ((right.r - left.r) * amount);
  67329. result.g = left.g + ((right.g - left.g) * amount);
  67330. result.b = left.b + ((right.b - left.b) * amount);
  67331. };
  67332. /**
  67333. * Returns a Color3 value containing a red color
  67334. * @returns a new Color3 object
  67335. */
  67336. Color3.Red = function () { return new Color3(1, 0, 0); };
  67337. /**
  67338. * Returns a Color3 value containing a green color
  67339. * @returns a new Color3 object
  67340. */
  67341. Color3.Green = function () { return new Color3(0, 1, 0); };
  67342. /**
  67343. * Returns a Color3 value containing a blue color
  67344. * @returns a new Color3 object
  67345. */
  67346. Color3.Blue = function () { return new Color3(0, 0, 1); };
  67347. /**
  67348. * Returns a Color3 value containing a black color
  67349. * @returns a new Color3 object
  67350. */
  67351. Color3.Black = function () { return new Color3(0, 0, 0); };
  67352. Object.defineProperty(Color3, "BlackReadOnly", {
  67353. /**
  67354. * Gets a Color3 value containing a black color that must not be updated
  67355. */
  67356. get: function () {
  67357. return Color3._BlackReadOnly;
  67358. },
  67359. enumerable: true,
  67360. configurable: true
  67361. });
  67362. /**
  67363. * Returns a Color3 value containing a white color
  67364. * @returns a new Color3 object
  67365. */
  67366. Color3.White = function () { return new Color3(1, 1, 1); };
  67367. /**
  67368. * Returns a Color3 value containing a purple color
  67369. * @returns a new Color3 object
  67370. */
  67371. Color3.Purple = function () { return new Color3(0.5, 0, 0.5); };
  67372. /**
  67373. * Returns a Color3 value containing a magenta color
  67374. * @returns a new Color3 object
  67375. */
  67376. Color3.Magenta = function () { return new Color3(1, 0, 1); };
  67377. /**
  67378. * Returns a Color3 value containing a yellow color
  67379. * @returns a new Color3 object
  67380. */
  67381. Color3.Yellow = function () { return new Color3(1, 1, 0); };
  67382. /**
  67383. * Returns a Color3 value containing a gray color
  67384. * @returns a new Color3 object
  67385. */
  67386. Color3.Gray = function () { return new Color3(0.5, 0.5, 0.5); };
  67387. /**
  67388. * Returns a Color3 value containing a teal color
  67389. * @returns a new Color3 object
  67390. */
  67391. Color3.Teal = function () { return new Color3(0, 1.0, 1.0); };
  67392. /**
  67393. * Returns a Color3 value containing a random color
  67394. * @returns a new Color3 object
  67395. */
  67396. Color3.Random = function () { return new Color3(Math.random(), Math.random(), Math.random()); };
  67397. // Statics
  67398. Color3._BlackReadOnly = Color3.Black();
  67399. return Color3;
  67400. }());
  67401. /**
  67402. * Class used to hold a RBGA color
  67403. */
  67404. var Color4 = /** @class */ (function () {
  67405. /**
  67406. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  67407. * @param r defines the red component (between 0 and 1, default is 0)
  67408. * @param g defines the green component (between 0 and 1, default is 0)
  67409. * @param b defines the blue component (between 0 and 1, default is 0)
  67410. * @param a defines the alpha component (between 0 and 1, default is 1)
  67411. */
  67412. function Color4(
  67413. /**
  67414. * Defines the red component (between 0 and 1, default is 0)
  67415. */
  67416. r,
  67417. /**
  67418. * Defines the green component (between 0 and 1, default is 0)
  67419. */
  67420. g,
  67421. /**
  67422. * Defines the blue component (between 0 and 1, default is 0)
  67423. */
  67424. b,
  67425. /**
  67426. * Defines the alpha component (between 0 and 1, default is 1)
  67427. */
  67428. a) {
  67429. if (r === void 0) { r = 0; }
  67430. if (g === void 0) { g = 0; }
  67431. if (b === void 0) { b = 0; }
  67432. if (a === void 0) { a = 1; }
  67433. this.r = r;
  67434. this.g = g;
  67435. this.b = b;
  67436. this.a = a;
  67437. }
  67438. // Operators
  67439. /**
  67440. * Adds in place the given Color4 values to the current Color4 object
  67441. * @param right defines the second operand
  67442. * @returns the current updated Color4 object
  67443. */
  67444. Color4.prototype.addInPlace = function (right) {
  67445. this.r += right.r;
  67446. this.g += right.g;
  67447. this.b += right.b;
  67448. this.a += right.a;
  67449. return this;
  67450. };
  67451. /**
  67452. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  67453. * @returns the new array
  67454. */
  67455. Color4.prototype.asArray = function () {
  67456. var result = new Array();
  67457. this.toArray(result, 0);
  67458. return result;
  67459. };
  67460. /**
  67461. * Stores from the starting index in the given array the Color4 successive values
  67462. * @param array defines the array where to store the r,g,b components
  67463. * @param index defines an optional index in the target array to define where to start storing values
  67464. * @returns the current Color4 object
  67465. */
  67466. Color4.prototype.toArray = function (array, index) {
  67467. if (index === void 0) { index = 0; }
  67468. array[index] = this.r;
  67469. array[index + 1] = this.g;
  67470. array[index + 2] = this.b;
  67471. array[index + 3] = this.a;
  67472. return this;
  67473. };
  67474. /**
  67475. * Determines equality between Color4 objects
  67476. * @param otherColor defines the second operand
  67477. * @returns true if the rgba values are equal to the given ones
  67478. */
  67479. Color4.prototype.equals = function (otherColor) {
  67480. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b && this.a === otherColor.a;
  67481. };
  67482. /**
  67483. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  67484. * @param right defines the second operand
  67485. * @returns a new Color4 object
  67486. */
  67487. Color4.prototype.add = function (right) {
  67488. return new Color4(this.r + right.r, this.g + right.g, this.b + right.b, this.a + right.a);
  67489. };
  67490. /**
  67491. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  67492. * @param right defines the second operand
  67493. * @returns a new Color4 object
  67494. */
  67495. Color4.prototype.subtract = function (right) {
  67496. return new Color4(this.r - right.r, this.g - right.g, this.b - right.b, this.a - right.a);
  67497. };
  67498. /**
  67499. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  67500. * @param right defines the second operand
  67501. * @param result defines the Color4 object where to store the result
  67502. * @returns the current Color4 object
  67503. */
  67504. Color4.prototype.subtractToRef = function (right, result) {
  67505. result.r = this.r - right.r;
  67506. result.g = this.g - right.g;
  67507. result.b = this.b - right.b;
  67508. result.a = this.a - right.a;
  67509. return this;
  67510. };
  67511. /**
  67512. * Creates a new Color4 with the current Color4 values multiplied by scale
  67513. * @param scale defines the scaling factor to apply
  67514. * @returns a new Color4 object
  67515. */
  67516. Color4.prototype.scale = function (scale) {
  67517. return new Color4(this.r * scale, this.g * scale, this.b * scale, this.a * scale);
  67518. };
  67519. /**
  67520. * Multiplies the current Color4 values by scale and stores the result in "result"
  67521. * @param scale defines the scaling factor to apply
  67522. * @param result defines the Color4 object where to store the result
  67523. * @returns the current unmodified Color4
  67524. */
  67525. Color4.prototype.scaleToRef = function (scale, result) {
  67526. result.r = this.r * scale;
  67527. result.g = this.g * scale;
  67528. result.b = this.b * scale;
  67529. result.a = this.a * scale;
  67530. return this;
  67531. };
  67532. /**
  67533. * Scale the current Color4 values by a factor and add the result to a given Color4
  67534. * @param scale defines the scale factor
  67535. * @param result defines the Color4 object where to store the result
  67536. * @returns the unmodified current Color4
  67537. */
  67538. Color4.prototype.scaleAndAddToRef = function (scale, result) {
  67539. result.r += this.r * scale;
  67540. result.g += this.g * scale;
  67541. result.b += this.b * scale;
  67542. result.a += this.a * scale;
  67543. return this;
  67544. };
  67545. /**
  67546. * Clamps the rgb values by the min and max values and stores the result into "result"
  67547. * @param min defines minimum clamping value (default is 0)
  67548. * @param max defines maximum clamping value (default is 1)
  67549. * @param result defines color to store the result into.
  67550. * @returns the cuurent Color4
  67551. */
  67552. Color4.prototype.clampToRef = function (min, max, result) {
  67553. if (min === void 0) { min = 0; }
  67554. if (max === void 0) { max = 1; }
  67555. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  67556. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  67557. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  67558. result.a = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.a, min, max);
  67559. return this;
  67560. };
  67561. /**
  67562. * Multipy an Color4 value by another and return a new Color4 object
  67563. * @param color defines the Color4 value to multiply by
  67564. * @returns a new Color4 object
  67565. */
  67566. Color4.prototype.multiply = function (color) {
  67567. return new Color4(this.r * color.r, this.g * color.g, this.b * color.b, this.a * color.a);
  67568. };
  67569. /**
  67570. * Multipy a Color4 value by another and push the result in a reference value
  67571. * @param color defines the Color4 value to multiply by
  67572. * @param result defines the Color4 to fill the result in
  67573. * @returns the result Color4
  67574. */
  67575. Color4.prototype.multiplyToRef = function (color, result) {
  67576. result.r = this.r * color.r;
  67577. result.g = this.g * color.g;
  67578. result.b = this.b * color.b;
  67579. result.a = this.a * color.a;
  67580. return result;
  67581. };
  67582. /**
  67583. * Creates a string with the Color4 current values
  67584. * @returns the string representation of the Color4 object
  67585. */
  67586. Color4.prototype.toString = function () {
  67587. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
  67588. };
  67589. /**
  67590. * Returns the string "Color4"
  67591. * @returns "Color4"
  67592. */
  67593. Color4.prototype.getClassName = function () {
  67594. return "Color4";
  67595. };
  67596. /**
  67597. * Compute the Color4 hash code
  67598. * @returns an unique number that can be used to hash Color4 objects
  67599. */
  67600. Color4.prototype.getHashCode = function () {
  67601. var hash = this.r || 0;
  67602. hash = (hash * 397) ^ (this.g || 0);
  67603. hash = (hash * 397) ^ (this.b || 0);
  67604. hash = (hash * 397) ^ (this.a || 0);
  67605. return hash;
  67606. };
  67607. /**
  67608. * Creates a new Color4 copied from the current one
  67609. * @returns a new Color4 object
  67610. */
  67611. Color4.prototype.clone = function () {
  67612. return new Color4(this.r, this.g, this.b, this.a);
  67613. };
  67614. /**
  67615. * Copies the given Color4 values into the current one
  67616. * @param source defines the source Color4 object
  67617. * @returns the current updated Color4 object
  67618. */
  67619. Color4.prototype.copyFrom = function (source) {
  67620. this.r = source.r;
  67621. this.g = source.g;
  67622. this.b = source.b;
  67623. this.a = source.a;
  67624. return this;
  67625. };
  67626. /**
  67627. * Copies the given float values into the current one
  67628. * @param r defines the red component to read from
  67629. * @param g defines the green component to read from
  67630. * @param b defines the blue component to read from
  67631. * @param a defines the alpha component to read from
  67632. * @returns the current updated Color4 object
  67633. */
  67634. Color4.prototype.copyFromFloats = function (r, g, b, a) {
  67635. this.r = r;
  67636. this.g = g;
  67637. this.b = b;
  67638. this.a = a;
  67639. return this;
  67640. };
  67641. /**
  67642. * Copies the given float values into the current one
  67643. * @param r defines the red component to read from
  67644. * @param g defines the green component to read from
  67645. * @param b defines the blue component to read from
  67646. * @param a defines the alpha component to read from
  67647. * @returns the current updated Color4 object
  67648. */
  67649. Color4.prototype.set = function (r, g, b, a) {
  67650. return this.copyFromFloats(r, g, b, a);
  67651. };
  67652. /**
  67653. * Compute the Color4 hexadecimal code as a string
  67654. * @returns a string containing the hexadecimal representation of the Color4 object
  67655. */
  67656. Color4.prototype.toHexString = function () {
  67657. var intR = (this.r * 255) | 0;
  67658. var intG = (this.g * 255) | 0;
  67659. var intB = (this.b * 255) | 0;
  67660. var intA = (this.a * 255) | 0;
  67661. 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);
  67662. };
  67663. /**
  67664. * Computes a new Color4 converted from the current one to linear space
  67665. * @returns a new Color4 object
  67666. */
  67667. Color4.prototype.toLinearSpace = function () {
  67668. var convertedColor = new Color4();
  67669. this.toLinearSpaceToRef(convertedColor);
  67670. return convertedColor;
  67671. };
  67672. /**
  67673. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  67674. * @param convertedColor defines the Color4 object where to store the linear space version
  67675. * @returns the unmodified Color4
  67676. */
  67677. Color4.prototype.toLinearSpaceToRef = function (convertedColor) {
  67678. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  67679. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  67680. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  67681. convertedColor.a = this.a;
  67682. return this;
  67683. };
  67684. /**
  67685. * Computes a new Color4 converted from the current one to gamma space
  67686. * @returns a new Color4 object
  67687. */
  67688. Color4.prototype.toGammaSpace = function () {
  67689. var convertedColor = new Color4();
  67690. this.toGammaSpaceToRef(convertedColor);
  67691. return convertedColor;
  67692. };
  67693. /**
  67694. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  67695. * @param convertedColor defines the Color4 object where to store the gamma space version
  67696. * @returns the unmodified Color4
  67697. */
  67698. Color4.prototype.toGammaSpaceToRef = function (convertedColor) {
  67699. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  67700. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  67701. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  67702. convertedColor.a = this.a;
  67703. return this;
  67704. };
  67705. // Statics
  67706. /**
  67707. * Creates a new Color4 from the string containing valid hexadecimal values
  67708. * @param hex defines a string containing valid hexadecimal values
  67709. * @returns a new Color4 object
  67710. */
  67711. Color4.FromHexString = function (hex) {
  67712. if (hex.substring(0, 1) !== "#" || hex.length !== 9) {
  67713. return new Color4(0.0, 0.0, 0.0, 0.0);
  67714. }
  67715. var r = parseInt(hex.substring(1, 3), 16);
  67716. var g = parseInt(hex.substring(3, 5), 16);
  67717. var b = parseInt(hex.substring(5, 7), 16);
  67718. var a = parseInt(hex.substring(7, 9), 16);
  67719. return Color4.FromInts(r, g, b, a);
  67720. };
  67721. /**
  67722. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  67723. * @param left defines the start value
  67724. * @param right defines the end value
  67725. * @param amount defines the gradient factor
  67726. * @returns a new Color4 object
  67727. */
  67728. Color4.Lerp = function (left, right, amount) {
  67729. var result = new Color4(0.0, 0.0, 0.0, 0.0);
  67730. Color4.LerpToRef(left, right, amount, result);
  67731. return result;
  67732. };
  67733. /**
  67734. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  67735. * @param left defines the start value
  67736. * @param right defines the end value
  67737. * @param amount defines the gradient factor
  67738. * @param result defines the Color4 object where to store data
  67739. */
  67740. Color4.LerpToRef = function (left, right, amount, result) {
  67741. result.r = left.r + (right.r - left.r) * amount;
  67742. result.g = left.g + (right.g - left.g) * amount;
  67743. result.b = left.b + (right.b - left.b) * amount;
  67744. result.a = left.a + (right.a - left.a) * amount;
  67745. };
  67746. /**
  67747. * Creates a new Color4 from a Color3 and an alpha value
  67748. * @param color3 defines the source Color3 to read from
  67749. * @param alpha defines the alpha component (1.0 by default)
  67750. * @returns a new Color4 object
  67751. */
  67752. Color4.FromColor3 = function (color3, alpha) {
  67753. if (alpha === void 0) { alpha = 1.0; }
  67754. return new Color4(color3.r, color3.g, color3.b, alpha);
  67755. };
  67756. /**
  67757. * Creates a new Color4 from the starting index element of the given array
  67758. * @param array defines the source array to read from
  67759. * @param offset defines the offset in the source array
  67760. * @returns a new Color4 object
  67761. */
  67762. Color4.FromArray = function (array, offset) {
  67763. if (offset === void 0) { offset = 0; }
  67764. return new Color4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  67765. };
  67766. /**
  67767. * Creates a new Color3 from integer values (< 256)
  67768. * @param r defines the red component to read from (value between 0 and 255)
  67769. * @param g defines the green component to read from (value between 0 and 255)
  67770. * @param b defines the blue component to read from (value between 0 and 255)
  67771. * @param a defines the alpha component to read from (value between 0 and 255)
  67772. * @returns a new Color3 object
  67773. */
  67774. Color4.FromInts = function (r, g, b, a) {
  67775. return new Color4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
  67776. };
  67777. /**
  67778. * Check the content of a given array and convert it to an array containing RGBA data
  67779. * If the original array was already containing count * 4 values then it is returned directly
  67780. * @param colors defines the array to check
  67781. * @param count defines the number of RGBA data to expect
  67782. * @returns an array containing count * 4 values (RGBA)
  67783. */
  67784. Color4.CheckColors4 = function (colors, count) {
  67785. // Check if color3 was used
  67786. if (colors.length === count * 3) {
  67787. var colors4 = [];
  67788. for (var index = 0; index < colors.length; index += 3) {
  67789. var newIndex = (index / 3) * 4;
  67790. colors4[newIndex] = colors[index];
  67791. colors4[newIndex + 1] = colors[index + 1];
  67792. colors4[newIndex + 2] = colors[index + 2];
  67793. colors4[newIndex + 3] = 1.0;
  67794. }
  67795. return colors4;
  67796. }
  67797. return colors;
  67798. };
  67799. return Color4;
  67800. }());
  67801. /**
  67802. * Class representing a vector containing 2 coordinates
  67803. */
  67804. var Vector2 = /** @class */ (function () {
  67805. /**
  67806. * Creates a new Vector2 from the given x and y coordinates
  67807. * @param x defines the first coordinate
  67808. * @param y defines the second coordinate
  67809. */
  67810. function Vector2(
  67811. /** defines the first coordinate */
  67812. x,
  67813. /** defines the second coordinate */
  67814. y) {
  67815. if (x === void 0) { x = 0; }
  67816. if (y === void 0) { y = 0; }
  67817. this.x = x;
  67818. this.y = y;
  67819. }
  67820. /**
  67821. * Gets a string with the Vector2 coordinates
  67822. * @returns a string with the Vector2 coordinates
  67823. */
  67824. Vector2.prototype.toString = function () {
  67825. return "{X: " + this.x + " Y:" + this.y + "}";
  67826. };
  67827. /**
  67828. * Gets class name
  67829. * @returns the string "Vector2"
  67830. */
  67831. Vector2.prototype.getClassName = function () {
  67832. return "Vector2";
  67833. };
  67834. /**
  67835. * Gets current vector hash code
  67836. * @returns the Vector2 hash code as a number
  67837. */
  67838. Vector2.prototype.getHashCode = function () {
  67839. var hash = this.x || 0;
  67840. hash = (hash * 397) ^ (this.y || 0);
  67841. return hash;
  67842. };
  67843. // Operators
  67844. /**
  67845. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67846. * @param array defines the source array
  67847. * @param index defines the offset in source array
  67848. * @returns the current Vector2
  67849. */
  67850. Vector2.prototype.toArray = function (array, index) {
  67851. if (index === void 0) { index = 0; }
  67852. array[index] = this.x;
  67853. array[index + 1] = this.y;
  67854. return this;
  67855. };
  67856. /**
  67857. * Copy the current vector to an array
  67858. * @returns a new array with 2 elements: the Vector2 coordinates.
  67859. */
  67860. Vector2.prototype.asArray = function () {
  67861. var result = new Array();
  67862. this.toArray(result, 0);
  67863. return result;
  67864. };
  67865. /**
  67866. * Sets the Vector2 coordinates with the given Vector2 coordinates
  67867. * @param source defines the source Vector2
  67868. * @returns the current updated Vector2
  67869. */
  67870. Vector2.prototype.copyFrom = function (source) {
  67871. this.x = source.x;
  67872. this.y = source.y;
  67873. return this;
  67874. };
  67875. /**
  67876. * Sets the Vector2 coordinates with the given floats
  67877. * @param x defines the first coordinate
  67878. * @param y defines the second coordinate
  67879. * @returns the current updated Vector2
  67880. */
  67881. Vector2.prototype.copyFromFloats = function (x, y) {
  67882. this.x = x;
  67883. this.y = y;
  67884. return this;
  67885. };
  67886. /**
  67887. * Sets the Vector2 coordinates with the given floats
  67888. * @param x defines the first coordinate
  67889. * @param y defines the second coordinate
  67890. * @returns the current updated Vector2
  67891. */
  67892. Vector2.prototype.set = function (x, y) {
  67893. return this.copyFromFloats(x, y);
  67894. };
  67895. /**
  67896. * Add another vector with the current one
  67897. * @param otherVector defines the other vector
  67898. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67899. */
  67900. Vector2.prototype.add = function (otherVector) {
  67901. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  67902. };
  67903. /**
  67904. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67905. * @param otherVector defines the other vector
  67906. * @param result defines the target vector
  67907. * @returns the unmodified current Vector2
  67908. */
  67909. Vector2.prototype.addToRef = function (otherVector, result) {
  67910. result.x = this.x + otherVector.x;
  67911. result.y = this.y + otherVector.y;
  67912. return this;
  67913. };
  67914. /**
  67915. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67916. * @param otherVector defines the other vector
  67917. * @returns the current updated Vector2
  67918. */
  67919. Vector2.prototype.addInPlace = function (otherVector) {
  67920. this.x += otherVector.x;
  67921. this.y += otherVector.y;
  67922. return this;
  67923. };
  67924. /**
  67925. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67926. * @param otherVector defines the other vector
  67927. * @returns a new Vector2
  67928. */
  67929. Vector2.prototype.addVector3 = function (otherVector) {
  67930. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  67931. };
  67932. /**
  67933. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67934. * @param otherVector defines the other vector
  67935. * @returns a new Vector2
  67936. */
  67937. Vector2.prototype.subtract = function (otherVector) {
  67938. return new Vector2(this.x - otherVector.x, this.y - otherVector.y);
  67939. };
  67940. /**
  67941. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67942. * @param otherVector defines the other vector
  67943. * @param result defines the target vector
  67944. * @returns the unmodified current Vector2
  67945. */
  67946. Vector2.prototype.subtractToRef = function (otherVector, result) {
  67947. result.x = this.x - otherVector.x;
  67948. result.y = this.y - otherVector.y;
  67949. return this;
  67950. };
  67951. /**
  67952. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67953. * @param otherVector defines the other vector
  67954. * @returns the current updated Vector2
  67955. */
  67956. Vector2.prototype.subtractInPlace = function (otherVector) {
  67957. this.x -= otherVector.x;
  67958. this.y -= otherVector.y;
  67959. return this;
  67960. };
  67961. /**
  67962. * Multiplies in place the current Vector2 coordinates by the given ones
  67963. * @param otherVector defines the other vector
  67964. * @returns the current updated Vector2
  67965. */
  67966. Vector2.prototype.multiplyInPlace = function (otherVector) {
  67967. this.x *= otherVector.x;
  67968. this.y *= otherVector.y;
  67969. return this;
  67970. };
  67971. /**
  67972. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67973. * @param otherVector defines the other vector
  67974. * @returns a new Vector2
  67975. */
  67976. Vector2.prototype.multiply = function (otherVector) {
  67977. return new Vector2(this.x * otherVector.x, this.y * otherVector.y);
  67978. };
  67979. /**
  67980. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67981. * @param otherVector defines the other vector
  67982. * @param result defines the target vector
  67983. * @returns the unmodified current Vector2
  67984. */
  67985. Vector2.prototype.multiplyToRef = function (otherVector, result) {
  67986. result.x = this.x * otherVector.x;
  67987. result.y = this.y * otherVector.y;
  67988. return this;
  67989. };
  67990. /**
  67991. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67992. * @param x defines the first coordinate
  67993. * @param y defines the second coordinate
  67994. * @returns a new Vector2
  67995. */
  67996. Vector2.prototype.multiplyByFloats = function (x, y) {
  67997. return new Vector2(this.x * x, this.y * y);
  67998. };
  67999. /**
  68000. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  68001. * @param otherVector defines the other vector
  68002. * @returns a new Vector2
  68003. */
  68004. Vector2.prototype.divide = function (otherVector) {
  68005. return new Vector2(this.x / otherVector.x, this.y / otherVector.y);
  68006. };
  68007. /**
  68008. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  68009. * @param otherVector defines the other vector
  68010. * @param result defines the target vector
  68011. * @returns the unmodified current Vector2
  68012. */
  68013. Vector2.prototype.divideToRef = function (otherVector, result) {
  68014. result.x = this.x / otherVector.x;
  68015. result.y = this.y / otherVector.y;
  68016. return this;
  68017. };
  68018. /**
  68019. * Divides the current Vector2 coordinates by the given ones
  68020. * @param otherVector defines the other vector
  68021. * @returns the current updated Vector2
  68022. */
  68023. Vector2.prototype.divideInPlace = function (otherVector) {
  68024. return this.divideToRef(otherVector, this);
  68025. };
  68026. /**
  68027. * Gets a new Vector2 with current Vector2 negated coordinates
  68028. * @returns a new Vector2
  68029. */
  68030. Vector2.prototype.negate = function () {
  68031. return new Vector2(-this.x, -this.y);
  68032. };
  68033. /**
  68034. * Multiply the Vector2 coordinates by scale
  68035. * @param scale defines the scaling factor
  68036. * @returns the current updated Vector2
  68037. */
  68038. Vector2.prototype.scaleInPlace = function (scale) {
  68039. this.x *= scale;
  68040. this.y *= scale;
  68041. return this;
  68042. };
  68043. /**
  68044. * Returns a new Vector2 scaled by "scale" from the current Vector2
  68045. * @param scale defines the scaling factor
  68046. * @returns a new Vector2
  68047. */
  68048. Vector2.prototype.scale = function (scale) {
  68049. var result = new Vector2(0, 0);
  68050. this.scaleToRef(scale, result);
  68051. return result;
  68052. };
  68053. /**
  68054. * Scale the current Vector2 values by a factor to a given Vector2
  68055. * @param scale defines the scale factor
  68056. * @param result defines the Vector2 object where to store the result
  68057. * @returns the unmodified current Vector2
  68058. */
  68059. Vector2.prototype.scaleToRef = function (scale, result) {
  68060. result.x = this.x * scale;
  68061. result.y = this.y * scale;
  68062. return this;
  68063. };
  68064. /**
  68065. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  68066. * @param scale defines the scale factor
  68067. * @param result defines the Vector2 object where to store the result
  68068. * @returns the unmodified current Vector2
  68069. */
  68070. Vector2.prototype.scaleAndAddToRef = function (scale, result) {
  68071. result.x += this.x * scale;
  68072. result.y += this.y * scale;
  68073. return this;
  68074. };
  68075. /**
  68076. * Gets a boolean if two vectors are equals
  68077. * @param otherVector defines the other vector
  68078. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  68079. */
  68080. Vector2.prototype.equals = function (otherVector) {
  68081. return otherVector && this.x === otherVector.x && this.y === otherVector.y;
  68082. };
  68083. /**
  68084. * Gets a boolean if two vectors are equals (using an epsilon value)
  68085. * @param otherVector defines the other vector
  68086. * @param epsilon defines the minimal distance to consider equality
  68087. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  68088. */
  68089. Vector2.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  68090. if (epsilon === void 0) { epsilon = Epsilon; }
  68091. 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);
  68092. };
  68093. /**
  68094. * Gets a new Vector2 from current Vector2 floored values
  68095. * @returns a new Vector2
  68096. */
  68097. Vector2.prototype.floor = function () {
  68098. return new Vector2(Math.floor(this.x), Math.floor(this.y));
  68099. };
  68100. /**
  68101. * Gets a new Vector2 from current Vector2 floored values
  68102. * @returns a new Vector2
  68103. */
  68104. Vector2.prototype.fract = function () {
  68105. return new Vector2(this.x - Math.floor(this.x), this.y - Math.floor(this.y));
  68106. };
  68107. // Properties
  68108. /**
  68109. * Gets the length of the vector
  68110. * @returns the vector length (float)
  68111. */
  68112. Vector2.prototype.length = function () {
  68113. return Math.sqrt(this.x * this.x + this.y * this.y);
  68114. };
  68115. /**
  68116. * Gets the vector squared length
  68117. * @returns the vector squared length (float)
  68118. */
  68119. Vector2.prototype.lengthSquared = function () {
  68120. return (this.x * this.x + this.y * this.y);
  68121. };
  68122. // Methods
  68123. /**
  68124. * Normalize the vector
  68125. * @returns the current updated Vector2
  68126. */
  68127. Vector2.prototype.normalize = function () {
  68128. var len = this.length();
  68129. if (len === 0) {
  68130. return this;
  68131. }
  68132. var num = 1.0 / len;
  68133. this.x *= num;
  68134. this.y *= num;
  68135. return this;
  68136. };
  68137. /**
  68138. * Gets a new Vector2 copied from the Vector2
  68139. * @returns a new Vector2
  68140. */
  68141. Vector2.prototype.clone = function () {
  68142. return new Vector2(this.x, this.y);
  68143. };
  68144. // Statics
  68145. /**
  68146. * Gets a new Vector2(0, 0)
  68147. * @returns a new Vector2
  68148. */
  68149. Vector2.Zero = function () {
  68150. return new Vector2(0, 0);
  68151. };
  68152. /**
  68153. * Gets a new Vector2(1, 1)
  68154. * @returns a new Vector2
  68155. */
  68156. Vector2.One = function () {
  68157. return new Vector2(1, 1);
  68158. };
  68159. /**
  68160. * Gets a new Vector2 set from the given index element of the given array
  68161. * @param array defines the data source
  68162. * @param offset defines the offset in the data source
  68163. * @returns a new Vector2
  68164. */
  68165. Vector2.FromArray = function (array, offset) {
  68166. if (offset === void 0) { offset = 0; }
  68167. return new Vector2(array[offset], array[offset + 1]);
  68168. };
  68169. /**
  68170. * Sets "result" from the given index element of the given array
  68171. * @param array defines the data source
  68172. * @param offset defines the offset in the data source
  68173. * @param result defines the target vector
  68174. */
  68175. Vector2.FromArrayToRef = function (array, offset, result) {
  68176. result.x = array[offset];
  68177. result.y = array[offset + 1];
  68178. };
  68179. /**
  68180. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  68181. * @param value1 defines 1st point of control
  68182. * @param value2 defines 2nd point of control
  68183. * @param value3 defines 3rd point of control
  68184. * @param value4 defines 4th point of control
  68185. * @param amount defines the interpolation factor
  68186. * @returns a new Vector2
  68187. */
  68188. Vector2.CatmullRom = function (value1, value2, value3, value4, amount) {
  68189. var squared = amount * amount;
  68190. var cubed = amount * squared;
  68191. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  68192. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  68193. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  68194. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  68195. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  68196. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  68197. return new Vector2(x, y);
  68198. };
  68199. /**
  68200. * 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".
  68201. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  68202. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  68203. * @param value defines the value to clamp
  68204. * @param min defines the lower limit
  68205. * @param max defines the upper limit
  68206. * @returns a new Vector2
  68207. */
  68208. Vector2.Clamp = function (value, min, max) {
  68209. var x = value.x;
  68210. x = (x > max.x) ? max.x : x;
  68211. x = (x < min.x) ? min.x : x;
  68212. var y = value.y;
  68213. y = (y > max.y) ? max.y : y;
  68214. y = (y < min.y) ? min.y : y;
  68215. return new Vector2(x, y);
  68216. };
  68217. /**
  68218. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  68219. * @param value1 defines the 1st control point
  68220. * @param tangent1 defines the outgoing tangent
  68221. * @param value2 defines the 2nd control point
  68222. * @param tangent2 defines the incoming tangent
  68223. * @param amount defines the interpolation factor
  68224. * @returns a new Vector2
  68225. */
  68226. Vector2.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  68227. var squared = amount * amount;
  68228. var cubed = amount * squared;
  68229. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  68230. var part2 = (-2.0 * cubed) + (3.0 * squared);
  68231. var part3 = (cubed - (2.0 * squared)) + amount;
  68232. var part4 = cubed - squared;
  68233. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  68234. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  68235. return new Vector2(x, y);
  68236. };
  68237. /**
  68238. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  68239. * @param start defines the start vector
  68240. * @param end defines the end vector
  68241. * @param amount defines the interpolation factor
  68242. * @returns a new Vector2
  68243. */
  68244. Vector2.Lerp = function (start, end, amount) {
  68245. var x = start.x + ((end.x - start.x) * amount);
  68246. var y = start.y + ((end.y - start.y) * amount);
  68247. return new Vector2(x, y);
  68248. };
  68249. /**
  68250. * Gets the dot product of the vector "left" and the vector "right"
  68251. * @param left defines first vector
  68252. * @param right defines second vector
  68253. * @returns the dot product (float)
  68254. */
  68255. Vector2.Dot = function (left, right) {
  68256. return left.x * right.x + left.y * right.y;
  68257. };
  68258. /**
  68259. * Returns a new Vector2 equal to the normalized given vector
  68260. * @param vector defines the vector to normalize
  68261. * @returns a new Vector2
  68262. */
  68263. Vector2.Normalize = function (vector) {
  68264. var newVector = vector.clone();
  68265. newVector.normalize();
  68266. return newVector;
  68267. };
  68268. /**
  68269. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  68270. * @param left defines 1st vector
  68271. * @param right defines 2nd vector
  68272. * @returns a new Vector2
  68273. */
  68274. Vector2.Minimize = function (left, right) {
  68275. var x = (left.x < right.x) ? left.x : right.x;
  68276. var y = (left.y < right.y) ? left.y : right.y;
  68277. return new Vector2(x, y);
  68278. };
  68279. /**
  68280. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  68281. * @param left defines 1st vector
  68282. * @param right defines 2nd vector
  68283. * @returns a new Vector2
  68284. */
  68285. Vector2.Maximize = function (left, right) {
  68286. var x = (left.x > right.x) ? left.x : right.x;
  68287. var y = (left.y > right.y) ? left.y : right.y;
  68288. return new Vector2(x, y);
  68289. };
  68290. /**
  68291. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  68292. * @param vector defines the vector to transform
  68293. * @param transformation defines the matrix to apply
  68294. * @returns a new Vector2
  68295. */
  68296. Vector2.Transform = function (vector, transformation) {
  68297. var r = Vector2.Zero();
  68298. Vector2.TransformToRef(vector, transformation, r);
  68299. return r;
  68300. };
  68301. /**
  68302. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  68303. * @param vector defines the vector to transform
  68304. * @param transformation defines the matrix to apply
  68305. * @param result defines the target vector
  68306. */
  68307. Vector2.TransformToRef = function (vector, transformation, result) {
  68308. var m = transformation.m;
  68309. var x = (vector.x * m[0]) + (vector.y * m[4]) + m[12];
  68310. var y = (vector.x * m[1]) + (vector.y * m[5]) + m[13];
  68311. result.x = x;
  68312. result.y = y;
  68313. };
  68314. /**
  68315. * Determines if a given vector is included in a triangle
  68316. * @param p defines the vector to test
  68317. * @param p0 defines 1st triangle point
  68318. * @param p1 defines 2nd triangle point
  68319. * @param p2 defines 3rd triangle point
  68320. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  68321. */
  68322. Vector2.PointInTriangle = function (p, p0, p1, p2) {
  68323. var a = 1 / 2 * (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);
  68324. var sign = a < 0 ? -1 : 1;
  68325. var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y) * sign;
  68326. var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y) * sign;
  68327. return s > 0 && t > 0 && (s + t) < 2 * a * sign;
  68328. };
  68329. /**
  68330. * Gets the distance between the vectors "value1" and "value2"
  68331. * @param value1 defines first vector
  68332. * @param value2 defines second vector
  68333. * @returns the distance between vectors
  68334. */
  68335. Vector2.Distance = function (value1, value2) {
  68336. return Math.sqrt(Vector2.DistanceSquared(value1, value2));
  68337. };
  68338. /**
  68339. * Returns the squared distance between the vectors "value1" and "value2"
  68340. * @param value1 defines first vector
  68341. * @param value2 defines second vector
  68342. * @returns the squared distance between vectors
  68343. */
  68344. Vector2.DistanceSquared = function (value1, value2) {
  68345. var x = value1.x - value2.x;
  68346. var y = value1.y - value2.y;
  68347. return (x * x) + (y * y);
  68348. };
  68349. /**
  68350. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  68351. * @param value1 defines first vector
  68352. * @param value2 defines second vector
  68353. * @returns a new Vector2
  68354. */
  68355. Vector2.Center = function (value1, value2) {
  68356. var center = value1.add(value2);
  68357. center.scaleInPlace(0.5);
  68358. return center;
  68359. };
  68360. /**
  68361. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  68362. * @param p defines the middle point
  68363. * @param segA defines one point of the segment
  68364. * @param segB defines the other point of the segment
  68365. * @returns the shortest distance
  68366. */
  68367. Vector2.DistanceOfPointFromSegment = function (p, segA, segB) {
  68368. var l2 = Vector2.DistanceSquared(segA, segB);
  68369. if (l2 === 0.0) {
  68370. return Vector2.Distance(p, segA);
  68371. }
  68372. var v = segB.subtract(segA);
  68373. var t = Math.max(0, Math.min(1, Vector2.Dot(p.subtract(segA), v) / l2));
  68374. var proj = segA.add(v.multiplyByFloats(t, t));
  68375. return Vector2.Distance(p, proj);
  68376. };
  68377. return Vector2;
  68378. }());
  68379. /**
  68380. * Classed used to store (x,y,z) vector representation
  68381. * A Vector3 is the main object used in 3D geometry
  68382. * It can represent etiher the coordinates of a point the space, either a direction
  68383. * Reminder: js uses a left handed forward facing system
  68384. */
  68385. var Vector3 = /** @class */ (function () {
  68386. /**
  68387. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  68388. * @param x defines the first coordinates (on X axis)
  68389. * @param y defines the second coordinates (on Y axis)
  68390. * @param z defines the third coordinates (on Z axis)
  68391. */
  68392. function Vector3(
  68393. /**
  68394. * Defines the first coordinates (on X axis)
  68395. */
  68396. x,
  68397. /**
  68398. * Defines the second coordinates (on Y axis)
  68399. */
  68400. y,
  68401. /**
  68402. * Defines the third coordinates (on Z axis)
  68403. */
  68404. z) {
  68405. if (x === void 0) { x = 0; }
  68406. if (y === void 0) { y = 0; }
  68407. if (z === void 0) { z = 0; }
  68408. this.x = x;
  68409. this.y = y;
  68410. this.z = z;
  68411. }
  68412. /**
  68413. * Creates a string representation of the Vector3
  68414. * @returns a string with the Vector3 coordinates.
  68415. */
  68416. Vector3.prototype.toString = function () {
  68417. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + "}";
  68418. };
  68419. /**
  68420. * Gets the class name
  68421. * @returns the string "Vector3"
  68422. */
  68423. Vector3.prototype.getClassName = function () {
  68424. return "Vector3";
  68425. };
  68426. /**
  68427. * Creates the Vector3 hash code
  68428. * @returns a number which tends to be unique between Vector3 instances
  68429. */
  68430. Vector3.prototype.getHashCode = function () {
  68431. var hash = this.x || 0;
  68432. hash = (hash * 397) ^ (this.y || 0);
  68433. hash = (hash * 397) ^ (this.z || 0);
  68434. return hash;
  68435. };
  68436. // Operators
  68437. /**
  68438. * Creates an array containing three elements : the coordinates of the Vector3
  68439. * @returns a new array of numbers
  68440. */
  68441. Vector3.prototype.asArray = function () {
  68442. var result = [];
  68443. this.toArray(result, 0);
  68444. return result;
  68445. };
  68446. /**
  68447. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  68448. * @param array defines the destination array
  68449. * @param index defines the offset in the destination array
  68450. * @returns the current Vector3
  68451. */
  68452. Vector3.prototype.toArray = function (array, index) {
  68453. if (index === void 0) { index = 0; }
  68454. array[index] = this.x;
  68455. array[index + 1] = this.y;
  68456. array[index + 2] = this.z;
  68457. return this;
  68458. };
  68459. /**
  68460. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  68461. * @returns a new Quaternion object, computed from the Vector3 coordinates
  68462. */
  68463. Vector3.prototype.toQuaternion = function () {
  68464. return Quaternion.RotationYawPitchRoll(this.y, this.x, this.z);
  68465. };
  68466. /**
  68467. * Adds the given vector to the current Vector3
  68468. * @param otherVector defines the second operand
  68469. * @returns the current updated Vector3
  68470. */
  68471. Vector3.prototype.addInPlace = function (otherVector) {
  68472. return this.addInPlaceFromFloats(otherVector.x, otherVector.y, otherVector.z);
  68473. };
  68474. /**
  68475. * Adds the given coordinates to the current Vector3
  68476. * @param x defines the x coordinate of the operand
  68477. * @param y defines the y coordinate of the operand
  68478. * @param z defines the z coordinate of the operand
  68479. * @returns the current updated Vector3
  68480. */
  68481. Vector3.prototype.addInPlaceFromFloats = function (x, y, z) {
  68482. this.x += x;
  68483. this.y += y;
  68484. this.z += z;
  68485. return this;
  68486. };
  68487. /**
  68488. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  68489. * @param otherVector defines the second operand
  68490. * @returns the resulting Vector3
  68491. */
  68492. Vector3.prototype.add = function (otherVector) {
  68493. return new Vector3(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  68494. };
  68495. /**
  68496. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  68497. * @param otherVector defines the second operand
  68498. * @param result defines the Vector3 object where to store the result
  68499. * @returns the current Vector3
  68500. */
  68501. Vector3.prototype.addToRef = function (otherVector, result) {
  68502. return result.copyFromFloats(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  68503. };
  68504. /**
  68505. * Subtract the given vector from the current Vector3
  68506. * @param otherVector defines the second operand
  68507. * @returns the current updated Vector3
  68508. */
  68509. Vector3.prototype.subtractInPlace = function (otherVector) {
  68510. this.x -= otherVector.x;
  68511. this.y -= otherVector.y;
  68512. this.z -= otherVector.z;
  68513. return this;
  68514. };
  68515. /**
  68516. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  68517. * @param otherVector defines the second operand
  68518. * @returns the resulting Vector3
  68519. */
  68520. Vector3.prototype.subtract = function (otherVector) {
  68521. return new Vector3(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z);
  68522. };
  68523. /**
  68524. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  68525. * @param otherVector defines the second operand
  68526. * @param result defines the Vector3 object where to store the result
  68527. * @returns the current Vector3
  68528. */
  68529. Vector3.prototype.subtractToRef = function (otherVector, result) {
  68530. return this.subtractFromFloatsToRef(otherVector.x, otherVector.y, otherVector.z, result);
  68531. };
  68532. /**
  68533. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  68534. * @param x defines the x coordinate of the operand
  68535. * @param y defines the y coordinate of the operand
  68536. * @param z defines the z coordinate of the operand
  68537. * @returns the resulting Vector3
  68538. */
  68539. Vector3.prototype.subtractFromFloats = function (x, y, z) {
  68540. return new Vector3(this.x - x, this.y - y, this.z - z);
  68541. };
  68542. /**
  68543. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  68544. * @param x defines the x coordinate of the operand
  68545. * @param y defines the y coordinate of the operand
  68546. * @param z defines the z coordinate of the operand
  68547. * @param result defines the Vector3 object where to store the result
  68548. * @returns the current Vector3
  68549. */
  68550. Vector3.prototype.subtractFromFloatsToRef = function (x, y, z, result) {
  68551. return result.copyFromFloats(this.x - x, this.y - y, this.z - z);
  68552. };
  68553. /**
  68554. * Gets a new Vector3 set with the current Vector3 negated coordinates
  68555. * @returns a new Vector3
  68556. */
  68557. Vector3.prototype.negate = function () {
  68558. return new Vector3(-this.x, -this.y, -this.z);
  68559. };
  68560. /**
  68561. * Multiplies the Vector3 coordinates by the float "scale"
  68562. * @param scale defines the multiplier factor
  68563. * @returns the current updated Vector3
  68564. */
  68565. Vector3.prototype.scaleInPlace = function (scale) {
  68566. this.x *= scale;
  68567. this.y *= scale;
  68568. this.z *= scale;
  68569. return this;
  68570. };
  68571. /**
  68572. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  68573. * @param scale defines the multiplier factor
  68574. * @returns a new Vector3
  68575. */
  68576. Vector3.prototype.scale = function (scale) {
  68577. return new Vector3(this.x * scale, this.y * scale, this.z * scale);
  68578. };
  68579. /**
  68580. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  68581. * @param scale defines the multiplier factor
  68582. * @param result defines the Vector3 object where to store the result
  68583. * @returns the current Vector3
  68584. */
  68585. Vector3.prototype.scaleToRef = function (scale, result) {
  68586. return result.copyFromFloats(this.x * scale, this.y * scale, this.z * scale);
  68587. };
  68588. /**
  68589. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  68590. * @param scale defines the scale factor
  68591. * @param result defines the Vector3 object where to store the result
  68592. * @returns the unmodified current Vector3
  68593. */
  68594. Vector3.prototype.scaleAndAddToRef = function (scale, result) {
  68595. return result.addInPlaceFromFloats(this.x * scale, this.y * scale, this.z * scale);
  68596. };
  68597. /**
  68598. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  68599. * @param otherVector defines the second operand
  68600. * @returns true if both vectors are equals
  68601. */
  68602. Vector3.prototype.equals = function (otherVector) {
  68603. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z;
  68604. };
  68605. /**
  68606. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  68607. * @param otherVector defines the second operand
  68608. * @param epsilon defines the minimal distance to define values as equals
  68609. * @returns true if both vectors are distant less than epsilon
  68610. */
  68611. Vector3.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  68612. if (epsilon === void 0) { epsilon = Epsilon; }
  68613. 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);
  68614. };
  68615. /**
  68616. * Returns true if the current Vector3 coordinates equals the given floats
  68617. * @param x defines the x coordinate of the operand
  68618. * @param y defines the y coordinate of the operand
  68619. * @param z defines the z coordinate of the operand
  68620. * @returns true if both vectors are equals
  68621. */
  68622. Vector3.prototype.equalsToFloats = function (x, y, z) {
  68623. return this.x === x && this.y === y && this.z === z;
  68624. };
  68625. /**
  68626. * Multiplies the current Vector3 coordinates by the given ones
  68627. * @param otherVector defines the second operand
  68628. * @returns the current updated Vector3
  68629. */
  68630. Vector3.prototype.multiplyInPlace = function (otherVector) {
  68631. this.x *= otherVector.x;
  68632. this.y *= otherVector.y;
  68633. this.z *= otherVector.z;
  68634. return this;
  68635. };
  68636. /**
  68637. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  68638. * @param otherVector defines the second operand
  68639. * @returns the new Vector3
  68640. */
  68641. Vector3.prototype.multiply = function (otherVector) {
  68642. return this.multiplyByFloats(otherVector.x, otherVector.y, otherVector.z);
  68643. };
  68644. /**
  68645. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  68646. * @param otherVector defines the second operand
  68647. * @param result defines the Vector3 object where to store the result
  68648. * @returns the current Vector3
  68649. */
  68650. Vector3.prototype.multiplyToRef = function (otherVector, result) {
  68651. return result.copyFromFloats(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z);
  68652. };
  68653. /**
  68654. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  68655. * @param x defines the x coordinate of the operand
  68656. * @param y defines the y coordinate of the operand
  68657. * @param z defines the z coordinate of the operand
  68658. * @returns the new Vector3
  68659. */
  68660. Vector3.prototype.multiplyByFloats = function (x, y, z) {
  68661. return new Vector3(this.x * x, this.y * y, this.z * z);
  68662. };
  68663. /**
  68664. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  68665. * @param otherVector defines the second operand
  68666. * @returns the new Vector3
  68667. */
  68668. Vector3.prototype.divide = function (otherVector) {
  68669. return new Vector3(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  68670. };
  68671. /**
  68672. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  68673. * @param otherVector defines the second operand
  68674. * @param result defines the Vector3 object where to store the result
  68675. * @returns the current Vector3
  68676. */
  68677. Vector3.prototype.divideToRef = function (otherVector, result) {
  68678. return result.copyFromFloats(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  68679. };
  68680. /**
  68681. * Divides the current Vector3 coordinates by the given ones.
  68682. * @param otherVector defines the second operand
  68683. * @returns the current updated Vector3
  68684. */
  68685. Vector3.prototype.divideInPlace = function (otherVector) {
  68686. return this.divideToRef(otherVector, this);
  68687. };
  68688. /**
  68689. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  68690. * @param other defines the second operand
  68691. * @returns the current updated Vector3
  68692. */
  68693. Vector3.prototype.minimizeInPlace = function (other) {
  68694. return this.minimizeInPlaceFromFloats(other.x, other.y, other.z);
  68695. };
  68696. /**
  68697. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  68698. * @param other defines the second operand
  68699. * @returns the current updated Vector3
  68700. */
  68701. Vector3.prototype.maximizeInPlace = function (other) {
  68702. return this.maximizeInPlaceFromFloats(other.x, other.y, other.z);
  68703. };
  68704. /**
  68705. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  68706. * @param x defines the x coordinate of the operand
  68707. * @param y defines the y coordinate of the operand
  68708. * @param z defines the z coordinate of the operand
  68709. * @returns the current updated Vector3
  68710. */
  68711. Vector3.prototype.minimizeInPlaceFromFloats = function (x, y, z) {
  68712. if (x < this.x) {
  68713. this.x = x;
  68714. }
  68715. if (y < this.y) {
  68716. this.y = y;
  68717. }
  68718. if (z < this.z) {
  68719. this.z = z;
  68720. }
  68721. return this;
  68722. };
  68723. /**
  68724. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  68725. * @param x defines the x coordinate of the operand
  68726. * @param y defines the y coordinate of the operand
  68727. * @param z defines the z coordinate of the operand
  68728. * @returns the current updated Vector3
  68729. */
  68730. Vector3.prototype.maximizeInPlaceFromFloats = function (x, y, z) {
  68731. if (x > this.x) {
  68732. this.x = x;
  68733. }
  68734. if (y > this.y) {
  68735. this.y = y;
  68736. }
  68737. if (z > this.z) {
  68738. this.z = z;
  68739. }
  68740. return this;
  68741. };
  68742. /**
  68743. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  68744. * Check if is non uniform within a certain amount of decimal places to account for this
  68745. * @param epsilon the amount the values can differ
  68746. * @returns if the the vector is non uniform to a certain number of decimal places
  68747. */
  68748. Vector3.prototype.isNonUniformWithinEpsilon = function (epsilon) {
  68749. var absX = Math.abs(this.x);
  68750. var absY = Math.abs(this.y);
  68751. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absY, epsilon)) {
  68752. return true;
  68753. }
  68754. var absZ = Math.abs(this.z);
  68755. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absZ, epsilon)) {
  68756. return true;
  68757. }
  68758. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absY, absZ, epsilon)) {
  68759. return true;
  68760. }
  68761. return false;
  68762. };
  68763. Object.defineProperty(Vector3.prototype, "isNonUniform", {
  68764. /**
  68765. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  68766. */
  68767. get: function () {
  68768. var absX = Math.abs(this.x);
  68769. var absY = Math.abs(this.y);
  68770. if (absX !== absY) {
  68771. return true;
  68772. }
  68773. var absZ = Math.abs(this.z);
  68774. if (absX !== absZ) {
  68775. return true;
  68776. }
  68777. if (absY !== absZ) {
  68778. return true;
  68779. }
  68780. return false;
  68781. },
  68782. enumerable: true,
  68783. configurable: true
  68784. });
  68785. /**
  68786. * Gets a new Vector3 from current Vector3 floored values
  68787. * @returns a new Vector3
  68788. */
  68789. Vector3.prototype.floor = function () {
  68790. return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
  68791. };
  68792. /**
  68793. * Gets a new Vector3 from current Vector3 floored values
  68794. * @returns a new Vector3
  68795. */
  68796. Vector3.prototype.fract = function () {
  68797. return new Vector3(this.x - Math.floor(this.x), this.y - Math.floor(this.y), this.z - Math.floor(this.z));
  68798. };
  68799. // Properties
  68800. /**
  68801. * Gets the length of the Vector3
  68802. * @returns the length of the Vecto3
  68803. */
  68804. Vector3.prototype.length = function () {
  68805. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  68806. };
  68807. /**
  68808. * Gets the squared length of the Vector3
  68809. * @returns squared length of the Vector3
  68810. */
  68811. Vector3.prototype.lengthSquared = function () {
  68812. return (this.x * this.x + this.y * this.y + this.z * this.z);
  68813. };
  68814. /**
  68815. * Normalize the current Vector3.
  68816. * Please note that this is an in place operation.
  68817. * @returns the current updated Vector3
  68818. */
  68819. Vector3.prototype.normalize = function () {
  68820. return this.normalizeFromLength(this.length());
  68821. };
  68822. /**
  68823. * Reorders the x y z properties of the vector in place
  68824. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  68825. * @returns the current updated vector
  68826. */
  68827. Vector3.prototype.reorderInPlace = function (order) {
  68828. var _this = this;
  68829. order = order.toLowerCase();
  68830. if (order === "xyz") {
  68831. return this;
  68832. }
  68833. MathTmp.Vector3[0].copyFrom(this);
  68834. ["x", "y", "z"].forEach(function (val, i) {
  68835. _this[val] = MathTmp.Vector3[0][order[i]];
  68836. });
  68837. return this;
  68838. };
  68839. /**
  68840. * Rotates the vector around 0,0,0 by a quaternion
  68841. * @param quaternion the rotation quaternion
  68842. * @param result vector to store the result
  68843. * @returns the resulting vector
  68844. */
  68845. Vector3.prototype.rotateByQuaternionToRef = function (quaternion, result) {
  68846. quaternion.toRotationMatrix(MathTmp.Matrix[0]);
  68847. Vector3.TransformCoordinatesToRef(this, MathTmp.Matrix[0], result);
  68848. return result;
  68849. };
  68850. /**
  68851. * Rotates a vector around a given point
  68852. * @param quaternion the rotation quaternion
  68853. * @param point the point to rotate around
  68854. * @param result vector to store the result
  68855. * @returns the resulting vector
  68856. */
  68857. Vector3.prototype.rotateByQuaternionAroundPointToRef = function (quaternion, point, result) {
  68858. this.subtractToRef(point, MathTmp.Vector3[0]);
  68859. MathTmp.Vector3[0].rotateByQuaternionToRef(quaternion, MathTmp.Vector3[0]);
  68860. point.addToRef(MathTmp.Vector3[0], result);
  68861. return result;
  68862. };
  68863. /**
  68864. * Normalize the current Vector3 with the given input length.
  68865. * Please note that this is an in place operation.
  68866. * @param len the length of the vector
  68867. * @returns the current updated Vector3
  68868. */
  68869. Vector3.prototype.normalizeFromLength = function (len) {
  68870. if (len === 0 || len === 1.0) {
  68871. return this;
  68872. }
  68873. return this.scaleInPlace(1.0 / len);
  68874. };
  68875. /**
  68876. * Normalize the current Vector3 to a new vector
  68877. * @returns the new Vector3
  68878. */
  68879. Vector3.prototype.normalizeToNew = function () {
  68880. var normalized = new Vector3(0, 0, 0);
  68881. this.normalizeToRef(normalized);
  68882. return normalized;
  68883. };
  68884. /**
  68885. * Normalize the current Vector3 to the reference
  68886. * @param reference define the Vector3 to update
  68887. * @returns the updated Vector3
  68888. */
  68889. Vector3.prototype.normalizeToRef = function (reference) {
  68890. var len = this.length();
  68891. if (len === 0 || len === 1.0) {
  68892. return reference.copyFromFloats(this.x, this.y, this.z);
  68893. }
  68894. return this.scaleToRef(1.0 / len, reference);
  68895. };
  68896. /**
  68897. * Creates a new Vector3 copied from the current Vector3
  68898. * @returns the new Vector3
  68899. */
  68900. Vector3.prototype.clone = function () {
  68901. return new Vector3(this.x, this.y, this.z);
  68902. };
  68903. /**
  68904. * Copies the given vector coordinates to the current Vector3 ones
  68905. * @param source defines the source Vector3
  68906. * @returns the current updated Vector3
  68907. */
  68908. Vector3.prototype.copyFrom = function (source) {
  68909. return this.copyFromFloats(source.x, source.y, source.z);
  68910. };
  68911. /**
  68912. * Copies the given floats to the current Vector3 coordinates
  68913. * @param x defines the x coordinate of the operand
  68914. * @param y defines the y coordinate of the operand
  68915. * @param z defines the z coordinate of the operand
  68916. * @returns the current updated Vector3
  68917. */
  68918. Vector3.prototype.copyFromFloats = function (x, y, z) {
  68919. this.x = x;
  68920. this.y = y;
  68921. this.z = z;
  68922. return this;
  68923. };
  68924. /**
  68925. * Copies the given floats to the current Vector3 coordinates
  68926. * @param x defines the x coordinate of the operand
  68927. * @param y defines the y coordinate of the operand
  68928. * @param z defines the z coordinate of the operand
  68929. * @returns the current updated Vector3
  68930. */
  68931. Vector3.prototype.set = function (x, y, z) {
  68932. return this.copyFromFloats(x, y, z);
  68933. };
  68934. /**
  68935. * Copies the given float to the current Vector3 coordinates
  68936. * @param v defines the x, y and z coordinates of the operand
  68937. * @returns the current updated Vector3
  68938. */
  68939. Vector3.prototype.setAll = function (v) {
  68940. this.x = this.y = this.z = v;
  68941. return this;
  68942. };
  68943. // Statics
  68944. /**
  68945. * Get the clip factor between two vectors
  68946. * @param vector0 defines the first operand
  68947. * @param vector1 defines the second operand
  68948. * @param axis defines the axis to use
  68949. * @param size defines the size along the axis
  68950. * @returns the clip factor
  68951. */
  68952. Vector3.GetClipFactor = function (vector0, vector1, axis, size) {
  68953. var d0 = Vector3.Dot(vector0, axis) - size;
  68954. var d1 = Vector3.Dot(vector1, axis) - size;
  68955. var s = d0 / (d0 - d1);
  68956. return s;
  68957. };
  68958. /**
  68959. * Get angle between two vectors
  68960. * @param vector0 angle between vector0 and vector1
  68961. * @param vector1 angle between vector0 and vector1
  68962. * @param normal direction of the normal
  68963. * @return the angle between vector0 and vector1
  68964. */
  68965. Vector3.GetAngleBetweenVectors = function (vector0, vector1, normal) {
  68966. var v0 = vector0.normalizeToRef(MathTmp.Vector3[1]);
  68967. var v1 = vector1.normalizeToRef(MathTmp.Vector3[2]);
  68968. var dot = Vector3.Dot(v0, v1);
  68969. var n = MathTmp.Vector3[3];
  68970. Vector3.CrossToRef(v0, v1, n);
  68971. if (Vector3.Dot(n, normal) > 0) {
  68972. return Math.acos(dot);
  68973. }
  68974. return -Math.acos(dot);
  68975. };
  68976. /**
  68977. * Returns a new Vector3 set from the index "offset" of the given array
  68978. * @param array defines the source array
  68979. * @param offset defines the offset in the source array
  68980. * @returns the new Vector3
  68981. */
  68982. Vector3.FromArray = function (array, offset) {
  68983. if (offset === void 0) { offset = 0; }
  68984. return new Vector3(array[offset], array[offset + 1], array[offset + 2]);
  68985. };
  68986. /**
  68987. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  68988. * This function is deprecated. Use FromArray instead
  68989. * @param array defines the source array
  68990. * @param offset defines the offset in the source array
  68991. * @returns the new Vector3
  68992. */
  68993. Vector3.FromFloatArray = function (array, offset) {
  68994. return Vector3.FromArray(array, offset);
  68995. };
  68996. /**
  68997. * Sets the given vector "result" with the element values from the index "offset" of the given array
  68998. * @param array defines the source array
  68999. * @param offset defines the offset in the source array
  69000. * @param result defines the Vector3 where to store the result
  69001. */
  69002. Vector3.FromArrayToRef = function (array, offset, result) {
  69003. result.x = array[offset];
  69004. result.y = array[offset + 1];
  69005. result.z = array[offset + 2];
  69006. };
  69007. /**
  69008. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  69009. * This function is deprecated. Use FromArrayToRef instead.
  69010. * @param array defines the source array
  69011. * @param offset defines the offset in the source array
  69012. * @param result defines the Vector3 where to store the result
  69013. */
  69014. Vector3.FromFloatArrayToRef = function (array, offset, result) {
  69015. return Vector3.FromArrayToRef(array, offset, result);
  69016. };
  69017. /**
  69018. * Sets the given vector "result" with the given floats.
  69019. * @param x defines the x coordinate of the source
  69020. * @param y defines the y coordinate of the source
  69021. * @param z defines the z coordinate of the source
  69022. * @param result defines the Vector3 where to store the result
  69023. */
  69024. Vector3.FromFloatsToRef = function (x, y, z, result) {
  69025. result.copyFromFloats(x, y, z);
  69026. };
  69027. /**
  69028. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  69029. * @returns a new empty Vector3
  69030. */
  69031. Vector3.Zero = function () {
  69032. return new Vector3(0.0, 0.0, 0.0);
  69033. };
  69034. /**
  69035. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  69036. * @returns a new unit Vector3
  69037. */
  69038. Vector3.One = function () {
  69039. return new Vector3(1.0, 1.0, 1.0);
  69040. };
  69041. /**
  69042. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  69043. * @returns a new up Vector3
  69044. */
  69045. Vector3.Up = function () {
  69046. return new Vector3(0.0, 1.0, 0.0);
  69047. };
  69048. Object.defineProperty(Vector3, "UpReadOnly", {
  69049. /**
  69050. * Gets a up Vector3 that must not be updated
  69051. */
  69052. get: function () {
  69053. return Vector3._UpReadOnly;
  69054. },
  69055. enumerable: true,
  69056. configurable: true
  69057. });
  69058. /**
  69059. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  69060. * @returns a new down Vector3
  69061. */
  69062. Vector3.Down = function () {
  69063. return new Vector3(0.0, -1.0, 0.0);
  69064. };
  69065. /**
  69066. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  69067. * @returns a new forward Vector3
  69068. */
  69069. Vector3.Forward = function () {
  69070. return new Vector3(0.0, 0.0, 1.0);
  69071. };
  69072. /**
  69073. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  69074. * @returns a new forward Vector3
  69075. */
  69076. Vector3.Backward = function () {
  69077. return new Vector3(0.0, 0.0, -1.0);
  69078. };
  69079. /**
  69080. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  69081. * @returns a new right Vector3
  69082. */
  69083. Vector3.Right = function () {
  69084. return new Vector3(1.0, 0.0, 0.0);
  69085. };
  69086. /**
  69087. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  69088. * @returns a new left Vector3
  69089. */
  69090. Vector3.Left = function () {
  69091. return new Vector3(-1.0, 0.0, 0.0);
  69092. };
  69093. /**
  69094. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  69095. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69096. * @param vector defines the Vector3 to transform
  69097. * @param transformation defines the transformation matrix
  69098. * @returns the transformed Vector3
  69099. */
  69100. Vector3.TransformCoordinates = function (vector, transformation) {
  69101. var result = Vector3.Zero();
  69102. Vector3.TransformCoordinatesToRef(vector, transformation, result);
  69103. return result;
  69104. };
  69105. /**
  69106. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  69107. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69108. * @param vector defines the Vector3 to transform
  69109. * @param transformation defines the transformation matrix
  69110. * @param result defines the Vector3 where to store the result
  69111. */
  69112. Vector3.TransformCoordinatesToRef = function (vector, transformation, result) {
  69113. Vector3.TransformCoordinatesFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  69114. };
  69115. /**
  69116. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  69117. * This method computes tranformed coordinates only, not transformed direction vectors
  69118. * @param x define the x coordinate of the source vector
  69119. * @param y define the y coordinate of the source vector
  69120. * @param z define the z coordinate of the source vector
  69121. * @param transformation defines the transformation matrix
  69122. * @param result defines the Vector3 where to store the result
  69123. */
  69124. Vector3.TransformCoordinatesFromFloatsToRef = function (x, y, z, transformation, result) {
  69125. var m = transformation.m;
  69126. var rx = x * m[0] + y * m[4] + z * m[8] + m[12];
  69127. var ry = x * m[1] + y * m[5] + z * m[9] + m[13];
  69128. var rz = x * m[2] + y * m[6] + z * m[10] + m[14];
  69129. var rw = 1 / (x * m[3] + y * m[7] + z * m[11] + m[15]);
  69130. result.x = rx * rw;
  69131. result.y = ry * rw;
  69132. result.z = rz * rw;
  69133. };
  69134. /**
  69135. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  69136. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69137. * @param vector defines the Vector3 to transform
  69138. * @param transformation defines the transformation matrix
  69139. * @returns the new Vector3
  69140. */
  69141. Vector3.TransformNormal = function (vector, transformation) {
  69142. var result = Vector3.Zero();
  69143. Vector3.TransformNormalToRef(vector, transformation, result);
  69144. return result;
  69145. };
  69146. /**
  69147. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  69148. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69149. * @param vector defines the Vector3 to transform
  69150. * @param transformation defines the transformation matrix
  69151. * @param result defines the Vector3 where to store the result
  69152. */
  69153. Vector3.TransformNormalToRef = function (vector, transformation, result) {
  69154. this.TransformNormalFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  69155. };
  69156. /**
  69157. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  69158. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69159. * @param x define the x coordinate of the source vector
  69160. * @param y define the y coordinate of the source vector
  69161. * @param z define the z coordinate of the source vector
  69162. * @param transformation defines the transformation matrix
  69163. * @param result defines the Vector3 where to store the result
  69164. */
  69165. Vector3.TransformNormalFromFloatsToRef = function (x, y, z, transformation, result) {
  69166. var m = transformation.m;
  69167. result.x = x * m[0] + y * m[4] + z * m[8];
  69168. result.y = x * m[1] + y * m[5] + z * m[9];
  69169. result.z = x * m[2] + y * m[6] + z * m[10];
  69170. };
  69171. /**
  69172. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  69173. * @param value1 defines the first control point
  69174. * @param value2 defines the second control point
  69175. * @param value3 defines the third control point
  69176. * @param value4 defines the fourth control point
  69177. * @param amount defines the amount on the spline to use
  69178. * @returns the new Vector3
  69179. */
  69180. Vector3.CatmullRom = function (value1, value2, value3, value4, amount) {
  69181. var squared = amount * amount;
  69182. var cubed = amount * squared;
  69183. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  69184. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  69185. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  69186. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  69187. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  69188. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  69189. var z = 0.5 * ((((2.0 * value2.z) + ((-value1.z + value3.z) * amount)) +
  69190. (((((2.0 * value1.z) - (5.0 * value2.z)) + (4.0 * value3.z)) - value4.z) * squared)) +
  69191. ((((-value1.z + (3.0 * value2.z)) - (3.0 * value3.z)) + value4.z) * cubed));
  69192. return new Vector3(x, y, z);
  69193. };
  69194. /**
  69195. * 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"
  69196. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  69197. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  69198. * @param value defines the current value
  69199. * @param min defines the lower range value
  69200. * @param max defines the upper range value
  69201. * @returns the new Vector3
  69202. */
  69203. Vector3.Clamp = function (value, min, max) {
  69204. var v = new Vector3();
  69205. Vector3.ClampToRef(value, min, max, v);
  69206. return v;
  69207. };
  69208. /**
  69209. * 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"
  69210. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  69211. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  69212. * @param value defines the current value
  69213. * @param min defines the lower range value
  69214. * @param max defines the upper range value
  69215. * @param result defines the Vector3 where to store the result
  69216. */
  69217. Vector3.ClampToRef = function (value, min, max, result) {
  69218. var x = value.x;
  69219. x = (x > max.x) ? max.x : x;
  69220. x = (x < min.x) ? min.x : x;
  69221. var y = value.y;
  69222. y = (y > max.y) ? max.y : y;
  69223. y = (y < min.y) ? min.y : y;
  69224. var z = value.z;
  69225. z = (z > max.z) ? max.z : z;
  69226. z = (z < min.z) ? min.z : z;
  69227. result.copyFromFloats(x, y, z);
  69228. };
  69229. /**
  69230. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  69231. * @param value1 defines the first control point
  69232. * @param tangent1 defines the first tangent vector
  69233. * @param value2 defines the second control point
  69234. * @param tangent2 defines the second tangent vector
  69235. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  69236. * @returns the new Vector3
  69237. */
  69238. Vector3.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  69239. var squared = amount * amount;
  69240. var cubed = amount * squared;
  69241. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  69242. var part2 = (-2.0 * cubed) + (3.0 * squared);
  69243. var part3 = (cubed - (2.0 * squared)) + amount;
  69244. var part4 = cubed - squared;
  69245. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  69246. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  69247. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  69248. return new Vector3(x, y, z);
  69249. };
  69250. /**
  69251. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  69252. * @param start defines the start value
  69253. * @param end defines the end value
  69254. * @param amount max defines amount between both (between 0 and 1)
  69255. * @returns the new Vector3
  69256. */
  69257. Vector3.Lerp = function (start, end, amount) {
  69258. var result = new Vector3(0, 0, 0);
  69259. Vector3.LerpToRef(start, end, amount, result);
  69260. return result;
  69261. };
  69262. /**
  69263. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  69264. * @param start defines the start value
  69265. * @param end defines the end value
  69266. * @param amount max defines amount between both (between 0 and 1)
  69267. * @param result defines the Vector3 where to store the result
  69268. */
  69269. Vector3.LerpToRef = function (start, end, amount, result) {
  69270. result.x = start.x + ((end.x - start.x) * amount);
  69271. result.y = start.y + ((end.y - start.y) * amount);
  69272. result.z = start.z + ((end.z - start.z) * amount);
  69273. };
  69274. /**
  69275. * Returns the dot product (float) between the vectors "left" and "right"
  69276. * @param left defines the left operand
  69277. * @param right defines the right operand
  69278. * @returns the dot product
  69279. */
  69280. Vector3.Dot = function (left, right) {
  69281. return (left.x * right.x + left.y * right.y + left.z * right.z);
  69282. };
  69283. /**
  69284. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  69285. * The cross product is then orthogonal to both "left" and "right"
  69286. * @param left defines the left operand
  69287. * @param right defines the right operand
  69288. * @returns the cross product
  69289. */
  69290. Vector3.Cross = function (left, right) {
  69291. var result = Vector3.Zero();
  69292. Vector3.CrossToRef(left, right, result);
  69293. return result;
  69294. };
  69295. /**
  69296. * Sets the given vector "result" with the cross product of "left" and "right"
  69297. * The cross product is then orthogonal to both "left" and "right"
  69298. * @param left defines the left operand
  69299. * @param right defines the right operand
  69300. * @param result defines the Vector3 where to store the result
  69301. */
  69302. Vector3.CrossToRef = function (left, right, result) {
  69303. var x = left.y * right.z - left.z * right.y;
  69304. var y = left.z * right.x - left.x * right.z;
  69305. var z = left.x * right.y - left.y * right.x;
  69306. result.copyFromFloats(x, y, z);
  69307. };
  69308. /**
  69309. * Returns a new Vector3 as the normalization of the given vector
  69310. * @param vector defines the Vector3 to normalize
  69311. * @returns the new Vector3
  69312. */
  69313. Vector3.Normalize = function (vector) {
  69314. var result = Vector3.Zero();
  69315. Vector3.NormalizeToRef(vector, result);
  69316. return result;
  69317. };
  69318. /**
  69319. * Sets the given vector "result" with the normalization of the given first vector
  69320. * @param vector defines the Vector3 to normalize
  69321. * @param result defines the Vector3 where to store the result
  69322. */
  69323. Vector3.NormalizeToRef = function (vector, result) {
  69324. vector.normalizeToRef(result);
  69325. };
  69326. /**
  69327. * Project a Vector3 onto screen space
  69328. * @param vector defines the Vector3 to project
  69329. * @param world defines the world matrix to use
  69330. * @param transform defines the transform (view x projection) matrix to use
  69331. * @param viewport defines the screen viewport to use
  69332. * @returns the new Vector3
  69333. */
  69334. Vector3.Project = function (vector, world, transform, viewport) {
  69335. var cw = viewport.width;
  69336. var ch = viewport.height;
  69337. var cx = viewport.x;
  69338. var cy = viewport.y;
  69339. var viewportMatrix = MathTmp.Matrix[1];
  69340. 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);
  69341. var matrix = MathTmp.Matrix[0];
  69342. world.multiplyToRef(transform, matrix);
  69343. matrix.multiplyToRef(viewportMatrix, matrix);
  69344. return Vector3.TransformCoordinates(vector, matrix);
  69345. };
  69346. /** @hidden */
  69347. Vector3._UnprojectFromInvertedMatrixToRef = function (source, matrix, result) {
  69348. Vector3.TransformCoordinatesToRef(source, matrix, result);
  69349. var m = matrix.m;
  69350. var num = source.x * m[3] + source.y * m[7] + source.z * m[11] + m[15];
  69351. if (_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(num, 1.0)) {
  69352. result.scaleInPlace(1.0 / num);
  69353. }
  69354. };
  69355. /**
  69356. * Unproject from screen space to object space
  69357. * @param source defines the screen space Vector3 to use
  69358. * @param viewportWidth defines the current width of the viewport
  69359. * @param viewportHeight defines the current height of the viewport
  69360. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69361. * @param transform defines the transform (view x projection) matrix to use
  69362. * @returns the new Vector3
  69363. */
  69364. Vector3.UnprojectFromTransform = function (source, viewportWidth, viewportHeight, world, transform) {
  69365. var matrix = MathTmp.Matrix[0];
  69366. world.multiplyToRef(transform, matrix);
  69367. matrix.invert();
  69368. source.x = source.x / viewportWidth * 2 - 1;
  69369. source.y = -(source.y / viewportHeight * 2 - 1);
  69370. var vector = new Vector3();
  69371. Vector3._UnprojectFromInvertedMatrixToRef(source, matrix, vector);
  69372. return vector;
  69373. };
  69374. /**
  69375. * Unproject from screen space to object space
  69376. * @param source defines the screen space Vector3 to use
  69377. * @param viewportWidth defines the current width of the viewport
  69378. * @param viewportHeight defines the current height of the viewport
  69379. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69380. * @param view defines the view matrix to use
  69381. * @param projection defines the projection matrix to use
  69382. * @returns the new Vector3
  69383. */
  69384. Vector3.Unproject = function (source, viewportWidth, viewportHeight, world, view, projection) {
  69385. var result = Vector3.Zero();
  69386. Vector3.UnprojectToRef(source, viewportWidth, viewportHeight, world, view, projection, result);
  69387. return result;
  69388. };
  69389. /**
  69390. * Unproject from screen space to object space
  69391. * @param source defines the screen space Vector3 to use
  69392. * @param viewportWidth defines the current width of the viewport
  69393. * @param viewportHeight defines the current height of the viewport
  69394. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69395. * @param view defines the view matrix to use
  69396. * @param projection defines the projection matrix to use
  69397. * @param result defines the Vector3 where to store the result
  69398. */
  69399. Vector3.UnprojectToRef = function (source, viewportWidth, viewportHeight, world, view, projection, result) {
  69400. Vector3.UnprojectFloatsToRef(source.x, source.y, source.z, viewportWidth, viewportHeight, world, view, projection, result);
  69401. };
  69402. /**
  69403. * Unproject from screen space to object space
  69404. * @param sourceX defines the screen space x coordinate to use
  69405. * @param sourceY defines the screen space y coordinate to use
  69406. * @param sourceZ defines the screen space z coordinate to use
  69407. * @param viewportWidth defines the current width of the viewport
  69408. * @param viewportHeight defines the current height of the viewport
  69409. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69410. * @param view defines the view matrix to use
  69411. * @param projection defines the projection matrix to use
  69412. * @param result defines the Vector3 where to store the result
  69413. */
  69414. Vector3.UnprojectFloatsToRef = function (sourceX, sourceY, sourceZ, viewportWidth, viewportHeight, world, view, projection, result) {
  69415. var matrix = MathTmp.Matrix[0];
  69416. world.multiplyToRef(view, matrix);
  69417. matrix.multiplyToRef(projection, matrix);
  69418. matrix.invert();
  69419. var screenSource = MathTmp.Vector3[0];
  69420. screenSource.x = sourceX / viewportWidth * 2 - 1;
  69421. screenSource.y = -(sourceY / viewportHeight * 2 - 1);
  69422. screenSource.z = 2 * sourceZ - 1.0;
  69423. Vector3._UnprojectFromInvertedMatrixToRef(screenSource, matrix, result);
  69424. };
  69425. /**
  69426. * Gets the minimal coordinate values between two Vector3
  69427. * @param left defines the first operand
  69428. * @param right defines the second operand
  69429. * @returns the new Vector3
  69430. */
  69431. Vector3.Minimize = function (left, right) {
  69432. var min = left.clone();
  69433. min.minimizeInPlace(right);
  69434. return min;
  69435. };
  69436. /**
  69437. * Gets the maximal coordinate values between two Vector3
  69438. * @param left defines the first operand
  69439. * @param right defines the second operand
  69440. * @returns the new Vector3
  69441. */
  69442. Vector3.Maximize = function (left, right) {
  69443. var max = left.clone();
  69444. max.maximizeInPlace(right);
  69445. return max;
  69446. };
  69447. /**
  69448. * Returns the distance between the vectors "value1" and "value2"
  69449. * @param value1 defines the first operand
  69450. * @param value2 defines the second operand
  69451. * @returns the distance
  69452. */
  69453. Vector3.Distance = function (value1, value2) {
  69454. return Math.sqrt(Vector3.DistanceSquared(value1, value2));
  69455. };
  69456. /**
  69457. * Returns the squared distance between the vectors "value1" and "value2"
  69458. * @param value1 defines the first operand
  69459. * @param value2 defines the second operand
  69460. * @returns the squared distance
  69461. */
  69462. Vector3.DistanceSquared = function (value1, value2) {
  69463. var x = value1.x - value2.x;
  69464. var y = value1.y - value2.y;
  69465. var z = value1.z - value2.z;
  69466. return (x * x) + (y * y) + (z * z);
  69467. };
  69468. /**
  69469. * Returns a new Vector3 located at the center between "value1" and "value2"
  69470. * @param value1 defines the first operand
  69471. * @param value2 defines the second operand
  69472. * @returns the new Vector3
  69473. */
  69474. Vector3.Center = function (value1, value2) {
  69475. var center = value1.add(value2);
  69476. center.scaleInPlace(0.5);
  69477. return center;
  69478. };
  69479. /**
  69480. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  69481. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  69482. * to something in order to rotate it from its local system to the given target system
  69483. * Note: axis1, axis2 and axis3 are normalized during this operation
  69484. * @param axis1 defines the first axis
  69485. * @param axis2 defines the second axis
  69486. * @param axis3 defines the third axis
  69487. * @returns a new Vector3
  69488. */
  69489. Vector3.RotationFromAxis = function (axis1, axis2, axis3) {
  69490. var rotation = Vector3.Zero();
  69491. Vector3.RotationFromAxisToRef(axis1, axis2, axis3, rotation);
  69492. return rotation;
  69493. };
  69494. /**
  69495. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  69496. * @param axis1 defines the first axis
  69497. * @param axis2 defines the second axis
  69498. * @param axis3 defines the third axis
  69499. * @param ref defines the Vector3 where to store the result
  69500. */
  69501. Vector3.RotationFromAxisToRef = function (axis1, axis2, axis3, ref) {
  69502. var quat = MathTmp.Quaternion[0];
  69503. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  69504. quat.toEulerAnglesToRef(ref);
  69505. };
  69506. Vector3._UpReadOnly = Vector3.Up();
  69507. return Vector3;
  69508. }());
  69509. /**
  69510. * Vector4 class created for EulerAngle class conversion to Quaternion
  69511. */
  69512. var Vector4 = /** @class */ (function () {
  69513. /**
  69514. * Creates a Vector4 object from the given floats.
  69515. * @param x x value of the vector
  69516. * @param y y value of the vector
  69517. * @param z z value of the vector
  69518. * @param w w value of the vector
  69519. */
  69520. function Vector4(
  69521. /** x value of the vector */
  69522. x,
  69523. /** y value of the vector */
  69524. y,
  69525. /** z value of the vector */
  69526. z,
  69527. /** w value of the vector */
  69528. w) {
  69529. this.x = x;
  69530. this.y = y;
  69531. this.z = z;
  69532. this.w = w;
  69533. }
  69534. /**
  69535. * Returns the string with the Vector4 coordinates.
  69536. * @returns a string containing all the vector values
  69537. */
  69538. Vector4.prototype.toString = function () {
  69539. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  69540. };
  69541. /**
  69542. * Returns the string "Vector4".
  69543. * @returns "Vector4"
  69544. */
  69545. Vector4.prototype.getClassName = function () {
  69546. return "Vector4";
  69547. };
  69548. /**
  69549. * Returns the Vector4 hash code.
  69550. * @returns a unique hash code
  69551. */
  69552. Vector4.prototype.getHashCode = function () {
  69553. var hash = this.x || 0;
  69554. hash = (hash * 397) ^ (this.y || 0);
  69555. hash = (hash * 397) ^ (this.z || 0);
  69556. hash = (hash * 397) ^ (this.w || 0);
  69557. return hash;
  69558. };
  69559. // Operators
  69560. /**
  69561. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  69562. * @returns the resulting array
  69563. */
  69564. Vector4.prototype.asArray = function () {
  69565. var result = new Array();
  69566. this.toArray(result, 0);
  69567. return result;
  69568. };
  69569. /**
  69570. * Populates the given array from the given index with the Vector4 coordinates.
  69571. * @param array array to populate
  69572. * @param index index of the array to start at (default: 0)
  69573. * @returns the Vector4.
  69574. */
  69575. Vector4.prototype.toArray = function (array, index) {
  69576. if (index === undefined) {
  69577. index = 0;
  69578. }
  69579. array[index] = this.x;
  69580. array[index + 1] = this.y;
  69581. array[index + 2] = this.z;
  69582. array[index + 3] = this.w;
  69583. return this;
  69584. };
  69585. /**
  69586. * Adds the given vector to the current Vector4.
  69587. * @param otherVector the vector to add
  69588. * @returns the updated Vector4.
  69589. */
  69590. Vector4.prototype.addInPlace = function (otherVector) {
  69591. this.x += otherVector.x;
  69592. this.y += otherVector.y;
  69593. this.z += otherVector.z;
  69594. this.w += otherVector.w;
  69595. return this;
  69596. };
  69597. /**
  69598. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  69599. * @param otherVector the vector to add
  69600. * @returns the resulting vector
  69601. */
  69602. Vector4.prototype.add = function (otherVector) {
  69603. return new Vector4(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z, this.w + otherVector.w);
  69604. };
  69605. /**
  69606. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  69607. * @param otherVector the vector to add
  69608. * @param result the vector to store the result
  69609. * @returns the current Vector4.
  69610. */
  69611. Vector4.prototype.addToRef = function (otherVector, result) {
  69612. result.x = this.x + otherVector.x;
  69613. result.y = this.y + otherVector.y;
  69614. result.z = this.z + otherVector.z;
  69615. result.w = this.w + otherVector.w;
  69616. return this;
  69617. };
  69618. /**
  69619. * Subtract in place the given vector from the current Vector4.
  69620. * @param otherVector the vector to subtract
  69621. * @returns the updated Vector4.
  69622. */
  69623. Vector4.prototype.subtractInPlace = function (otherVector) {
  69624. this.x -= otherVector.x;
  69625. this.y -= otherVector.y;
  69626. this.z -= otherVector.z;
  69627. this.w -= otherVector.w;
  69628. return this;
  69629. };
  69630. /**
  69631. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  69632. * @param otherVector the vector to add
  69633. * @returns the new vector with the result
  69634. */
  69635. Vector4.prototype.subtract = function (otherVector) {
  69636. return new Vector4(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z, this.w - otherVector.w);
  69637. };
  69638. /**
  69639. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  69640. * @param otherVector the vector to subtract
  69641. * @param result the vector to store the result
  69642. * @returns the current Vector4.
  69643. */
  69644. Vector4.prototype.subtractToRef = function (otherVector, result) {
  69645. result.x = this.x - otherVector.x;
  69646. result.y = this.y - otherVector.y;
  69647. result.z = this.z - otherVector.z;
  69648. result.w = this.w - otherVector.w;
  69649. return this;
  69650. };
  69651. /**
  69652. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69653. */
  69654. /**
  69655. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69656. * @param x value to subtract
  69657. * @param y value to subtract
  69658. * @param z value to subtract
  69659. * @param w value to subtract
  69660. * @returns new vector containing the result
  69661. */
  69662. Vector4.prototype.subtractFromFloats = function (x, y, z, w) {
  69663. return new Vector4(this.x - x, this.y - y, this.z - z, this.w - w);
  69664. };
  69665. /**
  69666. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69667. * @param x value to subtract
  69668. * @param y value to subtract
  69669. * @param z value to subtract
  69670. * @param w value to subtract
  69671. * @param result the vector to store the result in
  69672. * @returns the current Vector4.
  69673. */
  69674. Vector4.prototype.subtractFromFloatsToRef = function (x, y, z, w, result) {
  69675. result.x = this.x - x;
  69676. result.y = this.y - y;
  69677. result.z = this.z - z;
  69678. result.w = this.w - w;
  69679. return this;
  69680. };
  69681. /**
  69682. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  69683. * @returns a new vector with the negated values
  69684. */
  69685. Vector4.prototype.negate = function () {
  69686. return new Vector4(-this.x, -this.y, -this.z, -this.w);
  69687. };
  69688. /**
  69689. * Multiplies the current Vector4 coordinates by scale (float).
  69690. * @param scale the number to scale with
  69691. * @returns the updated Vector4.
  69692. */
  69693. Vector4.prototype.scaleInPlace = function (scale) {
  69694. this.x *= scale;
  69695. this.y *= scale;
  69696. this.z *= scale;
  69697. this.w *= scale;
  69698. return this;
  69699. };
  69700. /**
  69701. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  69702. * @param scale the number to scale with
  69703. * @returns a new vector with the result
  69704. */
  69705. Vector4.prototype.scale = function (scale) {
  69706. return new Vector4(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
  69707. };
  69708. /**
  69709. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  69710. * @param scale the number to scale with
  69711. * @param result a vector to store the result in
  69712. * @returns the current Vector4.
  69713. */
  69714. Vector4.prototype.scaleToRef = function (scale, result) {
  69715. result.x = this.x * scale;
  69716. result.y = this.y * scale;
  69717. result.z = this.z * scale;
  69718. result.w = this.w * scale;
  69719. return this;
  69720. };
  69721. /**
  69722. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  69723. * @param scale defines the scale factor
  69724. * @param result defines the Vector4 object where to store the result
  69725. * @returns the unmodified current Vector4
  69726. */
  69727. Vector4.prototype.scaleAndAddToRef = function (scale, result) {
  69728. result.x += this.x * scale;
  69729. result.y += this.y * scale;
  69730. result.z += this.z * scale;
  69731. result.w += this.w * scale;
  69732. return this;
  69733. };
  69734. /**
  69735. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  69736. * @param otherVector the vector to compare against
  69737. * @returns true if they are equal
  69738. */
  69739. Vector4.prototype.equals = function (otherVector) {
  69740. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z && this.w === otherVector.w;
  69741. };
  69742. /**
  69743. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  69744. * @param otherVector vector to compare against
  69745. * @param epsilon (Default: very small number)
  69746. * @returns true if they are equal
  69747. */
  69748. Vector4.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  69749. if (epsilon === void 0) { epsilon = Epsilon; }
  69750. return otherVector
  69751. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon)
  69752. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon)
  69753. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.z, otherVector.z, epsilon)
  69754. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.w, otherVector.w, epsilon);
  69755. };
  69756. /**
  69757. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  69758. * @param x x value to compare against
  69759. * @param y y value to compare against
  69760. * @param z z value to compare against
  69761. * @param w w value to compare against
  69762. * @returns true if equal
  69763. */
  69764. Vector4.prototype.equalsToFloats = function (x, y, z, w) {
  69765. return this.x === x && this.y === y && this.z === z && this.w === w;
  69766. };
  69767. /**
  69768. * Multiplies in place the current Vector4 by the given one.
  69769. * @param otherVector vector to multiple with
  69770. * @returns the updated Vector4.
  69771. */
  69772. Vector4.prototype.multiplyInPlace = function (otherVector) {
  69773. this.x *= otherVector.x;
  69774. this.y *= otherVector.y;
  69775. this.z *= otherVector.z;
  69776. this.w *= otherVector.w;
  69777. return this;
  69778. };
  69779. /**
  69780. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  69781. * @param otherVector vector to multiple with
  69782. * @returns resulting new vector
  69783. */
  69784. Vector4.prototype.multiply = function (otherVector) {
  69785. return new Vector4(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z, this.w * otherVector.w);
  69786. };
  69787. /**
  69788. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  69789. * @param otherVector vector to multiple with
  69790. * @param result vector to store the result
  69791. * @returns the current Vector4.
  69792. */
  69793. Vector4.prototype.multiplyToRef = function (otherVector, result) {
  69794. result.x = this.x * otherVector.x;
  69795. result.y = this.y * otherVector.y;
  69796. result.z = this.z * otherVector.z;
  69797. result.w = this.w * otherVector.w;
  69798. return this;
  69799. };
  69800. /**
  69801. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  69802. * @param x x value multiply with
  69803. * @param y y value multiply with
  69804. * @param z z value multiply with
  69805. * @param w w value multiply with
  69806. * @returns resulting new vector
  69807. */
  69808. Vector4.prototype.multiplyByFloats = function (x, y, z, w) {
  69809. return new Vector4(this.x * x, this.y * y, this.z * z, this.w * w);
  69810. };
  69811. /**
  69812. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  69813. * @param otherVector vector to devide with
  69814. * @returns resulting new vector
  69815. */
  69816. Vector4.prototype.divide = function (otherVector) {
  69817. return new Vector4(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z, this.w / otherVector.w);
  69818. };
  69819. /**
  69820. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  69821. * @param otherVector vector to devide with
  69822. * @param result vector to store the result
  69823. * @returns the current Vector4.
  69824. */
  69825. Vector4.prototype.divideToRef = function (otherVector, result) {
  69826. result.x = this.x / otherVector.x;
  69827. result.y = this.y / otherVector.y;
  69828. result.z = this.z / otherVector.z;
  69829. result.w = this.w / otherVector.w;
  69830. return this;
  69831. };
  69832. /**
  69833. * Divides the current Vector3 coordinates by the given ones.
  69834. * @param otherVector vector to devide with
  69835. * @returns the updated Vector3.
  69836. */
  69837. Vector4.prototype.divideInPlace = function (otherVector) {
  69838. return this.divideToRef(otherVector, this);
  69839. };
  69840. /**
  69841. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  69842. * @param other defines the second operand
  69843. * @returns the current updated Vector4
  69844. */
  69845. Vector4.prototype.minimizeInPlace = function (other) {
  69846. if (other.x < this.x) {
  69847. this.x = other.x;
  69848. }
  69849. if (other.y < this.y) {
  69850. this.y = other.y;
  69851. }
  69852. if (other.z < this.z) {
  69853. this.z = other.z;
  69854. }
  69855. if (other.w < this.w) {
  69856. this.w = other.w;
  69857. }
  69858. return this;
  69859. };
  69860. /**
  69861. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  69862. * @param other defines the second operand
  69863. * @returns the current updated Vector4
  69864. */
  69865. Vector4.prototype.maximizeInPlace = function (other) {
  69866. if (other.x > this.x) {
  69867. this.x = other.x;
  69868. }
  69869. if (other.y > this.y) {
  69870. this.y = other.y;
  69871. }
  69872. if (other.z > this.z) {
  69873. this.z = other.z;
  69874. }
  69875. if (other.w > this.w) {
  69876. this.w = other.w;
  69877. }
  69878. return this;
  69879. };
  69880. /**
  69881. * Gets a new Vector4 from current Vector4 floored values
  69882. * @returns a new Vector4
  69883. */
  69884. Vector4.prototype.floor = function () {
  69885. return new Vector4(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
  69886. };
  69887. /**
  69888. * Gets a new Vector4 from current Vector3 floored values
  69889. * @returns a new Vector4
  69890. */
  69891. Vector4.prototype.fract = function () {
  69892. 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));
  69893. };
  69894. // Properties
  69895. /**
  69896. * Returns the Vector4 length (float).
  69897. * @returns the length
  69898. */
  69899. Vector4.prototype.length = function () {
  69900. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  69901. };
  69902. /**
  69903. * Returns the Vector4 squared length (float).
  69904. * @returns the length squared
  69905. */
  69906. Vector4.prototype.lengthSquared = function () {
  69907. return (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  69908. };
  69909. // Methods
  69910. /**
  69911. * Normalizes in place the Vector4.
  69912. * @returns the updated Vector4.
  69913. */
  69914. Vector4.prototype.normalize = function () {
  69915. var len = this.length();
  69916. if (len === 0) {
  69917. return this;
  69918. }
  69919. return this.scaleInPlace(1.0 / len);
  69920. };
  69921. /**
  69922. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  69923. * @returns this converted to a new vector3
  69924. */
  69925. Vector4.prototype.toVector3 = function () {
  69926. return new Vector3(this.x, this.y, this.z);
  69927. };
  69928. /**
  69929. * Returns a new Vector4 copied from the current one.
  69930. * @returns the new cloned vector
  69931. */
  69932. Vector4.prototype.clone = function () {
  69933. return new Vector4(this.x, this.y, this.z, this.w);
  69934. };
  69935. /**
  69936. * Updates the current Vector4 with the given one coordinates.
  69937. * @param source the source vector to copy from
  69938. * @returns the updated Vector4.
  69939. */
  69940. Vector4.prototype.copyFrom = function (source) {
  69941. this.x = source.x;
  69942. this.y = source.y;
  69943. this.z = source.z;
  69944. this.w = source.w;
  69945. return this;
  69946. };
  69947. /**
  69948. * Updates the current Vector4 coordinates with the given floats.
  69949. * @param x float to copy from
  69950. * @param y float to copy from
  69951. * @param z float to copy from
  69952. * @param w float to copy from
  69953. * @returns the updated Vector4.
  69954. */
  69955. Vector4.prototype.copyFromFloats = function (x, y, z, w) {
  69956. this.x = x;
  69957. this.y = y;
  69958. this.z = z;
  69959. this.w = w;
  69960. return this;
  69961. };
  69962. /**
  69963. * Updates the current Vector4 coordinates with the given floats.
  69964. * @param x float to set from
  69965. * @param y float to set from
  69966. * @param z float to set from
  69967. * @param w float to set from
  69968. * @returns the updated Vector4.
  69969. */
  69970. Vector4.prototype.set = function (x, y, z, w) {
  69971. return this.copyFromFloats(x, y, z, w);
  69972. };
  69973. /**
  69974. * Copies the given float to the current Vector3 coordinates
  69975. * @param v defines the x, y, z and w coordinates of the operand
  69976. * @returns the current updated Vector3
  69977. */
  69978. Vector4.prototype.setAll = function (v) {
  69979. this.x = this.y = this.z = this.w = v;
  69980. return this;
  69981. };
  69982. // Statics
  69983. /**
  69984. * Returns a new Vector4 set from the starting index of the given array.
  69985. * @param array the array to pull values from
  69986. * @param offset the offset into the array to start at
  69987. * @returns the new vector
  69988. */
  69989. Vector4.FromArray = function (array, offset) {
  69990. if (!offset) {
  69991. offset = 0;
  69992. }
  69993. return new Vector4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  69994. };
  69995. /**
  69996. * Updates the given vector "result" from the starting index of the given array.
  69997. * @param array the array to pull values from
  69998. * @param offset the offset into the array to start at
  69999. * @param result the vector to store the result in
  70000. */
  70001. Vector4.FromArrayToRef = function (array, offset, result) {
  70002. result.x = array[offset];
  70003. result.y = array[offset + 1];
  70004. result.z = array[offset + 2];
  70005. result.w = array[offset + 3];
  70006. };
  70007. /**
  70008. * Updates the given vector "result" from the starting index of the given Float32Array.
  70009. * @param array the array to pull values from
  70010. * @param offset the offset into the array to start at
  70011. * @param result the vector to store the result in
  70012. */
  70013. Vector4.FromFloatArrayToRef = function (array, offset, result) {
  70014. Vector4.FromArrayToRef(array, offset, result);
  70015. };
  70016. /**
  70017. * Updates the given vector "result" coordinates from the given floats.
  70018. * @param x float to set from
  70019. * @param y float to set from
  70020. * @param z float to set from
  70021. * @param w float to set from
  70022. * @param result the vector to the floats in
  70023. */
  70024. Vector4.FromFloatsToRef = function (x, y, z, w, result) {
  70025. result.x = x;
  70026. result.y = y;
  70027. result.z = z;
  70028. result.w = w;
  70029. };
  70030. /**
  70031. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  70032. * @returns the new vector
  70033. */
  70034. Vector4.Zero = function () {
  70035. return new Vector4(0.0, 0.0, 0.0, 0.0);
  70036. };
  70037. /**
  70038. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  70039. * @returns the new vector
  70040. */
  70041. Vector4.One = function () {
  70042. return new Vector4(1.0, 1.0, 1.0, 1.0);
  70043. };
  70044. /**
  70045. * Returns a new normalized Vector4 from the given one.
  70046. * @param vector the vector to normalize
  70047. * @returns the vector
  70048. */
  70049. Vector4.Normalize = function (vector) {
  70050. var result = Vector4.Zero();
  70051. Vector4.NormalizeToRef(vector, result);
  70052. return result;
  70053. };
  70054. /**
  70055. * Updates the given vector "result" from the normalization of the given one.
  70056. * @param vector the vector to normalize
  70057. * @param result the vector to store the result in
  70058. */
  70059. Vector4.NormalizeToRef = function (vector, result) {
  70060. result.copyFrom(vector);
  70061. result.normalize();
  70062. };
  70063. /**
  70064. * Returns a vector with the minimum values from the left and right vectors
  70065. * @param left left vector to minimize
  70066. * @param right right vector to minimize
  70067. * @returns a new vector with the minimum of the left and right vector values
  70068. */
  70069. Vector4.Minimize = function (left, right) {
  70070. var min = left.clone();
  70071. min.minimizeInPlace(right);
  70072. return min;
  70073. };
  70074. /**
  70075. * Returns a vector with the maximum values from the left and right vectors
  70076. * @param left left vector to maximize
  70077. * @param right right vector to maximize
  70078. * @returns a new vector with the maximum of the left and right vector values
  70079. */
  70080. Vector4.Maximize = function (left, right) {
  70081. var max = left.clone();
  70082. max.maximizeInPlace(right);
  70083. return max;
  70084. };
  70085. /**
  70086. * Returns the distance (float) between the vectors "value1" and "value2".
  70087. * @param value1 value to calulate the distance between
  70088. * @param value2 value to calulate the distance between
  70089. * @return the distance between the two vectors
  70090. */
  70091. Vector4.Distance = function (value1, value2) {
  70092. return Math.sqrt(Vector4.DistanceSquared(value1, value2));
  70093. };
  70094. /**
  70095. * Returns the squared distance (float) between the vectors "value1" and "value2".
  70096. * @param value1 value to calulate the distance between
  70097. * @param value2 value to calulate the distance between
  70098. * @return the distance between the two vectors squared
  70099. */
  70100. Vector4.DistanceSquared = function (value1, value2) {
  70101. var x = value1.x - value2.x;
  70102. var y = value1.y - value2.y;
  70103. var z = value1.z - value2.z;
  70104. var w = value1.w - value2.w;
  70105. return (x * x) + (y * y) + (z * z) + (w * w);
  70106. };
  70107. /**
  70108. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  70109. * @param value1 value to calulate the center between
  70110. * @param value2 value to calulate the center between
  70111. * @return the center between the two vectors
  70112. */
  70113. Vector4.Center = function (value1, value2) {
  70114. var center = value1.add(value2);
  70115. center.scaleInPlace(0.5);
  70116. return center;
  70117. };
  70118. /**
  70119. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  70120. * This methods computes transformed normalized direction vectors only.
  70121. * @param vector the vector to transform
  70122. * @param transformation the transformation matrix to apply
  70123. * @returns the new vector
  70124. */
  70125. Vector4.TransformNormal = function (vector, transformation) {
  70126. var result = Vector4.Zero();
  70127. Vector4.TransformNormalToRef(vector, transformation, result);
  70128. return result;
  70129. };
  70130. /**
  70131. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  70132. * This methods computes transformed normalized direction vectors only.
  70133. * @param vector the vector to transform
  70134. * @param transformation the transformation matrix to apply
  70135. * @param result the vector to store the result in
  70136. */
  70137. Vector4.TransformNormalToRef = function (vector, transformation, result) {
  70138. var m = transformation.m;
  70139. var x = (vector.x * m[0]) + (vector.y * m[4]) + (vector.z * m[8]);
  70140. var y = (vector.x * m[1]) + (vector.y * m[5]) + (vector.z * m[9]);
  70141. var z = (vector.x * m[2]) + (vector.y * m[6]) + (vector.z * m[10]);
  70142. result.x = x;
  70143. result.y = y;
  70144. result.z = z;
  70145. result.w = vector.w;
  70146. };
  70147. /**
  70148. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  70149. * This methods computes transformed normalized direction vectors only.
  70150. * @param x value to transform
  70151. * @param y value to transform
  70152. * @param z value to transform
  70153. * @param w value to transform
  70154. * @param transformation the transformation matrix to apply
  70155. * @param result the vector to store the results in
  70156. */
  70157. Vector4.TransformNormalFromFloatsToRef = function (x, y, z, w, transformation, result) {
  70158. var m = transformation.m;
  70159. result.x = (x * m[0]) + (y * m[4]) + (z * m[8]);
  70160. result.y = (x * m[1]) + (y * m[5]) + (z * m[9]);
  70161. result.z = (x * m[2]) + (y * m[6]) + (z * m[10]);
  70162. result.w = w;
  70163. };
  70164. /**
  70165. * Creates a new Vector4 from a Vector3
  70166. * @param source defines the source data
  70167. * @param w defines the 4th component (default is 0)
  70168. * @returns a new Vector4
  70169. */
  70170. Vector4.FromVector3 = function (source, w) {
  70171. if (w === void 0) { w = 0; }
  70172. return new Vector4(source.x, source.y, source.z, w);
  70173. };
  70174. return Vector4;
  70175. }());
  70176. /**
  70177. * Size containing widht and height
  70178. */
  70179. var Size = /** @class */ (function () {
  70180. /**
  70181. * Creates a Size object from the given width and height (floats).
  70182. * @param width width of the new size
  70183. * @param height height of the new size
  70184. */
  70185. function Size(width, height) {
  70186. this.width = width;
  70187. this.height = height;
  70188. }
  70189. /**
  70190. * Returns a string with the Size width and height
  70191. * @returns a string with the Size width and height
  70192. */
  70193. Size.prototype.toString = function () {
  70194. return "{W: " + this.width + ", H: " + this.height + "}";
  70195. };
  70196. /**
  70197. * "Size"
  70198. * @returns the string "Size"
  70199. */
  70200. Size.prototype.getClassName = function () {
  70201. return "Size";
  70202. };
  70203. /**
  70204. * Returns the Size hash code.
  70205. * @returns a hash code for a unique width and height
  70206. */
  70207. Size.prototype.getHashCode = function () {
  70208. var hash = this.width || 0;
  70209. hash = (hash * 397) ^ (this.height || 0);
  70210. return hash;
  70211. };
  70212. /**
  70213. * Updates the current size from the given one.
  70214. * @param src the given size
  70215. */
  70216. Size.prototype.copyFrom = function (src) {
  70217. this.width = src.width;
  70218. this.height = src.height;
  70219. };
  70220. /**
  70221. * Updates in place the current Size from the given floats.
  70222. * @param width width of the new size
  70223. * @param height height of the new size
  70224. * @returns the updated Size.
  70225. */
  70226. Size.prototype.copyFromFloats = function (width, height) {
  70227. this.width = width;
  70228. this.height = height;
  70229. return this;
  70230. };
  70231. /**
  70232. * Updates in place the current Size from the given floats.
  70233. * @param width width to set
  70234. * @param height height to set
  70235. * @returns the updated Size.
  70236. */
  70237. Size.prototype.set = function (width, height) {
  70238. return this.copyFromFloats(width, height);
  70239. };
  70240. /**
  70241. * Multiplies the width and height by numbers
  70242. * @param w factor to multiple the width by
  70243. * @param h factor to multiple the height by
  70244. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  70245. */
  70246. Size.prototype.multiplyByFloats = function (w, h) {
  70247. return new Size(this.width * w, this.height * h);
  70248. };
  70249. /**
  70250. * Clones the size
  70251. * @returns a new Size copied from the given one.
  70252. */
  70253. Size.prototype.clone = function () {
  70254. return new Size(this.width, this.height);
  70255. };
  70256. /**
  70257. * True if the current Size and the given one width and height are strictly equal.
  70258. * @param other the other size to compare against
  70259. * @returns True if the current Size and the given one width and height are strictly equal.
  70260. */
  70261. Size.prototype.equals = function (other) {
  70262. if (!other) {
  70263. return false;
  70264. }
  70265. return (this.width === other.width) && (this.height === other.height);
  70266. };
  70267. Object.defineProperty(Size.prototype, "surface", {
  70268. /**
  70269. * The surface of the Size : width * height (float).
  70270. */
  70271. get: function () {
  70272. return this.width * this.height;
  70273. },
  70274. enumerable: true,
  70275. configurable: true
  70276. });
  70277. /**
  70278. * Create a new size of zero
  70279. * @returns a new Size set to (0.0, 0.0)
  70280. */
  70281. Size.Zero = function () {
  70282. return new Size(0.0, 0.0);
  70283. };
  70284. /**
  70285. * Sums the width and height of two sizes
  70286. * @param otherSize size to add to this size
  70287. * @returns a new Size set as the addition result of the current Size and the given one.
  70288. */
  70289. Size.prototype.add = function (otherSize) {
  70290. var r = new Size(this.width + otherSize.width, this.height + otherSize.height);
  70291. return r;
  70292. };
  70293. /**
  70294. * Subtracts the width and height of two
  70295. * @param otherSize size to subtract to this size
  70296. * @returns a new Size set as the subtraction result of the given one from the current Size.
  70297. */
  70298. Size.prototype.subtract = function (otherSize) {
  70299. var r = new Size(this.width - otherSize.width, this.height - otherSize.height);
  70300. return r;
  70301. };
  70302. /**
  70303. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  70304. * @param start starting size to lerp between
  70305. * @param end end size to lerp between
  70306. * @param amount amount to lerp between the start and end values
  70307. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  70308. */
  70309. Size.Lerp = function (start, end, amount) {
  70310. var w = start.width + ((end.width - start.width) * amount);
  70311. var h = start.height + ((end.height - start.height) * amount);
  70312. return new Size(w, h);
  70313. };
  70314. return Size;
  70315. }());
  70316. /**
  70317. * Class used to store quaternion data
  70318. * @see https://en.wikipedia.org/wiki/Quaternion
  70319. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  70320. */
  70321. var Quaternion = /** @class */ (function () {
  70322. /**
  70323. * Creates a new Quaternion from the given floats
  70324. * @param x defines the first component (0 by default)
  70325. * @param y defines the second component (0 by default)
  70326. * @param z defines the third component (0 by default)
  70327. * @param w defines the fourth component (1.0 by default)
  70328. */
  70329. function Quaternion(
  70330. /** defines the first component (0 by default) */
  70331. x,
  70332. /** defines the second component (0 by default) */
  70333. y,
  70334. /** defines the third component (0 by default) */
  70335. z,
  70336. /** defines the fourth component (1.0 by default) */
  70337. w) {
  70338. if (x === void 0) { x = 0.0; }
  70339. if (y === void 0) { y = 0.0; }
  70340. if (z === void 0) { z = 0.0; }
  70341. if (w === void 0) { w = 1.0; }
  70342. this.x = x;
  70343. this.y = y;
  70344. this.z = z;
  70345. this.w = w;
  70346. }
  70347. /**
  70348. * Gets a string representation for the current quaternion
  70349. * @returns a string with the Quaternion coordinates
  70350. */
  70351. Quaternion.prototype.toString = function () {
  70352. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  70353. };
  70354. /**
  70355. * Gets the class name of the quaternion
  70356. * @returns the string "Quaternion"
  70357. */
  70358. Quaternion.prototype.getClassName = function () {
  70359. return "Quaternion";
  70360. };
  70361. /**
  70362. * Gets a hash code for this quaternion
  70363. * @returns the quaternion hash code
  70364. */
  70365. Quaternion.prototype.getHashCode = function () {
  70366. var hash = this.x || 0;
  70367. hash = (hash * 397) ^ (this.y || 0);
  70368. hash = (hash * 397) ^ (this.z || 0);
  70369. hash = (hash * 397) ^ (this.w || 0);
  70370. return hash;
  70371. };
  70372. /**
  70373. * Copy the quaternion to an array
  70374. * @returns a new array populated with 4 elements from the quaternion coordinates
  70375. */
  70376. Quaternion.prototype.asArray = function () {
  70377. return [this.x, this.y, this.z, this.w];
  70378. };
  70379. /**
  70380. * Check if two quaternions are equals
  70381. * @param otherQuaternion defines the second operand
  70382. * @return true if the current quaternion and the given one coordinates are strictly equals
  70383. */
  70384. Quaternion.prototype.equals = function (otherQuaternion) {
  70385. return otherQuaternion && this.x === otherQuaternion.x && this.y === otherQuaternion.y && this.z === otherQuaternion.z && this.w === otherQuaternion.w;
  70386. };
  70387. /**
  70388. * Clone the current quaternion
  70389. * @returns a new quaternion copied from the current one
  70390. */
  70391. Quaternion.prototype.clone = function () {
  70392. return new Quaternion(this.x, this.y, this.z, this.w);
  70393. };
  70394. /**
  70395. * Copy a quaternion to the current one
  70396. * @param other defines the other quaternion
  70397. * @returns the updated current quaternion
  70398. */
  70399. Quaternion.prototype.copyFrom = function (other) {
  70400. this.x = other.x;
  70401. this.y = other.y;
  70402. this.z = other.z;
  70403. this.w = other.w;
  70404. return this;
  70405. };
  70406. /**
  70407. * Updates the current quaternion with the given float coordinates
  70408. * @param x defines the x coordinate
  70409. * @param y defines the y coordinate
  70410. * @param z defines the z coordinate
  70411. * @param w defines the w coordinate
  70412. * @returns the updated current quaternion
  70413. */
  70414. Quaternion.prototype.copyFromFloats = function (x, y, z, w) {
  70415. this.x = x;
  70416. this.y = y;
  70417. this.z = z;
  70418. this.w = w;
  70419. return this;
  70420. };
  70421. /**
  70422. * Updates the current quaternion from the given float coordinates
  70423. * @param x defines the x coordinate
  70424. * @param y defines the y coordinate
  70425. * @param z defines the z coordinate
  70426. * @param w defines the w coordinate
  70427. * @returns the updated current quaternion
  70428. */
  70429. Quaternion.prototype.set = function (x, y, z, w) {
  70430. return this.copyFromFloats(x, y, z, w);
  70431. };
  70432. /**
  70433. * Adds two quaternions
  70434. * @param other defines the second operand
  70435. * @returns a new quaternion as the addition result of the given one and the current quaternion
  70436. */
  70437. Quaternion.prototype.add = function (other) {
  70438. return new Quaternion(this.x + other.x, this.y + other.y, this.z + other.z, this.w + other.w);
  70439. };
  70440. /**
  70441. * Add a quaternion to the current one
  70442. * @param other defines the quaternion to add
  70443. * @returns the current quaternion
  70444. */
  70445. Quaternion.prototype.addInPlace = function (other) {
  70446. this.x += other.x;
  70447. this.y += other.y;
  70448. this.z += other.z;
  70449. this.w += other.w;
  70450. return this;
  70451. };
  70452. /**
  70453. * Subtract two quaternions
  70454. * @param other defines the second operand
  70455. * @returns a new quaternion as the subtraction result of the given one from the current one
  70456. */
  70457. Quaternion.prototype.subtract = function (other) {
  70458. return new Quaternion(this.x - other.x, this.y - other.y, this.z - other.z, this.w - other.w);
  70459. };
  70460. /**
  70461. * Multiplies the current quaternion by a scale factor
  70462. * @param value defines the scale factor
  70463. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  70464. */
  70465. Quaternion.prototype.scale = function (value) {
  70466. return new Quaternion(this.x * value, this.y * value, this.z * value, this.w * value);
  70467. };
  70468. /**
  70469. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  70470. * @param scale defines the scale factor
  70471. * @param result defines the Quaternion object where to store the result
  70472. * @returns the unmodified current quaternion
  70473. */
  70474. Quaternion.prototype.scaleToRef = function (scale, result) {
  70475. result.x = this.x * scale;
  70476. result.y = this.y * scale;
  70477. result.z = this.z * scale;
  70478. result.w = this.w * scale;
  70479. return this;
  70480. };
  70481. /**
  70482. * Multiplies in place the current quaternion by a scale factor
  70483. * @param value defines the scale factor
  70484. * @returns the current modified quaternion
  70485. */
  70486. Quaternion.prototype.scaleInPlace = function (value) {
  70487. this.x *= value;
  70488. this.y *= value;
  70489. this.z *= value;
  70490. this.w *= value;
  70491. return this;
  70492. };
  70493. /**
  70494. * Scale the current quaternion values by a factor and add the result to a given quaternion
  70495. * @param scale defines the scale factor
  70496. * @param result defines the Quaternion object where to store the result
  70497. * @returns the unmodified current quaternion
  70498. */
  70499. Quaternion.prototype.scaleAndAddToRef = function (scale, result) {
  70500. result.x += this.x * scale;
  70501. result.y += this.y * scale;
  70502. result.z += this.z * scale;
  70503. result.w += this.w * scale;
  70504. return this;
  70505. };
  70506. /**
  70507. * Multiplies two quaternions
  70508. * @param q1 defines the second operand
  70509. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  70510. */
  70511. Quaternion.prototype.multiply = function (q1) {
  70512. var result = new Quaternion(0, 0, 0, 1.0);
  70513. this.multiplyToRef(q1, result);
  70514. return result;
  70515. };
  70516. /**
  70517. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  70518. * @param q1 defines the second operand
  70519. * @param result defines the target quaternion
  70520. * @returns the current quaternion
  70521. */
  70522. Quaternion.prototype.multiplyToRef = function (q1, result) {
  70523. var x = this.x * q1.w + this.y * q1.z - this.z * q1.y + this.w * q1.x;
  70524. var y = -this.x * q1.z + this.y * q1.w + this.z * q1.x + this.w * q1.y;
  70525. var z = this.x * q1.y - this.y * q1.x + this.z * q1.w + this.w * q1.z;
  70526. var w = -this.x * q1.x - this.y * q1.y - this.z * q1.z + this.w * q1.w;
  70527. result.copyFromFloats(x, y, z, w);
  70528. return this;
  70529. };
  70530. /**
  70531. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  70532. * @param q1 defines the second operand
  70533. * @returns the currentupdated quaternion
  70534. */
  70535. Quaternion.prototype.multiplyInPlace = function (q1) {
  70536. this.multiplyToRef(q1, this);
  70537. return this;
  70538. };
  70539. /**
  70540. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  70541. * @param ref defines the target quaternion
  70542. * @returns the current quaternion
  70543. */
  70544. Quaternion.prototype.conjugateToRef = function (ref) {
  70545. ref.copyFromFloats(-this.x, -this.y, -this.z, this.w);
  70546. return this;
  70547. };
  70548. /**
  70549. * Conjugates in place (1-q) the current quaternion
  70550. * @returns the current updated quaternion
  70551. */
  70552. Quaternion.prototype.conjugateInPlace = function () {
  70553. this.x *= -1;
  70554. this.y *= -1;
  70555. this.z *= -1;
  70556. return this;
  70557. };
  70558. /**
  70559. * Conjugates in place (1-q) the current quaternion
  70560. * @returns a new quaternion
  70561. */
  70562. Quaternion.prototype.conjugate = function () {
  70563. var result = new Quaternion(-this.x, -this.y, -this.z, this.w);
  70564. return result;
  70565. };
  70566. /**
  70567. * Gets length of current quaternion
  70568. * @returns the quaternion length (float)
  70569. */
  70570. Quaternion.prototype.length = function () {
  70571. return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z) + (this.w * this.w));
  70572. };
  70573. /**
  70574. * Normalize in place the current quaternion
  70575. * @returns the current updated quaternion
  70576. */
  70577. Quaternion.prototype.normalize = function () {
  70578. var length = 1.0 / this.length();
  70579. this.x *= length;
  70580. this.y *= length;
  70581. this.z *= length;
  70582. this.w *= length;
  70583. return this;
  70584. };
  70585. /**
  70586. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  70587. * @param order is a reserved parameter and is ignore for now
  70588. * @returns a new Vector3 containing the Euler angles
  70589. */
  70590. Quaternion.prototype.toEulerAngles = function (order) {
  70591. if (order === void 0) { order = "YZX"; }
  70592. var result = Vector3.Zero();
  70593. this.toEulerAnglesToRef(result);
  70594. return result;
  70595. };
  70596. /**
  70597. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  70598. * @param result defines the vector which will be filled with the Euler angles
  70599. * @param order is a reserved parameter and is ignore for now
  70600. * @returns the current unchanged quaternion
  70601. */
  70602. Quaternion.prototype.toEulerAnglesToRef = function (result) {
  70603. var qz = this.z;
  70604. var qx = this.x;
  70605. var qy = this.y;
  70606. var qw = this.w;
  70607. var sqw = qw * qw;
  70608. var sqz = qz * qz;
  70609. var sqx = qx * qx;
  70610. var sqy = qy * qy;
  70611. var zAxisY = qy * qz - qx * qw;
  70612. var limit = .4999999;
  70613. if (zAxisY < -limit) {
  70614. result.y = 2 * Math.atan2(qy, qw);
  70615. result.x = Math.PI / 2;
  70616. result.z = 0;
  70617. }
  70618. else if (zAxisY > limit) {
  70619. result.y = 2 * Math.atan2(qy, qw);
  70620. result.x = -Math.PI / 2;
  70621. result.z = 0;
  70622. }
  70623. else {
  70624. result.z = Math.atan2(2.0 * (qx * qy + qz * qw), (-sqz - sqx + sqy + sqw));
  70625. result.x = Math.asin(-2.0 * (qz * qy - qx * qw));
  70626. result.y = Math.atan2(2.0 * (qz * qx + qy * qw), (sqz - sqx - sqy + sqw));
  70627. }
  70628. return this;
  70629. };
  70630. /**
  70631. * Updates the given rotation matrix with the current quaternion values
  70632. * @param result defines the target matrix
  70633. * @returns the current unchanged quaternion
  70634. */
  70635. Quaternion.prototype.toRotationMatrix = function (result) {
  70636. Matrix.FromQuaternionToRef(this, result);
  70637. return this;
  70638. };
  70639. /**
  70640. * Updates the current quaternion from the given rotation matrix values
  70641. * @param matrix defines the source matrix
  70642. * @returns the current updated quaternion
  70643. */
  70644. Quaternion.prototype.fromRotationMatrix = function (matrix) {
  70645. Quaternion.FromRotationMatrixToRef(matrix, this);
  70646. return this;
  70647. };
  70648. // Statics
  70649. /**
  70650. * Creates a new quaternion from a rotation matrix
  70651. * @param matrix defines the source matrix
  70652. * @returns a new quaternion created from the given rotation matrix values
  70653. */
  70654. Quaternion.FromRotationMatrix = function (matrix) {
  70655. var result = new Quaternion();
  70656. Quaternion.FromRotationMatrixToRef(matrix, result);
  70657. return result;
  70658. };
  70659. /**
  70660. * Updates the given quaternion with the given rotation matrix values
  70661. * @param matrix defines the source matrix
  70662. * @param result defines the target quaternion
  70663. */
  70664. Quaternion.FromRotationMatrixToRef = function (matrix, result) {
  70665. var data = matrix.m;
  70666. var m11 = data[0], m12 = data[4], m13 = data[8];
  70667. var m21 = data[1], m22 = data[5], m23 = data[9];
  70668. var m31 = data[2], m32 = data[6], m33 = data[10];
  70669. var trace = m11 + m22 + m33;
  70670. var s;
  70671. if (trace > 0) {
  70672. s = 0.5 / Math.sqrt(trace + 1.0);
  70673. result.w = 0.25 / s;
  70674. result.x = (m32 - m23) * s;
  70675. result.y = (m13 - m31) * s;
  70676. result.z = (m21 - m12) * s;
  70677. }
  70678. else if (m11 > m22 && m11 > m33) {
  70679. s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
  70680. result.w = (m32 - m23) / s;
  70681. result.x = 0.25 * s;
  70682. result.y = (m12 + m21) / s;
  70683. result.z = (m13 + m31) / s;
  70684. }
  70685. else if (m22 > m33) {
  70686. s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
  70687. result.w = (m13 - m31) / s;
  70688. result.x = (m12 + m21) / s;
  70689. result.y = 0.25 * s;
  70690. result.z = (m23 + m32) / s;
  70691. }
  70692. else {
  70693. s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
  70694. result.w = (m21 - m12) / s;
  70695. result.x = (m13 + m31) / s;
  70696. result.y = (m23 + m32) / s;
  70697. result.z = 0.25 * s;
  70698. }
  70699. };
  70700. /**
  70701. * Returns the dot product (float) between the quaternions "left" and "right"
  70702. * @param left defines the left operand
  70703. * @param right defines the right operand
  70704. * @returns the dot product
  70705. */
  70706. Quaternion.Dot = function (left, right) {
  70707. return (left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w);
  70708. };
  70709. /**
  70710. * Checks if the two quaternions are close to each other
  70711. * @param quat0 defines the first quaternion to check
  70712. * @param quat1 defines the second quaternion to check
  70713. * @returns true if the two quaternions are close to each other
  70714. */
  70715. Quaternion.AreClose = function (quat0, quat1) {
  70716. var dot = Quaternion.Dot(quat0, quat1);
  70717. return dot >= 0;
  70718. };
  70719. /**
  70720. * Creates an empty quaternion
  70721. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  70722. */
  70723. Quaternion.Zero = function () {
  70724. return new Quaternion(0.0, 0.0, 0.0, 0.0);
  70725. };
  70726. /**
  70727. * Inverse a given quaternion
  70728. * @param q defines the source quaternion
  70729. * @returns a new quaternion as the inverted current quaternion
  70730. */
  70731. Quaternion.Inverse = function (q) {
  70732. return new Quaternion(-q.x, -q.y, -q.z, q.w);
  70733. };
  70734. /**
  70735. * Inverse a given quaternion
  70736. * @param q defines the source quaternion
  70737. * @param result the quaternion the result will be stored in
  70738. * @returns the result quaternion
  70739. */
  70740. Quaternion.InverseToRef = function (q, result) {
  70741. result.set(-q.x, -q.y, -q.z, q.w);
  70742. return result;
  70743. };
  70744. /**
  70745. * Creates an identity quaternion
  70746. * @returns the identity quaternion
  70747. */
  70748. Quaternion.Identity = function () {
  70749. return new Quaternion(0.0, 0.0, 0.0, 1.0);
  70750. };
  70751. /**
  70752. * Gets a boolean indicating if the given quaternion is identity
  70753. * @param quaternion defines the quaternion to check
  70754. * @returns true if the quaternion is identity
  70755. */
  70756. Quaternion.IsIdentity = function (quaternion) {
  70757. return quaternion && quaternion.x === 0 && quaternion.y === 0 && quaternion.z === 0 && quaternion.w === 1;
  70758. };
  70759. /**
  70760. * Creates a quaternion from a rotation around an axis
  70761. * @param axis defines the axis to use
  70762. * @param angle defines the angle to use
  70763. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  70764. */
  70765. Quaternion.RotationAxis = function (axis, angle) {
  70766. return Quaternion.RotationAxisToRef(axis, angle, new Quaternion());
  70767. };
  70768. /**
  70769. * Creates a rotation around an axis and stores it into the given quaternion
  70770. * @param axis defines the axis to use
  70771. * @param angle defines the angle to use
  70772. * @param result defines the target quaternion
  70773. * @returns the target quaternion
  70774. */
  70775. Quaternion.RotationAxisToRef = function (axis, angle, result) {
  70776. var sin = Math.sin(angle / 2);
  70777. axis.normalize();
  70778. result.w = Math.cos(angle / 2);
  70779. result.x = axis.x * sin;
  70780. result.y = axis.y * sin;
  70781. result.z = axis.z * sin;
  70782. return result;
  70783. };
  70784. /**
  70785. * Creates a new quaternion from data stored into an array
  70786. * @param array defines the data source
  70787. * @param offset defines the offset in the source array where the data starts
  70788. * @returns a new quaternion
  70789. */
  70790. Quaternion.FromArray = function (array, offset) {
  70791. if (!offset) {
  70792. offset = 0;
  70793. }
  70794. return new Quaternion(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  70795. };
  70796. /**
  70797. * Create a quaternion from Euler rotation angles
  70798. * @param x Pitch
  70799. * @param y Yaw
  70800. * @param z Roll
  70801. * @returns the new Quaternion
  70802. */
  70803. Quaternion.FromEulerAngles = function (x, y, z) {
  70804. var q = new Quaternion();
  70805. Quaternion.RotationYawPitchRollToRef(y, x, z, q);
  70806. return q;
  70807. };
  70808. /**
  70809. * Updates a quaternion from Euler rotation angles
  70810. * @param x Pitch
  70811. * @param y Yaw
  70812. * @param z Roll
  70813. * @param result the quaternion to store the result
  70814. * @returns the updated quaternion
  70815. */
  70816. Quaternion.FromEulerAnglesToRef = function (x, y, z, result) {
  70817. Quaternion.RotationYawPitchRollToRef(y, x, z, result);
  70818. return result;
  70819. };
  70820. /**
  70821. * Create a quaternion from Euler rotation vector
  70822. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  70823. * @returns the new Quaternion
  70824. */
  70825. Quaternion.FromEulerVector = function (vec) {
  70826. var q = new Quaternion();
  70827. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, q);
  70828. return q;
  70829. };
  70830. /**
  70831. * Updates a quaternion from Euler rotation vector
  70832. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  70833. * @param result the quaternion to store the result
  70834. * @returns the updated quaternion
  70835. */
  70836. Quaternion.FromEulerVectorToRef = function (vec, result) {
  70837. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, result);
  70838. return result;
  70839. };
  70840. /**
  70841. * Creates a new quaternion from the given Euler float angles (y, x, z)
  70842. * @param yaw defines the rotation around Y axis
  70843. * @param pitch defines the rotation around X axis
  70844. * @param roll defines the rotation around Z axis
  70845. * @returns the new quaternion
  70846. */
  70847. Quaternion.RotationYawPitchRoll = function (yaw, pitch, roll) {
  70848. var q = new Quaternion();
  70849. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, q);
  70850. return q;
  70851. };
  70852. /**
  70853. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  70854. * @param yaw defines the rotation around Y axis
  70855. * @param pitch defines the rotation around X axis
  70856. * @param roll defines the rotation around Z axis
  70857. * @param result defines the target quaternion
  70858. */
  70859. Quaternion.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  70860. // Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
  70861. var halfRoll = roll * 0.5;
  70862. var halfPitch = pitch * 0.5;
  70863. var halfYaw = yaw * 0.5;
  70864. var sinRoll = Math.sin(halfRoll);
  70865. var cosRoll = Math.cos(halfRoll);
  70866. var sinPitch = Math.sin(halfPitch);
  70867. var cosPitch = Math.cos(halfPitch);
  70868. var sinYaw = Math.sin(halfYaw);
  70869. var cosYaw = Math.cos(halfYaw);
  70870. result.x = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);
  70871. result.y = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);
  70872. result.z = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);
  70873. result.w = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);
  70874. };
  70875. /**
  70876. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  70877. * @param alpha defines the rotation around first axis
  70878. * @param beta defines the rotation around second axis
  70879. * @param gamma defines the rotation around third axis
  70880. * @returns the new quaternion
  70881. */
  70882. Quaternion.RotationAlphaBetaGamma = function (alpha, beta, gamma) {
  70883. var result = new Quaternion();
  70884. Quaternion.RotationAlphaBetaGammaToRef(alpha, beta, gamma, result);
  70885. return result;
  70886. };
  70887. /**
  70888. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  70889. * @param alpha defines the rotation around first axis
  70890. * @param beta defines the rotation around second axis
  70891. * @param gamma defines the rotation around third axis
  70892. * @param result defines the target quaternion
  70893. */
  70894. Quaternion.RotationAlphaBetaGammaToRef = function (alpha, beta, gamma, result) {
  70895. // Produces a quaternion from Euler angles in the z-x-z orientation
  70896. var halfGammaPlusAlpha = (gamma + alpha) * 0.5;
  70897. var halfGammaMinusAlpha = (gamma - alpha) * 0.5;
  70898. var halfBeta = beta * 0.5;
  70899. result.x = Math.cos(halfGammaMinusAlpha) * Math.sin(halfBeta);
  70900. result.y = Math.sin(halfGammaMinusAlpha) * Math.sin(halfBeta);
  70901. result.z = Math.sin(halfGammaPlusAlpha) * Math.cos(halfBeta);
  70902. result.w = Math.cos(halfGammaPlusAlpha) * Math.cos(halfBeta);
  70903. };
  70904. /**
  70905. * 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)
  70906. * @param axis1 defines the first axis
  70907. * @param axis2 defines the second axis
  70908. * @param axis3 defines the third axis
  70909. * @returns the new quaternion
  70910. */
  70911. Quaternion.RotationQuaternionFromAxis = function (axis1, axis2, axis3) {
  70912. var quat = new Quaternion(0.0, 0.0, 0.0, 0.0);
  70913. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  70914. return quat;
  70915. };
  70916. /**
  70917. * 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
  70918. * @param axis1 defines the first axis
  70919. * @param axis2 defines the second axis
  70920. * @param axis3 defines the third axis
  70921. * @param ref defines the target quaternion
  70922. */
  70923. Quaternion.RotationQuaternionFromAxisToRef = function (axis1, axis2, axis3, ref) {
  70924. var rotMat = MathTmp.Matrix[0];
  70925. Matrix.FromXYZAxesToRef(axis1.normalize(), axis2.normalize(), axis3.normalize(), rotMat);
  70926. Quaternion.FromRotationMatrixToRef(rotMat, ref);
  70927. };
  70928. /**
  70929. * Interpolates between two quaternions
  70930. * @param left defines first quaternion
  70931. * @param right defines second quaternion
  70932. * @param amount defines the gradient to use
  70933. * @returns the new interpolated quaternion
  70934. */
  70935. Quaternion.Slerp = function (left, right, amount) {
  70936. var result = Quaternion.Identity();
  70937. Quaternion.SlerpToRef(left, right, amount, result);
  70938. return result;
  70939. };
  70940. /**
  70941. * Interpolates between two quaternions and stores it into a target quaternion
  70942. * @param left defines first quaternion
  70943. * @param right defines second quaternion
  70944. * @param amount defines the gradient to use
  70945. * @param result defines the target quaternion
  70946. */
  70947. Quaternion.SlerpToRef = function (left, right, amount, result) {
  70948. var num2;
  70949. var num3;
  70950. var num4 = (((left.x * right.x) + (left.y * right.y)) + (left.z * right.z)) + (left.w * right.w);
  70951. var flag = false;
  70952. if (num4 < 0) {
  70953. flag = true;
  70954. num4 = -num4;
  70955. }
  70956. if (num4 > 0.999999) {
  70957. num3 = 1 - amount;
  70958. num2 = flag ? -amount : amount;
  70959. }
  70960. else {
  70961. var num5 = Math.acos(num4);
  70962. var num6 = (1.0 / Math.sin(num5));
  70963. num3 = (Math.sin((1.0 - amount) * num5)) * num6;
  70964. num2 = flag ? ((-Math.sin(amount * num5)) * num6) : ((Math.sin(amount * num5)) * num6);
  70965. }
  70966. result.x = (num3 * left.x) + (num2 * right.x);
  70967. result.y = (num3 * left.y) + (num2 * right.y);
  70968. result.z = (num3 * left.z) + (num2 * right.z);
  70969. result.w = (num3 * left.w) + (num2 * right.w);
  70970. };
  70971. /**
  70972. * Interpolate between two quaternions using Hermite interpolation
  70973. * @param value1 defines first quaternion
  70974. * @param tangent1 defines the incoming tangent
  70975. * @param value2 defines second quaternion
  70976. * @param tangent2 defines the outgoing tangent
  70977. * @param amount defines the target quaternion
  70978. * @returns the new interpolated quaternion
  70979. */
  70980. Quaternion.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  70981. var squared = amount * amount;
  70982. var cubed = amount * squared;
  70983. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  70984. var part2 = (-2.0 * cubed) + (3.0 * squared);
  70985. var part3 = (cubed - (2.0 * squared)) + amount;
  70986. var part4 = cubed - squared;
  70987. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  70988. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  70989. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  70990. var w = (((value1.w * part1) + (value2.w * part2)) + (tangent1.w * part3)) + (tangent2.w * part4);
  70991. return new Quaternion(x, y, z, w);
  70992. };
  70993. return Quaternion;
  70994. }());
  70995. /**
  70996. * Class used to store matrix data (4x4)
  70997. */
  70998. var Matrix = /** @class */ (function () {
  70999. /**
  71000. * Creates an empty matrix (filled with zeros)
  71001. */
  71002. function Matrix() {
  71003. this._isIdentity = false;
  71004. this._isIdentityDirty = true;
  71005. this._isIdentity3x2 = true;
  71006. this._isIdentity3x2Dirty = true;
  71007. this._m = new Float32Array(16);
  71008. this._updateIdentityStatus(false);
  71009. }
  71010. Object.defineProperty(Matrix.prototype, "m", {
  71011. /**
  71012. * Gets the internal data of the matrix
  71013. */
  71014. get: function () { return this._m; },
  71015. enumerable: true,
  71016. configurable: true
  71017. });
  71018. /** @hidden */
  71019. Matrix.prototype._markAsUpdated = function () {
  71020. this.updateFlag = Matrix._updateFlagSeed++;
  71021. this._isIdentity = false;
  71022. this._isIdentity3x2 = false;
  71023. this._isIdentityDirty = true;
  71024. this._isIdentity3x2Dirty = true;
  71025. };
  71026. /** @hidden */
  71027. Matrix.prototype._updateIdentityStatus = function (isIdentity, isIdentityDirty, isIdentity3x2, isIdentity3x2Dirty) {
  71028. if (isIdentityDirty === void 0) { isIdentityDirty = false; }
  71029. if (isIdentity3x2 === void 0) { isIdentity3x2 = false; }
  71030. if (isIdentity3x2Dirty === void 0) { isIdentity3x2Dirty = true; }
  71031. this.updateFlag = Matrix._updateFlagSeed++;
  71032. this._isIdentity = isIdentity;
  71033. this._isIdentity3x2 = isIdentity || isIdentity3x2;
  71034. this._isIdentityDirty = this._isIdentity ? false : isIdentityDirty;
  71035. this._isIdentity3x2Dirty = this._isIdentity3x2 ? false : isIdentity3x2Dirty;
  71036. };
  71037. // Properties
  71038. /**
  71039. * Check if the current matrix is identity
  71040. * @returns true is the matrix is the identity matrix
  71041. */
  71042. Matrix.prototype.isIdentity = function () {
  71043. if (this._isIdentityDirty) {
  71044. this._isIdentityDirty = false;
  71045. var m = this._m;
  71046. this._isIdentity = (m[0] === 1.0 && m[1] === 0.0 && m[2] === 0.0 && m[3] === 0.0 &&
  71047. m[4] === 0.0 && m[5] === 1.0 && m[6] === 0.0 && m[7] === 0.0 &&
  71048. m[8] === 0.0 && m[9] === 0.0 && m[10] === 1.0 && m[11] === 0.0 &&
  71049. m[12] === 0.0 && m[13] === 0.0 && m[14] === 0.0 && m[15] === 1.0);
  71050. }
  71051. return this._isIdentity;
  71052. };
  71053. /**
  71054. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71055. * @returns true is the matrix is the identity matrix
  71056. */
  71057. Matrix.prototype.isIdentityAs3x2 = function () {
  71058. if (this._isIdentity3x2Dirty) {
  71059. this._isIdentity3x2Dirty = false;
  71060. if (this._m[0] !== 1.0 || this._m[5] !== 1.0 || this._m[15] !== 1.0) {
  71061. this._isIdentity3x2 = false;
  71062. }
  71063. else if (this._m[1] !== 0.0 || this._m[2] !== 0.0 || this._m[3] !== 0.0 ||
  71064. this._m[4] !== 0.0 || this._m[6] !== 0.0 || this._m[7] !== 0.0 ||
  71065. this._m[8] !== 0.0 || this._m[9] !== 0.0 || this._m[10] !== 0.0 || this._m[11] !== 0.0 ||
  71066. this._m[12] !== 0.0 || this._m[13] !== 0.0 || this._m[14] !== 0.0) {
  71067. this._isIdentity3x2 = false;
  71068. }
  71069. else {
  71070. this._isIdentity3x2 = true;
  71071. }
  71072. }
  71073. return this._isIdentity3x2;
  71074. };
  71075. /**
  71076. * Gets the determinant of the matrix
  71077. * @returns the matrix determinant
  71078. */
  71079. Matrix.prototype.determinant = function () {
  71080. if (this._isIdentity === true) {
  71081. return 1;
  71082. }
  71083. var m = this._m;
  71084. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  71085. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  71086. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  71087. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  71088. // https://en.wikipedia.org/wiki/Laplace_expansion
  71089. // to compute the deterrminant of a 4x4 Matrix we compute the cofactors of any row or column,
  71090. // then we multiply each Cofactor by its corresponding matrix value and sum them all to get the determinant
  71091. // Cofactor(i, j) = sign(i,j) * det(Minor(i, j))
  71092. // where
  71093. // - sign(i,j) = (i+j) % 2 === 0 ? 1 : -1
  71094. // - Minor(i, j) is the 3x3 matrix we get by removing row i and column j from current Matrix
  71095. //
  71096. // Here we do that for the 1st row.
  71097. var det_22_33 = m22 * m33 - m32 * m23;
  71098. var det_21_33 = m21 * m33 - m31 * m23;
  71099. var det_21_32 = m21 * m32 - m31 * m22;
  71100. var det_20_33 = m20 * m33 - m30 * m23;
  71101. var det_20_32 = m20 * m32 - m22 * m30;
  71102. var det_20_31 = m20 * m31 - m30 * m21;
  71103. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  71104. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  71105. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  71106. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  71107. return m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  71108. };
  71109. // Methods
  71110. /**
  71111. * Returns the matrix as a Float32Array
  71112. * @returns the matrix underlying array
  71113. */
  71114. Matrix.prototype.toArray = function () {
  71115. return this._m;
  71116. };
  71117. /**
  71118. * Returns the matrix as a Float32Array
  71119. * @returns the matrix underlying array.
  71120. */
  71121. Matrix.prototype.asArray = function () {
  71122. return this._m;
  71123. };
  71124. /**
  71125. * Inverts the current matrix in place
  71126. * @returns the current inverted matrix
  71127. */
  71128. Matrix.prototype.invert = function () {
  71129. this.invertToRef(this);
  71130. return this;
  71131. };
  71132. /**
  71133. * Sets all the matrix elements to zero
  71134. * @returns the current matrix
  71135. */
  71136. Matrix.prototype.reset = function () {
  71137. 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);
  71138. this._updateIdentityStatus(false);
  71139. return this;
  71140. };
  71141. /**
  71142. * Adds the current matrix with a second one
  71143. * @param other defines the matrix to add
  71144. * @returns a new matrix as the addition of the current matrix and the given one
  71145. */
  71146. Matrix.prototype.add = function (other) {
  71147. var result = new Matrix();
  71148. this.addToRef(other, result);
  71149. return result;
  71150. };
  71151. /**
  71152. * Sets the given matrix "result" to the addition of the current matrix and the given one
  71153. * @param other defines the matrix to add
  71154. * @param result defines the target matrix
  71155. * @returns the current matrix
  71156. */
  71157. Matrix.prototype.addToRef = function (other, result) {
  71158. var m = this._m;
  71159. var resultM = result._m;
  71160. var otherM = other.m;
  71161. for (var index = 0; index < 16; index++) {
  71162. resultM[index] = m[index] + otherM[index];
  71163. }
  71164. result._markAsUpdated();
  71165. return this;
  71166. };
  71167. /**
  71168. * Adds in place the given matrix to the current matrix
  71169. * @param other defines the second operand
  71170. * @returns the current updated matrix
  71171. */
  71172. Matrix.prototype.addToSelf = function (other) {
  71173. var m = this._m;
  71174. var otherM = other.m;
  71175. for (var index = 0; index < 16; index++) {
  71176. m[index] += otherM[index];
  71177. }
  71178. this._markAsUpdated();
  71179. return this;
  71180. };
  71181. /**
  71182. * Sets the given matrix to the current inverted Matrix
  71183. * @param other defines the target matrix
  71184. * @returns the unmodified current matrix
  71185. */
  71186. Matrix.prototype.invertToRef = function (other) {
  71187. if (this._isIdentity === true) {
  71188. Matrix.IdentityToRef(other);
  71189. return this;
  71190. }
  71191. // the inverse of a Matrix is the transpose of cofactor matrix divided by the determinant
  71192. var m = this._m;
  71193. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  71194. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  71195. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  71196. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  71197. var det_22_33 = m22 * m33 - m32 * m23;
  71198. var det_21_33 = m21 * m33 - m31 * m23;
  71199. var det_21_32 = m21 * m32 - m31 * m22;
  71200. var det_20_33 = m20 * m33 - m30 * m23;
  71201. var det_20_32 = m20 * m32 - m22 * m30;
  71202. var det_20_31 = m20 * m31 - m30 * m21;
  71203. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  71204. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  71205. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  71206. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  71207. var det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  71208. if (det === 0) {
  71209. // not invertible
  71210. other.copyFrom(this);
  71211. return this;
  71212. }
  71213. var detInv = 1 / det;
  71214. var det_12_33 = m12 * m33 - m32 * m13;
  71215. var det_11_33 = m11 * m33 - m31 * m13;
  71216. var det_11_32 = m11 * m32 - m31 * m12;
  71217. var det_10_33 = m10 * m33 - m30 * m13;
  71218. var det_10_32 = m10 * m32 - m30 * m12;
  71219. var det_10_31 = m10 * m31 - m30 * m11;
  71220. var det_12_23 = m12 * m23 - m22 * m13;
  71221. var det_11_23 = m11 * m23 - m21 * m13;
  71222. var det_11_22 = m11 * m22 - m21 * m12;
  71223. var det_10_23 = m10 * m23 - m20 * m13;
  71224. var det_10_22 = m10 * m22 - m20 * m12;
  71225. var det_10_21 = m10 * m21 - m20 * m11;
  71226. var cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);
  71227. var cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);
  71228. var cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);
  71229. var cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);
  71230. var cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);
  71231. var cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);
  71232. var cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);
  71233. var cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);
  71234. var cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);
  71235. var cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);
  71236. var cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);
  71237. var cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);
  71238. 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);
  71239. return this;
  71240. };
  71241. /**
  71242. * add a value at the specified position in the current Matrix
  71243. * @param index the index of the value within the matrix. between 0 and 15.
  71244. * @param value the value to be added
  71245. * @returns the current updated matrix
  71246. */
  71247. Matrix.prototype.addAtIndex = function (index, value) {
  71248. this._m[index] += value;
  71249. this._markAsUpdated();
  71250. return this;
  71251. };
  71252. /**
  71253. * mutiply the specified position in the current Matrix by a value
  71254. * @param index the index of the value within the matrix. between 0 and 15.
  71255. * @param value the value to be added
  71256. * @returns the current updated matrix
  71257. */
  71258. Matrix.prototype.multiplyAtIndex = function (index, value) {
  71259. this._m[index] *= value;
  71260. this._markAsUpdated();
  71261. return this;
  71262. };
  71263. /**
  71264. * Inserts the translation vector (using 3 floats) in the current matrix
  71265. * @param x defines the 1st component of the translation
  71266. * @param y defines the 2nd component of the translation
  71267. * @param z defines the 3rd component of the translation
  71268. * @returns the current updated matrix
  71269. */
  71270. Matrix.prototype.setTranslationFromFloats = function (x, y, z) {
  71271. this._m[12] = x;
  71272. this._m[13] = y;
  71273. this._m[14] = z;
  71274. this._markAsUpdated();
  71275. return this;
  71276. };
  71277. /**
  71278. * Inserts the translation vector in the current matrix
  71279. * @param vector3 defines the translation to insert
  71280. * @returns the current updated matrix
  71281. */
  71282. Matrix.prototype.setTranslation = function (vector3) {
  71283. return this.setTranslationFromFloats(vector3.x, vector3.y, vector3.z);
  71284. };
  71285. /**
  71286. * Gets the translation value of the current matrix
  71287. * @returns a new Vector3 as the extracted translation from the matrix
  71288. */
  71289. Matrix.prototype.getTranslation = function () {
  71290. return new Vector3(this._m[12], this._m[13], this._m[14]);
  71291. };
  71292. /**
  71293. * Fill a Vector3 with the extracted translation from the matrix
  71294. * @param result defines the Vector3 where to store the translation
  71295. * @returns the current matrix
  71296. */
  71297. Matrix.prototype.getTranslationToRef = function (result) {
  71298. result.x = this._m[12];
  71299. result.y = this._m[13];
  71300. result.z = this._m[14];
  71301. return this;
  71302. };
  71303. /**
  71304. * Remove rotation and scaling part from the matrix
  71305. * @returns the updated matrix
  71306. */
  71307. Matrix.prototype.removeRotationAndScaling = function () {
  71308. var m = this.m;
  71309. 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);
  71310. this._updateIdentityStatus(m[12] === 0 && m[13] === 0 && m[14] === 0 && m[15] === 1);
  71311. return this;
  71312. };
  71313. /**
  71314. * Multiply two matrices
  71315. * @param other defines the second operand
  71316. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  71317. */
  71318. Matrix.prototype.multiply = function (other) {
  71319. var result = new Matrix();
  71320. this.multiplyToRef(other, result);
  71321. return result;
  71322. };
  71323. /**
  71324. * Copy the current matrix from the given one
  71325. * @param other defines the source matrix
  71326. * @returns the current updated matrix
  71327. */
  71328. Matrix.prototype.copyFrom = function (other) {
  71329. other.copyToArray(this._m);
  71330. var o = other;
  71331. this._updateIdentityStatus(o._isIdentity, o._isIdentityDirty, o._isIdentity3x2, o._isIdentity3x2Dirty);
  71332. return this;
  71333. };
  71334. /**
  71335. * Populates the given array from the starting index with the current matrix values
  71336. * @param array defines the target array
  71337. * @param offset defines the offset in the target array where to start storing values
  71338. * @returns the current matrix
  71339. */
  71340. Matrix.prototype.copyToArray = function (array, offset) {
  71341. if (offset === void 0) { offset = 0; }
  71342. for (var index = 0; index < 16; index++) {
  71343. array[offset + index] = this._m[index];
  71344. }
  71345. return this;
  71346. };
  71347. /**
  71348. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  71349. * @param other defines the second operand
  71350. * @param result defines the matrix where to store the multiplication
  71351. * @returns the current matrix
  71352. */
  71353. Matrix.prototype.multiplyToRef = function (other, result) {
  71354. if (this._isIdentity) {
  71355. result.copyFrom(other);
  71356. return this;
  71357. }
  71358. if (other._isIdentity) {
  71359. result.copyFrom(this);
  71360. return this;
  71361. }
  71362. this.multiplyToArray(other, result._m, 0);
  71363. result._markAsUpdated();
  71364. return this;
  71365. };
  71366. /**
  71367. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  71368. * @param other defines the second operand
  71369. * @param result defines the array where to store the multiplication
  71370. * @param offset defines the offset in the target array where to start storing values
  71371. * @returns the current matrix
  71372. */
  71373. Matrix.prototype.multiplyToArray = function (other, result, offset) {
  71374. var m = this._m;
  71375. var otherM = other.m;
  71376. var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
  71377. var tm4 = m[4], tm5 = m[5], tm6 = m[6], tm7 = m[7];
  71378. var tm8 = m[8], tm9 = m[9], tm10 = m[10], tm11 = m[11];
  71379. var tm12 = m[12], tm13 = m[13], tm14 = m[14], tm15 = m[15];
  71380. var om0 = otherM[0], om1 = otherM[1], om2 = otherM[2], om3 = otherM[3];
  71381. var om4 = otherM[4], om5 = otherM[5], om6 = otherM[6], om7 = otherM[7];
  71382. var om8 = otherM[8], om9 = otherM[9], om10 = otherM[10], om11 = otherM[11];
  71383. var om12 = otherM[12], om13 = otherM[13], om14 = otherM[14], om15 = otherM[15];
  71384. result[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;
  71385. result[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;
  71386. result[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;
  71387. result[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;
  71388. result[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;
  71389. result[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;
  71390. result[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;
  71391. result[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;
  71392. result[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;
  71393. result[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;
  71394. result[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;
  71395. result[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;
  71396. result[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;
  71397. result[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;
  71398. result[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;
  71399. result[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;
  71400. return this;
  71401. };
  71402. /**
  71403. * Check equality between this matrix and a second one
  71404. * @param value defines the second matrix to compare
  71405. * @returns true is the current matrix and the given one values are strictly equal
  71406. */
  71407. Matrix.prototype.equals = function (value) {
  71408. var other = value;
  71409. if (!other) {
  71410. return false;
  71411. }
  71412. if (this._isIdentity || other._isIdentity) {
  71413. if (!this._isIdentityDirty && !other._isIdentityDirty) {
  71414. return this._isIdentity && other._isIdentity;
  71415. }
  71416. }
  71417. var m = this.m;
  71418. var om = other.m;
  71419. return (m[0] === om[0] && m[1] === om[1] && m[2] === om[2] && m[3] === om[3] &&
  71420. m[4] === om[4] && m[5] === om[5] && m[6] === om[6] && m[7] === om[7] &&
  71421. m[8] === om[8] && m[9] === om[9] && m[10] === om[10] && m[11] === om[11] &&
  71422. m[12] === om[12] && m[13] === om[13] && m[14] === om[14] && m[15] === om[15]);
  71423. };
  71424. /**
  71425. * Clone the current matrix
  71426. * @returns a new matrix from the current matrix
  71427. */
  71428. Matrix.prototype.clone = function () {
  71429. var matrix = new Matrix();
  71430. matrix.copyFrom(this);
  71431. return matrix;
  71432. };
  71433. /**
  71434. * Returns the name of the current matrix class
  71435. * @returns the string "Matrix"
  71436. */
  71437. Matrix.prototype.getClassName = function () {
  71438. return "Matrix";
  71439. };
  71440. /**
  71441. * Gets the hash code of the current matrix
  71442. * @returns the hash code
  71443. */
  71444. Matrix.prototype.getHashCode = function () {
  71445. var hash = this._m[0] || 0;
  71446. for (var i = 1; i < 16; i++) {
  71447. hash = (hash * 397) ^ (this._m[i] || 0);
  71448. }
  71449. return hash;
  71450. };
  71451. /**
  71452. * Decomposes the current Matrix into a translation, rotation and scaling components
  71453. * @param scale defines the scale vector3 given as a reference to update
  71454. * @param rotation defines the rotation quaternion given as a reference to update
  71455. * @param translation defines the translation vector3 given as a reference to update
  71456. * @returns true if operation was successful
  71457. */
  71458. Matrix.prototype.decompose = function (scale, rotation, translation) {
  71459. if (this._isIdentity) {
  71460. if (translation) {
  71461. translation.setAll(0);
  71462. }
  71463. if (scale) {
  71464. scale.setAll(1);
  71465. }
  71466. if (rotation) {
  71467. rotation.copyFromFloats(0, 0, 0, 1);
  71468. }
  71469. return true;
  71470. }
  71471. var m = this._m;
  71472. if (translation) {
  71473. translation.copyFromFloats(m[12], m[13], m[14]);
  71474. }
  71475. scale = scale || MathTmp.Vector3[0];
  71476. scale.x = Math.sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
  71477. scale.y = Math.sqrt(m[4] * m[4] + m[5] * m[5] + m[6] * m[6]);
  71478. scale.z = Math.sqrt(m[8] * m[8] + m[9] * m[9] + m[10] * m[10]);
  71479. if (this.determinant() <= 0) {
  71480. scale.y *= -1;
  71481. }
  71482. if (scale.x === 0 || scale.y === 0 || scale.z === 0) {
  71483. if (rotation) {
  71484. rotation.copyFromFloats(0.0, 0.0, 0.0, 1.0);
  71485. }
  71486. return false;
  71487. }
  71488. if (rotation) {
  71489. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  71490. 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]);
  71491. Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], rotation);
  71492. }
  71493. return true;
  71494. };
  71495. /**
  71496. * Gets specific row of the matrix
  71497. * @param index defines the number of the row to get
  71498. * @returns the index-th row of the current matrix as a new Vector4
  71499. */
  71500. Matrix.prototype.getRow = function (index) {
  71501. if (index < 0 || index > 3) {
  71502. return null;
  71503. }
  71504. var i = index * 4;
  71505. return new Vector4(this._m[i + 0], this._m[i + 1], this._m[i + 2], this._m[i + 3]);
  71506. };
  71507. /**
  71508. * Sets the index-th row of the current matrix to the vector4 values
  71509. * @param index defines the number of the row to set
  71510. * @param row defines the target vector4
  71511. * @returns the updated current matrix
  71512. */
  71513. Matrix.prototype.setRow = function (index, row) {
  71514. return this.setRowFromFloats(index, row.x, row.y, row.z, row.w);
  71515. };
  71516. /**
  71517. * Compute the transpose of the matrix
  71518. * @returns the new transposed matrix
  71519. */
  71520. Matrix.prototype.transpose = function () {
  71521. return Matrix.Transpose(this);
  71522. };
  71523. /**
  71524. * Compute the transpose of the matrix and store it in a given matrix
  71525. * @param result defines the target matrix
  71526. * @returns the current matrix
  71527. */
  71528. Matrix.prototype.transposeToRef = function (result) {
  71529. Matrix.TransposeToRef(this, result);
  71530. return this;
  71531. };
  71532. /**
  71533. * Sets the index-th row of the current matrix with the given 4 x float values
  71534. * @param index defines the row index
  71535. * @param x defines the x component to set
  71536. * @param y defines the y component to set
  71537. * @param z defines the z component to set
  71538. * @param w defines the w component to set
  71539. * @returns the updated current matrix
  71540. */
  71541. Matrix.prototype.setRowFromFloats = function (index, x, y, z, w) {
  71542. if (index < 0 || index > 3) {
  71543. return this;
  71544. }
  71545. var i = index * 4;
  71546. this._m[i + 0] = x;
  71547. this._m[i + 1] = y;
  71548. this._m[i + 2] = z;
  71549. this._m[i + 3] = w;
  71550. this._markAsUpdated();
  71551. return this;
  71552. };
  71553. /**
  71554. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  71555. * @param scale defines the scale factor
  71556. * @returns a new matrix
  71557. */
  71558. Matrix.prototype.scale = function (scale) {
  71559. var result = new Matrix();
  71560. this.scaleToRef(scale, result);
  71561. return result;
  71562. };
  71563. /**
  71564. * Scale the current matrix values by a factor to a given result matrix
  71565. * @param scale defines the scale factor
  71566. * @param result defines the matrix to store the result
  71567. * @returns the current matrix
  71568. */
  71569. Matrix.prototype.scaleToRef = function (scale, result) {
  71570. for (var index = 0; index < 16; index++) {
  71571. result._m[index] = this._m[index] * scale;
  71572. }
  71573. result._markAsUpdated();
  71574. return this;
  71575. };
  71576. /**
  71577. * Scale the current matrix values by a factor and add the result to a given matrix
  71578. * @param scale defines the scale factor
  71579. * @param result defines the Matrix to store the result
  71580. * @returns the current matrix
  71581. */
  71582. Matrix.prototype.scaleAndAddToRef = function (scale, result) {
  71583. for (var index = 0; index < 16; index++) {
  71584. result._m[index] += this._m[index] * scale;
  71585. }
  71586. result._markAsUpdated();
  71587. return this;
  71588. };
  71589. /**
  71590. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  71591. * @param ref matrix to store the result
  71592. */
  71593. Matrix.prototype.toNormalMatrix = function (ref) {
  71594. var tmp = MathTmp.Matrix[0];
  71595. this.invertToRef(tmp);
  71596. tmp.transposeToRef(ref);
  71597. var m = ref._m;
  71598. 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);
  71599. };
  71600. /**
  71601. * Gets only rotation part of the current matrix
  71602. * @returns a new matrix sets to the extracted rotation matrix from the current one
  71603. */
  71604. Matrix.prototype.getRotationMatrix = function () {
  71605. var result = new Matrix();
  71606. this.getRotationMatrixToRef(result);
  71607. return result;
  71608. };
  71609. /**
  71610. * Extracts the rotation matrix from the current one and sets it as the given "result"
  71611. * @param result defines the target matrix to store data to
  71612. * @returns the current matrix
  71613. */
  71614. Matrix.prototype.getRotationMatrixToRef = function (result) {
  71615. var scale = MathTmp.Vector3[0];
  71616. if (!this.decompose(scale)) {
  71617. Matrix.IdentityToRef(result);
  71618. return this;
  71619. }
  71620. var m = this._m;
  71621. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  71622. 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);
  71623. return this;
  71624. };
  71625. /**
  71626. * Toggles model matrix from being right handed to left handed in place and vice versa
  71627. */
  71628. Matrix.prototype.toggleModelMatrixHandInPlace = function () {
  71629. var m = this._m;
  71630. m[2] *= -1;
  71631. m[6] *= -1;
  71632. m[8] *= -1;
  71633. m[9] *= -1;
  71634. m[14] *= -1;
  71635. this._markAsUpdated();
  71636. };
  71637. /**
  71638. * Toggles projection matrix from being right handed to left handed in place and vice versa
  71639. */
  71640. Matrix.prototype.toggleProjectionMatrixHandInPlace = function () {
  71641. var m = this._m;
  71642. m[8] *= -1;
  71643. m[9] *= -1;
  71644. m[10] *= -1;
  71645. m[11] *= -1;
  71646. this._markAsUpdated();
  71647. };
  71648. // Statics
  71649. /**
  71650. * Creates a matrix from an array
  71651. * @param array defines the source array
  71652. * @param offset defines an offset in the source array
  71653. * @returns a new Matrix set from the starting index of the given array
  71654. */
  71655. Matrix.FromArray = function (array, offset) {
  71656. if (offset === void 0) { offset = 0; }
  71657. var result = new Matrix();
  71658. Matrix.FromArrayToRef(array, offset, result);
  71659. return result;
  71660. };
  71661. /**
  71662. * Copy the content of an array into a given matrix
  71663. * @param array defines the source array
  71664. * @param offset defines an offset in the source array
  71665. * @param result defines the target matrix
  71666. */
  71667. Matrix.FromArrayToRef = function (array, offset, result) {
  71668. for (var index = 0; index < 16; index++) {
  71669. result._m[index] = array[index + offset];
  71670. }
  71671. result._markAsUpdated();
  71672. };
  71673. /**
  71674. * Stores an array into a matrix after having multiplied each component by a given factor
  71675. * @param array defines the source array
  71676. * @param offset defines the offset in the source array
  71677. * @param scale defines the scaling factor
  71678. * @param result defines the target matrix
  71679. */
  71680. Matrix.FromFloat32ArrayToRefScaled = function (array, offset, scale, result) {
  71681. for (var index = 0; index < 16; index++) {
  71682. result._m[index] = array[index + offset] * scale;
  71683. }
  71684. result._markAsUpdated();
  71685. };
  71686. Object.defineProperty(Matrix, "IdentityReadOnly", {
  71687. /**
  71688. * Gets an identity matrix that must not be updated
  71689. */
  71690. get: function () {
  71691. return Matrix._identityReadOnly;
  71692. },
  71693. enumerable: true,
  71694. configurable: true
  71695. });
  71696. /**
  71697. * Stores a list of values (16) inside a given matrix
  71698. * @param initialM11 defines 1st value of 1st row
  71699. * @param initialM12 defines 2nd value of 1st row
  71700. * @param initialM13 defines 3rd value of 1st row
  71701. * @param initialM14 defines 4th value of 1st row
  71702. * @param initialM21 defines 1st value of 2nd row
  71703. * @param initialM22 defines 2nd value of 2nd row
  71704. * @param initialM23 defines 3rd value of 2nd row
  71705. * @param initialM24 defines 4th value of 2nd row
  71706. * @param initialM31 defines 1st value of 3rd row
  71707. * @param initialM32 defines 2nd value of 3rd row
  71708. * @param initialM33 defines 3rd value of 3rd row
  71709. * @param initialM34 defines 4th value of 3rd row
  71710. * @param initialM41 defines 1st value of 4th row
  71711. * @param initialM42 defines 2nd value of 4th row
  71712. * @param initialM43 defines 3rd value of 4th row
  71713. * @param initialM44 defines 4th value of 4th row
  71714. * @param result defines the target matrix
  71715. */
  71716. Matrix.FromValuesToRef = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44, result) {
  71717. var m = result._m;
  71718. m[0] = initialM11;
  71719. m[1] = initialM12;
  71720. m[2] = initialM13;
  71721. m[3] = initialM14;
  71722. m[4] = initialM21;
  71723. m[5] = initialM22;
  71724. m[6] = initialM23;
  71725. m[7] = initialM24;
  71726. m[8] = initialM31;
  71727. m[9] = initialM32;
  71728. m[10] = initialM33;
  71729. m[11] = initialM34;
  71730. m[12] = initialM41;
  71731. m[13] = initialM42;
  71732. m[14] = initialM43;
  71733. m[15] = initialM44;
  71734. result._markAsUpdated();
  71735. };
  71736. /**
  71737. * Creates new matrix from a list of values (16)
  71738. * @param initialM11 defines 1st value of 1st row
  71739. * @param initialM12 defines 2nd value of 1st row
  71740. * @param initialM13 defines 3rd value of 1st row
  71741. * @param initialM14 defines 4th value of 1st row
  71742. * @param initialM21 defines 1st value of 2nd row
  71743. * @param initialM22 defines 2nd value of 2nd row
  71744. * @param initialM23 defines 3rd value of 2nd row
  71745. * @param initialM24 defines 4th value of 2nd row
  71746. * @param initialM31 defines 1st value of 3rd row
  71747. * @param initialM32 defines 2nd value of 3rd row
  71748. * @param initialM33 defines 3rd value of 3rd row
  71749. * @param initialM34 defines 4th value of 3rd row
  71750. * @param initialM41 defines 1st value of 4th row
  71751. * @param initialM42 defines 2nd value of 4th row
  71752. * @param initialM43 defines 3rd value of 4th row
  71753. * @param initialM44 defines 4th value of 4th row
  71754. * @returns the new matrix
  71755. */
  71756. Matrix.FromValues = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44) {
  71757. var result = new Matrix();
  71758. var m = result._m;
  71759. m[0] = initialM11;
  71760. m[1] = initialM12;
  71761. m[2] = initialM13;
  71762. m[3] = initialM14;
  71763. m[4] = initialM21;
  71764. m[5] = initialM22;
  71765. m[6] = initialM23;
  71766. m[7] = initialM24;
  71767. m[8] = initialM31;
  71768. m[9] = initialM32;
  71769. m[10] = initialM33;
  71770. m[11] = initialM34;
  71771. m[12] = initialM41;
  71772. m[13] = initialM42;
  71773. m[14] = initialM43;
  71774. m[15] = initialM44;
  71775. result._markAsUpdated();
  71776. return result;
  71777. };
  71778. /**
  71779. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71780. * @param scale defines the scale vector3
  71781. * @param rotation defines the rotation quaternion
  71782. * @param translation defines the translation vector3
  71783. * @returns a new matrix
  71784. */
  71785. Matrix.Compose = function (scale, rotation, translation) {
  71786. var result = new Matrix();
  71787. Matrix.ComposeToRef(scale, rotation, translation, result);
  71788. return result;
  71789. };
  71790. /**
  71791. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71792. * @param scale defines the scale vector3
  71793. * @param rotation defines the rotation quaternion
  71794. * @param translation defines the translation vector3
  71795. * @param result defines the target matrix
  71796. */
  71797. Matrix.ComposeToRef = function (scale, rotation, translation, result) {
  71798. Matrix.ScalingToRef(scale.x, scale.y, scale.z, MathTmp.Matrix[1]);
  71799. rotation.toRotationMatrix(MathTmp.Matrix[0]);
  71800. MathTmp.Matrix[1].multiplyToRef(MathTmp.Matrix[0], result);
  71801. result.setTranslation(translation);
  71802. };
  71803. /**
  71804. * Creates a new identity matrix
  71805. * @returns a new identity matrix
  71806. */
  71807. Matrix.Identity = function () {
  71808. 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);
  71809. identity._updateIdentityStatus(true);
  71810. return identity;
  71811. };
  71812. /**
  71813. * Creates a new identity matrix and stores the result in a given matrix
  71814. * @param result defines the target matrix
  71815. */
  71816. Matrix.IdentityToRef = function (result) {
  71817. 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);
  71818. result._updateIdentityStatus(true);
  71819. };
  71820. /**
  71821. * Creates a new zero matrix
  71822. * @returns a new zero matrix
  71823. */
  71824. Matrix.Zero = function () {
  71825. 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);
  71826. zero._updateIdentityStatus(false);
  71827. return zero;
  71828. };
  71829. /**
  71830. * Creates a new rotation matrix for "angle" radians around the X axis
  71831. * @param angle defines the angle (in radians) to use
  71832. * @return the new matrix
  71833. */
  71834. Matrix.RotationX = function (angle) {
  71835. var result = new Matrix();
  71836. Matrix.RotationXToRef(angle, result);
  71837. return result;
  71838. };
  71839. /**
  71840. * Creates a new matrix as the invert of a given matrix
  71841. * @param source defines the source matrix
  71842. * @returns the new matrix
  71843. */
  71844. Matrix.Invert = function (source) {
  71845. var result = new Matrix();
  71846. source.invertToRef(result);
  71847. return result;
  71848. };
  71849. /**
  71850. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  71851. * @param angle defines the angle (in radians) to use
  71852. * @param result defines the target matrix
  71853. */
  71854. Matrix.RotationXToRef = function (angle, result) {
  71855. var s = Math.sin(angle);
  71856. var c = Math.cos(angle);
  71857. 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);
  71858. result._updateIdentityStatus(c === 1 && s === 0);
  71859. };
  71860. /**
  71861. * Creates a new rotation matrix for "angle" radians around the Y axis
  71862. * @param angle defines the angle (in radians) to use
  71863. * @return the new matrix
  71864. */
  71865. Matrix.RotationY = function (angle) {
  71866. var result = new Matrix();
  71867. Matrix.RotationYToRef(angle, result);
  71868. return result;
  71869. };
  71870. /**
  71871. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  71872. * @param angle defines the angle (in radians) to use
  71873. * @param result defines the target matrix
  71874. */
  71875. Matrix.RotationYToRef = function (angle, result) {
  71876. var s = Math.sin(angle);
  71877. var c = Math.cos(angle);
  71878. 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);
  71879. result._updateIdentityStatus(c === 1 && s === 0);
  71880. };
  71881. /**
  71882. * Creates a new rotation matrix for "angle" radians around the Z axis
  71883. * @param angle defines the angle (in radians) to use
  71884. * @return the new matrix
  71885. */
  71886. Matrix.RotationZ = function (angle) {
  71887. var result = new Matrix();
  71888. Matrix.RotationZToRef(angle, result);
  71889. return result;
  71890. };
  71891. /**
  71892. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  71893. * @param angle defines the angle (in radians) to use
  71894. * @param result defines the target matrix
  71895. */
  71896. Matrix.RotationZToRef = function (angle, result) {
  71897. var s = Math.sin(angle);
  71898. var c = Math.cos(angle);
  71899. 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);
  71900. result._updateIdentityStatus(c === 1 && s === 0);
  71901. };
  71902. /**
  71903. * Creates a new rotation matrix for "angle" radians around the given axis
  71904. * @param axis defines the axis to use
  71905. * @param angle defines the angle (in radians) to use
  71906. * @return the new matrix
  71907. */
  71908. Matrix.RotationAxis = function (axis, angle) {
  71909. var result = new Matrix();
  71910. Matrix.RotationAxisToRef(axis, angle, result);
  71911. return result;
  71912. };
  71913. /**
  71914. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  71915. * @param axis defines the axis to use
  71916. * @param angle defines the angle (in radians) to use
  71917. * @param result defines the target matrix
  71918. */
  71919. Matrix.RotationAxisToRef = function (axis, angle, result) {
  71920. var s = Math.sin(-angle);
  71921. var c = Math.cos(-angle);
  71922. var c1 = 1 - c;
  71923. axis.normalize();
  71924. var m = result._m;
  71925. m[0] = (axis.x * axis.x) * c1 + c;
  71926. m[1] = (axis.x * axis.y) * c1 - (axis.z * s);
  71927. m[2] = (axis.x * axis.z) * c1 + (axis.y * s);
  71928. m[3] = 0.0;
  71929. m[4] = (axis.y * axis.x) * c1 + (axis.z * s);
  71930. m[5] = (axis.y * axis.y) * c1 + c;
  71931. m[6] = (axis.y * axis.z) * c1 - (axis.x * s);
  71932. m[7] = 0.0;
  71933. m[8] = (axis.z * axis.x) * c1 - (axis.y * s);
  71934. m[9] = (axis.z * axis.y) * c1 + (axis.x * s);
  71935. m[10] = (axis.z * axis.z) * c1 + c;
  71936. m[11] = 0.0;
  71937. m[12] = 0.0;
  71938. m[13] = 0.0;
  71939. m[14] = 0.0;
  71940. m[15] = 1.0;
  71941. result._markAsUpdated();
  71942. };
  71943. /**
  71944. * Creates a rotation matrix
  71945. * @param yaw defines the yaw angle in radians (Y axis)
  71946. * @param pitch defines the pitch angle in radians (X axis)
  71947. * @param roll defines the roll angle in radians (X axis)
  71948. * @returns the new rotation matrix
  71949. */
  71950. Matrix.RotationYawPitchRoll = function (yaw, pitch, roll) {
  71951. var result = new Matrix();
  71952. Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, result);
  71953. return result;
  71954. };
  71955. /**
  71956. * Creates a rotation matrix and stores it in a given matrix
  71957. * @param yaw defines the yaw angle in radians (Y axis)
  71958. * @param pitch defines the pitch angle in radians (X axis)
  71959. * @param roll defines the roll angle in radians (X axis)
  71960. * @param result defines the target matrix
  71961. */
  71962. Matrix.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  71963. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, MathTmp.Quaternion[0]);
  71964. MathTmp.Quaternion[0].toRotationMatrix(result);
  71965. };
  71966. /**
  71967. * Creates a scaling matrix
  71968. * @param x defines the scale factor on X axis
  71969. * @param y defines the scale factor on Y axis
  71970. * @param z defines the scale factor on Z axis
  71971. * @returns the new matrix
  71972. */
  71973. Matrix.Scaling = function (x, y, z) {
  71974. var result = new Matrix();
  71975. Matrix.ScalingToRef(x, y, z, result);
  71976. return result;
  71977. };
  71978. /**
  71979. * Creates a scaling matrix and stores it in a given matrix
  71980. * @param x defines the scale factor on X axis
  71981. * @param y defines the scale factor on Y axis
  71982. * @param z defines the scale factor on Z axis
  71983. * @param result defines the target matrix
  71984. */
  71985. Matrix.ScalingToRef = function (x, y, z, result) {
  71986. 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);
  71987. result._updateIdentityStatus(x === 1 && y === 1 && z === 1);
  71988. };
  71989. /**
  71990. * Creates a translation matrix
  71991. * @param x defines the translation on X axis
  71992. * @param y defines the translation on Y axis
  71993. * @param z defines the translationon Z axis
  71994. * @returns the new matrix
  71995. */
  71996. Matrix.Translation = function (x, y, z) {
  71997. var result = new Matrix();
  71998. Matrix.TranslationToRef(x, y, z, result);
  71999. return result;
  72000. };
  72001. /**
  72002. * Creates a translation matrix and stores it in a given matrix
  72003. * @param x defines the translation on X axis
  72004. * @param y defines the translation on Y axis
  72005. * @param z defines the translationon Z axis
  72006. * @param result defines the target matrix
  72007. */
  72008. Matrix.TranslationToRef = function (x, y, z, result) {
  72009. 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);
  72010. result._updateIdentityStatus(x === 0 && y === 0 && z === 0);
  72011. };
  72012. /**
  72013. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72014. * @param startValue defines the start value
  72015. * @param endValue defines the end value
  72016. * @param gradient defines the gradient factor
  72017. * @returns the new matrix
  72018. */
  72019. Matrix.Lerp = function (startValue, endValue, gradient) {
  72020. var result = new Matrix();
  72021. Matrix.LerpToRef(startValue, endValue, gradient, result);
  72022. return result;
  72023. };
  72024. /**
  72025. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72026. * @param startValue defines the start value
  72027. * @param endValue defines the end value
  72028. * @param gradient defines the gradient factor
  72029. * @param result defines the Matrix object where to store data
  72030. */
  72031. Matrix.LerpToRef = function (startValue, endValue, gradient, result) {
  72032. var resultM = result._m;
  72033. var startM = startValue.m;
  72034. var endM = endValue.m;
  72035. for (var index = 0; index < 16; index++) {
  72036. resultM[index] = startM[index] * (1.0 - gradient) + endM[index] * gradient;
  72037. }
  72038. result._markAsUpdated();
  72039. };
  72040. /**
  72041. * Builds a new matrix whose values are computed by:
  72042. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72043. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72044. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72045. * @param startValue defines the first matrix
  72046. * @param endValue defines the second matrix
  72047. * @param gradient defines the gradient between the two matrices
  72048. * @returns the new matrix
  72049. */
  72050. Matrix.DecomposeLerp = function (startValue, endValue, gradient) {
  72051. var result = new Matrix();
  72052. Matrix.DecomposeLerpToRef(startValue, endValue, gradient, result);
  72053. return result;
  72054. };
  72055. /**
  72056. * Update a matrix to values which are computed by:
  72057. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72058. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72059. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72060. * @param startValue defines the first matrix
  72061. * @param endValue defines the second matrix
  72062. * @param gradient defines the gradient between the two matrices
  72063. * @param result defines the target matrix
  72064. */
  72065. Matrix.DecomposeLerpToRef = function (startValue, endValue, gradient, result) {
  72066. var startScale = MathTmp.Vector3[0];
  72067. var startRotation = MathTmp.Quaternion[0];
  72068. var startTranslation = MathTmp.Vector3[1];
  72069. startValue.decompose(startScale, startRotation, startTranslation);
  72070. var endScale = MathTmp.Vector3[2];
  72071. var endRotation = MathTmp.Quaternion[1];
  72072. var endTranslation = MathTmp.Vector3[3];
  72073. endValue.decompose(endScale, endRotation, endTranslation);
  72074. var resultScale = MathTmp.Vector3[4];
  72075. Vector3.LerpToRef(startScale, endScale, gradient, resultScale);
  72076. var resultRotation = MathTmp.Quaternion[2];
  72077. Quaternion.SlerpToRef(startRotation, endRotation, gradient, resultRotation);
  72078. var resultTranslation = MathTmp.Vector3[5];
  72079. Vector3.LerpToRef(startTranslation, endTranslation, gradient, resultTranslation);
  72080. Matrix.ComposeToRef(resultScale, resultRotation, resultTranslation, result);
  72081. };
  72082. /**
  72083. * 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"
  72084. * This function works in left handed mode
  72085. * @param eye defines the final position of the entity
  72086. * @param target defines where the entity should look at
  72087. * @param up defines the up vector for the entity
  72088. * @returns the new matrix
  72089. */
  72090. Matrix.LookAtLH = function (eye, target, up) {
  72091. var result = new Matrix();
  72092. Matrix.LookAtLHToRef(eye, target, up, result);
  72093. return result;
  72094. };
  72095. /**
  72096. * 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".
  72097. * This function works in left handed mode
  72098. * @param eye defines the final position of the entity
  72099. * @param target defines where the entity should look at
  72100. * @param up defines the up vector for the entity
  72101. * @param result defines the target matrix
  72102. */
  72103. Matrix.LookAtLHToRef = function (eye, target, up, result) {
  72104. var xAxis = MathTmp.Vector3[0];
  72105. var yAxis = MathTmp.Vector3[1];
  72106. var zAxis = MathTmp.Vector3[2];
  72107. // Z axis
  72108. target.subtractToRef(eye, zAxis);
  72109. zAxis.normalize();
  72110. // X axis
  72111. Vector3.CrossToRef(up, zAxis, xAxis);
  72112. var xSquareLength = xAxis.lengthSquared();
  72113. if (xSquareLength === 0) {
  72114. xAxis.x = 1.0;
  72115. }
  72116. else {
  72117. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  72118. }
  72119. // Y axis
  72120. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  72121. yAxis.normalize();
  72122. // Eye angles
  72123. var ex = -Vector3.Dot(xAxis, eye);
  72124. var ey = -Vector3.Dot(yAxis, eye);
  72125. var ez = -Vector3.Dot(zAxis, eye);
  72126. 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);
  72127. };
  72128. /**
  72129. * 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"
  72130. * This function works in right handed mode
  72131. * @param eye defines the final position of the entity
  72132. * @param target defines where the entity should look at
  72133. * @param up defines the up vector for the entity
  72134. * @returns the new matrix
  72135. */
  72136. Matrix.LookAtRH = function (eye, target, up) {
  72137. var result = new Matrix();
  72138. Matrix.LookAtRHToRef(eye, target, up, result);
  72139. return result;
  72140. };
  72141. /**
  72142. * 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".
  72143. * This function works in right handed mode
  72144. * @param eye defines the final position of the entity
  72145. * @param target defines where the entity should look at
  72146. * @param up defines the up vector for the entity
  72147. * @param result defines the target matrix
  72148. */
  72149. Matrix.LookAtRHToRef = function (eye, target, up, result) {
  72150. var xAxis = MathTmp.Vector3[0];
  72151. var yAxis = MathTmp.Vector3[1];
  72152. var zAxis = MathTmp.Vector3[2];
  72153. // Z axis
  72154. eye.subtractToRef(target, zAxis);
  72155. zAxis.normalize();
  72156. // X axis
  72157. Vector3.CrossToRef(up, zAxis, xAxis);
  72158. var xSquareLength = xAxis.lengthSquared();
  72159. if (xSquareLength === 0) {
  72160. xAxis.x = 1.0;
  72161. }
  72162. else {
  72163. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  72164. }
  72165. // Y axis
  72166. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  72167. yAxis.normalize();
  72168. // Eye angles
  72169. var ex = -Vector3.Dot(xAxis, eye);
  72170. var ey = -Vector3.Dot(yAxis, eye);
  72171. var ez = -Vector3.Dot(zAxis, eye);
  72172. 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);
  72173. };
  72174. /**
  72175. * Create a left-handed orthographic projection matrix
  72176. * @param width defines the viewport width
  72177. * @param height defines the viewport height
  72178. * @param znear defines the near clip plane
  72179. * @param zfar defines the far clip plane
  72180. * @returns a new matrix as a left-handed orthographic projection matrix
  72181. */
  72182. Matrix.OrthoLH = function (width, height, znear, zfar) {
  72183. var matrix = new Matrix();
  72184. Matrix.OrthoLHToRef(width, height, znear, zfar, matrix);
  72185. return matrix;
  72186. };
  72187. /**
  72188. * Store a left-handed orthographic projection to a given matrix
  72189. * @param width defines the viewport width
  72190. * @param height defines the viewport height
  72191. * @param znear defines the near clip plane
  72192. * @param zfar defines the far clip plane
  72193. * @param result defines the target matrix
  72194. */
  72195. Matrix.OrthoLHToRef = function (width, height, znear, zfar, result) {
  72196. var n = znear;
  72197. var f = zfar;
  72198. var a = 2.0 / width;
  72199. var b = 2.0 / height;
  72200. var c = 2.0 / (f - n);
  72201. var d = -(f + n) / (f - n);
  72202. 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);
  72203. result._updateIdentityStatus(a === 1 && b === 1 && c === 1 && d === 0);
  72204. };
  72205. /**
  72206. * Create a left-handed orthographic projection matrix
  72207. * @param left defines the viewport left coordinate
  72208. * @param right defines the viewport right coordinate
  72209. * @param bottom defines the viewport bottom coordinate
  72210. * @param top defines the viewport top coordinate
  72211. * @param znear defines the near clip plane
  72212. * @param zfar defines the far clip plane
  72213. * @returns a new matrix as a left-handed orthographic projection matrix
  72214. */
  72215. Matrix.OrthoOffCenterLH = function (left, right, bottom, top, znear, zfar) {
  72216. var matrix = new Matrix();
  72217. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, matrix);
  72218. return matrix;
  72219. };
  72220. /**
  72221. * Stores a left-handed orthographic projection into a given matrix
  72222. * @param left defines the viewport left coordinate
  72223. * @param right defines the viewport right coordinate
  72224. * @param bottom defines the viewport bottom coordinate
  72225. * @param top defines the viewport top coordinate
  72226. * @param znear defines the near clip plane
  72227. * @param zfar defines the far clip plane
  72228. * @param result defines the target matrix
  72229. */
  72230. Matrix.OrthoOffCenterLHToRef = function (left, right, bottom, top, znear, zfar, result) {
  72231. var n = znear;
  72232. var f = zfar;
  72233. var a = 2.0 / (right - left);
  72234. var b = 2.0 / (top - bottom);
  72235. var c = 2.0 / (f - n);
  72236. var d = -(f + n) / (f - n);
  72237. var i0 = (left + right) / (left - right);
  72238. var i1 = (top + bottom) / (bottom - top);
  72239. 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);
  72240. result._markAsUpdated();
  72241. };
  72242. /**
  72243. * Creates a right-handed orthographic projection matrix
  72244. * @param left defines the viewport left coordinate
  72245. * @param right defines the viewport right coordinate
  72246. * @param bottom defines the viewport bottom coordinate
  72247. * @param top defines the viewport top coordinate
  72248. * @param znear defines the near clip plane
  72249. * @param zfar defines the far clip plane
  72250. * @returns a new matrix as a right-handed orthographic projection matrix
  72251. */
  72252. Matrix.OrthoOffCenterRH = function (left, right, bottom, top, znear, zfar) {
  72253. var matrix = new Matrix();
  72254. Matrix.OrthoOffCenterRHToRef(left, right, bottom, top, znear, zfar, matrix);
  72255. return matrix;
  72256. };
  72257. /**
  72258. * Stores a right-handed orthographic projection into a given matrix
  72259. * @param left defines the viewport left coordinate
  72260. * @param right defines the viewport right coordinate
  72261. * @param bottom defines the viewport bottom coordinate
  72262. * @param top defines the viewport top coordinate
  72263. * @param znear defines the near clip plane
  72264. * @param zfar defines the far clip plane
  72265. * @param result defines the target matrix
  72266. */
  72267. Matrix.OrthoOffCenterRHToRef = function (left, right, bottom, top, znear, zfar, result) {
  72268. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, result);
  72269. result._m[10] *= -1; // No need to call _markAsUpdated as previous function already called it and let _isIdentityDirty to true
  72270. };
  72271. /**
  72272. * Creates a left-handed perspective projection matrix
  72273. * @param width defines the viewport width
  72274. * @param height defines the viewport height
  72275. * @param znear defines the near clip plane
  72276. * @param zfar defines the far clip plane
  72277. * @returns a new matrix as a left-handed perspective projection matrix
  72278. */
  72279. Matrix.PerspectiveLH = function (width, height, znear, zfar) {
  72280. var matrix = new Matrix();
  72281. var n = znear;
  72282. var f = zfar;
  72283. var a = 2.0 * n / width;
  72284. var b = 2.0 * n / height;
  72285. var c = (f + n) / (f - n);
  72286. var d = -2.0 * f * n / (f - n);
  72287. 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);
  72288. matrix._updateIdentityStatus(false);
  72289. return matrix;
  72290. };
  72291. /**
  72292. * Creates a left-handed perspective projection matrix
  72293. * @param fov defines the horizontal field of view
  72294. * @param aspect defines the aspect ratio
  72295. * @param znear defines the near clip plane
  72296. * @param zfar defines the far clip plane
  72297. * @returns a new matrix as a left-handed perspective projection matrix
  72298. */
  72299. Matrix.PerspectiveFovLH = function (fov, aspect, znear, zfar) {
  72300. var matrix = new Matrix();
  72301. Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
  72302. return matrix;
  72303. };
  72304. /**
  72305. * Stores a left-handed perspective projection into a given matrix
  72306. * @param fov defines the horizontal field of view
  72307. * @param aspect defines the aspect ratio
  72308. * @param znear defines the near clip plane
  72309. * @param zfar defines the far clip plane
  72310. * @param result defines the target matrix
  72311. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72312. */
  72313. Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  72314. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  72315. var n = znear;
  72316. var f = zfar;
  72317. var t = 1.0 / (Math.tan(fov * 0.5));
  72318. var a = isVerticalFovFixed ? (t / aspect) : t;
  72319. var b = isVerticalFovFixed ? t : (t * aspect);
  72320. var c = (f + n) / (f - n);
  72321. var d = -2.0 * f * n / (f - n);
  72322. 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);
  72323. result._updateIdentityStatus(false);
  72324. };
  72325. /**
  72326. * Creates a right-handed perspective projection matrix
  72327. * @param fov defines the horizontal field of view
  72328. * @param aspect defines the aspect ratio
  72329. * @param znear defines the near clip plane
  72330. * @param zfar defines the far clip plane
  72331. * @returns a new matrix as a right-handed perspective projection matrix
  72332. */
  72333. Matrix.PerspectiveFovRH = function (fov, aspect, znear, zfar) {
  72334. var matrix = new Matrix();
  72335. Matrix.PerspectiveFovRHToRef(fov, aspect, znear, zfar, matrix);
  72336. return matrix;
  72337. };
  72338. /**
  72339. * Stores a right-handed perspective projection into a given matrix
  72340. * @param fov defines the horizontal field of view
  72341. * @param aspect defines the aspect ratio
  72342. * @param znear defines the near clip plane
  72343. * @param zfar defines the far clip plane
  72344. * @param result defines the target matrix
  72345. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72346. */
  72347. Matrix.PerspectiveFovRHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  72348. //alternatively this could be expressed as:
  72349. // m = PerspectiveFovLHToRef
  72350. // m[10] *= -1.0;
  72351. // m[11] *= -1.0;
  72352. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  72353. var n = znear;
  72354. var f = zfar;
  72355. var t = 1.0 / (Math.tan(fov * 0.5));
  72356. var a = isVerticalFovFixed ? (t / aspect) : t;
  72357. var b = isVerticalFovFixed ? t : (t * aspect);
  72358. var c = -(f + n) / (f - n);
  72359. var d = -2 * f * n / (f - n);
  72360. 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);
  72361. result._updateIdentityStatus(false);
  72362. };
  72363. /**
  72364. * Stores a perspective projection for WebVR info a given matrix
  72365. * @param fov defines the field of view
  72366. * @param znear defines the near clip plane
  72367. * @param zfar defines the far clip plane
  72368. * @param result defines the target matrix
  72369. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  72370. */
  72371. Matrix.PerspectiveFovWebVRToRef = function (fov, znear, zfar, result, rightHanded) {
  72372. if (rightHanded === void 0) { rightHanded = false; }
  72373. var rightHandedFactor = rightHanded ? -1 : 1;
  72374. var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
  72375. var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);
  72376. var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);
  72377. var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
  72378. var xScale = 2.0 / (leftTan + rightTan);
  72379. var yScale = 2.0 / (upTan + downTan);
  72380. var m = result._m;
  72381. m[0] = xScale;
  72382. m[1] = m[2] = m[3] = m[4] = 0.0;
  72383. m[5] = yScale;
  72384. m[6] = m[7] = 0.0;
  72385. m[8] = ((leftTan - rightTan) * xScale * 0.5);
  72386. m[9] = -((upTan - downTan) * yScale * 0.5);
  72387. m[10] = -zfar / (znear - zfar);
  72388. m[11] = 1.0 * rightHandedFactor;
  72389. m[12] = m[13] = m[15] = 0.0;
  72390. m[14] = -(2.0 * zfar * znear) / (zfar - znear);
  72391. result._markAsUpdated();
  72392. };
  72393. /**
  72394. * Computes a complete transformation matrix
  72395. * @param viewport defines the viewport to use
  72396. * @param world defines the world matrix
  72397. * @param view defines the view matrix
  72398. * @param projection defines the projection matrix
  72399. * @param zmin defines the near clip plane
  72400. * @param zmax defines the far clip plane
  72401. * @returns the transformation matrix
  72402. */
  72403. Matrix.GetFinalMatrix = function (viewport, world, view, projection, zmin, zmax) {
  72404. var cw = viewport.width;
  72405. var ch = viewport.height;
  72406. var cx = viewport.x;
  72407. var cy = viewport.y;
  72408. 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);
  72409. var matrix = MathTmp.Matrix[0];
  72410. world.multiplyToRef(view, matrix);
  72411. matrix.multiplyToRef(projection, matrix);
  72412. return matrix.multiply(viewportMatrix);
  72413. };
  72414. /**
  72415. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  72416. * @param matrix defines the matrix to use
  72417. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  72418. */
  72419. Matrix.GetAsMatrix2x2 = function (matrix) {
  72420. var m = matrix.m;
  72421. return new Float32Array([m[0], m[1], m[4], m[5]]);
  72422. };
  72423. /**
  72424. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  72425. * @param matrix defines the matrix to use
  72426. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  72427. */
  72428. Matrix.GetAsMatrix3x3 = function (matrix) {
  72429. var m = matrix.m;
  72430. return new Float32Array([
  72431. m[0], m[1], m[2],
  72432. m[4], m[5], m[6],
  72433. m[8], m[9], m[10]
  72434. ]);
  72435. };
  72436. /**
  72437. * Compute the transpose of a given matrix
  72438. * @param matrix defines the matrix to transpose
  72439. * @returns the new matrix
  72440. */
  72441. Matrix.Transpose = function (matrix) {
  72442. var result = new Matrix();
  72443. Matrix.TransposeToRef(matrix, result);
  72444. return result;
  72445. };
  72446. /**
  72447. * Compute the transpose of a matrix and store it in a target matrix
  72448. * @param matrix defines the matrix to transpose
  72449. * @param result defines the target matrix
  72450. */
  72451. Matrix.TransposeToRef = function (matrix, result) {
  72452. var rm = result._m;
  72453. var mm = matrix.m;
  72454. rm[0] = mm[0];
  72455. rm[1] = mm[4];
  72456. rm[2] = mm[8];
  72457. rm[3] = mm[12];
  72458. rm[4] = mm[1];
  72459. rm[5] = mm[5];
  72460. rm[6] = mm[9];
  72461. rm[7] = mm[13];
  72462. rm[8] = mm[2];
  72463. rm[9] = mm[6];
  72464. rm[10] = mm[10];
  72465. rm[11] = mm[14];
  72466. rm[12] = mm[3];
  72467. rm[13] = mm[7];
  72468. rm[14] = mm[11];
  72469. rm[15] = mm[15];
  72470. // identity-ness does not change when transposing
  72471. result._updateIdentityStatus(matrix._isIdentity, matrix._isIdentityDirty);
  72472. };
  72473. /**
  72474. * Computes a reflection matrix from a plane
  72475. * @param plane defines the reflection plane
  72476. * @returns a new matrix
  72477. */
  72478. Matrix.Reflection = function (plane) {
  72479. var matrix = new Matrix();
  72480. Matrix.ReflectionToRef(plane, matrix);
  72481. return matrix;
  72482. };
  72483. /**
  72484. * Computes a reflection matrix from a plane
  72485. * @param plane defines the reflection plane
  72486. * @param result defines the target matrix
  72487. */
  72488. Matrix.ReflectionToRef = function (plane, result) {
  72489. plane.normalize();
  72490. var x = plane.normal.x;
  72491. var y = plane.normal.y;
  72492. var z = plane.normal.z;
  72493. var temp = -2 * x;
  72494. var temp2 = -2 * y;
  72495. var temp3 = -2 * z;
  72496. 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);
  72497. };
  72498. /**
  72499. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  72500. * @param xaxis defines the value of the 1st axis
  72501. * @param yaxis defines the value of the 2nd axis
  72502. * @param zaxis defines the value of the 3rd axis
  72503. * @param result defines the target matrix
  72504. */
  72505. Matrix.FromXYZAxesToRef = function (xaxis, yaxis, zaxis, result) {
  72506. 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);
  72507. };
  72508. /**
  72509. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  72510. * @param quat defines the quaternion to use
  72511. * @param result defines the target matrix
  72512. */
  72513. Matrix.FromQuaternionToRef = function (quat, result) {
  72514. var xx = quat.x * quat.x;
  72515. var yy = quat.y * quat.y;
  72516. var zz = quat.z * quat.z;
  72517. var xy = quat.x * quat.y;
  72518. var zw = quat.z * quat.w;
  72519. var zx = quat.z * quat.x;
  72520. var yw = quat.y * quat.w;
  72521. var yz = quat.y * quat.z;
  72522. var xw = quat.x * quat.w;
  72523. result._m[0] = 1.0 - (2.0 * (yy + zz));
  72524. result._m[1] = 2.0 * (xy + zw);
  72525. result._m[2] = 2.0 * (zx - yw);
  72526. result._m[3] = 0.0;
  72527. result._m[4] = 2.0 * (xy - zw);
  72528. result._m[5] = 1.0 - (2.0 * (zz + xx));
  72529. result._m[6] = 2.0 * (yz + xw);
  72530. result._m[7] = 0.0;
  72531. result._m[8] = 2.0 * (zx + yw);
  72532. result._m[9] = 2.0 * (yz - xw);
  72533. result._m[10] = 1.0 - (2.0 * (yy + xx));
  72534. result._m[11] = 0.0;
  72535. result._m[12] = 0.0;
  72536. result._m[13] = 0.0;
  72537. result._m[14] = 0.0;
  72538. result._m[15] = 1.0;
  72539. result._markAsUpdated();
  72540. };
  72541. Matrix._updateFlagSeed = 0;
  72542. Matrix._identityReadOnly = Matrix.Identity();
  72543. return Matrix;
  72544. }());
  72545. /**
  72546. * Represens a plane by the equation ax + by + cz + d = 0
  72547. */
  72548. var Plane = /** @class */ (function () {
  72549. /**
  72550. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  72551. * @param a a component of the plane
  72552. * @param b b component of the plane
  72553. * @param c c component of the plane
  72554. * @param d d component of the plane
  72555. */
  72556. function Plane(a, b, c, d) {
  72557. this.normal = new Vector3(a, b, c);
  72558. this.d = d;
  72559. }
  72560. /**
  72561. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  72562. */
  72563. Plane.prototype.asArray = function () {
  72564. return [this.normal.x, this.normal.y, this.normal.z, this.d];
  72565. };
  72566. // Methods
  72567. /**
  72568. * @returns a new plane copied from the current Plane.
  72569. */
  72570. Plane.prototype.clone = function () {
  72571. return new Plane(this.normal.x, this.normal.y, this.normal.z, this.d);
  72572. };
  72573. /**
  72574. * @returns the string "Plane".
  72575. */
  72576. Plane.prototype.getClassName = function () {
  72577. return "Plane";
  72578. };
  72579. /**
  72580. * @returns the Plane hash code.
  72581. */
  72582. Plane.prototype.getHashCode = function () {
  72583. var hash = this.normal.getHashCode();
  72584. hash = (hash * 397) ^ (this.d || 0);
  72585. return hash;
  72586. };
  72587. /**
  72588. * Normalize the current Plane in place.
  72589. * @returns the updated Plane.
  72590. */
  72591. Plane.prototype.normalize = function () {
  72592. var norm = (Math.sqrt((this.normal.x * this.normal.x) + (this.normal.y * this.normal.y) + (this.normal.z * this.normal.z)));
  72593. var magnitude = 0.0;
  72594. if (norm !== 0) {
  72595. magnitude = 1.0 / norm;
  72596. }
  72597. this.normal.x *= magnitude;
  72598. this.normal.y *= magnitude;
  72599. this.normal.z *= magnitude;
  72600. this.d *= magnitude;
  72601. return this;
  72602. };
  72603. /**
  72604. * Applies a transformation the plane and returns the result
  72605. * @param transformation the transformation matrix to be applied to the plane
  72606. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  72607. */
  72608. Plane.prototype.transform = function (transformation) {
  72609. var transposedMatrix = MathTmp.Matrix[0];
  72610. Matrix.TransposeToRef(transformation, transposedMatrix);
  72611. var m = transposedMatrix.m;
  72612. var x = this.normal.x;
  72613. var y = this.normal.y;
  72614. var z = this.normal.z;
  72615. var d = this.d;
  72616. var normalX = x * m[0] + y * m[1] + z * m[2] + d * m[3];
  72617. var normalY = x * m[4] + y * m[5] + z * m[6] + d * m[7];
  72618. var normalZ = x * m[8] + y * m[9] + z * m[10] + d * m[11];
  72619. var finalD = x * m[12] + y * m[13] + z * m[14] + d * m[15];
  72620. return new Plane(normalX, normalY, normalZ, finalD);
  72621. };
  72622. /**
  72623. * Calcualtte the dot product between the point and the plane normal
  72624. * @param point point to calculate the dot product with
  72625. * @returns the dot product (float) of the point coordinates and the plane normal.
  72626. */
  72627. Plane.prototype.dotCoordinate = function (point) {
  72628. return ((((this.normal.x * point.x) + (this.normal.y * point.y)) + (this.normal.z * point.z)) + this.d);
  72629. };
  72630. /**
  72631. * Updates the current Plane from the plane defined by the three given points.
  72632. * @param point1 one of the points used to contruct the plane
  72633. * @param point2 one of the points used to contruct the plane
  72634. * @param point3 one of the points used to contruct the plane
  72635. * @returns the updated Plane.
  72636. */
  72637. Plane.prototype.copyFromPoints = function (point1, point2, point3) {
  72638. var x1 = point2.x - point1.x;
  72639. var y1 = point2.y - point1.y;
  72640. var z1 = point2.z - point1.z;
  72641. var x2 = point3.x - point1.x;
  72642. var y2 = point3.y - point1.y;
  72643. var z2 = point3.z - point1.z;
  72644. var yz = (y1 * z2) - (z1 * y2);
  72645. var xz = (z1 * x2) - (x1 * z2);
  72646. var xy = (x1 * y2) - (y1 * x2);
  72647. var pyth = (Math.sqrt((yz * yz) + (xz * xz) + (xy * xy)));
  72648. var invPyth;
  72649. if (pyth !== 0) {
  72650. invPyth = 1.0 / pyth;
  72651. }
  72652. else {
  72653. invPyth = 0.0;
  72654. }
  72655. this.normal.x = yz * invPyth;
  72656. this.normal.y = xz * invPyth;
  72657. this.normal.z = xy * invPyth;
  72658. this.d = -((this.normal.x * point1.x) + (this.normal.y * point1.y) + (this.normal.z * point1.z));
  72659. return this;
  72660. };
  72661. /**
  72662. * Checks if the plane is facing a given direction
  72663. * @param direction the direction to check if the plane is facing
  72664. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  72665. * @returns True is the vector "direction" is the same side than the plane normal.
  72666. */
  72667. Plane.prototype.isFrontFacingTo = function (direction, epsilon) {
  72668. var dot = Vector3.Dot(this.normal, direction);
  72669. return (dot <= epsilon);
  72670. };
  72671. /**
  72672. * Calculates the distance to a point
  72673. * @param point point to calculate distance to
  72674. * @returns the signed distance (float) from the given point to the Plane.
  72675. */
  72676. Plane.prototype.signedDistanceTo = function (point) {
  72677. return Vector3.Dot(point, this.normal) + this.d;
  72678. };
  72679. // Statics
  72680. /**
  72681. * Creates a plane from an array
  72682. * @param array the array to create a plane from
  72683. * @returns a new Plane from the given array.
  72684. */
  72685. Plane.FromArray = function (array) {
  72686. return new Plane(array[0], array[1], array[2], array[3]);
  72687. };
  72688. /**
  72689. * Creates a plane from three points
  72690. * @param point1 point used to create the plane
  72691. * @param point2 point used to create the plane
  72692. * @param point3 point used to create the plane
  72693. * @returns a new Plane defined by the three given points.
  72694. */
  72695. Plane.FromPoints = function (point1, point2, point3) {
  72696. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  72697. result.copyFromPoints(point1, point2, point3);
  72698. return result;
  72699. };
  72700. /**
  72701. * Creates a plane from an origin point and a normal
  72702. * @param origin origin of the plane to be constructed
  72703. * @param normal normal of the plane to be constructed
  72704. * @returns a new Plane the normal vector to this plane at the given origin point.
  72705. * Note : the vector "normal" is updated because normalized.
  72706. */
  72707. Plane.FromPositionAndNormal = function (origin, normal) {
  72708. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  72709. normal.normalize();
  72710. result.normal = normal;
  72711. result.d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  72712. return result;
  72713. };
  72714. /**
  72715. * Calculates the distance from a plane and a point
  72716. * @param origin origin of the plane to be constructed
  72717. * @param normal normal of the plane to be constructed
  72718. * @param point point to calculate distance to
  72719. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  72720. */
  72721. Plane.SignedDistanceToPlaneFromPositionAndNormal = function (origin, normal, point) {
  72722. var d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  72723. return Vector3.Dot(point, normal) + d;
  72724. };
  72725. return Plane;
  72726. }());
  72727. /**
  72728. * Class used to represent a viewport on screen
  72729. */
  72730. var Viewport = /** @class */ (function () {
  72731. /**
  72732. * Creates a Viewport object located at (x, y) and sized (width, height)
  72733. * @param x defines viewport left coordinate
  72734. * @param y defines viewport top coordinate
  72735. * @param width defines the viewport width
  72736. * @param height defines the viewport height
  72737. */
  72738. function Viewport(
  72739. /** viewport left coordinate */
  72740. x,
  72741. /** viewport top coordinate */
  72742. y,
  72743. /**viewport width */
  72744. width,
  72745. /** viewport height */
  72746. height) {
  72747. this.x = x;
  72748. this.y = y;
  72749. this.width = width;
  72750. this.height = height;
  72751. }
  72752. /**
  72753. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  72754. * @param renderWidth defines the rendering width
  72755. * @param renderHeight defines the rendering height
  72756. * @returns a new Viewport
  72757. */
  72758. Viewport.prototype.toGlobal = function (renderWidth, renderHeight) {
  72759. return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);
  72760. };
  72761. /**
  72762. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  72763. * @param renderWidth defines the rendering width
  72764. * @param renderHeight defines the rendering height
  72765. * @param ref defines the target viewport
  72766. * @returns the current viewport
  72767. */
  72768. Viewport.prototype.toGlobalToRef = function (renderWidth, renderHeight, ref) {
  72769. ref.x = this.x * renderWidth;
  72770. ref.y = this.y * renderHeight;
  72771. ref.width = this.width * renderWidth;
  72772. ref.height = this.height * renderHeight;
  72773. return this;
  72774. };
  72775. /**
  72776. * Returns a new Viewport copied from the current one
  72777. * @returns a new Viewport
  72778. */
  72779. Viewport.prototype.clone = function () {
  72780. return new Viewport(this.x, this.y, this.width, this.height);
  72781. };
  72782. return Viewport;
  72783. }());
  72784. /**
  72785. * Reprasents a camera frustum
  72786. */
  72787. var Frustum = /** @class */ (function () {
  72788. function Frustum() {
  72789. }
  72790. /**
  72791. * Gets the planes representing the frustum
  72792. * @param transform matrix to be applied to the returned planes
  72793. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  72794. */
  72795. Frustum.GetPlanes = function (transform) {
  72796. var frustumPlanes = [];
  72797. for (var index = 0; index < 6; index++) {
  72798. frustumPlanes.push(new Plane(0.0, 0.0, 0.0, 0.0));
  72799. }
  72800. Frustum.GetPlanesToRef(transform, frustumPlanes);
  72801. return frustumPlanes;
  72802. };
  72803. /**
  72804. * Gets the near frustum plane transformed by the transform matrix
  72805. * @param transform transformation matrix to be applied to the resulting frustum plane
  72806. * @param frustumPlane the resuling frustum plane
  72807. */
  72808. Frustum.GetNearPlaneToRef = function (transform, frustumPlane) {
  72809. var m = transform.m;
  72810. frustumPlane.normal.x = m[3] + m[2];
  72811. frustumPlane.normal.y = m[7] + m[6];
  72812. frustumPlane.normal.z = m[11] + m[10];
  72813. frustumPlane.d = m[15] + m[14];
  72814. frustumPlane.normalize();
  72815. };
  72816. /**
  72817. * Gets the far frustum plane transformed by the transform matrix
  72818. * @param transform transformation matrix to be applied to the resulting frustum plane
  72819. * @param frustumPlane the resuling frustum plane
  72820. */
  72821. Frustum.GetFarPlaneToRef = function (transform, frustumPlane) {
  72822. var m = transform.m;
  72823. frustumPlane.normal.x = m[3] - m[2];
  72824. frustumPlane.normal.y = m[7] - m[6];
  72825. frustumPlane.normal.z = m[11] - m[10];
  72826. frustumPlane.d = m[15] - m[14];
  72827. frustumPlane.normalize();
  72828. };
  72829. /**
  72830. * Gets the left frustum plane transformed by the transform matrix
  72831. * @param transform transformation matrix to be applied to the resulting frustum plane
  72832. * @param frustumPlane the resuling frustum plane
  72833. */
  72834. Frustum.GetLeftPlaneToRef = function (transform, frustumPlane) {
  72835. var m = transform.m;
  72836. frustumPlane.normal.x = m[3] + m[0];
  72837. frustumPlane.normal.y = m[7] + m[4];
  72838. frustumPlane.normal.z = m[11] + m[8];
  72839. frustumPlane.d = m[15] + m[12];
  72840. frustumPlane.normalize();
  72841. };
  72842. /**
  72843. * Gets the right frustum plane transformed by the transform matrix
  72844. * @param transform transformation matrix to be applied to the resulting frustum plane
  72845. * @param frustumPlane the resuling frustum plane
  72846. */
  72847. Frustum.GetRightPlaneToRef = function (transform, frustumPlane) {
  72848. var m = transform.m;
  72849. frustumPlane.normal.x = m[3] - m[0];
  72850. frustumPlane.normal.y = m[7] - m[4];
  72851. frustumPlane.normal.z = m[11] - m[8];
  72852. frustumPlane.d = m[15] - m[12];
  72853. frustumPlane.normalize();
  72854. };
  72855. /**
  72856. * Gets the top frustum plane transformed by the transform matrix
  72857. * @param transform transformation matrix to be applied to the resulting frustum plane
  72858. * @param frustumPlane the resuling frustum plane
  72859. */
  72860. Frustum.GetTopPlaneToRef = function (transform, frustumPlane) {
  72861. var m = transform.m;
  72862. frustumPlane.normal.x = m[3] - m[1];
  72863. frustumPlane.normal.y = m[7] - m[5];
  72864. frustumPlane.normal.z = m[11] - m[9];
  72865. frustumPlane.d = m[15] - m[13];
  72866. frustumPlane.normalize();
  72867. };
  72868. /**
  72869. * Gets the bottom frustum plane transformed by the transform matrix
  72870. * @param transform transformation matrix to be applied to the resulting frustum plane
  72871. * @param frustumPlane the resuling frustum plane
  72872. */
  72873. Frustum.GetBottomPlaneToRef = function (transform, frustumPlane) {
  72874. var m = transform.m;
  72875. frustumPlane.normal.x = m[3] + m[1];
  72876. frustumPlane.normal.y = m[7] + m[5];
  72877. frustumPlane.normal.z = m[11] + m[9];
  72878. frustumPlane.d = m[15] + m[13];
  72879. frustumPlane.normalize();
  72880. };
  72881. /**
  72882. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  72883. * @param transform transformation matrix to be applied to the resulting frustum planes
  72884. * @param frustumPlanes the resuling frustum planes
  72885. */
  72886. Frustum.GetPlanesToRef = function (transform, frustumPlanes) {
  72887. // Near
  72888. Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);
  72889. // Far
  72890. Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);
  72891. // Left
  72892. Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);
  72893. // Right
  72894. Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);
  72895. // Top
  72896. Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);
  72897. // Bottom
  72898. Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);
  72899. };
  72900. return Frustum;
  72901. }());
  72902. /** Defines supported spaces */
  72903. var Space;
  72904. (function (Space) {
  72905. /** Local (object) space */
  72906. Space[Space["LOCAL"] = 0] = "LOCAL";
  72907. /** World space */
  72908. Space[Space["WORLD"] = 1] = "WORLD";
  72909. /** Bone space */
  72910. Space[Space["BONE"] = 2] = "BONE";
  72911. })(Space || (Space = {}));
  72912. /** Defines the 3 main axes */
  72913. var Axis = /** @class */ (function () {
  72914. function Axis() {
  72915. }
  72916. /** X axis */
  72917. Axis.X = new Vector3(1.0, 0.0, 0.0);
  72918. /** Y axis */
  72919. Axis.Y = new Vector3(0.0, 1.0, 0.0);
  72920. /** Z axis */
  72921. Axis.Z = new Vector3(0.0, 0.0, 1.0);
  72922. return Axis;
  72923. }());
  72924. /** Class used to represent a Bezier curve */
  72925. var BezierCurve = /** @class */ (function () {
  72926. function BezierCurve() {
  72927. }
  72928. /**
  72929. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  72930. * @param t defines the time
  72931. * @param x1 defines the left coordinate on X axis
  72932. * @param y1 defines the left coordinate on Y axis
  72933. * @param x2 defines the right coordinate on X axis
  72934. * @param y2 defines the right coordinate on Y axis
  72935. * @returns the interpolated value
  72936. */
  72937. BezierCurve.Interpolate = function (t, x1, y1, x2, y2) {
  72938. // Extract X (which is equal to time here)
  72939. var f0 = 1 - 3 * x2 + 3 * x1;
  72940. var f1 = 3 * x2 - 6 * x1;
  72941. var f2 = 3 * x1;
  72942. var refinedT = t;
  72943. for (var i = 0; i < 5; i++) {
  72944. var refinedT2 = refinedT * refinedT;
  72945. var refinedT3 = refinedT2 * refinedT;
  72946. var x = f0 * refinedT3 + f1 * refinedT2 + f2 * refinedT;
  72947. var slope = 1.0 / (3.0 * f0 * refinedT2 + 2.0 * f1 * refinedT + f2);
  72948. refinedT -= (x - t) * slope;
  72949. refinedT = Math.min(1, Math.max(0, refinedT));
  72950. }
  72951. // Resolve cubic bezier for the given x
  72952. return 3 * Math.pow(1 - refinedT, 2) * refinedT * y1 +
  72953. 3 * (1 - refinedT) * Math.pow(refinedT, 2) * y2 +
  72954. Math.pow(refinedT, 3);
  72955. };
  72956. return BezierCurve;
  72957. }());
  72958. /**
  72959. * Defines potential orientation for back face culling
  72960. */
  72961. var Orientation;
  72962. (function (Orientation) {
  72963. /**
  72964. * Clockwise
  72965. */
  72966. Orientation[Orientation["CW"] = 0] = "CW";
  72967. /** Counter clockwise */
  72968. Orientation[Orientation["CCW"] = 1] = "CCW";
  72969. })(Orientation || (Orientation = {}));
  72970. /**
  72971. * Defines angle representation
  72972. */
  72973. var Angle = /** @class */ (function () {
  72974. /**
  72975. * Creates an Angle object of "radians" radians (float).
  72976. */
  72977. function Angle(radians) {
  72978. this._radians = radians;
  72979. if (this._radians < 0.0) {
  72980. this._radians += (2.0 * Math.PI);
  72981. }
  72982. }
  72983. /**
  72984. * Get value in degrees
  72985. * @returns the Angle value in degrees (float)
  72986. */
  72987. Angle.prototype.degrees = function () {
  72988. return this._radians * 180.0 / Math.PI;
  72989. };
  72990. /**
  72991. * Get value in radians
  72992. * @returns the Angle value in radians (float)
  72993. */
  72994. Angle.prototype.radians = function () {
  72995. return this._radians;
  72996. };
  72997. /**
  72998. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  72999. * @param a defines first vector
  73000. * @param b defines second vector
  73001. * @returns a new Angle
  73002. */
  73003. Angle.BetweenTwoPoints = function (a, b) {
  73004. var delta = b.subtract(a);
  73005. var theta = Math.atan2(delta.y, delta.x);
  73006. return new Angle(theta);
  73007. };
  73008. /**
  73009. * Gets a new Angle object from the given float in radians
  73010. * @param radians defines the angle value in radians
  73011. * @returns a new Angle
  73012. */
  73013. Angle.FromRadians = function (radians) {
  73014. return new Angle(radians);
  73015. };
  73016. /**
  73017. * Gets a new Angle object from the given float in degrees
  73018. * @param degrees defines the angle value in degrees
  73019. * @returns a new Angle
  73020. */
  73021. Angle.FromDegrees = function (degrees) {
  73022. return new Angle(degrees * Math.PI / 180.0);
  73023. };
  73024. return Angle;
  73025. }());
  73026. /**
  73027. * This represents an arc in a 2d space.
  73028. */
  73029. var Arc2 = /** @class */ (function () {
  73030. /**
  73031. * Creates an Arc object from the three given points : start, middle and end.
  73032. * @param startPoint Defines the start point of the arc
  73033. * @param midPoint Defines the midlle point of the arc
  73034. * @param endPoint Defines the end point of the arc
  73035. */
  73036. function Arc2(
  73037. /** Defines the start point of the arc */
  73038. startPoint,
  73039. /** Defines the mid point of the arc */
  73040. midPoint,
  73041. /** Defines the end point of the arc */
  73042. endPoint) {
  73043. this.startPoint = startPoint;
  73044. this.midPoint = midPoint;
  73045. this.endPoint = endPoint;
  73046. var temp = Math.pow(midPoint.x, 2) + Math.pow(midPoint.y, 2);
  73047. var startToMid = (Math.pow(startPoint.x, 2) + Math.pow(startPoint.y, 2) - temp) / 2.;
  73048. var midToEnd = (temp - Math.pow(endPoint.x, 2) - Math.pow(endPoint.y, 2)) / 2.;
  73049. var det = (startPoint.x - midPoint.x) * (midPoint.y - endPoint.y) - (midPoint.x - endPoint.x) * (startPoint.y - midPoint.y);
  73050. 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);
  73051. this.radius = this.centerPoint.subtract(this.startPoint).length();
  73052. this.startAngle = Angle.BetweenTwoPoints(this.centerPoint, this.startPoint);
  73053. var a1 = this.startAngle.degrees();
  73054. var a2 = Angle.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees();
  73055. var a3 = Angle.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
  73056. // angles correction
  73057. if (a2 - a1 > +180.0) {
  73058. a2 -= 360.0;
  73059. }
  73060. if (a2 - a1 < -180.0) {
  73061. a2 += 360.0;
  73062. }
  73063. if (a3 - a2 > +180.0) {
  73064. a3 -= 360.0;
  73065. }
  73066. if (a3 - a2 < -180.0) {
  73067. a3 += 360.0;
  73068. }
  73069. this.orientation = (a2 - a1) < 0 ? Orientation.CW : Orientation.CCW;
  73070. this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? a1 - a3 : a3 - a1);
  73071. }
  73072. return Arc2;
  73073. }());
  73074. /**
  73075. * Represents a 2D path made up of multiple 2D points
  73076. */
  73077. var Path2 = /** @class */ (function () {
  73078. /**
  73079. * Creates a Path2 object from the starting 2D coordinates x and y.
  73080. * @param x the starting points x value
  73081. * @param y the starting points y value
  73082. */
  73083. function Path2(x, y) {
  73084. this._points = new Array();
  73085. this._length = 0.0;
  73086. /**
  73087. * If the path start and end point are the same
  73088. */
  73089. this.closed = false;
  73090. this._points.push(new Vector2(x, y));
  73091. }
  73092. /**
  73093. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  73094. * @param x the added points x value
  73095. * @param y the added points y value
  73096. * @returns the updated Path2.
  73097. */
  73098. Path2.prototype.addLineTo = function (x, y) {
  73099. if (this.closed) {
  73100. return this;
  73101. }
  73102. var newPoint = new Vector2(x, y);
  73103. var previousPoint = this._points[this._points.length - 1];
  73104. this._points.push(newPoint);
  73105. this._length += newPoint.subtract(previousPoint).length();
  73106. return this;
  73107. };
  73108. /**
  73109. * 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.
  73110. * @param midX middle point x value
  73111. * @param midY middle point y value
  73112. * @param endX end point x value
  73113. * @param endY end point y value
  73114. * @param numberOfSegments (default: 36)
  73115. * @returns the updated Path2.
  73116. */
  73117. Path2.prototype.addArcTo = function (midX, midY, endX, endY, numberOfSegments) {
  73118. if (numberOfSegments === void 0) { numberOfSegments = 36; }
  73119. if (this.closed) {
  73120. return this;
  73121. }
  73122. var startPoint = this._points[this._points.length - 1];
  73123. var midPoint = new Vector2(midX, midY);
  73124. var endPoint = new Vector2(endX, endY);
  73125. var arc = new Arc2(startPoint, midPoint, endPoint);
  73126. var increment = arc.angle.radians() / numberOfSegments;
  73127. if (arc.orientation === Orientation.CW) {
  73128. increment *= -1;
  73129. }
  73130. var currentAngle = arc.startAngle.radians() + increment;
  73131. for (var i = 0; i < numberOfSegments; i++) {
  73132. var x = Math.cos(currentAngle) * arc.radius + arc.centerPoint.x;
  73133. var y = Math.sin(currentAngle) * arc.radius + arc.centerPoint.y;
  73134. this.addLineTo(x, y);
  73135. currentAngle += increment;
  73136. }
  73137. return this;
  73138. };
  73139. /**
  73140. * Closes the Path2.
  73141. * @returns the Path2.
  73142. */
  73143. Path2.prototype.close = function () {
  73144. this.closed = true;
  73145. return this;
  73146. };
  73147. /**
  73148. * Gets the sum of the distance between each sequential point in the path
  73149. * @returns the Path2 total length (float).
  73150. */
  73151. Path2.prototype.length = function () {
  73152. var result = this._length;
  73153. if (!this.closed) {
  73154. var lastPoint = this._points[this._points.length - 1];
  73155. var firstPoint = this._points[0];
  73156. result += (firstPoint.subtract(lastPoint).length());
  73157. }
  73158. return result;
  73159. };
  73160. /**
  73161. * Gets the points which construct the path
  73162. * @returns the Path2 internal array of points.
  73163. */
  73164. Path2.prototype.getPoints = function () {
  73165. return this._points;
  73166. };
  73167. /**
  73168. * Retreives the point at the distance aways from the starting point
  73169. * @param normalizedLengthPosition the length along the path to retreive the point from
  73170. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  73171. */
  73172. Path2.prototype.getPointAtLengthPosition = function (normalizedLengthPosition) {
  73173. if (normalizedLengthPosition < 0 || normalizedLengthPosition > 1) {
  73174. return Vector2.Zero();
  73175. }
  73176. var lengthPosition = normalizedLengthPosition * this.length();
  73177. var previousOffset = 0;
  73178. for (var i = 0; i < this._points.length; i++) {
  73179. var j = (i + 1) % this._points.length;
  73180. var a = this._points[i];
  73181. var b = this._points[j];
  73182. var bToA = b.subtract(a);
  73183. var nextOffset = (bToA.length() + previousOffset);
  73184. if (lengthPosition >= previousOffset && lengthPosition <= nextOffset) {
  73185. var dir = bToA.normalize();
  73186. var localOffset = lengthPosition - previousOffset;
  73187. return new Vector2(a.x + (dir.x * localOffset), a.y + (dir.y * localOffset));
  73188. }
  73189. previousOffset = nextOffset;
  73190. }
  73191. return Vector2.Zero();
  73192. };
  73193. /**
  73194. * Creates a new path starting from an x and y position
  73195. * @param x starting x value
  73196. * @param y starting y value
  73197. * @returns a new Path2 starting at the coordinates (x, y).
  73198. */
  73199. Path2.StartingAt = function (x, y) {
  73200. return new Path2(x, y);
  73201. };
  73202. return Path2;
  73203. }());
  73204. /**
  73205. * Represents a 3D path made up of multiple 3D points
  73206. */
  73207. var Path3D = /** @class */ (function () {
  73208. /**
  73209. * new Path3D(path, normal, raw)
  73210. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  73211. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  73212. * @param path an array of Vector3, the curve axis of the Path3D
  73213. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  73214. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  73215. */
  73216. function Path3D(
  73217. /**
  73218. * an array of Vector3, the curve axis of the Path3D
  73219. */
  73220. path, firstNormal, raw) {
  73221. if (firstNormal === void 0) { firstNormal = null; }
  73222. this.path = path;
  73223. this._curve = new Array();
  73224. this._distances = new Array();
  73225. this._tangents = new Array();
  73226. this._normals = new Array();
  73227. this._binormals = new Array();
  73228. for (var p = 0; p < path.length; p++) {
  73229. this._curve[p] = path[p].clone(); // hard copy
  73230. }
  73231. this._raw = raw || false;
  73232. this._compute(firstNormal);
  73233. }
  73234. /**
  73235. * Returns the Path3D array of successive Vector3 designing its curve.
  73236. * @returns the Path3D array of successive Vector3 designing its curve.
  73237. */
  73238. Path3D.prototype.getCurve = function () {
  73239. return this._curve;
  73240. };
  73241. /**
  73242. * Returns an array populated with tangent vectors on each Path3D curve point.
  73243. * @returns an array populated with tangent vectors on each Path3D curve point.
  73244. */
  73245. Path3D.prototype.getTangents = function () {
  73246. return this._tangents;
  73247. };
  73248. /**
  73249. * Returns an array populated with normal vectors on each Path3D curve point.
  73250. * @returns an array populated with normal vectors on each Path3D curve point.
  73251. */
  73252. Path3D.prototype.getNormals = function () {
  73253. return this._normals;
  73254. };
  73255. /**
  73256. * Returns an array populated with binormal vectors on each Path3D curve point.
  73257. * @returns an array populated with binormal vectors on each Path3D curve point.
  73258. */
  73259. Path3D.prototype.getBinormals = function () {
  73260. return this._binormals;
  73261. };
  73262. /**
  73263. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  73264. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  73265. */
  73266. Path3D.prototype.getDistances = function () {
  73267. return this._distances;
  73268. };
  73269. /**
  73270. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  73271. * @param path path which all values are copied into the curves points
  73272. * @param firstNormal which should be projected onto the curve
  73273. * @returns the same object updated.
  73274. */
  73275. Path3D.prototype.update = function (path, firstNormal) {
  73276. if (firstNormal === void 0) { firstNormal = null; }
  73277. for (var p = 0; p < path.length; p++) {
  73278. this._curve[p].x = path[p].x;
  73279. this._curve[p].y = path[p].y;
  73280. this._curve[p].z = path[p].z;
  73281. }
  73282. this._compute(firstNormal);
  73283. return this;
  73284. };
  73285. // private function compute() : computes tangents, normals and binormals
  73286. Path3D.prototype._compute = function (firstNormal) {
  73287. var l = this._curve.length;
  73288. // first and last tangents
  73289. this._tangents[0] = this._getFirstNonNullVector(0);
  73290. if (!this._raw) {
  73291. this._tangents[0].normalize();
  73292. }
  73293. this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
  73294. if (!this._raw) {
  73295. this._tangents[l - 1].normalize();
  73296. }
  73297. // normals and binormals at first point : arbitrary vector with _normalVector()
  73298. var tg0 = this._tangents[0];
  73299. var pp0 = this._normalVector(tg0, firstNormal);
  73300. this._normals[0] = pp0;
  73301. if (!this._raw) {
  73302. this._normals[0].normalize();
  73303. }
  73304. this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
  73305. if (!this._raw) {
  73306. this._binormals[0].normalize();
  73307. }
  73308. this._distances[0] = 0.0;
  73309. // normals and binormals : next points
  73310. var prev; // previous vector (segment)
  73311. var cur; // current vector (segment)
  73312. var curTang; // current tangent
  73313. // previous normal
  73314. var prevBinor; // previous binormal
  73315. for (var i = 1; i < l; i++) {
  73316. // tangents
  73317. prev = this._getLastNonNullVector(i);
  73318. if (i < l - 1) {
  73319. cur = this._getFirstNonNullVector(i);
  73320. this._tangents[i] = prev.add(cur);
  73321. this._tangents[i].normalize();
  73322. }
  73323. this._distances[i] = this._distances[i - 1] + prev.length();
  73324. // normals and binormals
  73325. // http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
  73326. curTang = this._tangents[i];
  73327. prevBinor = this._binormals[i - 1];
  73328. this._normals[i] = Vector3.Cross(prevBinor, curTang);
  73329. if (!this._raw) {
  73330. this._normals[i].normalize();
  73331. }
  73332. this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
  73333. if (!this._raw) {
  73334. this._binormals[i].normalize();
  73335. }
  73336. }
  73337. };
  73338. // private function getFirstNonNullVector(index)
  73339. // returns the first non null vector from index : curve[index + N].subtract(curve[index])
  73340. Path3D.prototype._getFirstNonNullVector = function (index) {
  73341. var i = 1;
  73342. var nNVector = this._curve[index + i].subtract(this._curve[index]);
  73343. while (nNVector.length() === 0 && index + i + 1 < this._curve.length) {
  73344. i++;
  73345. nNVector = this._curve[index + i].subtract(this._curve[index]);
  73346. }
  73347. return nNVector;
  73348. };
  73349. // private function getLastNonNullVector(index)
  73350. // returns the last non null vector from index : curve[index].subtract(curve[index - N])
  73351. Path3D.prototype._getLastNonNullVector = function (index) {
  73352. var i = 1;
  73353. var nLVector = this._curve[index].subtract(this._curve[index - i]);
  73354. while (nLVector.length() === 0 && index > i + 1) {
  73355. i++;
  73356. nLVector = this._curve[index].subtract(this._curve[index - i]);
  73357. }
  73358. return nLVector;
  73359. };
  73360. // private function normalVector(v0, vt, va) :
  73361. // returns an arbitrary point in the plane defined by the point v0 and the vector vt orthogonal to this plane
  73362. // if va is passed, it returns the va projection on the plane orthogonal to vt at the point v0
  73363. Path3D.prototype._normalVector = function (vt, va) {
  73364. var normal0;
  73365. var tgl = vt.length();
  73366. if (tgl === 0.0) {
  73367. tgl = 1.0;
  73368. }
  73369. if (va === undefined || va === null) {
  73370. var point;
  73371. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.y) / tgl, 1.0, Epsilon)) { // search for a point in the plane
  73372. point = new Vector3(0.0, -1.0, 0.0);
  73373. }
  73374. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.x) / tgl, 1.0, Epsilon)) {
  73375. point = new Vector3(1.0, 0.0, 0.0);
  73376. }
  73377. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.z) / tgl, 1.0, Epsilon)) {
  73378. point = new Vector3(0.0, 0.0, 1.0);
  73379. }
  73380. else {
  73381. point = Vector3.Zero();
  73382. }
  73383. normal0 = Vector3.Cross(vt, point);
  73384. }
  73385. else {
  73386. normal0 = Vector3.Cross(vt, va);
  73387. Vector3.CrossToRef(normal0, vt, normal0);
  73388. }
  73389. normal0.normalize();
  73390. return normal0;
  73391. };
  73392. return Path3D;
  73393. }());
  73394. /**
  73395. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73396. * A Curve3 is designed from a series of successive Vector3.
  73397. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  73398. */
  73399. var Curve3 = /** @class */ (function () {
  73400. /**
  73401. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73402. * A Curve3 is designed from a series of successive Vector3.
  73403. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  73404. * @param points points which make up the curve
  73405. */
  73406. function Curve3(points) {
  73407. this._length = 0.0;
  73408. this._points = points;
  73409. this._length = this._computeLength(points);
  73410. }
  73411. /**
  73412. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  73413. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  73414. * @param v1 (Vector3) the control point
  73415. * @param v2 (Vector3) the end point of the Quadratic Bezier
  73416. * @param nbPoints (integer) the wanted number of points in the curve
  73417. * @returns the created Curve3
  73418. */
  73419. Curve3.CreateQuadraticBezier = function (v0, v1, v2, nbPoints) {
  73420. nbPoints = nbPoints > 2 ? nbPoints : 3;
  73421. var bez = new Array();
  73422. var equation = function (t, val0, val1, val2) {
  73423. var res = (1.0 - t) * (1.0 - t) * val0 + 2.0 * t * (1.0 - t) * val1 + t * t * val2;
  73424. return res;
  73425. };
  73426. for (var i = 0; i <= nbPoints; i++) {
  73427. 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)));
  73428. }
  73429. return new Curve3(bez);
  73430. };
  73431. /**
  73432. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  73433. * @param v0 (Vector3) the origin point of the Cubic Bezier
  73434. * @param v1 (Vector3) the first control point
  73435. * @param v2 (Vector3) the second control point
  73436. * @param v3 (Vector3) the end point of the Cubic Bezier
  73437. * @param nbPoints (integer) the wanted number of points in the curve
  73438. * @returns the created Curve3
  73439. */
  73440. Curve3.CreateCubicBezier = function (v0, v1, v2, v3, nbPoints) {
  73441. nbPoints = nbPoints > 3 ? nbPoints : 4;
  73442. var bez = new Array();
  73443. var equation = function (t, val0, val1, val2, val3) {
  73444. 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;
  73445. return res;
  73446. };
  73447. for (var i = 0; i <= nbPoints; i++) {
  73448. 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)));
  73449. }
  73450. return new Curve3(bez);
  73451. };
  73452. /**
  73453. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  73454. * @param p1 (Vector3) the origin point of the Hermite Spline
  73455. * @param t1 (Vector3) the tangent vector at the origin point
  73456. * @param p2 (Vector3) the end point of the Hermite Spline
  73457. * @param t2 (Vector3) the tangent vector at the end point
  73458. * @param nbPoints (integer) the wanted number of points in the curve
  73459. * @returns the created Curve3
  73460. */
  73461. Curve3.CreateHermiteSpline = function (p1, t1, p2, t2, nbPoints) {
  73462. var hermite = new Array();
  73463. var step = 1.0 / nbPoints;
  73464. for (var i = 0; i <= nbPoints; i++) {
  73465. hermite.push(Vector3.Hermite(p1, t1, p2, t2, i * step));
  73466. }
  73467. return new Curve3(hermite);
  73468. };
  73469. /**
  73470. * Returns a Curve3 object along a CatmullRom Spline curve :
  73471. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  73472. * @param nbPoints (integer) the wanted number of points between each curve control points
  73473. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  73474. * @returns the created Curve3
  73475. */
  73476. Curve3.CreateCatmullRomSpline = function (points, nbPoints, closed) {
  73477. var catmullRom = new Array();
  73478. var step = 1.0 / nbPoints;
  73479. var amount = 0.0;
  73480. if (closed) {
  73481. var pointsCount = points.length;
  73482. for (var i = 0; i < pointsCount; i++) {
  73483. amount = 0;
  73484. for (var c = 0; c < nbPoints; c++) {
  73485. catmullRom.push(Vector3.CatmullRom(points[i % pointsCount], points[(i + 1) % pointsCount], points[(i + 2) % pointsCount], points[(i + 3) % pointsCount], amount));
  73486. amount += step;
  73487. }
  73488. }
  73489. catmullRom.push(catmullRom[0]);
  73490. }
  73491. else {
  73492. var totalPoints = new Array();
  73493. totalPoints.push(points[0].clone());
  73494. Array.prototype.push.apply(totalPoints, points);
  73495. totalPoints.push(points[points.length - 1].clone());
  73496. for (var i = 0; i < totalPoints.length - 3; i++) {
  73497. amount = 0;
  73498. for (var c = 0; c < nbPoints; c++) {
  73499. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  73500. amount += step;
  73501. }
  73502. }
  73503. i--;
  73504. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  73505. }
  73506. return new Curve3(catmullRom);
  73507. };
  73508. /**
  73509. * @returns the Curve3 stored array of successive Vector3
  73510. */
  73511. Curve3.prototype.getPoints = function () {
  73512. return this._points;
  73513. };
  73514. /**
  73515. * @returns the computed length (float) of the curve.
  73516. */
  73517. Curve3.prototype.length = function () {
  73518. return this._length;
  73519. };
  73520. /**
  73521. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  73522. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  73523. * curveA and curveB keep unchanged.
  73524. * @param curve the curve to continue from this curve
  73525. * @returns the newly constructed curve
  73526. */
  73527. Curve3.prototype.continue = function (curve) {
  73528. var lastPoint = this._points[this._points.length - 1];
  73529. var continuedPoints = this._points.slice();
  73530. var curvePoints = curve.getPoints();
  73531. for (var i = 1; i < curvePoints.length; i++) {
  73532. continuedPoints.push(curvePoints[i].subtract(curvePoints[0]).add(lastPoint));
  73533. }
  73534. var continuedCurve = new Curve3(continuedPoints);
  73535. return continuedCurve;
  73536. };
  73537. Curve3.prototype._computeLength = function (path) {
  73538. var l = 0;
  73539. for (var i = 1; i < path.length; i++) {
  73540. l += (path[i].subtract(path[i - 1])).length();
  73541. }
  73542. return l;
  73543. };
  73544. return Curve3;
  73545. }());
  73546. // Vertex formats
  73547. /**
  73548. * Contains position and normal vectors for a vertex
  73549. */
  73550. var PositionNormalVertex = /** @class */ (function () {
  73551. /**
  73552. * Creates a PositionNormalVertex
  73553. * @param position the position of the vertex (defaut: 0,0,0)
  73554. * @param normal the normal of the vertex (defaut: 0,1,0)
  73555. */
  73556. function PositionNormalVertex(
  73557. /** the position of the vertex (defaut: 0,0,0) */
  73558. position,
  73559. /** the normal of the vertex (defaut: 0,1,0) */
  73560. normal) {
  73561. if (position === void 0) { position = Vector3.Zero(); }
  73562. if (normal === void 0) { normal = Vector3.Up(); }
  73563. this.position = position;
  73564. this.normal = normal;
  73565. }
  73566. /**
  73567. * Clones the PositionNormalVertex
  73568. * @returns the cloned PositionNormalVertex
  73569. */
  73570. PositionNormalVertex.prototype.clone = function () {
  73571. return new PositionNormalVertex(this.position.clone(), this.normal.clone());
  73572. };
  73573. return PositionNormalVertex;
  73574. }());
  73575. /**
  73576. * Contains position, normal and uv vectors for a vertex
  73577. */
  73578. var PositionNormalTextureVertex = /** @class */ (function () {
  73579. /**
  73580. * Creates a PositionNormalTextureVertex
  73581. * @param position the position of the vertex (defaut: 0,0,0)
  73582. * @param normal the normal of the vertex (defaut: 0,1,0)
  73583. * @param uv the uv of the vertex (default: 0,0)
  73584. */
  73585. function PositionNormalTextureVertex(
  73586. /** the position of the vertex (defaut: 0,0,0) */
  73587. position,
  73588. /** the normal of the vertex (defaut: 0,1,0) */
  73589. normal,
  73590. /** the uv of the vertex (default: 0,0) */
  73591. uv) {
  73592. if (position === void 0) { position = Vector3.Zero(); }
  73593. if (normal === void 0) { normal = Vector3.Up(); }
  73594. if (uv === void 0) { uv = Vector2.Zero(); }
  73595. this.position = position;
  73596. this.normal = normal;
  73597. this.uv = uv;
  73598. }
  73599. /**
  73600. * Clones the PositionNormalTextureVertex
  73601. * @returns the cloned PositionNormalTextureVertex
  73602. */
  73603. PositionNormalTextureVertex.prototype.clone = function () {
  73604. return new PositionNormalTextureVertex(this.position.clone(), this.normal.clone(), this.uv.clone());
  73605. };
  73606. return PositionNormalTextureVertex;
  73607. }());
  73608. // Temporary pre-allocated objects for engine internal use
  73609. // usage in any internal function :
  73610. // var tmp = Tmp.Vector3[0]; <= gets access to the first pre-created Vector3
  73611. // There's a Tmp array per object type : int, float, Vector2, Vector3, Vector4, Quaternion, Matrix
  73612. /**
  73613. * @hidden
  73614. */
  73615. var Tmp = /** @class */ (function () {
  73616. function Tmp() {
  73617. }
  73618. Tmp.Color3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Color3.Black);
  73619. Tmp.Color4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, function () { return new Color4(0, 0, 0, 0); });
  73620. Tmp.Vector2 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector2.Zero); // 3 temp Vector2 at once should be enough
  73621. Tmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(13, Vector3.Zero); // 13 temp Vector3 at once should be enough
  73622. Tmp.Vector4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector4.Zero); // 3 temp Vector4 at once should be enough
  73623. Tmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Quaternion.Zero); // 2 temp Quaternion at once should be enough
  73624. Tmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, Matrix.Identity); // 8 temp Matrices at once should be enough
  73625. return Tmp;
  73626. }());
  73627. /**
  73628. * @hidden
  73629. * Same as Tmp but not exported to keep it only for math functions to avoid conflicts
  73630. */
  73631. var MathTmp = /** @class */ (function () {
  73632. function MathTmp() {
  73633. }
  73634. MathTmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, Vector3.Zero);
  73635. MathTmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Matrix.Identity);
  73636. MathTmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Quaternion.Zero);
  73637. return MathTmp;
  73638. }());
  73639. /***/ }),
  73640. /***/ "./Maths/sphericalPolynomial.ts":
  73641. /*!**************************************!*\
  73642. !*** ./Maths/sphericalPolynomial.ts ***!
  73643. \**************************************/
  73644. /*! exports provided: SphericalPolynomial, SphericalHarmonics */
  73645. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  73646. "use strict";
  73647. __webpack_require__.r(__webpack_exports__);
  73648. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return SphericalPolynomial; });
  73649. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return SphericalHarmonics; });
  73650. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  73651. /**
  73652. * Class representing spherical polynomial coefficients to the 3rd degree
  73653. */
  73654. var SphericalPolynomial = /** @class */ (function () {
  73655. function SphericalPolynomial() {
  73656. /**
  73657. * The x coefficients of the spherical polynomial
  73658. */
  73659. this.x = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73660. /**
  73661. * The y coefficients of the spherical polynomial
  73662. */
  73663. this.y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73664. /**
  73665. * The z coefficients of the spherical polynomial
  73666. */
  73667. this.z = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73668. /**
  73669. * The xx coefficients of the spherical polynomial
  73670. */
  73671. this.xx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73672. /**
  73673. * The yy coefficients of the spherical polynomial
  73674. */
  73675. this.yy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73676. /**
  73677. * The zz coefficients of the spherical polynomial
  73678. */
  73679. this.zz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73680. /**
  73681. * The xy coefficients of the spherical polynomial
  73682. */
  73683. this.xy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73684. /**
  73685. * The yz coefficients of the spherical polynomial
  73686. */
  73687. this.yz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73688. /**
  73689. * The zx coefficients of the spherical polynomial
  73690. */
  73691. this.zx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73692. }
  73693. /**
  73694. * Adds an ambient color to the spherical polynomial
  73695. * @param color the color to add
  73696. */
  73697. SphericalPolynomial.prototype.addAmbient = function (color) {
  73698. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  73699. this.xx = this.xx.add(colorVector);
  73700. this.yy = this.yy.add(colorVector);
  73701. this.zz = this.zz.add(colorVector);
  73702. };
  73703. /**
  73704. * Scales the spherical polynomial by the given amount
  73705. * @param scale the amount to scale
  73706. */
  73707. SphericalPolynomial.prototype.scale = function (scale) {
  73708. this.x = this.x.scale(scale);
  73709. this.y = this.y.scale(scale);
  73710. this.z = this.z.scale(scale);
  73711. this.xx = this.xx.scale(scale);
  73712. this.yy = this.yy.scale(scale);
  73713. this.zz = this.zz.scale(scale);
  73714. this.yz = this.yz.scale(scale);
  73715. this.zx = this.zx.scale(scale);
  73716. this.xy = this.xy.scale(scale);
  73717. };
  73718. /**
  73719. * Gets the spherical polynomial from harmonics
  73720. * @param harmonics the spherical harmonics
  73721. * @returns the spherical polynomial
  73722. */
  73723. SphericalPolynomial.FromHarmonics = function (harmonics) {
  73724. var result = new SphericalPolynomial();
  73725. result.x = harmonics.l11.scale(1.02333);
  73726. result.y = harmonics.l1_1.scale(1.02333);
  73727. result.z = harmonics.l10.scale(1.02333);
  73728. result.xx = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).add(harmonics.lL22.scale(0.429043));
  73729. result.yy = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).subtract(harmonics.lL22.scale(0.429043));
  73730. result.zz = harmonics.l00.scale(0.886277).add(harmonics.l20.scale(0.495417));
  73731. result.yz = harmonics.l2_1.scale(0.858086);
  73732. result.zx = harmonics.l21.scale(0.858086);
  73733. result.xy = harmonics.l2_2.scale(0.858086);
  73734. result.scale(1.0 / Math.PI);
  73735. return result;
  73736. };
  73737. /**
  73738. * Constructs a spherical polynomial from an array.
  73739. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  73740. * @returns the spherical polynomial
  73741. */
  73742. SphericalPolynomial.FromArray = function (data) {
  73743. var sp = new SphericalPolynomial();
  73744. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sp.x);
  73745. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sp.y);
  73746. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sp.z);
  73747. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sp.xx);
  73748. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sp.yy);
  73749. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sp.zz);
  73750. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sp.yz);
  73751. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sp.zx);
  73752. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sp.xy);
  73753. return sp;
  73754. };
  73755. return SphericalPolynomial;
  73756. }());
  73757. /**
  73758. * Class representing spherical harmonics coefficients to the 3rd degree
  73759. */
  73760. var SphericalHarmonics = /** @class */ (function () {
  73761. function SphericalHarmonics() {
  73762. /**
  73763. * The l0,0 coefficients of the spherical harmonics
  73764. */
  73765. this.l00 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73766. /**
  73767. * The l1,-1 coefficients of the spherical harmonics
  73768. */
  73769. this.l1_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73770. /**
  73771. * The l1,0 coefficients of the spherical harmonics
  73772. */
  73773. this.l10 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73774. /**
  73775. * The l1,1 coefficients of the spherical harmonics
  73776. */
  73777. this.l11 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73778. /**
  73779. * The l2,-2 coefficients of the spherical harmonics
  73780. */
  73781. this.l2_2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73782. /**
  73783. * The l2,-1 coefficients of the spherical harmonics
  73784. */
  73785. this.l2_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73786. /**
  73787. * The l2,0 coefficients of the spherical harmonics
  73788. */
  73789. this.l20 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73790. /**
  73791. * The l2,1 coefficients of the spherical harmonics
  73792. */
  73793. this.l21 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73794. /**
  73795. * The l2,2 coefficients of the spherical harmonics
  73796. */
  73797. this.lL22 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  73798. }
  73799. /**
  73800. * Adds a light to the spherical harmonics
  73801. * @param direction the direction of the light
  73802. * @param color the color of the light
  73803. * @param deltaSolidAngle the delta solid angle of the light
  73804. */
  73805. SphericalHarmonics.prototype.addLight = function (direction, color, deltaSolidAngle) {
  73806. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  73807. var c = colorVector.scale(deltaSolidAngle);
  73808. this.l00 = this.l00.add(c.scale(0.282095));
  73809. this.l1_1 = this.l1_1.add(c.scale(0.488603 * direction.y));
  73810. this.l10 = this.l10.add(c.scale(0.488603 * direction.z));
  73811. this.l11 = this.l11.add(c.scale(0.488603 * direction.x));
  73812. this.l2_2 = this.l2_2.add(c.scale(1.092548 * direction.x * direction.y));
  73813. this.l2_1 = this.l2_1.add(c.scale(1.092548 * direction.y * direction.z));
  73814. this.l21 = this.l21.add(c.scale(1.092548 * direction.x * direction.z));
  73815. this.l20 = this.l20.add(c.scale(0.315392 * (3.0 * direction.z * direction.z - 1.0)));
  73816. this.lL22 = this.lL22.add(c.scale(0.546274 * (direction.x * direction.x - direction.y * direction.y)));
  73817. };
  73818. /**
  73819. * Scales the spherical harmonics by the given amount
  73820. * @param scale the amount to scale
  73821. */
  73822. SphericalHarmonics.prototype.scale = function (scale) {
  73823. this.l00 = this.l00.scale(scale);
  73824. this.l1_1 = this.l1_1.scale(scale);
  73825. this.l10 = this.l10.scale(scale);
  73826. this.l11 = this.l11.scale(scale);
  73827. this.l2_2 = this.l2_2.scale(scale);
  73828. this.l2_1 = this.l2_1.scale(scale);
  73829. this.l20 = this.l20.scale(scale);
  73830. this.l21 = this.l21.scale(scale);
  73831. this.lL22 = this.lL22.scale(scale);
  73832. };
  73833. /**
  73834. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  73835. *
  73836. * ```
  73837. * E_lm = A_l * L_lm
  73838. * ```
  73839. *
  73840. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  73841. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  73842. * the scaling factors are given in equation 9.
  73843. */
  73844. SphericalHarmonics.prototype.convertIncidentRadianceToIrradiance = function () {
  73845. // Constant (Band 0)
  73846. this.l00 = this.l00.scale(3.141593);
  73847. // Linear (Band 1)
  73848. this.l1_1 = this.l1_1.scale(2.094395);
  73849. this.l10 = this.l10.scale(2.094395);
  73850. this.l11 = this.l11.scale(2.094395);
  73851. // Quadratic (Band 2)
  73852. this.l2_2 = this.l2_2.scale(0.785398);
  73853. this.l2_1 = this.l2_1.scale(0.785398);
  73854. this.l20 = this.l20.scale(0.785398);
  73855. this.l21 = this.l21.scale(0.785398);
  73856. this.lL22 = this.lL22.scale(0.785398);
  73857. };
  73858. /**
  73859. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  73860. *
  73861. * ```
  73862. * L = (1/pi) * E * rho
  73863. * ```
  73864. *
  73865. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  73866. */
  73867. SphericalHarmonics.prototype.convertIrradianceToLambertianRadiance = function () {
  73868. this.scale(1.0 / Math.PI);
  73869. // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied
  73870. // (The pixel shader must apply albedo after texture fetches, etc).
  73871. };
  73872. /**
  73873. * Gets the spherical harmonics from polynomial
  73874. * @param polynomial the spherical polynomial
  73875. * @returns the spherical harmonics
  73876. */
  73877. SphericalHarmonics.FromPolynomial = function (polynomial) {
  73878. var result = new SphericalHarmonics();
  73879. result.l00 = polynomial.xx.scale(0.376127).add(polynomial.yy.scale(0.376127)).add(polynomial.zz.scale(0.376126));
  73880. result.l1_1 = polynomial.y.scale(0.977204);
  73881. result.l10 = polynomial.z.scale(0.977204);
  73882. result.l11 = polynomial.x.scale(0.977204);
  73883. result.l2_2 = polynomial.xy.scale(1.16538);
  73884. result.l2_1 = polynomial.yz.scale(1.16538);
  73885. result.l20 = polynomial.zz.scale(1.34567).subtract(polynomial.xx.scale(0.672834)).subtract(polynomial.yy.scale(0.672834));
  73886. result.l21 = polynomial.zx.scale(1.16538);
  73887. result.lL22 = polynomial.xx.scale(1.16538).subtract(polynomial.yy.scale(1.16538));
  73888. result.scale(Math.PI);
  73889. return result;
  73890. };
  73891. /**
  73892. * Constructs a spherical harmonics from an array.
  73893. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  73894. * @returns the spherical harmonics
  73895. */
  73896. SphericalHarmonics.FromArray = function (data) {
  73897. var sh = new SphericalHarmonics();
  73898. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sh.l00);
  73899. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sh.l1_1);
  73900. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sh.l10);
  73901. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sh.l11);
  73902. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sh.l2_2);
  73903. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sh.l2_1);
  73904. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sh.l20);
  73905. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sh.l21);
  73906. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sh.lL22);
  73907. return sh;
  73908. };
  73909. return SphericalHarmonics;
  73910. }());
  73911. /***/ }),
  73912. /***/ "./Meshes/Compression/dracoCompression.ts":
  73913. /*!************************************************!*\
  73914. !*** ./Meshes/Compression/dracoCompression.ts ***!
  73915. \************************************************/
  73916. /*! exports provided: DracoCompression */
  73917. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  73918. "use strict";
  73919. __webpack_require__.r(__webpack_exports__);
  73920. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return DracoCompression; });
  73921. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  73922. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  73923. /**
  73924. * Draco compression (https://google.github.io/draco/)
  73925. *
  73926. * This class wraps the Draco module.
  73927. *
  73928. * **Encoder**
  73929. *
  73930. * The encoder is not currently implemented.
  73931. *
  73932. * **Decoder**
  73933. *
  73934. * 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.
  73935. *
  73936. * To update the configuration, use the following code:
  73937. * ```javascript
  73938. * DracoCompression.Configuration = {
  73939. * decoder: {
  73940. * wasmUrl: "<url to the WebAssembly library>",
  73941. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  73942. * fallbackUrl: "<url to the fallback JavaScript library>",
  73943. * }
  73944. * };
  73945. * ```
  73946. *
  73947. * 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.
  73948. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  73949. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  73950. *
  73951. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  73952. * ```javascript
  73953. * var dracoCompression = new DracoCompression();
  73954. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  73955. * [VertexBuffer.PositionKind]: 0
  73956. * });
  73957. * ```
  73958. *
  73959. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  73960. */
  73961. var DracoCompression = /** @class */ (function () {
  73962. /**
  73963. * Constructor
  73964. */
  73965. function DracoCompression() {
  73966. }
  73967. Object.defineProperty(DracoCompression, "DecoderAvailable", {
  73968. /**
  73969. * Returns true if the decoder is available.
  73970. */
  73971. get: function () {
  73972. if (typeof DracoDecoderModule !== "undefined") {
  73973. return true;
  73974. }
  73975. var decoder = DracoCompression.Configuration.decoder;
  73976. if (decoder) {
  73977. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  73978. return true;
  73979. }
  73980. if (decoder.fallbackUrl) {
  73981. return true;
  73982. }
  73983. }
  73984. return false;
  73985. },
  73986. enumerable: true,
  73987. configurable: true
  73988. });
  73989. /**
  73990. * Stop all async operations and release resources.
  73991. */
  73992. DracoCompression.prototype.dispose = function () {
  73993. };
  73994. /**
  73995. * Decode Draco compressed mesh data to vertex data.
  73996. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  73997. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  73998. * @returns A promise that resolves with the decoded vertex data
  73999. */
  74000. DracoCompression.prototype.decodeMeshAsync = function (data, attributes) {
  74001. var dataView = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
  74002. return DracoCompression._GetDecoderModule().then(function (wrappedModule) {
  74003. var module = wrappedModule.module;
  74004. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  74005. var buffer = new module.DecoderBuffer();
  74006. buffer.Init(dataView, dataView.byteLength);
  74007. var decoder = new module.Decoder();
  74008. var geometry;
  74009. var status;
  74010. try {
  74011. var type = decoder.GetEncodedGeometryType(buffer);
  74012. switch (type) {
  74013. case module.TRIANGULAR_MESH:
  74014. geometry = new module.Mesh();
  74015. status = decoder.DecodeBufferToMesh(buffer, geometry);
  74016. break;
  74017. case module.POINT_CLOUD:
  74018. geometry = new module.PointCloud();
  74019. status = decoder.DecodeBufferToPointCloud(buffer, geometry);
  74020. break;
  74021. default:
  74022. throw new Error("Invalid geometry type " + type);
  74023. }
  74024. if (!status.ok() || !geometry.ptr) {
  74025. throw new Error(status.error_msg());
  74026. }
  74027. var numPoints = geometry.num_points();
  74028. if (type === module.TRIANGULAR_MESH) {
  74029. var numFaces = geometry.num_faces();
  74030. var faceIndices = new module.DracoInt32Array();
  74031. try {
  74032. var indices = new Uint32Array(numFaces * 3);
  74033. for (var i = 0; i < numFaces; i++) {
  74034. decoder.GetFaceFromMesh(geometry, i, faceIndices);
  74035. var offset = i * 3;
  74036. indices[offset + 0] = faceIndices.GetValue(0);
  74037. indices[offset + 1] = faceIndices.GetValue(1);
  74038. indices[offset + 2] = faceIndices.GetValue(2);
  74039. }
  74040. vertexData.indices = indices;
  74041. }
  74042. finally {
  74043. module.destroy(faceIndices);
  74044. }
  74045. }
  74046. for (var kind in attributes) {
  74047. var uniqueId = attributes[kind];
  74048. var attribute = decoder.GetAttributeByUniqueId(geometry, uniqueId);
  74049. var dracoData = new module.DracoFloat32Array();
  74050. try {
  74051. decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
  74052. var babylonData = new Float32Array(numPoints * attribute.num_components());
  74053. for (var i = 0; i < babylonData.length; i++) {
  74054. babylonData[i] = dracoData.GetValue(i);
  74055. }
  74056. vertexData.set(babylonData, kind);
  74057. }
  74058. finally {
  74059. module.destroy(dracoData);
  74060. }
  74061. }
  74062. }
  74063. finally {
  74064. if (geometry) {
  74065. module.destroy(geometry);
  74066. }
  74067. module.destroy(decoder);
  74068. module.destroy(buffer);
  74069. }
  74070. return vertexData;
  74071. });
  74072. };
  74073. DracoCompression._GetDecoderModule = function () {
  74074. if (!DracoCompression._DecoderModulePromise) {
  74075. var promise = null;
  74076. var config_1 = {};
  74077. if (typeof DracoDecoderModule !== "undefined") {
  74078. promise = Promise.resolve();
  74079. }
  74080. else {
  74081. var decoder = DracoCompression.Configuration.decoder;
  74082. if (decoder) {
  74083. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  74084. promise = Promise.all([
  74085. DracoCompression._LoadScriptAsync(decoder.wasmUrl),
  74086. DracoCompression._LoadFileAsync(decoder.wasmBinaryUrl).then(function (data) {
  74087. config_1.wasmBinary = data;
  74088. })
  74089. ]);
  74090. }
  74091. else if (decoder.fallbackUrl) {
  74092. promise = DracoCompression._LoadScriptAsync(decoder.fallbackUrl);
  74093. }
  74094. }
  74095. }
  74096. if (!promise) {
  74097. throw new Error("Draco decoder module is not available");
  74098. }
  74099. DracoCompression._DecoderModulePromise = promise.then(function () {
  74100. return new Promise(function (resolve) {
  74101. config_1.onModuleLoaded = function (decoderModule) {
  74102. // decoderModule is Promise-like. Wrap before resolving to avoid loop.
  74103. resolve({ module: decoderModule });
  74104. };
  74105. DracoDecoderModule(config_1);
  74106. });
  74107. });
  74108. }
  74109. return DracoCompression._DecoderModulePromise;
  74110. };
  74111. DracoCompression._LoadScriptAsync = function (url) {
  74112. return new Promise(function (resolve, reject) {
  74113. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadScript(url, function () {
  74114. resolve();
  74115. }, function (message) {
  74116. reject(new Error(message));
  74117. });
  74118. });
  74119. };
  74120. DracoCompression._LoadFileAsync = function (url) {
  74121. return new Promise(function (resolve, reject) {
  74122. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(url, function (data) {
  74123. resolve(data);
  74124. }, undefined, undefined, true, function (request, exception) {
  74125. reject(exception);
  74126. });
  74127. });
  74128. };
  74129. /**
  74130. * The configuration. Defaults to the following urls:
  74131. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  74132. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  74133. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  74134. */
  74135. DracoCompression.Configuration = {
  74136. decoder: {
  74137. wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
  74138. wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
  74139. fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  74140. }
  74141. };
  74142. return DracoCompression;
  74143. }());
  74144. /***/ }),
  74145. /***/ "./Meshes/Compression/index.ts":
  74146. /*!*************************************!*\
  74147. !*** ./Meshes/Compression/index.ts ***!
  74148. \*************************************/
  74149. /*! exports provided: DracoCompression */
  74150. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74151. "use strict";
  74152. __webpack_require__.r(__webpack_exports__);
  74153. /* harmony import */ var _dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dracoCompression */ "./Meshes/Compression/dracoCompression.ts");
  74154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _dracoCompression__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  74155. /***/ }),
  74156. /***/ "./Meshes/abstractMesh.ts":
  74157. /*!********************************!*\
  74158. !*** ./Meshes/abstractMesh.ts ***!
  74159. \********************************/
  74160. /*! exports provided: AbstractMesh */
  74161. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74162. "use strict";
  74163. __webpack_require__.r(__webpack_exports__);
  74164. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return AbstractMesh; });
  74165. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  74166. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  74167. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  74168. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  74169. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  74170. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  74171. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  74172. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  74173. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  74174. /* harmony import */ var _Collisions_collider__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Collisions/collider */ "./Collisions/collider.ts");
  74175. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  74176. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  74177. /** @hidden */
  74178. var _FacetDataStorage = /** @class */ (function () {
  74179. function _FacetDataStorage() {
  74180. this.facetNb = 0; // facet number
  74181. this.partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space
  74182. this.partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
  74183. this.facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
  74184. this.facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
  74185. this.bbSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(); // bbox size approximated for facet data
  74186. this.subDiv = {
  74187. max: 1,
  74188. X: 1,
  74189. Y: 1,
  74190. Z: 1
  74191. };
  74192. this.facetDepthSort = false; // is the facet depth sort to be computed
  74193. this.facetDepthSortEnabled = false; // is the facet depth sort initialized
  74194. }
  74195. return _FacetDataStorage;
  74196. }());
  74197. /**
  74198. * Class used to store all common mesh properties
  74199. */
  74200. var AbstractMesh = /** @class */ (function (_super) {
  74201. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractMesh, _super);
  74202. // Constructor
  74203. /**
  74204. * Creates a new AbstractMesh
  74205. * @param name defines the name of the mesh
  74206. * @param scene defines the hosting scene
  74207. */
  74208. function AbstractMesh(name, scene) {
  74209. if (scene === void 0) { scene = null; }
  74210. var _this = _super.call(this, name, scene, false) || this;
  74211. _this._facetData = new _FacetDataStorage();
  74212. /**
  74213. * The culling strategy to use to check whether the mesh must be rendered or not.
  74214. * This value can be changed at any time and will be used on the next render mesh selection.
  74215. * The possible values are :
  74216. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  74217. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  74218. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  74219. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  74220. * Please read each static variable documentation to get details about the culling process.
  74221. * */
  74222. _this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
  74223. // Events
  74224. /**
  74225. * An event triggered when this mesh collides with another one
  74226. */
  74227. _this.onCollideObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  74228. /**
  74229. * An event triggered when the collision's position changes
  74230. */
  74231. _this.onCollisionPositionChangeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  74232. /**
  74233. * An event triggered when material is changed
  74234. */
  74235. _this.onMaterialChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  74236. // Properties
  74237. /**
  74238. * Gets or sets the orientation for POV movement & rotation
  74239. */
  74240. _this.definedFacingForward = true;
  74241. _this._visibility = 1.0;
  74242. /** Gets or sets the alpha index used to sort transparent meshes
  74243. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  74244. */
  74245. _this.alphaIndex = Number.MAX_VALUE;
  74246. /**
  74247. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  74248. */
  74249. _this.isVisible = true;
  74250. /**
  74251. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  74252. */
  74253. _this.isPickable = true;
  74254. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  74255. _this.showSubMeshesBoundingBox = false;
  74256. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  74257. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  74258. */
  74259. _this.isBlocker = false;
  74260. /**
  74261. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  74262. */
  74263. _this.enablePointerMoveEvents = false;
  74264. /**
  74265. * Specifies the rendering group id for this mesh (0 by default)
  74266. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  74267. */
  74268. _this.renderingGroupId = 0;
  74269. _this._receiveShadows = false;
  74270. /** Defines color to use when rendering outline */
  74271. _this.outlineColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  74272. /** Define width to use when rendering outline */
  74273. _this.outlineWidth = 0.02;
  74274. /** Defines color to use when rendering overlay */
  74275. _this.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  74276. /** Defines alpha to use when rendering overlay */
  74277. _this.overlayAlpha = 0.5;
  74278. _this._hasVertexAlpha = false;
  74279. _this._useVertexColors = true;
  74280. _this._computeBonesUsingShaders = true;
  74281. _this._numBoneInfluencers = 4;
  74282. _this._applyFog = true;
  74283. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  74284. _this.useOctreeForRenderingSelection = true;
  74285. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  74286. _this.useOctreeForPicking = true;
  74287. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  74288. _this.useOctreeForCollisions = true;
  74289. _this._layerMask = 0x0FFFFFFF;
  74290. /**
  74291. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  74292. */
  74293. _this.alwaysSelectAsActiveMesh = false;
  74294. /**
  74295. * Gets or sets the current action manager
  74296. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74297. */
  74298. _this.actionManager = null;
  74299. // Collisions
  74300. _this._checkCollisions = false;
  74301. _this._collisionMask = -1;
  74302. _this._collisionGroup = -1;
  74303. /**
  74304. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  74305. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  74306. */
  74307. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 1, 0.5);
  74308. /**
  74309. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  74310. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  74311. */
  74312. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  74313. _this._oldPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  74314. _this._diffPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  74315. // Edges
  74316. /**
  74317. * Defines edge width used when edgesRenderer is enabled
  74318. * @see https://www.babylonjs-playground.com/#10OJSG#13
  74319. */
  74320. _this.edgesWidth = 1;
  74321. /**
  74322. * Defines edge color used when edgesRenderer is enabled
  74323. * @see https://www.babylonjs-playground.com/#10OJSG#13
  74324. */
  74325. _this.edgesColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](1, 0, 0, 1);
  74326. /** @hidden */
  74327. _this._renderId = 0;
  74328. /** @hidden */
  74329. _this._intersectionsInProgress = new Array();
  74330. /** @hidden */
  74331. _this._unIndexed = false;
  74332. /** @hidden */
  74333. _this._lightSources = new Array();
  74334. /**
  74335. * An event triggered when the mesh is rebuilt.
  74336. */
  74337. _this.onRebuildObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  74338. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  74339. if (collidedMesh === void 0) { collidedMesh = null; }
  74340. newPosition.subtractToRef(_this._oldPositionForCollisions, _this._diffPositionForCollisions);
  74341. if (_this._diffPositionForCollisions.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].CollisionsEpsilon) {
  74342. _this.position.addInPlace(_this._diffPositionForCollisions);
  74343. }
  74344. if (collidedMesh) {
  74345. _this.onCollideObservable.notifyObservers(collidedMesh);
  74346. }
  74347. _this.onCollisionPositionChangeObservable.notifyObservers(_this.position);
  74348. };
  74349. _this.getScene().addMesh(_this);
  74350. _this._resyncLightSources();
  74351. return _this;
  74352. }
  74353. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_NONE", {
  74354. /**
  74355. * No billboard
  74356. */
  74357. get: function () {
  74358. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE;
  74359. },
  74360. enumerable: true,
  74361. configurable: true
  74362. });
  74363. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_X", {
  74364. /** Billboard on X axis */
  74365. get: function () {
  74366. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_X;
  74367. },
  74368. enumerable: true,
  74369. configurable: true
  74370. });
  74371. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Y", {
  74372. /** Billboard on Y axis */
  74373. get: function () {
  74374. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Y;
  74375. },
  74376. enumerable: true,
  74377. configurable: true
  74378. });
  74379. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Z", {
  74380. /** Billboard on Z axis */
  74381. get: function () {
  74382. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Z;
  74383. },
  74384. enumerable: true,
  74385. configurable: true
  74386. });
  74387. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_ALL", {
  74388. /** Billboard on all axes */
  74389. get: function () {
  74390. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_ALL;
  74391. },
  74392. enumerable: true,
  74393. configurable: true
  74394. });
  74395. Object.defineProperty(AbstractMesh.prototype, "facetNb", {
  74396. /**
  74397. * Gets the number of facets in the mesh
  74398. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  74399. */
  74400. get: function () {
  74401. return this._facetData.facetNb;
  74402. },
  74403. enumerable: true,
  74404. configurable: true
  74405. });
  74406. Object.defineProperty(AbstractMesh.prototype, "partitioningSubdivisions", {
  74407. /**
  74408. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  74409. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  74410. */
  74411. get: function () {
  74412. return this._facetData.partitioningSubdivisions;
  74413. },
  74414. set: function (nb) {
  74415. this._facetData.partitioningSubdivisions = nb;
  74416. },
  74417. enumerable: true,
  74418. configurable: true
  74419. });
  74420. Object.defineProperty(AbstractMesh.prototype, "partitioningBBoxRatio", {
  74421. /**
  74422. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  74423. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  74424. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  74425. */
  74426. get: function () {
  74427. return this._facetData.partitioningBBoxRatio;
  74428. },
  74429. set: function (ratio) {
  74430. this._facetData.partitioningBBoxRatio = ratio;
  74431. },
  74432. enumerable: true,
  74433. configurable: true
  74434. });
  74435. Object.defineProperty(AbstractMesh.prototype, "mustDepthSortFacets", {
  74436. /**
  74437. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  74438. * Works only for updatable meshes.
  74439. * Doesn't work with multi-materials
  74440. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  74441. */
  74442. get: function () {
  74443. return this._facetData.facetDepthSort;
  74444. },
  74445. set: function (sort) {
  74446. this._facetData.facetDepthSort = sort;
  74447. },
  74448. enumerable: true,
  74449. configurable: true
  74450. });
  74451. Object.defineProperty(AbstractMesh.prototype, "facetDepthSortFrom", {
  74452. /**
  74453. * The location (Vector3) where the facet depth sort must be computed from.
  74454. * By default, the active camera position.
  74455. * Used only when facet depth sort is enabled
  74456. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  74457. */
  74458. get: function () {
  74459. return this._facetData.facetDepthSortFrom;
  74460. },
  74461. set: function (location) {
  74462. this._facetData.facetDepthSortFrom = location;
  74463. },
  74464. enumerable: true,
  74465. configurable: true
  74466. });
  74467. Object.defineProperty(AbstractMesh.prototype, "isFacetDataEnabled", {
  74468. /**
  74469. * gets a boolean indicating if facetData is enabled
  74470. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  74471. */
  74472. get: function () {
  74473. return this._facetData.facetDataEnabled;
  74474. },
  74475. enumerable: true,
  74476. configurable: true
  74477. });
  74478. /** @hidden */
  74479. AbstractMesh.prototype._updateNonUniformScalingState = function (value) {
  74480. if (!_super.prototype._updateNonUniformScalingState.call(this, value)) {
  74481. return false;
  74482. }
  74483. this._markSubMeshesAsMiscDirty();
  74484. return true;
  74485. };
  74486. Object.defineProperty(AbstractMesh.prototype, "onCollide", {
  74487. /** Set a function to call when this mesh collides with another one */
  74488. set: function (callback) {
  74489. if (this._onCollideObserver) {
  74490. this.onCollideObservable.remove(this._onCollideObserver);
  74491. }
  74492. this._onCollideObserver = this.onCollideObservable.add(callback);
  74493. },
  74494. enumerable: true,
  74495. configurable: true
  74496. });
  74497. Object.defineProperty(AbstractMesh.prototype, "onCollisionPositionChange", {
  74498. /** Set a function to call when the collision's position changes */
  74499. set: function (callback) {
  74500. if (this._onCollisionPositionChangeObserver) {
  74501. this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver);
  74502. }
  74503. this._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(callback);
  74504. },
  74505. enumerable: true,
  74506. configurable: true
  74507. });
  74508. Object.defineProperty(AbstractMesh.prototype, "visibility", {
  74509. /**
  74510. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  74511. */
  74512. get: function () {
  74513. return this._visibility;
  74514. },
  74515. /**
  74516. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  74517. */
  74518. set: function (value) {
  74519. if (this._visibility === value) {
  74520. return;
  74521. }
  74522. this._visibility = value;
  74523. this._markSubMeshesAsMiscDirty();
  74524. },
  74525. enumerable: true,
  74526. configurable: true
  74527. });
  74528. Object.defineProperty(AbstractMesh.prototype, "material", {
  74529. /** Gets or sets current material */
  74530. get: function () {
  74531. return this._material;
  74532. },
  74533. set: function (value) {
  74534. if (this._material === value) {
  74535. return;
  74536. }
  74537. // remove from material mesh map id needed
  74538. if (this._material && this._material.meshMap) {
  74539. this._material.meshMap[this.uniqueId] = undefined;
  74540. }
  74541. this._material = value;
  74542. if (value && value.meshMap) {
  74543. value.meshMap[this.uniqueId] = this;
  74544. }
  74545. if (this.onMaterialChangedObservable.hasObservers) {
  74546. this.onMaterialChangedObservable.notifyObservers(this);
  74547. }
  74548. if (!this.subMeshes) {
  74549. return;
  74550. }
  74551. this._unBindEffect();
  74552. },
  74553. enumerable: true,
  74554. configurable: true
  74555. });
  74556. Object.defineProperty(AbstractMesh.prototype, "receiveShadows", {
  74557. /**
  74558. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  74559. * @see http://doc.babylonjs.com/babylon101/shadows
  74560. */
  74561. get: function () {
  74562. return this._receiveShadows;
  74563. },
  74564. set: function (value) {
  74565. if (this._receiveShadows === value) {
  74566. return;
  74567. }
  74568. this._receiveShadows = value;
  74569. this._markSubMeshesAsLightDirty();
  74570. },
  74571. enumerable: true,
  74572. configurable: true
  74573. });
  74574. Object.defineProperty(AbstractMesh.prototype, "hasVertexAlpha", {
  74575. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  74576. get: function () {
  74577. return this._hasVertexAlpha;
  74578. },
  74579. set: function (value) {
  74580. if (this._hasVertexAlpha === value) {
  74581. return;
  74582. }
  74583. this._hasVertexAlpha = value;
  74584. this._markSubMeshesAsAttributesDirty();
  74585. this._markSubMeshesAsMiscDirty();
  74586. },
  74587. enumerable: true,
  74588. configurable: true
  74589. });
  74590. Object.defineProperty(AbstractMesh.prototype, "useVertexColors", {
  74591. /** 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) */
  74592. get: function () {
  74593. return this._useVertexColors;
  74594. },
  74595. set: function (value) {
  74596. if (this._useVertexColors === value) {
  74597. return;
  74598. }
  74599. this._useVertexColors = value;
  74600. this._markSubMeshesAsAttributesDirty();
  74601. },
  74602. enumerable: true,
  74603. configurable: true
  74604. });
  74605. Object.defineProperty(AbstractMesh.prototype, "computeBonesUsingShaders", {
  74606. /**
  74607. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  74608. */
  74609. get: function () {
  74610. return this._computeBonesUsingShaders;
  74611. },
  74612. set: function (value) {
  74613. if (this._computeBonesUsingShaders === value) {
  74614. return;
  74615. }
  74616. this._computeBonesUsingShaders = value;
  74617. this._markSubMeshesAsAttributesDirty();
  74618. },
  74619. enumerable: true,
  74620. configurable: true
  74621. });
  74622. Object.defineProperty(AbstractMesh.prototype, "numBoneInfluencers", {
  74623. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  74624. get: function () {
  74625. return this._numBoneInfluencers;
  74626. },
  74627. set: function (value) {
  74628. if (this._numBoneInfluencers === value) {
  74629. return;
  74630. }
  74631. this._numBoneInfluencers = value;
  74632. this._markSubMeshesAsAttributesDirty();
  74633. },
  74634. enumerable: true,
  74635. configurable: true
  74636. });
  74637. Object.defineProperty(AbstractMesh.prototype, "applyFog", {
  74638. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  74639. get: function () {
  74640. return this._applyFog;
  74641. },
  74642. set: function (value) {
  74643. if (this._applyFog === value) {
  74644. return;
  74645. }
  74646. this._applyFog = value;
  74647. this._markSubMeshesAsMiscDirty();
  74648. },
  74649. enumerable: true,
  74650. configurable: true
  74651. });
  74652. Object.defineProperty(AbstractMesh.prototype, "layerMask", {
  74653. /**
  74654. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  74655. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  74656. */
  74657. get: function () {
  74658. return this._layerMask;
  74659. },
  74660. set: function (value) {
  74661. if (value === this._layerMask) {
  74662. return;
  74663. }
  74664. this._layerMask = value;
  74665. this._resyncLightSources();
  74666. },
  74667. enumerable: true,
  74668. configurable: true
  74669. });
  74670. Object.defineProperty(AbstractMesh.prototype, "collisionMask", {
  74671. /**
  74672. * Gets or sets a collision mask used to mask collisions (default is -1).
  74673. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  74674. */
  74675. get: function () {
  74676. return this._collisionMask;
  74677. },
  74678. set: function (mask) {
  74679. this._collisionMask = !isNaN(mask) ? mask : -1;
  74680. },
  74681. enumerable: true,
  74682. configurable: true
  74683. });
  74684. Object.defineProperty(AbstractMesh.prototype, "collisionGroup", {
  74685. /**
  74686. * Gets or sets the current collision group mask (-1 by default).
  74687. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  74688. */
  74689. get: function () {
  74690. return this._collisionGroup;
  74691. },
  74692. set: function (mask) {
  74693. this._collisionGroup = !isNaN(mask) ? mask : -1;
  74694. },
  74695. enumerable: true,
  74696. configurable: true
  74697. });
  74698. Object.defineProperty(AbstractMesh.prototype, "_positions", {
  74699. /** @hidden */
  74700. get: function () {
  74701. return null;
  74702. },
  74703. enumerable: true,
  74704. configurable: true
  74705. });
  74706. Object.defineProperty(AbstractMesh.prototype, "skeleton", {
  74707. get: function () {
  74708. return this._skeleton;
  74709. },
  74710. /**
  74711. * Gets or sets a skeleton to apply skining transformations
  74712. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  74713. */
  74714. set: function (value) {
  74715. if (this._skeleton && this._skeleton.needInitialSkinMatrix) {
  74716. this._skeleton._unregisterMeshWithPoseMatrix(this);
  74717. }
  74718. if (value && value.needInitialSkinMatrix) {
  74719. value._registerMeshWithPoseMatrix(this);
  74720. }
  74721. this._skeleton = value;
  74722. if (!this._skeleton) {
  74723. this._bonesTransformMatrices = null;
  74724. }
  74725. this._markSubMeshesAsAttributesDirty();
  74726. },
  74727. enumerable: true,
  74728. configurable: true
  74729. });
  74730. /**
  74731. * Returns the string "AbstractMesh"
  74732. * @returns "AbstractMesh"
  74733. */
  74734. AbstractMesh.prototype.getClassName = function () {
  74735. return "AbstractMesh";
  74736. };
  74737. /**
  74738. * Gets a string representation of the current mesh
  74739. * @param fullDetails defines a boolean indicating if full details must be included
  74740. * @returns a string representation of the current mesh
  74741. */
  74742. AbstractMesh.prototype.toString = function (fullDetails) {
  74743. var ret = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
  74744. ret += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
  74745. if (this._skeleton) {
  74746. ret += ", skeleton: " + this._skeleton.name;
  74747. }
  74748. if (fullDetails) {
  74749. ret += ", billboard mode: " + (["NONE", "X", "Y", null, "Z", null, null, "ALL"])[this.billboardMode];
  74750. ret += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingFreezeWorldMatrix ? "YES" : "NO");
  74751. }
  74752. return ret;
  74753. };
  74754. /** @hidden */
  74755. AbstractMesh.prototype._rebuild = function () {
  74756. this.onRebuildObservable.notifyObservers(this);
  74757. if (this._occlusionQuery) {
  74758. this._occlusionQuery = null;
  74759. }
  74760. if (!this.subMeshes) {
  74761. return;
  74762. }
  74763. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  74764. var subMesh = _a[_i];
  74765. subMesh._rebuild();
  74766. }
  74767. };
  74768. /** @hidden */
  74769. AbstractMesh.prototype._resyncLightSources = function () {
  74770. this._lightSources.length = 0;
  74771. for (var _i = 0, _a = this.getScene().lights; _i < _a.length; _i++) {
  74772. var light = _a[_i];
  74773. if (!light.isEnabled()) {
  74774. continue;
  74775. }
  74776. if (light.canAffectMesh(this)) {
  74777. this._lightSources.push(light);
  74778. }
  74779. }
  74780. this._markSubMeshesAsLightDirty();
  74781. };
  74782. /** @hidden */
  74783. AbstractMesh.prototype._resyncLighSource = function (light) {
  74784. var isIn = light.isEnabled() && light.canAffectMesh(this);
  74785. var index = this._lightSources.indexOf(light);
  74786. if (index === -1) {
  74787. if (!isIn) {
  74788. return;
  74789. }
  74790. this._lightSources.push(light);
  74791. }
  74792. else {
  74793. if (isIn) {
  74794. return;
  74795. }
  74796. this._lightSources.splice(index, 1);
  74797. }
  74798. this._markSubMeshesAsLightDirty();
  74799. };
  74800. /** @hidden */
  74801. AbstractMesh.prototype._unBindEffect = function () {
  74802. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  74803. var subMesh = _a[_i];
  74804. subMesh.setEffect(null);
  74805. }
  74806. };
  74807. /** @hidden */
  74808. AbstractMesh.prototype._removeLightSource = function (light) {
  74809. var index = this._lightSources.indexOf(light);
  74810. if (index === -1) {
  74811. return;
  74812. }
  74813. this._lightSources.splice(index, 1);
  74814. this._markSubMeshesAsLightDirty();
  74815. };
  74816. AbstractMesh.prototype._markSubMeshesAsDirty = function (func) {
  74817. if (!this.subMeshes) {
  74818. return;
  74819. }
  74820. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  74821. var subMesh = _a[_i];
  74822. if (subMesh._materialDefines) {
  74823. func(subMesh._materialDefines);
  74824. }
  74825. }
  74826. };
  74827. /** @hidden */
  74828. AbstractMesh.prototype._markSubMeshesAsLightDirty = function () {
  74829. this._markSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
  74830. };
  74831. /** @hidden */
  74832. AbstractMesh.prototype._markSubMeshesAsAttributesDirty = function () {
  74833. this._markSubMeshesAsDirty(function (defines) { return defines.markAsAttributesDirty(); });
  74834. };
  74835. /** @hidden */
  74836. AbstractMesh.prototype._markSubMeshesAsMiscDirty = function () {
  74837. if (!this.subMeshes) {
  74838. return;
  74839. }
  74840. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  74841. var subMesh = _a[_i];
  74842. var material = subMesh.getMaterial();
  74843. if (material) {
  74844. material.markAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].MATERIAL_MiscDirtyFlag);
  74845. }
  74846. }
  74847. };
  74848. Object.defineProperty(AbstractMesh.prototype, "scaling", {
  74849. /**
  74850. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  74851. */
  74852. get: function () {
  74853. return this._scaling;
  74854. },
  74855. set: function (newScaling) {
  74856. this._scaling = newScaling;
  74857. if (this.physicsImpostor) {
  74858. this.physicsImpostor.forceUpdate();
  74859. }
  74860. },
  74861. enumerable: true,
  74862. configurable: true
  74863. });
  74864. Object.defineProperty(AbstractMesh.prototype, "isBlocked", {
  74865. // Methods
  74866. /**
  74867. * Returns true if the mesh is blocked. Implemented by child classes
  74868. */
  74869. get: function () {
  74870. return false;
  74871. },
  74872. enumerable: true,
  74873. configurable: true
  74874. });
  74875. /**
  74876. * Returns the mesh itself by default. Implemented by child classes
  74877. * @param camera defines the camera to use to pick the right LOD level
  74878. * @returns the currentAbstractMesh
  74879. */
  74880. AbstractMesh.prototype.getLOD = function (camera) {
  74881. return this;
  74882. };
  74883. /**
  74884. * Returns 0 by default. Implemented by child classes
  74885. * @returns an integer
  74886. */
  74887. AbstractMesh.prototype.getTotalVertices = function () {
  74888. return 0;
  74889. };
  74890. /**
  74891. * Returns a positive integer : the total number of indices in this mesh geometry.
  74892. * @returns the numner of indices or zero if the mesh has no geometry.
  74893. */
  74894. AbstractMesh.prototype.getTotalIndices = function () {
  74895. return 0;
  74896. };
  74897. /**
  74898. * Returns null by default. Implemented by child classes
  74899. * @returns null
  74900. */
  74901. AbstractMesh.prototype.getIndices = function () {
  74902. return null;
  74903. };
  74904. /**
  74905. * Returns the array of the requested vertex data kind. Implemented by child classes
  74906. * @param kind defines the vertex data kind to use
  74907. * @returns null
  74908. */
  74909. AbstractMesh.prototype.getVerticesData = function (kind) {
  74910. return null;
  74911. };
  74912. /**
  74913. * Sets the vertex data of the mesh geometry for the requested `kind`.
  74914. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  74915. * Note that a new underlying VertexBuffer object is created each call.
  74916. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  74917. * @param kind defines vertex data kind:
  74918. * * VertexBuffer.PositionKind
  74919. * * VertexBuffer.UVKind
  74920. * * VertexBuffer.UV2Kind
  74921. * * VertexBuffer.UV3Kind
  74922. * * VertexBuffer.UV4Kind
  74923. * * VertexBuffer.UV5Kind
  74924. * * VertexBuffer.UV6Kind
  74925. * * VertexBuffer.ColorKind
  74926. * * VertexBuffer.MatricesIndicesKind
  74927. * * VertexBuffer.MatricesIndicesExtraKind
  74928. * * VertexBuffer.MatricesWeightsKind
  74929. * * VertexBuffer.MatricesWeightsExtraKind
  74930. * @param data defines the data source
  74931. * @param updatable defines if the data must be flagged as updatable (or static)
  74932. * @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
  74933. * @returns the current mesh
  74934. */
  74935. AbstractMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  74936. return this;
  74937. };
  74938. /**
  74939. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  74940. * If the mesh has no geometry, it is simply returned as it is.
  74941. * @param kind defines vertex data kind:
  74942. * * VertexBuffer.PositionKind
  74943. * * VertexBuffer.UVKind
  74944. * * VertexBuffer.UV2Kind
  74945. * * VertexBuffer.UV3Kind
  74946. * * VertexBuffer.UV4Kind
  74947. * * VertexBuffer.UV5Kind
  74948. * * VertexBuffer.UV6Kind
  74949. * * VertexBuffer.ColorKind
  74950. * * VertexBuffer.MatricesIndicesKind
  74951. * * VertexBuffer.MatricesIndicesExtraKind
  74952. * * VertexBuffer.MatricesWeightsKind
  74953. * * VertexBuffer.MatricesWeightsExtraKind
  74954. * @param data defines the data source
  74955. * @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
  74956. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  74957. * @returns the current mesh
  74958. */
  74959. AbstractMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  74960. return this;
  74961. };
  74962. /**
  74963. * Sets the mesh indices,
  74964. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  74965. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  74966. * @param totalVertices Defines the total number of vertices
  74967. * @returns the current mesh
  74968. */
  74969. AbstractMesh.prototype.setIndices = function (indices, totalVertices) {
  74970. return this;
  74971. };
  74972. /**
  74973. * Gets a boolean indicating if specific vertex data is present
  74974. * @param kind defines the vertex data kind to use
  74975. * @returns true is data kind is present
  74976. */
  74977. AbstractMesh.prototype.isVerticesDataPresent = function (kind) {
  74978. return false;
  74979. };
  74980. /**
  74981. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  74982. * @returns a BoundingInfo
  74983. */
  74984. AbstractMesh.prototype.getBoundingInfo = function () {
  74985. if (this._masterMesh) {
  74986. return this._masterMesh.getBoundingInfo();
  74987. }
  74988. if (!this._boundingInfo) {
  74989. // this._boundingInfo is being created here
  74990. this._updateBoundingInfo();
  74991. }
  74992. // cannot be null.
  74993. return this._boundingInfo;
  74994. };
  74995. /**
  74996. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  74997. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  74998. * @returns the current mesh
  74999. */
  75000. AbstractMesh.prototype.normalizeToUnitCube = function (includeDescendants) {
  75001. if (includeDescendants === void 0) { includeDescendants = true; }
  75002. var boundingVectors = this.getHierarchyBoundingVectors(includeDescendants);
  75003. var sizeVec = boundingVectors.max.subtract(boundingVectors.min);
  75004. var maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
  75005. if (maxDimension === 0) {
  75006. return this;
  75007. }
  75008. var scale = 1 / maxDimension;
  75009. this.scaling.scaleInPlace(scale);
  75010. return this;
  75011. };
  75012. /**
  75013. * Overwrite the current bounding info
  75014. * @param boundingInfo defines the new bounding info
  75015. * @returns the current mesh
  75016. */
  75017. AbstractMesh.prototype.setBoundingInfo = function (boundingInfo) {
  75018. this._boundingInfo = boundingInfo;
  75019. return this;
  75020. };
  75021. Object.defineProperty(AbstractMesh.prototype, "useBones", {
  75022. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  75023. get: function () {
  75024. 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));
  75025. },
  75026. enumerable: true,
  75027. configurable: true
  75028. });
  75029. /** @hidden */
  75030. AbstractMesh.prototype._preActivate = function () {
  75031. };
  75032. /** @hidden */
  75033. AbstractMesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  75034. };
  75035. /** @hidden */
  75036. AbstractMesh.prototype._activate = function (renderId) {
  75037. this._renderId = renderId;
  75038. };
  75039. /**
  75040. * Gets the current world matrix
  75041. * @returns a Matrix
  75042. */
  75043. AbstractMesh.prototype.getWorldMatrix = function () {
  75044. if (this._masterMesh) {
  75045. return this._masterMesh.getWorldMatrix();
  75046. }
  75047. return _super.prototype.getWorldMatrix.call(this);
  75048. };
  75049. /** @hidden */
  75050. AbstractMesh.prototype._getWorldMatrixDeterminant = function () {
  75051. if (this._masterMesh) {
  75052. return this._masterMesh._getWorldMatrixDeterminant();
  75053. }
  75054. return _super.prototype._getWorldMatrixDeterminant.call(this);
  75055. };
  75056. // ================================== Point of View Movement =================================
  75057. /**
  75058. * Perform relative position change from the point of view of behind the front of the mesh.
  75059. * This is performed taking into account the meshes current rotation, so you do not have to care.
  75060. * Supports definition of mesh facing forward or backward
  75061. * @param amountRight defines the distance on the right axis
  75062. * @param amountUp defines the distance on the up axis
  75063. * @param amountForward defines the distance on the forward axis
  75064. * @returns the current mesh
  75065. */
  75066. AbstractMesh.prototype.movePOV = function (amountRight, amountUp, amountForward) {
  75067. this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
  75068. return this;
  75069. };
  75070. /**
  75071. * Calculate relative position change from the point of view of behind the front of the mesh.
  75072. * This is performed taking into account the meshes current rotation, so you do not have to care.
  75073. * Supports definition of mesh facing forward or backward
  75074. * @param amountRight defines the distance on the right axis
  75075. * @param amountUp defines the distance on the up axis
  75076. * @param amountForward defines the distance on the forward axis
  75077. * @returns the new displacement vector
  75078. */
  75079. AbstractMesh.prototype.calcMovePOV = function (amountRight, amountUp, amountForward) {
  75080. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  75081. var rotQuaternion = (this.rotationQuaternion) ? this.rotationQuaternion : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  75082. rotQuaternion.toRotationMatrix(rotMatrix);
  75083. var translationDelta = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  75084. var defForwardMult = this.definedFacingForward ? -1 : 1;
  75085. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
  75086. return translationDelta;
  75087. };
  75088. // ================================== Point of View Rotation =================================
  75089. /**
  75090. * Perform relative rotation change from the point of view of behind the front of the mesh.
  75091. * Supports definition of mesh facing forward or backward
  75092. * @param flipBack defines the flip
  75093. * @param twirlClockwise defines the twirl
  75094. * @param tiltRight defines the tilt
  75095. * @returns the current mesh
  75096. */
  75097. AbstractMesh.prototype.rotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  75098. this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
  75099. return this;
  75100. };
  75101. /**
  75102. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  75103. * Supports definition of mesh facing forward or backward.
  75104. * @param flipBack defines the flip
  75105. * @param twirlClockwise defines the twirl
  75106. * @param tiltRight defines the tilt
  75107. * @returns the new rotation vector
  75108. */
  75109. AbstractMesh.prototype.calcRotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  75110. var defForwardMult = this.definedFacingForward ? 1 : -1;
  75111. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
  75112. };
  75113. /**
  75114. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  75115. * @param includeDescendants Include bounding info from descendants as well (true by default)
  75116. * @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
  75117. * @returns the new bounding vectors
  75118. */
  75119. AbstractMesh.prototype.getHierarchyBoundingVectors = function (includeDescendants, predicate) {
  75120. if (includeDescendants === void 0) { includeDescendants = true; }
  75121. if (predicate === void 0) { predicate = null; }
  75122. // Ensures that all world matrix will be recomputed.
  75123. this.getScene().incrementRenderId();
  75124. this.computeWorldMatrix(true);
  75125. var min;
  75126. var max;
  75127. var boundingInfo = this.getBoundingInfo();
  75128. if (!this.subMeshes) {
  75129. min = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  75130. max = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  75131. }
  75132. else {
  75133. min = boundingInfo.boundingBox.minimumWorld;
  75134. max = boundingInfo.boundingBox.maximumWorld;
  75135. }
  75136. if (includeDescendants) {
  75137. var descendants = this.getDescendants(false);
  75138. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  75139. var descendant = descendants_1[_i];
  75140. var childMesh = descendant;
  75141. childMesh.computeWorldMatrix(true);
  75142. // Filters meshes based on custom predicate function.
  75143. if (predicate && !predicate(childMesh)) {
  75144. continue;
  75145. }
  75146. //make sure we have the needed params to get mix and max
  75147. if (!childMesh.getBoundingInfo || childMesh.getTotalVertices() === 0) {
  75148. continue;
  75149. }
  75150. var childBoundingInfo = childMesh.getBoundingInfo();
  75151. var boundingBox = childBoundingInfo.boundingBox;
  75152. var minBox = boundingBox.minimumWorld;
  75153. var maxBox = boundingBox.maximumWorld;
  75154. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  75155. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  75156. }
  75157. }
  75158. return {
  75159. min: min,
  75160. max: max
  75161. };
  75162. };
  75163. /**
  75164. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75165. * This means the mesh underlying bounding box and sphere are recomputed.
  75166. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75167. * @returns the current mesh
  75168. */
  75169. AbstractMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  75170. if (applySkeleton === void 0) { applySkeleton = false; }
  75171. if (this._boundingInfo && this._boundingInfo.isLocked) {
  75172. return this;
  75173. }
  75174. this._refreshBoundingInfo(this._getPositionData(applySkeleton), null);
  75175. return this;
  75176. };
  75177. /** @hidden */
  75178. AbstractMesh.prototype._refreshBoundingInfo = function (data, bias) {
  75179. if (data) {
  75180. var extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMax(data, 0, this.getTotalVertices(), bias);
  75181. if (this._boundingInfo) {
  75182. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  75183. }
  75184. else {
  75185. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_10__["BoundingInfo"](extend.minimum, extend.maximum);
  75186. }
  75187. }
  75188. if (this.subMeshes) {
  75189. for (var index = 0; index < this.subMeshes.length; index++) {
  75190. this.subMeshes[index].refreshBoundingInfo();
  75191. }
  75192. }
  75193. this._updateBoundingInfo();
  75194. };
  75195. /** @hidden */
  75196. AbstractMesh.prototype._getPositionData = function (applySkeleton) {
  75197. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  75198. if (data && applySkeleton && this.skeleton) {
  75199. data = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Slice(data);
  75200. var matricesIndicesData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesKind);
  75201. var matricesWeightsData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsKind);
  75202. if (matricesWeightsData && matricesIndicesData) {
  75203. var needExtras = this.numBoneInfluencers > 4;
  75204. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  75205. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  75206. var skeletonMatrices = this.skeleton.getTransformMatrices(this);
  75207. var tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  75208. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  75209. var tempMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  75210. var matWeightIdx = 0;
  75211. for (var index = 0; index < data.length; index += 3, matWeightIdx += 4) {
  75212. finalMatrix.reset();
  75213. var inf;
  75214. var weight;
  75215. for (inf = 0; inf < 4; inf++) {
  75216. weight = matricesWeightsData[matWeightIdx + inf];
  75217. if (weight > 0) {
  75218. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  75219. finalMatrix.addToSelf(tempMatrix);
  75220. }
  75221. }
  75222. if (needExtras) {
  75223. for (inf = 0; inf < 4; inf++) {
  75224. weight = matricesWeightsExtraData[matWeightIdx + inf];
  75225. if (weight > 0) {
  75226. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  75227. finalMatrix.addToSelf(tempMatrix);
  75228. }
  75229. }
  75230. }
  75231. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
  75232. tempVector.toArray(data, index);
  75233. }
  75234. }
  75235. }
  75236. return data;
  75237. };
  75238. /** @hidden */
  75239. AbstractMesh.prototype._updateBoundingInfo = function () {
  75240. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  75241. if (this._boundingInfo) {
  75242. this._boundingInfo.update(effectiveMesh.worldMatrixFromCache);
  75243. }
  75244. else {
  75245. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_10__["BoundingInfo"](this.absolutePosition, this.absolutePosition, effectiveMesh.worldMatrixFromCache);
  75246. }
  75247. this._updateSubMeshesBoundingInfo(effectiveMesh.worldMatrixFromCache);
  75248. return this;
  75249. };
  75250. /** @hidden */
  75251. AbstractMesh.prototype._updateSubMeshesBoundingInfo = function (matrix) {
  75252. if (!this.subMeshes) {
  75253. return this;
  75254. }
  75255. var count = this.subMeshes.length;
  75256. for (var subIndex = 0; subIndex < count; subIndex++) {
  75257. var subMesh = this.subMeshes[subIndex];
  75258. if (count > 1 || !subMesh.IsGlobal) {
  75259. subMesh.updateBoundingInfo(matrix);
  75260. }
  75261. }
  75262. return this;
  75263. };
  75264. /** @hidden */
  75265. AbstractMesh.prototype._afterComputeWorldMatrix = function () {
  75266. // Bounding info
  75267. this._updateBoundingInfo();
  75268. };
  75269. /**
  75270. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  75271. * A mesh is in the frustum if its bounding box intersects the frustum
  75272. * @param frustumPlanes defines the frustum to test
  75273. * @returns true if the mesh is in the frustum planes
  75274. */
  75275. AbstractMesh.prototype.isInFrustum = function (frustumPlanes) {
  75276. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  75277. };
  75278. /**
  75279. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  75280. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  75281. * @param frustumPlanes defines the frustum to test
  75282. * @returns true if the mesh is completely in the frustum planes
  75283. */
  75284. AbstractMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  75285. return this._boundingInfo !== null && this._boundingInfo.isCompletelyInFrustum(frustumPlanes);
  75286. };
  75287. /**
  75288. * True if the mesh intersects another mesh or a SolidParticle object
  75289. * @param mesh defines a target mesh or SolidParticle to test
  75290. * @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)
  75291. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  75292. * @returns true if there is an intersection
  75293. */
  75294. AbstractMesh.prototype.intersectsMesh = function (mesh, precise, includeDescendants) {
  75295. if (precise === void 0) { precise = false; }
  75296. if (!this._boundingInfo || !mesh._boundingInfo) {
  75297. return false;
  75298. }
  75299. if (this._boundingInfo.intersects(mesh._boundingInfo, precise)) {
  75300. return true;
  75301. }
  75302. if (includeDescendants) {
  75303. for (var _i = 0, _a = this.getChildMeshes(); _i < _a.length; _i++) {
  75304. var child = _a[_i];
  75305. if (child.intersectsMesh(mesh, precise, true)) {
  75306. return true;
  75307. }
  75308. }
  75309. }
  75310. return false;
  75311. };
  75312. /**
  75313. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  75314. * @param point defines the point to test
  75315. * @returns true if there is an intersection
  75316. */
  75317. AbstractMesh.prototype.intersectsPoint = function (point) {
  75318. if (!this._boundingInfo) {
  75319. return false;
  75320. }
  75321. return this._boundingInfo.intersectsPoint(point);
  75322. };
  75323. Object.defineProperty(AbstractMesh.prototype, "checkCollisions", {
  75324. // Collisions
  75325. /**
  75326. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  75327. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  75328. */
  75329. get: function () {
  75330. return this._checkCollisions;
  75331. },
  75332. set: function (collisionEnabled) {
  75333. this._checkCollisions = collisionEnabled;
  75334. },
  75335. enumerable: true,
  75336. configurable: true
  75337. });
  75338. Object.defineProperty(AbstractMesh.prototype, "collider", {
  75339. /**
  75340. * Gets Collider object used to compute collisions (not physics)
  75341. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  75342. */
  75343. get: function () {
  75344. return this._collider;
  75345. },
  75346. enumerable: true,
  75347. configurable: true
  75348. });
  75349. /**
  75350. * Move the mesh using collision engine
  75351. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  75352. * @param displacement defines the requested displacement vector
  75353. * @returns the current mesh
  75354. */
  75355. AbstractMesh.prototype.moveWithCollisions = function (displacement) {
  75356. var globalPosition = this.getAbsolutePosition();
  75357. globalPosition.addToRef(this.ellipsoidOffset, this._oldPositionForCollisions);
  75358. if (!this._collider) {
  75359. this._collider = new _Collisions_collider__WEBPACK_IMPORTED_MODULE_9__["Collider"]();
  75360. }
  75361. this._collider._radius = this.ellipsoid;
  75362. this.getScene().collisionCoordinator.getNewPosition(this._oldPositionForCollisions, displacement, this._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
  75363. return this;
  75364. };
  75365. // Collisions
  75366. /** @hidden */
  75367. AbstractMesh.prototype._collideForSubMesh = function (subMesh, transformMatrix, collider) {
  75368. this._generatePointsArray();
  75369. if (!this._positions) {
  75370. return this;
  75371. }
  75372. // Transformation
  75373. if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
  75374. subMesh._lastColliderTransformMatrix = transformMatrix.clone();
  75375. subMesh._lastColliderWorldVertices = [];
  75376. subMesh._trianglePlanes = [];
  75377. var start = subMesh.verticesStart;
  75378. var end = (subMesh.verticesStart + subMesh.verticesCount);
  75379. for (var i = start; i < end; i++) {
  75380. subMesh._lastColliderWorldVertices.push(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this._positions[i], transformMatrix));
  75381. }
  75382. }
  75383. // Collide
  75384. collider._collide(subMesh._trianglePlanes, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart, !!subMesh.getMaterial());
  75385. if (collider.collisionFound) {
  75386. collider.collidedMesh = this;
  75387. }
  75388. return this;
  75389. };
  75390. /** @hidden */
  75391. AbstractMesh.prototype._processCollisionsForSubMeshes = function (collider, transformMatrix) {
  75392. var subMeshes = this._scene.getCollidingSubMeshCandidates(this, collider);
  75393. var len = subMeshes.length;
  75394. for (var index = 0; index < len; index++) {
  75395. var subMesh = subMeshes.data[index];
  75396. // Bounding test
  75397. if (len > 1 && !subMesh._checkCollision(collider)) {
  75398. continue;
  75399. }
  75400. this._collideForSubMesh(subMesh, transformMatrix, collider);
  75401. }
  75402. return this;
  75403. };
  75404. /** @hidden */
  75405. AbstractMesh.prototype._checkCollision = function (collider) {
  75406. // Bounding box test
  75407. if (!this._boundingInfo || !this._boundingInfo._checkCollision(collider)) {
  75408. return this;
  75409. }
  75410. // Transformation matrix
  75411. var collisionsScalingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  75412. var collisionsTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  75413. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
  75414. this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
  75415. this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
  75416. return this;
  75417. };
  75418. // Picking
  75419. /** @hidden */
  75420. AbstractMesh.prototype._generatePointsArray = function () {
  75421. return false;
  75422. };
  75423. /**
  75424. * Checks if the passed Ray intersects with the mesh
  75425. * @param ray defines the ray to use
  75426. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  75427. * @returns the picking info
  75428. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75429. */
  75430. AbstractMesh.prototype.intersects = function (ray, fastCheck) {
  75431. var pickingInfo = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]();
  75432. var intersectionThreshold = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0;
  75433. var boundingInfo = this._boundingInfo;
  75434. if (!this.subMeshes || !boundingInfo || !ray.intersectsSphere(boundingInfo.boundingSphere, intersectionThreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionThreshold)) {
  75435. return pickingInfo;
  75436. }
  75437. if (!this._generatePointsArray()) {
  75438. return pickingInfo;
  75439. }
  75440. var intersectInfo = null;
  75441. var subMeshes = this._scene.getIntersectingSubMeshCandidates(this, ray);
  75442. var len = subMeshes.length;
  75443. for (var index = 0; index < len; index++) {
  75444. var subMesh = subMeshes.data[index];
  75445. // Bounding test
  75446. if (len > 1 && !subMesh.canIntersects(ray)) {
  75447. continue;
  75448. }
  75449. var currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck);
  75450. if (currentIntersectInfo) {
  75451. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  75452. intersectInfo = currentIntersectInfo;
  75453. intersectInfo.subMeshId = index;
  75454. if (fastCheck) {
  75455. break;
  75456. }
  75457. }
  75458. }
  75459. }
  75460. if (intersectInfo) {
  75461. // Get picked point
  75462. var world = this.getWorldMatrix();
  75463. var worldOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  75464. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  75465. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(ray.origin, world, worldOrigin);
  75466. ray.direction.scaleToRef(intersectInfo.distance, direction);
  75467. var worldDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(direction, world);
  75468. var pickedPoint = worldDirection.addInPlace(worldOrigin);
  75469. // Return result
  75470. pickingInfo.hit = true;
  75471. pickingInfo.distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(worldOrigin, pickedPoint);
  75472. pickingInfo.pickedPoint = pickedPoint;
  75473. pickingInfo.pickedMesh = this;
  75474. pickingInfo.bu = intersectInfo.bu || 0;
  75475. pickingInfo.bv = intersectInfo.bv || 0;
  75476. pickingInfo.faceId = intersectInfo.faceId;
  75477. pickingInfo.subMeshId = intersectInfo.subMeshId;
  75478. return pickingInfo;
  75479. }
  75480. return pickingInfo;
  75481. };
  75482. /**
  75483. * Clones the current mesh
  75484. * @param name defines the mesh name
  75485. * @param newParent defines the new mesh parent
  75486. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  75487. * @returns the new mesh
  75488. */
  75489. AbstractMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  75490. return null;
  75491. };
  75492. /**
  75493. * Disposes all the submeshes of the current meshnp
  75494. * @returns the current mesh
  75495. */
  75496. AbstractMesh.prototype.releaseSubMeshes = function () {
  75497. if (this.subMeshes) {
  75498. while (this.subMeshes.length) {
  75499. this.subMeshes[0].dispose();
  75500. }
  75501. }
  75502. else {
  75503. this.subMeshes = new Array();
  75504. }
  75505. return this;
  75506. };
  75507. /**
  75508. * Releases resources associated with this abstract mesh.
  75509. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  75510. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  75511. */
  75512. AbstractMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  75513. var _this = this;
  75514. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  75515. var index;
  75516. // Smart Array Retainers.
  75517. this.getScene().freeActiveMeshes();
  75518. this.getScene().freeRenderingGroups();
  75519. // Action manager
  75520. if (this.actionManager !== undefined && this.actionManager !== null) {
  75521. this.actionManager.dispose();
  75522. this.actionManager = null;
  75523. }
  75524. // Skeleton
  75525. this._skeleton = null;
  75526. // Intersections in progress
  75527. for (index = 0; index < this._intersectionsInProgress.length; index++) {
  75528. var other = this._intersectionsInProgress[index];
  75529. var pos = other._intersectionsInProgress.indexOf(this);
  75530. other._intersectionsInProgress.splice(pos, 1);
  75531. }
  75532. this._intersectionsInProgress = [];
  75533. // Lights
  75534. var lights = this.getScene().lights;
  75535. lights.forEach(function (light) {
  75536. var meshIndex = light.includedOnlyMeshes.indexOf(_this);
  75537. if (meshIndex !== -1) {
  75538. light.includedOnlyMeshes.splice(meshIndex, 1);
  75539. }
  75540. meshIndex = light.excludedMeshes.indexOf(_this);
  75541. if (meshIndex !== -1) {
  75542. light.excludedMeshes.splice(meshIndex, 1);
  75543. }
  75544. // Shadow generators
  75545. var generator = light.getShadowGenerator();
  75546. if (generator) {
  75547. var shadowMap = generator.getShadowMap();
  75548. if (shadowMap && shadowMap.renderList) {
  75549. meshIndex = shadowMap.renderList.indexOf(_this);
  75550. if (meshIndex !== -1) {
  75551. shadowMap.renderList.splice(meshIndex, 1);
  75552. }
  75553. }
  75554. }
  75555. });
  75556. // SubMeshes
  75557. if (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") {
  75558. this.releaseSubMeshes();
  75559. }
  75560. // Query
  75561. var engine = this.getScene().getEngine();
  75562. if (this._occlusionQuery) {
  75563. this.isOcclusionQueryInProgress = false;
  75564. engine.deleteQuery(this._occlusionQuery);
  75565. this._occlusionQuery = null;
  75566. }
  75567. // Engine
  75568. engine.wipeCaches();
  75569. // Remove from scene
  75570. this.getScene().removeMesh(this);
  75571. if (disposeMaterialAndTextures) {
  75572. if (this.material) {
  75573. this.material.dispose(false, true);
  75574. }
  75575. }
  75576. if (!doNotRecurse) {
  75577. // Particles
  75578. for (index = 0; index < this.getScene().particleSystems.length; index++) {
  75579. if (this.getScene().particleSystems[index].emitter === this) {
  75580. this.getScene().particleSystems[index].dispose();
  75581. index--;
  75582. }
  75583. }
  75584. }
  75585. // facet data
  75586. if (this._facetData.facetDataEnabled) {
  75587. this.disableFacetData();
  75588. }
  75589. this.onAfterWorldMatrixUpdateObservable.clear();
  75590. this.onCollideObservable.clear();
  75591. this.onCollisionPositionChangeObservable.clear();
  75592. this.onRebuildObservable.clear();
  75593. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  75594. };
  75595. /**
  75596. * Adds the passed mesh as a child to the current mesh
  75597. * @param mesh defines the child mesh
  75598. * @returns the current mesh
  75599. */
  75600. AbstractMesh.prototype.addChild = function (mesh) {
  75601. mesh.setParent(this);
  75602. return this;
  75603. };
  75604. /**
  75605. * Removes the passed mesh from the current mesh children list
  75606. * @param mesh defines the child mesh
  75607. * @returns the current mesh
  75608. */
  75609. AbstractMesh.prototype.removeChild = function (mesh) {
  75610. mesh.setParent(null);
  75611. return this;
  75612. };
  75613. // Facet data
  75614. /** @hidden */
  75615. AbstractMesh.prototype._initFacetData = function () {
  75616. var data = this._facetData;
  75617. if (!data.facetNormals) {
  75618. data.facetNormals = new Array();
  75619. }
  75620. if (!data.facetPositions) {
  75621. data.facetPositions = new Array();
  75622. }
  75623. if (!data.facetPartitioning) {
  75624. data.facetPartitioning = new Array();
  75625. }
  75626. data.facetNb = (this.getIndices().length / 3) | 0;
  75627. data.partitioningSubdivisions = (data.partitioningSubdivisions) ? data.partitioningSubdivisions : 10; // default nb of partitioning subdivisions = 10
  75628. data.partitioningBBoxRatio = (data.partitioningBBoxRatio) ? data.partitioningBBoxRatio : 1.01; // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
  75629. for (var f = 0; f < data.facetNb; f++) {
  75630. data.facetNormals[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  75631. data.facetPositions[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  75632. }
  75633. data.facetDataEnabled = true;
  75634. return this;
  75635. };
  75636. /**
  75637. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  75638. * This method can be called within the render loop.
  75639. * 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
  75640. * @returns the current mesh
  75641. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75642. */
  75643. AbstractMesh.prototype.updateFacetData = function () {
  75644. var data = this._facetData;
  75645. if (!data.facetDataEnabled) {
  75646. this._initFacetData();
  75647. }
  75648. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  75649. var indices = this.getIndices();
  75650. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  75651. var bInfo = this.getBoundingInfo();
  75652. if (data.facetDepthSort && !data.facetDepthSortEnabled) {
  75653. // init arrays, matrix and sort function on first call
  75654. data.facetDepthSortEnabled = true;
  75655. if (indices instanceof Uint16Array) {
  75656. data.depthSortedIndices = new Uint16Array(indices);
  75657. }
  75658. else if (indices instanceof Uint32Array) {
  75659. data.depthSortedIndices = new Uint32Array(indices);
  75660. }
  75661. else {
  75662. var needs32bits = false;
  75663. for (var i = 0; i < indices.length; i++) {
  75664. if (indices[i] > 65535) {
  75665. needs32bits = true;
  75666. break;
  75667. }
  75668. }
  75669. if (needs32bits) {
  75670. data.depthSortedIndices = new Uint32Array(indices);
  75671. }
  75672. else {
  75673. data.depthSortedIndices = new Uint16Array(indices);
  75674. }
  75675. }
  75676. data.facetDepthSortFunction = function (f1, f2) {
  75677. return (f2.sqDistance - f1.sqDistance);
  75678. };
  75679. if (!data.facetDepthSortFrom) {
  75680. var camera = this.getScene().activeCamera;
  75681. data.facetDepthSortFrom = (camera) ? camera.position : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  75682. }
  75683. data.depthSortedFacets = [];
  75684. for (var f = 0; f < data.facetNb; f++) {
  75685. var depthSortedFacet = { ind: f * 3, sqDistance: 0.0 };
  75686. data.depthSortedFacets.push(depthSortedFacet);
  75687. }
  75688. data.invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  75689. data.facetDepthSortOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  75690. }
  75691. 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"];
  75692. 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"];
  75693. 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"];
  75694. var bbSizeMax = (data.bbSize.x > data.bbSize.y) ? data.bbSize.x : data.bbSize.y;
  75695. bbSizeMax = (bbSizeMax > data.bbSize.z) ? bbSizeMax : data.bbSize.z;
  75696. data.subDiv.max = data.partitioningSubdivisions;
  75697. data.subDiv.X = Math.floor(data.subDiv.max * data.bbSize.x / bbSizeMax); // adjust the number of subdivisions per axis
  75698. data.subDiv.Y = Math.floor(data.subDiv.max * data.bbSize.y / bbSizeMax); // according to each bbox size per axis
  75699. data.subDiv.Z = Math.floor(data.subDiv.max * data.bbSize.z / bbSizeMax);
  75700. data.subDiv.X = data.subDiv.X < 1 ? 1 : data.subDiv.X; // at least one subdivision
  75701. data.subDiv.Y = data.subDiv.Y < 1 ? 1 : data.subDiv.Y;
  75702. data.subDiv.Z = data.subDiv.Z < 1 ? 1 : data.subDiv.Z;
  75703. // set the parameters for ComputeNormals()
  75704. data.facetParameters.facetNormals = this.getFacetLocalNormals();
  75705. data.facetParameters.facetPositions = this.getFacetLocalPositions();
  75706. data.facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
  75707. data.facetParameters.bInfo = bInfo;
  75708. data.facetParameters.bbSize = data.bbSize;
  75709. data.facetParameters.subDiv = data.subDiv;
  75710. data.facetParameters.ratio = this.partitioningBBoxRatio;
  75711. data.facetParameters.depthSort = data.facetDepthSort;
  75712. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  75713. this.computeWorldMatrix(true);
  75714. this._worldMatrix.invertToRef(data.invertedMatrix);
  75715. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
  75716. data.facetParameters.distanceTo = data.facetDepthSortOrigin;
  75717. }
  75718. data.facetParameters.depthSortedFacets = data.depthSortedFacets;
  75719. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, data.facetParameters);
  75720. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  75721. data.depthSortedFacets.sort(data.facetDepthSortFunction);
  75722. var l = (data.depthSortedIndices.length / 3) | 0;
  75723. for (var f = 0; f < l; f++) {
  75724. var sind = data.depthSortedFacets[f].ind;
  75725. data.depthSortedIndices[f * 3] = indices[sind];
  75726. data.depthSortedIndices[f * 3 + 1] = indices[sind + 1];
  75727. data.depthSortedIndices[f * 3 + 2] = indices[sind + 2];
  75728. }
  75729. this.updateIndices(data.depthSortedIndices);
  75730. }
  75731. return this;
  75732. };
  75733. /**
  75734. * Returns the facetLocalNormals array.
  75735. * The normals are expressed in the mesh local spac
  75736. * @returns an array of Vector3
  75737. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75738. */
  75739. AbstractMesh.prototype.getFacetLocalNormals = function () {
  75740. if (!this._facetData.facetNormals) {
  75741. this.updateFacetData();
  75742. }
  75743. return this._facetData.facetNormals;
  75744. };
  75745. /**
  75746. * Returns the facetLocalPositions array.
  75747. * The facet positions are expressed in the mesh local space
  75748. * @returns an array of Vector3
  75749. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75750. */
  75751. AbstractMesh.prototype.getFacetLocalPositions = function () {
  75752. if (!this._facetData.facetPositions) {
  75753. this.updateFacetData();
  75754. }
  75755. return this._facetData.facetPositions;
  75756. };
  75757. /**
  75758. * Returns the facetLocalPartioning array
  75759. * @returns an array of array of numbers
  75760. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75761. */
  75762. AbstractMesh.prototype.getFacetLocalPartitioning = function () {
  75763. if (!this._facetData.facetPartitioning) {
  75764. this.updateFacetData();
  75765. }
  75766. return this._facetData.facetPartitioning;
  75767. };
  75768. /**
  75769. * Returns the i-th facet position in the world system.
  75770. * This method allocates a new Vector3 per call
  75771. * @param i defines the facet index
  75772. * @returns a new Vector3
  75773. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75774. */
  75775. AbstractMesh.prototype.getFacetPosition = function (i) {
  75776. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  75777. this.getFacetPositionToRef(i, pos);
  75778. return pos;
  75779. };
  75780. /**
  75781. * Sets the reference Vector3 with the i-th facet position in the world system
  75782. * @param i defines the facet index
  75783. * @param ref defines the target vector
  75784. * @returns the current mesh
  75785. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75786. */
  75787. AbstractMesh.prototype.getFacetPositionToRef = function (i, ref) {
  75788. var localPos = (this.getFacetLocalPositions())[i];
  75789. var world = this.getWorldMatrix();
  75790. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(localPos, world, ref);
  75791. return this;
  75792. };
  75793. /**
  75794. * Returns the i-th facet normal in the world system.
  75795. * This method allocates a new Vector3 per call
  75796. * @param i defines the facet index
  75797. * @returns a new Vector3
  75798. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75799. */
  75800. AbstractMesh.prototype.getFacetNormal = function (i) {
  75801. var norm = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  75802. this.getFacetNormalToRef(i, norm);
  75803. return norm;
  75804. };
  75805. /**
  75806. * Sets the reference Vector3 with the i-th facet normal in the world system
  75807. * @param i defines the facet index
  75808. * @param ref defines the target vector
  75809. * @returns the current mesh
  75810. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75811. */
  75812. AbstractMesh.prototype.getFacetNormalToRef = function (i, ref) {
  75813. var localNorm = (this.getFacetLocalNormals())[i];
  75814. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localNorm, this.getWorldMatrix(), ref);
  75815. return this;
  75816. };
  75817. /**
  75818. * 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)
  75819. * @param x defines x coordinate
  75820. * @param y defines y coordinate
  75821. * @param z defines z coordinate
  75822. * @returns the array of facet indexes
  75823. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75824. */
  75825. AbstractMesh.prototype.getFacetsAtLocalCoordinates = function (x, y, z) {
  75826. var bInfo = this.getBoundingInfo();
  75827. var data = this._facetData;
  75828. var ox = Math.floor((x - bInfo.minimum.x * data.partitioningBBoxRatio) * data.subDiv.X * data.partitioningBBoxRatio / data.bbSize.x);
  75829. var oy = Math.floor((y - bInfo.minimum.y * data.partitioningBBoxRatio) * data.subDiv.Y * data.partitioningBBoxRatio / data.bbSize.y);
  75830. var oz = Math.floor((z - bInfo.minimum.z * data.partitioningBBoxRatio) * data.subDiv.Z * data.partitioningBBoxRatio / data.bbSize.z);
  75831. if (ox < 0 || ox > data.subDiv.max || oy < 0 || oy > data.subDiv.max || oz < 0 || oz > data.subDiv.max) {
  75832. return null;
  75833. }
  75834. return data.facetPartitioning[ox + data.subDiv.max * oy + data.subDiv.max * data.subDiv.max * oz];
  75835. };
  75836. /**
  75837. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  75838. * @param projected sets as the (x,y,z) world projection on the facet
  75839. * @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
  75840. * @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
  75841. * @param x defines x coordinate
  75842. * @param y defines y coordinate
  75843. * @param z defines z coordinate
  75844. * @returns the face index if found (or null instead)
  75845. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75846. */
  75847. AbstractMesh.prototype.getClosestFacetAtCoordinates = function (x, y, z, projected, checkFace, facing) {
  75848. if (checkFace === void 0) { checkFace = false; }
  75849. if (facing === void 0) { facing = true; }
  75850. var world = this.getWorldMatrix();
  75851. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5];
  75852. world.invertToRef(invMat);
  75853. var invVect = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[8];
  75854. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, invMat, invVect); // transform (x,y,z) to coordinates in the mesh local space
  75855. var closest = this.getClosestFacetAtLocalCoordinates(invVect.x, invVect.y, invVect.z, projected, checkFace, facing);
  75856. if (projected) {
  75857. // tranform the local computed projected vector to world coordinates
  75858. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(projected.x, projected.y, projected.z, world, projected);
  75859. }
  75860. return closest;
  75861. };
  75862. /**
  75863. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  75864. * @param projected sets as the (x,y,z) local projection on the facet
  75865. * @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
  75866. * @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
  75867. * @param x defines x coordinate
  75868. * @param y defines y coordinate
  75869. * @param z defines z coordinate
  75870. * @returns the face index if found (or null instead)
  75871. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75872. */
  75873. AbstractMesh.prototype.getClosestFacetAtLocalCoordinates = function (x, y, z, projected, checkFace, facing) {
  75874. if (checkFace === void 0) { checkFace = false; }
  75875. if (facing === void 0) { facing = true; }
  75876. var closest = null;
  75877. var tmpx = 0.0;
  75878. var tmpy = 0.0;
  75879. var tmpz = 0.0;
  75880. var d = 0.0; // tmp dot facet normal * facet position
  75881. var t0 = 0.0;
  75882. var projx = 0.0;
  75883. var projy = 0.0;
  75884. var projz = 0.0;
  75885. // Get all the facets in the same partitioning block than (x, y, z)
  75886. var facetPositions = this.getFacetLocalPositions();
  75887. var facetNormals = this.getFacetLocalNormals();
  75888. var facetsInBlock = this.getFacetsAtLocalCoordinates(x, y, z);
  75889. if (!facetsInBlock) {
  75890. return null;
  75891. }
  75892. // Get the closest facet to (x, y, z)
  75893. var shortest = Number.MAX_VALUE; // init distance vars
  75894. var tmpDistance = shortest;
  75895. var fib; // current facet in the block
  75896. var norm; // current facet normal
  75897. var p0; // current facet barycenter position
  75898. // loop on all the facets in the current partitioning block
  75899. for (var idx = 0; idx < facetsInBlock.length; idx++) {
  75900. fib = facetsInBlock[idx];
  75901. norm = facetNormals[fib];
  75902. p0 = facetPositions[fib];
  75903. d = (x - p0.x) * norm.x + (y - p0.y) * norm.y + (z - p0.z) * norm.z;
  75904. if (!checkFace || (checkFace && facing && d >= 0.0) || (checkFace && !facing && d <= 0.0)) {
  75905. // compute (x,y,z) projection on the facet = (projx, projy, projz)
  75906. d = norm.x * p0.x + norm.y * p0.y + norm.z * p0.z;
  75907. t0 = -(norm.x * x + norm.y * y + norm.z * z - d) / (norm.x * norm.x + norm.y * norm.y + norm.z * norm.z);
  75908. projx = x + norm.x * t0;
  75909. projy = y + norm.y * t0;
  75910. projz = z + norm.z * t0;
  75911. tmpx = projx - x;
  75912. tmpy = projy - y;
  75913. tmpz = projz - z;
  75914. tmpDistance = tmpx * tmpx + tmpy * tmpy + tmpz * tmpz; // compute length between (x, y, z) and its projection on the facet
  75915. if (tmpDistance < shortest) { // just keep the closest facet to (x, y, z)
  75916. shortest = tmpDistance;
  75917. closest = fib;
  75918. if (projected) {
  75919. projected.x = projx;
  75920. projected.y = projy;
  75921. projected.z = projz;
  75922. }
  75923. }
  75924. }
  75925. }
  75926. return closest;
  75927. };
  75928. /**
  75929. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  75930. * @returns the parameters
  75931. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75932. */
  75933. AbstractMesh.prototype.getFacetDataParameters = function () {
  75934. return this._facetData.facetParameters;
  75935. };
  75936. /**
  75937. * Disables the feature FacetData and frees the related memory
  75938. * @returns the current mesh
  75939. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  75940. */
  75941. AbstractMesh.prototype.disableFacetData = function () {
  75942. if (this._facetData.facetDataEnabled) {
  75943. this._facetData.facetDataEnabled = false;
  75944. this._facetData.facetPositions = new Array();
  75945. this._facetData.facetNormals = new Array();
  75946. this._facetData.facetPartitioning = new Array();
  75947. this._facetData.facetParameters = null;
  75948. this._facetData.depthSortedIndices = new Uint32Array(0);
  75949. }
  75950. return this;
  75951. };
  75952. /**
  75953. * Updates the AbstractMesh indices array
  75954. * @param indices defines the data source
  75955. * @returns the current mesh
  75956. */
  75957. AbstractMesh.prototype.updateIndices = function (indices) {
  75958. return this;
  75959. };
  75960. /**
  75961. * Creates new normals data for the mesh
  75962. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  75963. * @returns the current mesh
  75964. */
  75965. AbstractMesh.prototype.createNormals = function (updatable) {
  75966. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  75967. var indices = this.getIndices();
  75968. var normals;
  75969. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  75970. normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  75971. }
  75972. else {
  75973. normals = [];
  75974. }
  75975. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
  75976. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind, normals, updatable);
  75977. return this;
  75978. };
  75979. /**
  75980. * Align the mesh with a normal
  75981. * @param normal defines the normal to use
  75982. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  75983. * @returns the current mesh
  75984. */
  75985. AbstractMesh.prototype.alignWithNormal = function (normal, upDirection) {
  75986. if (!upDirection) {
  75987. upDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y;
  75988. }
  75989. var axisX = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  75990. var axisZ = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  75991. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(upDirection, normal, axisZ);
  75992. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(normal, axisZ, axisX);
  75993. if (this.rotationQuaternion) {
  75994. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationQuaternionFromAxisToRef(axisX, normal, axisZ, this.rotationQuaternion);
  75995. }
  75996. else {
  75997. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].RotationFromAxisToRef(axisX, normal, axisZ, this.rotation);
  75998. }
  75999. return this;
  76000. };
  76001. /** @hidden */
  76002. AbstractMesh.prototype._checkOcclusionQuery = function () {
  76003. return false;
  76004. };
  76005. /** No occlusion */
  76006. AbstractMesh.OCCLUSION_TYPE_NONE = 0;
  76007. /** Occlusion set to optimisitic */
  76008. AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC = 1;
  76009. /** Occlusion set to strict */
  76010. AbstractMesh.OCCLUSION_TYPE_STRICT = 2;
  76011. /** Use an accurante occlusion algorithm */
  76012. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0;
  76013. /** Use a conservative occlusion algorithm */
  76014. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1;
  76015. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  76016. * Test order :
  76017. * Is the bounding sphere outside the frustum ?
  76018. * If not, are the bounding box vertices outside the frustum ?
  76019. * It not, then the cullable object is in the frustum.
  76020. */
  76021. AbstractMesh.CULLINGSTRATEGY_STANDARD = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD;
  76022. /** Culling strategy : Bounding Sphere Only.
  76023. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  76024. * It's also less accurate than the standard because some not visible objects can still be selected.
  76025. * Test : is the bounding sphere outside the frustum ?
  76026. * If not, then the cullable object is in the frustum.
  76027. */
  76028. AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  76029. /** Culling strategy : Optimistic Inclusion.
  76030. * This in an inclusion test first, then the standard exclusion test.
  76031. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  76032. * 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.
  76033. * Anyway, it's as accurate as the standard strategy.
  76034. * Test :
  76035. * Is the cullable object bounding sphere center in the frustum ?
  76036. * If not, apply the default culling strategy.
  76037. */
  76038. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION;
  76039. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  76040. * This in an inclusion test first, then the bounding sphere only exclusion test.
  76041. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  76042. * 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.
  76043. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  76044. * Test :
  76045. * Is the cullable object bounding sphere center in the frustum ?
  76046. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  76047. */
  76048. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;
  76049. return AbstractMesh;
  76050. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"]));
  76051. /***/ }),
  76052. /***/ "./Meshes/buffer.ts":
  76053. /*!**************************!*\
  76054. !*** ./Meshes/buffer.ts ***!
  76055. \**************************/
  76056. /*! exports provided: Buffer, VertexBuffer */
  76057. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76058. "use strict";
  76059. __webpack_require__.r(__webpack_exports__);
  76060. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return Buffer; });
  76061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return VertexBuffer; });
  76062. /**
  76063. * Class used to store data that will be store in GPU memory
  76064. */
  76065. var Buffer = /** @class */ (function () {
  76066. /**
  76067. * Constructor
  76068. * @param engine the engine
  76069. * @param data the data to use for this buffer
  76070. * @param updatable whether the data is updatable
  76071. * @param stride the stride (optional)
  76072. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  76073. * @param instanced whether the buffer is instanced (optional)
  76074. * @param useBytes set to true if the stride in in bytes (optional)
  76075. */
  76076. function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes) {
  76077. if (stride === void 0) { stride = 0; }
  76078. if (postponeInternalCreation === void 0) { postponeInternalCreation = false; }
  76079. if (instanced === void 0) { instanced = false; }
  76080. if (useBytes === void 0) { useBytes = false; }
  76081. if (engine.getScene) { // old versions of VertexBuffer accepted 'mesh' instead of 'engine'
  76082. this._engine = engine.getScene().getEngine();
  76083. }
  76084. else {
  76085. this._engine = engine;
  76086. }
  76087. this._updatable = updatable;
  76088. this._instanced = instanced;
  76089. this._data = data;
  76090. this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
  76091. if (!postponeInternalCreation) { // by default
  76092. this.create();
  76093. }
  76094. }
  76095. /**
  76096. * Create a new VertexBuffer based on the current buffer
  76097. * @param kind defines the vertex buffer kind (position, normal, etc.)
  76098. * @param offset defines offset in the buffer (0 by default)
  76099. * @param size defines the size in floats of attributes (position is 3 for instance)
  76100. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  76101. * @param instanced defines if the vertex buffer contains indexed data
  76102. * @param useBytes defines if the offset and stride are in bytes
  76103. * @returns the new vertex buffer
  76104. */
  76105. Buffer.prototype.createVertexBuffer = function (kind, offset, size, stride, instanced, useBytes) {
  76106. if (useBytes === void 0) { useBytes = false; }
  76107. var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
  76108. var byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;
  76109. // a lot of these parameters are ignored as they are overriden by the buffer
  76110. return new VertexBuffer(this._engine, this, kind, this._updatable, true, byteStride, instanced === undefined ? this._instanced : instanced, byteOffset, size, undefined, undefined, true);
  76111. };
  76112. // Properties
  76113. /**
  76114. * Gets a boolean indicating if the Buffer is updatable?
  76115. * @returns true if the buffer is updatable
  76116. */
  76117. Buffer.prototype.isUpdatable = function () {
  76118. return this._updatable;
  76119. };
  76120. /**
  76121. * Gets current buffer's data
  76122. * @returns a DataArray or null
  76123. */
  76124. Buffer.prototype.getData = function () {
  76125. return this._data;
  76126. };
  76127. /**
  76128. * Gets underlying native buffer
  76129. * @returns underlying native buffer
  76130. */
  76131. Buffer.prototype.getBuffer = function () {
  76132. return this._buffer;
  76133. };
  76134. /**
  76135. * Gets the stride in float32 units (i.e. byte stride / 4).
  76136. * May not be an integer if the byte stride is not divisible by 4.
  76137. * DEPRECATED. Use byteStride instead.
  76138. * @returns the stride in float32 units
  76139. */
  76140. Buffer.prototype.getStrideSize = function () {
  76141. return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
  76142. };
  76143. // Methods
  76144. /**
  76145. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  76146. * @param data defines the data to store
  76147. */
  76148. Buffer.prototype.create = function (data) {
  76149. if (data === void 0) { data = null; }
  76150. if (!data && this._buffer) {
  76151. return; // nothing to do
  76152. }
  76153. data = data || this._data;
  76154. if (!data) {
  76155. return;
  76156. }
  76157. if (!this._buffer) { // create buffer
  76158. if (this._updatable) {
  76159. this._buffer = this._engine.createDynamicVertexBuffer(data);
  76160. this._data = data;
  76161. }
  76162. else {
  76163. this._buffer = this._engine.createVertexBuffer(data);
  76164. }
  76165. }
  76166. else if (this._updatable) { // update buffer
  76167. this._engine.updateDynamicVertexBuffer(this._buffer, data);
  76168. this._data = data;
  76169. }
  76170. };
  76171. /** @hidden */
  76172. Buffer.prototype._rebuild = function () {
  76173. this._buffer = null;
  76174. this.create(this._data);
  76175. };
  76176. /**
  76177. * Update current buffer data
  76178. * @param data defines the data to store
  76179. */
  76180. Buffer.prototype.update = function (data) {
  76181. this.create(data);
  76182. };
  76183. /**
  76184. * Updates the data directly.
  76185. * @param data the new data
  76186. * @param offset the new offset
  76187. * @param vertexCount the vertex count (optional)
  76188. * @param useBytes set to true if the offset is in bytes
  76189. */
  76190. Buffer.prototype.updateDirectly = function (data, offset, vertexCount, useBytes) {
  76191. if (useBytes === void 0) { useBytes = false; }
  76192. if (!this._buffer) {
  76193. return;
  76194. }
  76195. if (this._updatable) { // update buffer
  76196. this._engine.updateDynamicVertexBuffer(this._buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, (vertexCount ? vertexCount * this.byteStride : undefined));
  76197. this._data = null;
  76198. }
  76199. };
  76200. /**
  76201. * Release all resources
  76202. */
  76203. Buffer.prototype.dispose = function () {
  76204. if (!this._buffer) {
  76205. return;
  76206. }
  76207. if (this._engine._releaseBuffer(this._buffer)) {
  76208. this._buffer = null;
  76209. }
  76210. };
  76211. return Buffer;
  76212. }());
  76213. /**
  76214. * Specialized buffer used to store vertex data
  76215. */
  76216. var VertexBuffer = /** @class */ (function () {
  76217. /**
  76218. * Constructor
  76219. * @param engine the engine
  76220. * @param data the data to use for this vertex buffer
  76221. * @param kind the vertex buffer kind
  76222. * @param updatable whether the data is updatable
  76223. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  76224. * @param stride the stride (optional)
  76225. * @param instanced whether the buffer is instanced (optional)
  76226. * @param offset the offset of the data (optional)
  76227. * @param size the number of components (optional)
  76228. * @param type the type of the component (optional)
  76229. * @param normalized whether the data contains normalized data (optional)
  76230. * @param useBytes set to true if stride and offset are in bytes (optional)
  76231. */
  76232. function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation, stride, instanced, offset, size, type, normalized, useBytes) {
  76233. if (normalized === void 0) { normalized = false; }
  76234. if (useBytes === void 0) { useBytes = false; }
  76235. if (data instanceof Buffer) {
  76236. this._buffer = data;
  76237. this._ownsBuffer = false;
  76238. }
  76239. else {
  76240. this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);
  76241. this._ownsBuffer = true;
  76242. }
  76243. this._kind = kind;
  76244. if (type == undefined) {
  76245. var data_1 = this.getData();
  76246. this.type = VertexBuffer.FLOAT;
  76247. if (data_1 instanceof Int8Array) {
  76248. this.type = VertexBuffer.BYTE;
  76249. }
  76250. else if (data_1 instanceof Uint8Array) {
  76251. this.type = VertexBuffer.UNSIGNED_BYTE;
  76252. }
  76253. else if (data_1 instanceof Int16Array) {
  76254. this.type = VertexBuffer.SHORT;
  76255. }
  76256. else if (data_1 instanceof Uint16Array) {
  76257. this.type = VertexBuffer.UNSIGNED_SHORT;
  76258. }
  76259. else if (data_1 instanceof Int32Array) {
  76260. this.type = VertexBuffer.INT;
  76261. }
  76262. else if (data_1 instanceof Uint32Array) {
  76263. this.type = VertexBuffer.UNSIGNED_INT;
  76264. }
  76265. }
  76266. else {
  76267. this.type = type;
  76268. }
  76269. var typeByteLength = VertexBuffer.GetTypeByteLength(this.type);
  76270. if (useBytes) {
  76271. this._size = size || (stride ? (stride / typeByteLength) : VertexBuffer.DeduceStride(kind));
  76272. this.byteStride = stride || this._buffer.byteStride || (this._size * typeByteLength);
  76273. this.byteOffset = offset || 0;
  76274. }
  76275. else {
  76276. this._size = size || stride || VertexBuffer.DeduceStride(kind);
  76277. this.byteStride = stride ? (stride * typeByteLength) : (this._buffer.byteStride || (this._size * typeByteLength));
  76278. this.byteOffset = (offset || 0) * typeByteLength;
  76279. }
  76280. this.normalized = normalized;
  76281. this._instanced = instanced !== undefined ? instanced : false;
  76282. this._instanceDivisor = instanced ? 1 : 0;
  76283. }
  76284. Object.defineProperty(VertexBuffer.prototype, "instanceDivisor", {
  76285. /**
  76286. * Gets or sets the instance divisor when in instanced mode
  76287. */
  76288. get: function () {
  76289. return this._instanceDivisor;
  76290. },
  76291. set: function (value) {
  76292. this._instanceDivisor = value;
  76293. if (value == 0) {
  76294. this._instanced = false;
  76295. }
  76296. else {
  76297. this._instanced = true;
  76298. }
  76299. },
  76300. enumerable: true,
  76301. configurable: true
  76302. });
  76303. /** @hidden */
  76304. VertexBuffer.prototype._rebuild = function () {
  76305. if (!this._buffer) {
  76306. return;
  76307. }
  76308. this._buffer._rebuild();
  76309. };
  76310. /**
  76311. * Returns the kind of the VertexBuffer (string)
  76312. * @returns a string
  76313. */
  76314. VertexBuffer.prototype.getKind = function () {
  76315. return this._kind;
  76316. };
  76317. // Properties
  76318. /**
  76319. * Gets a boolean indicating if the VertexBuffer is updatable?
  76320. * @returns true if the buffer is updatable
  76321. */
  76322. VertexBuffer.prototype.isUpdatable = function () {
  76323. return this._buffer.isUpdatable();
  76324. };
  76325. /**
  76326. * Gets current buffer's data
  76327. * @returns a DataArray or null
  76328. */
  76329. VertexBuffer.prototype.getData = function () {
  76330. return this._buffer.getData();
  76331. };
  76332. /**
  76333. * Gets underlying native buffer
  76334. * @returns underlying native buffer
  76335. */
  76336. VertexBuffer.prototype.getBuffer = function () {
  76337. return this._buffer.getBuffer();
  76338. };
  76339. /**
  76340. * Gets the stride in float32 units (i.e. byte stride / 4).
  76341. * May not be an integer if the byte stride is not divisible by 4.
  76342. * DEPRECATED. Use byteStride instead.
  76343. * @returns the stride in float32 units
  76344. */
  76345. VertexBuffer.prototype.getStrideSize = function () {
  76346. return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);
  76347. };
  76348. /**
  76349. * Returns the offset as a multiple of the type byte length.
  76350. * DEPRECATED. Use byteOffset instead.
  76351. * @returns the offset in bytes
  76352. */
  76353. VertexBuffer.prototype.getOffset = function () {
  76354. return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);
  76355. };
  76356. /**
  76357. * Returns the number of components per vertex attribute (integer)
  76358. * @returns the size in float
  76359. */
  76360. VertexBuffer.prototype.getSize = function () {
  76361. return this._size;
  76362. };
  76363. /**
  76364. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  76365. * @returns true if this buffer is instanced
  76366. */
  76367. VertexBuffer.prototype.getIsInstanced = function () {
  76368. return this._instanced;
  76369. };
  76370. /**
  76371. * Returns the instancing divisor, zero for non-instanced (integer).
  76372. * @returns a number
  76373. */
  76374. VertexBuffer.prototype.getInstanceDivisor = function () {
  76375. return this._instanceDivisor;
  76376. };
  76377. // Methods
  76378. /**
  76379. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  76380. * @param data defines the data to store
  76381. */
  76382. VertexBuffer.prototype.create = function (data) {
  76383. this._buffer.create(data);
  76384. };
  76385. /**
  76386. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  76387. * This function will create a new buffer if the current one is not updatable
  76388. * @param data defines the data to store
  76389. */
  76390. VertexBuffer.prototype.update = function (data) {
  76391. this._buffer.update(data);
  76392. };
  76393. /**
  76394. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  76395. * Returns the directly updated WebGLBuffer.
  76396. * @param data the new data
  76397. * @param offset the new offset
  76398. * @param useBytes set to true if the offset is in bytes
  76399. */
  76400. VertexBuffer.prototype.updateDirectly = function (data, offset, useBytes) {
  76401. if (useBytes === void 0) { useBytes = false; }
  76402. this._buffer.updateDirectly(data, offset, undefined, useBytes);
  76403. };
  76404. /**
  76405. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  76406. */
  76407. VertexBuffer.prototype.dispose = function () {
  76408. if (this._ownsBuffer) {
  76409. this._buffer.dispose();
  76410. }
  76411. };
  76412. /**
  76413. * Enumerates each value of this vertex buffer as numbers.
  76414. * @param count the number of values to enumerate
  76415. * @param callback the callback function called for each value
  76416. */
  76417. VertexBuffer.prototype.forEach = function (count, callback) {
  76418. VertexBuffer.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);
  76419. };
  76420. /**
  76421. * Deduces the stride given a kind.
  76422. * @param kind The kind string to deduce
  76423. * @returns The deduced stride
  76424. */
  76425. VertexBuffer.DeduceStride = function (kind) {
  76426. switch (kind) {
  76427. case VertexBuffer.UVKind:
  76428. case VertexBuffer.UV2Kind:
  76429. case VertexBuffer.UV3Kind:
  76430. case VertexBuffer.UV4Kind:
  76431. case VertexBuffer.UV5Kind:
  76432. case VertexBuffer.UV6Kind:
  76433. return 2;
  76434. case VertexBuffer.NormalKind:
  76435. case VertexBuffer.PositionKind:
  76436. return 3;
  76437. case VertexBuffer.ColorKind:
  76438. case VertexBuffer.MatricesIndicesKind:
  76439. case VertexBuffer.MatricesIndicesExtraKind:
  76440. case VertexBuffer.MatricesWeightsKind:
  76441. case VertexBuffer.MatricesWeightsExtraKind:
  76442. case VertexBuffer.TangentKind:
  76443. return 4;
  76444. default:
  76445. throw new Error("Invalid kind '" + kind + "'");
  76446. }
  76447. };
  76448. /**
  76449. * Gets the byte length of the given type.
  76450. * @param type the type
  76451. * @returns the number of bytes
  76452. */
  76453. VertexBuffer.GetTypeByteLength = function (type) {
  76454. switch (type) {
  76455. case VertexBuffer.BYTE:
  76456. case VertexBuffer.UNSIGNED_BYTE:
  76457. return 1;
  76458. case VertexBuffer.SHORT:
  76459. case VertexBuffer.UNSIGNED_SHORT:
  76460. return 2;
  76461. case VertexBuffer.INT:
  76462. case VertexBuffer.FLOAT:
  76463. return 4;
  76464. default:
  76465. throw new Error("Invalid type '" + type + "'");
  76466. }
  76467. };
  76468. /**
  76469. * Enumerates each value of the given parameters as numbers.
  76470. * @param data the data to enumerate
  76471. * @param byteOffset the byte offset of the data
  76472. * @param byteStride the byte stride of the data
  76473. * @param componentCount the number of components per element
  76474. * @param componentType the type of the component
  76475. * @param count the total number of components
  76476. * @param normalized whether the data is normalized
  76477. * @param callback the callback function called for each value
  76478. */
  76479. VertexBuffer.ForEach = function (data, byteOffset, byteStride, componentCount, componentType, count, normalized, callback) {
  76480. if (data instanceof Array) {
  76481. var offset = byteOffset / 4;
  76482. var stride = byteStride / 4;
  76483. for (var index = 0; index < count; index += componentCount) {
  76484. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  76485. callback(data[offset + componentIndex], index + componentIndex);
  76486. }
  76487. offset += stride;
  76488. }
  76489. }
  76490. else {
  76491. var dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);
  76492. var componentByteLength = VertexBuffer.GetTypeByteLength(componentType);
  76493. for (var index = 0; index < count; index += componentCount) {
  76494. var componentByteOffset = byteOffset;
  76495. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  76496. var value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);
  76497. callback(value, index + componentIndex);
  76498. componentByteOffset += componentByteLength;
  76499. }
  76500. byteOffset += byteStride;
  76501. }
  76502. }
  76503. };
  76504. VertexBuffer._GetFloatValue = function (dataView, type, byteOffset, normalized) {
  76505. switch (type) {
  76506. case VertexBuffer.BYTE: {
  76507. var value = dataView.getInt8(byteOffset);
  76508. if (normalized) {
  76509. value = Math.max(value / 127, -1);
  76510. }
  76511. return value;
  76512. }
  76513. case VertexBuffer.UNSIGNED_BYTE: {
  76514. var value = dataView.getUint8(byteOffset);
  76515. if (normalized) {
  76516. value = value / 255;
  76517. }
  76518. return value;
  76519. }
  76520. case VertexBuffer.SHORT: {
  76521. var value = dataView.getInt16(byteOffset, true);
  76522. if (normalized) {
  76523. value = Math.max(value / 16383, -1);
  76524. }
  76525. return value;
  76526. }
  76527. case VertexBuffer.UNSIGNED_SHORT: {
  76528. var value = dataView.getUint16(byteOffset, true);
  76529. if (normalized) {
  76530. value = value / 65535;
  76531. }
  76532. return value;
  76533. }
  76534. case VertexBuffer.FLOAT: {
  76535. return dataView.getFloat32(byteOffset, true);
  76536. }
  76537. default: {
  76538. throw new Error("Invalid component type " + type);
  76539. }
  76540. }
  76541. };
  76542. /**
  76543. * The byte type.
  76544. */
  76545. VertexBuffer.BYTE = 5120;
  76546. /**
  76547. * The unsigned byte type.
  76548. */
  76549. VertexBuffer.UNSIGNED_BYTE = 5121;
  76550. /**
  76551. * The short type.
  76552. */
  76553. VertexBuffer.SHORT = 5122;
  76554. /**
  76555. * The unsigned short type.
  76556. */
  76557. VertexBuffer.UNSIGNED_SHORT = 5123;
  76558. /**
  76559. * The integer type.
  76560. */
  76561. VertexBuffer.INT = 5124;
  76562. /**
  76563. * The unsigned integer type.
  76564. */
  76565. VertexBuffer.UNSIGNED_INT = 5125;
  76566. /**
  76567. * The float type.
  76568. */
  76569. VertexBuffer.FLOAT = 5126;
  76570. // Enums
  76571. /**
  76572. * Positions
  76573. */
  76574. VertexBuffer.PositionKind = "position";
  76575. /**
  76576. * Normals
  76577. */
  76578. VertexBuffer.NormalKind = "normal";
  76579. /**
  76580. * Tangents
  76581. */
  76582. VertexBuffer.TangentKind = "tangent";
  76583. /**
  76584. * Texture coordinates
  76585. */
  76586. VertexBuffer.UVKind = "uv";
  76587. /**
  76588. * Texture coordinates 2
  76589. */
  76590. VertexBuffer.UV2Kind = "uv2";
  76591. /**
  76592. * Texture coordinates 3
  76593. */
  76594. VertexBuffer.UV3Kind = "uv3";
  76595. /**
  76596. * Texture coordinates 4
  76597. */
  76598. VertexBuffer.UV4Kind = "uv4";
  76599. /**
  76600. * Texture coordinates 5
  76601. */
  76602. VertexBuffer.UV5Kind = "uv5";
  76603. /**
  76604. * Texture coordinates 6
  76605. */
  76606. VertexBuffer.UV6Kind = "uv6";
  76607. /**
  76608. * Colors
  76609. */
  76610. VertexBuffer.ColorKind = "color";
  76611. /**
  76612. * Matrix indices (for bones)
  76613. */
  76614. VertexBuffer.MatricesIndicesKind = "matricesIndices";
  76615. /**
  76616. * Matrix weights (for bones)
  76617. */
  76618. VertexBuffer.MatricesWeightsKind = "matricesWeights";
  76619. /**
  76620. * Additional matrix indices (for bones)
  76621. */
  76622. VertexBuffer.MatricesIndicesExtraKind = "matricesIndicesExtra";
  76623. /**
  76624. * Additional matrix weights (for bones)
  76625. */
  76626. VertexBuffer.MatricesWeightsExtraKind = "matricesWeightsExtra";
  76627. return VertexBuffer;
  76628. }());
  76629. /***/ }),
  76630. /***/ "./Meshes/csg.ts":
  76631. /*!***********************!*\
  76632. !*** ./Meshes/csg.ts ***!
  76633. \***********************/
  76634. /*! exports provided: CSG */
  76635. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76636. "use strict";
  76637. __webpack_require__.r(__webpack_exports__);
  76638. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return CSG; });
  76639. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  76640. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  76641. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  76642. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  76643. /**
  76644. * Unique ID when we import meshes from Babylon to CSG
  76645. */
  76646. var currentCSGMeshId = 0;
  76647. /**
  76648. * Represents a vertex of a polygon. Use your own vertex class instead of this
  76649. * one to provide additional features like texture coordinates and vertex
  76650. * colors. Custom vertex classes need to provide a `pos` property and `clone()`,
  76651. * `flip()`, and `interpolate()` methods that behave analogous to the ones
  76652. * defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience
  76653. * functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`
  76654. * is not used anywhere else.
  76655. * Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes
  76656. */
  76657. var Vertex = /** @class */ (function () {
  76658. /**
  76659. * Initializes the vertex
  76660. * @param pos The position of the vertex
  76661. * @param normal The normal of the vertex
  76662. * @param uv The texture coordinate of the vertex
  76663. */
  76664. function Vertex(
  76665. /**
  76666. * The position of the vertex
  76667. */
  76668. pos,
  76669. /**
  76670. * The normal of the vertex
  76671. */
  76672. normal,
  76673. /**
  76674. * The texture coordinate of the vertex
  76675. */
  76676. uv) {
  76677. this.pos = pos;
  76678. this.normal = normal;
  76679. this.uv = uv;
  76680. }
  76681. /**
  76682. * Make a clone, or deep copy, of the vertex
  76683. * @returns A new Vertex
  76684. */
  76685. Vertex.prototype.clone = function () {
  76686. return new Vertex(this.pos.clone(), this.normal.clone(), this.uv.clone());
  76687. };
  76688. /**
  76689. * Invert all orientation-specific data (e.g. vertex normal). Called when the
  76690. * orientation of a polygon is flipped.
  76691. */
  76692. Vertex.prototype.flip = function () {
  76693. this.normal = this.normal.scale(-1);
  76694. };
  76695. /**
  76696. * Create a new vertex between this vertex and `other` by linearly
  76697. * interpolating all properties using a parameter of `t`. Subclasses should
  76698. * override this to interpolate additional properties.
  76699. * @param other the vertex to interpolate against
  76700. * @param t The factor used to linearly interpolate between the vertices
  76701. */
  76702. Vertex.prototype.interpolate = function (other, t) {
  76703. 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));
  76704. };
  76705. return Vertex;
  76706. }());
  76707. /**
  76708. * Represents a plane in 3D space.
  76709. */
  76710. var Plane = /** @class */ (function () {
  76711. /**
  76712. * Initializes the plane
  76713. * @param normal The normal for the plane
  76714. * @param w
  76715. */
  76716. function Plane(normal, w) {
  76717. this.normal = normal;
  76718. this.w = w;
  76719. }
  76720. /**
  76721. * Construct a plane from three points
  76722. * @param a Point a
  76723. * @param b Point b
  76724. * @param c Point c
  76725. */
  76726. Plane.FromPoints = function (a, b, c) {
  76727. var v0 = c.subtract(a);
  76728. var v1 = b.subtract(a);
  76729. if (v0.lengthSquared() === 0 || v1.lengthSquared() === 0) {
  76730. return null;
  76731. }
  76732. var n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v0, v1));
  76733. return new Plane(n, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(n, a));
  76734. };
  76735. /**
  76736. * Clone, or make a deep copy of the plane
  76737. * @returns a new Plane
  76738. */
  76739. Plane.prototype.clone = function () {
  76740. return new Plane(this.normal.clone(), this.w);
  76741. };
  76742. /**
  76743. * Flip the face of the plane
  76744. */
  76745. Plane.prototype.flip = function () {
  76746. this.normal.scaleInPlace(-1);
  76747. this.w = -this.w;
  76748. };
  76749. /**
  76750. * Split `polygon` by this plane if needed, then put the polygon or polygon
  76751. * fragments in the appropriate lists. Coplanar polygons go into either
  76752. `* coplanarFront` or `coplanarBack` depending on their orientation with
  76753. * respect to this plane. Polygons in front or in back of this plane go into
  76754. * either `front` or `back`
  76755. * @param polygon The polygon to be split
  76756. * @param coplanarFront Will contain polygons coplanar with the plane that are oriented to the front of the plane
  76757. * @param coplanarBack Will contain polygons coplanar with the plane that are oriented to the back of the plane
  76758. * @param front Will contain the polygons in front of the plane
  76759. * @param back Will contain the polygons begind the plane
  76760. */
  76761. Plane.prototype.splitPolygon = function (polygon, coplanarFront, coplanarBack, front, back) {
  76762. var COPLANAR = 0;
  76763. var FRONT = 1;
  76764. var BACK = 2;
  76765. var SPANNING = 3;
  76766. // Classify each point as well as the entire polygon into one of the above
  76767. // four classes.
  76768. var polygonType = 0;
  76769. var types = [];
  76770. var i;
  76771. var t;
  76772. for (i = 0; i < polygon.vertices.length; i++) {
  76773. t = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.vertices[i].pos) - this.w;
  76774. var type = (t < -Plane.EPSILON) ? BACK : (t > Plane.EPSILON) ? FRONT : COPLANAR;
  76775. polygonType |= type;
  76776. types.push(type);
  76777. }
  76778. // Put the polygon in the correct list, splitting it when necessary
  76779. switch (polygonType) {
  76780. case COPLANAR:
  76781. (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
  76782. break;
  76783. case FRONT:
  76784. front.push(polygon);
  76785. break;
  76786. case BACK:
  76787. back.push(polygon);
  76788. break;
  76789. case SPANNING:
  76790. var f = [], b = [];
  76791. for (i = 0; i < polygon.vertices.length; i++) {
  76792. var j = (i + 1) % polygon.vertices.length;
  76793. var ti = types[i], tj = types[j];
  76794. var vi = polygon.vertices[i], vj = polygon.vertices[j];
  76795. if (ti !== BACK) {
  76796. f.push(vi);
  76797. }
  76798. if (ti !== FRONT) {
  76799. b.push(ti !== BACK ? vi.clone() : vi);
  76800. }
  76801. if ((ti | tj) === SPANNING) {
  76802. 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));
  76803. var v = vi.interpolate(vj, t);
  76804. f.push(v);
  76805. b.push(v.clone());
  76806. }
  76807. }
  76808. var poly;
  76809. if (f.length >= 3) {
  76810. poly = new Polygon(f, polygon.shared);
  76811. if (poly.plane) {
  76812. front.push(poly);
  76813. }
  76814. }
  76815. if (b.length >= 3) {
  76816. poly = new Polygon(b, polygon.shared);
  76817. if (poly.plane) {
  76818. back.push(poly);
  76819. }
  76820. }
  76821. break;
  76822. }
  76823. };
  76824. /**
  76825. * `CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a
  76826. * point is on the plane
  76827. */
  76828. Plane.EPSILON = 1e-5;
  76829. return Plane;
  76830. }());
  76831. /**
  76832. * Represents a convex polygon. The vertices used to initialize a polygon must
  76833. * be coplanar and form a convex loop.
  76834. *
  76835. * Each convex polygon has a `shared` property, which is shared between all
  76836. * polygons that are clones of each other or were split from the same polygon.
  76837. * This can be used to define per-polygon properties (such as surface color)
  76838. */
  76839. var Polygon = /** @class */ (function () {
  76840. /**
  76841. * Initializes the polygon
  76842. * @param vertices The vertices of the polygon
  76843. * @param shared The properties shared across all polygons
  76844. */
  76845. function Polygon(vertices, shared) {
  76846. this.vertices = vertices;
  76847. this.shared = shared;
  76848. this.plane = Plane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
  76849. }
  76850. /**
  76851. * Clones, or makes a deep copy, or the polygon
  76852. */
  76853. Polygon.prototype.clone = function () {
  76854. var vertices = this.vertices.map(function (v) { return v.clone(); });
  76855. return new Polygon(vertices, this.shared);
  76856. };
  76857. /**
  76858. * Flips the faces of the polygon
  76859. */
  76860. Polygon.prototype.flip = function () {
  76861. this.vertices.reverse().map(function (v) { v.flip(); });
  76862. this.plane.flip();
  76863. };
  76864. return Polygon;
  76865. }());
  76866. /**
  76867. * Holds a node in a BSP tree. A BSP tree is built from a collection of polygons
  76868. * by picking a polygon to split along. That polygon (and all other coplanar
  76869. * polygons) are added directly to that node and the other polygons are added to
  76870. * the front and/or back subtrees. This is not a leafy BSP tree since there is
  76871. * no distinction between internal and leaf nodes
  76872. */
  76873. var Node = /** @class */ (function () {
  76874. /**
  76875. * Initializes the node
  76876. * @param polygons A collection of polygons held in the node
  76877. */
  76878. function Node(polygons) {
  76879. this.plane = null;
  76880. this.front = null;
  76881. this.back = null;
  76882. this.polygons = new Array();
  76883. if (polygons) {
  76884. this.build(polygons);
  76885. }
  76886. }
  76887. /**
  76888. * Clones, or makes a deep copy, of the node
  76889. * @returns The cloned node
  76890. */
  76891. Node.prototype.clone = function () {
  76892. var node = new Node();
  76893. node.plane = this.plane && this.plane.clone();
  76894. node.front = this.front && this.front.clone();
  76895. node.back = this.back && this.back.clone();
  76896. node.polygons = this.polygons.map(function (p) { return p.clone(); });
  76897. return node;
  76898. };
  76899. /**
  76900. * Convert solid space to empty space and empty space to solid space
  76901. */
  76902. Node.prototype.invert = function () {
  76903. for (var i = 0; i < this.polygons.length; i++) {
  76904. this.polygons[i].flip();
  76905. }
  76906. if (this.plane) {
  76907. this.plane.flip();
  76908. }
  76909. if (this.front) {
  76910. this.front.invert();
  76911. }
  76912. if (this.back) {
  76913. this.back.invert();
  76914. }
  76915. var temp = this.front;
  76916. this.front = this.back;
  76917. this.back = temp;
  76918. };
  76919. /**
  76920. * Recursively remove all polygons in `polygons` that are inside this BSP
  76921. * tree.
  76922. * @param polygons Polygons to remove from the BSP
  76923. * @returns Polygons clipped from the BSP
  76924. */
  76925. Node.prototype.clipPolygons = function (polygons) {
  76926. if (!this.plane) {
  76927. return polygons.slice();
  76928. }
  76929. var front = new Array(), back = new Array();
  76930. for (var i = 0; i < polygons.length; i++) {
  76931. this.plane.splitPolygon(polygons[i], front, back, front, back);
  76932. }
  76933. if (this.front) {
  76934. front = this.front.clipPolygons(front);
  76935. }
  76936. if (this.back) {
  76937. back = this.back.clipPolygons(back);
  76938. }
  76939. else {
  76940. back = [];
  76941. }
  76942. return front.concat(back);
  76943. };
  76944. /**
  76945. * Remove all polygons in this BSP tree that are inside the other BSP tree
  76946. * `bsp`.
  76947. * @param bsp BSP containing polygons to remove from this BSP
  76948. */
  76949. Node.prototype.clipTo = function (bsp) {
  76950. this.polygons = bsp.clipPolygons(this.polygons);
  76951. if (this.front) {
  76952. this.front.clipTo(bsp);
  76953. }
  76954. if (this.back) {
  76955. this.back.clipTo(bsp);
  76956. }
  76957. };
  76958. /**
  76959. * Return a list of all polygons in this BSP tree
  76960. * @returns List of all polygons in this BSP tree
  76961. */
  76962. Node.prototype.allPolygons = function () {
  76963. var polygons = this.polygons.slice();
  76964. if (this.front) {
  76965. polygons = polygons.concat(this.front.allPolygons());
  76966. }
  76967. if (this.back) {
  76968. polygons = polygons.concat(this.back.allPolygons());
  76969. }
  76970. return polygons;
  76971. };
  76972. /**
  76973. * Build a BSP tree out of `polygons`. When called on an existing tree, the
  76974. * new polygons are filtered down to the bottom of the tree and become new
  76975. * nodes there. Each set of polygons is partitioned using the first polygon
  76976. * (no heuristic is used to pick a good split)
  76977. * @param polygons Polygons used to construct the BSP tree
  76978. */
  76979. Node.prototype.build = function (polygons) {
  76980. if (!polygons.length) {
  76981. return;
  76982. }
  76983. if (!this.plane) {
  76984. this.plane = polygons[0].plane.clone();
  76985. }
  76986. var front = new Array(), back = new Array();
  76987. for (var i = 0; i < polygons.length; i++) {
  76988. this.plane.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
  76989. }
  76990. if (front.length) {
  76991. if (!this.front) {
  76992. this.front = new Node();
  76993. }
  76994. this.front.build(front);
  76995. }
  76996. if (back.length) {
  76997. if (!this.back) {
  76998. this.back = new Node();
  76999. }
  77000. this.back.build(back);
  77001. }
  77002. };
  77003. return Node;
  77004. }());
  77005. /**
  77006. * Class for building Constructive Solid Geometry
  77007. */
  77008. var CSG = /** @class */ (function () {
  77009. function CSG() {
  77010. this.polygons = new Array();
  77011. }
  77012. /**
  77013. * Convert the Mesh to CSG
  77014. * @param mesh The Mesh to convert to CSG
  77015. * @returns A new CSG from the Mesh
  77016. */
  77017. CSG.FromMesh = function (mesh) {
  77018. var vertex, normal, uv, position, polygon, polygons = new Array(), vertices;
  77019. var matrix, meshPosition, meshRotation, meshRotationQuaternion = null, meshScaling;
  77020. if (mesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]) {
  77021. mesh.computeWorldMatrix(true);
  77022. matrix = mesh.getWorldMatrix();
  77023. meshPosition = mesh.position.clone();
  77024. meshRotation = mesh.rotation.clone();
  77025. if (mesh.rotationQuaternion) {
  77026. meshRotationQuaternion = mesh.rotationQuaternion.clone();
  77027. }
  77028. meshScaling = mesh.scaling.clone();
  77029. }
  77030. else {
  77031. throw 'BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh';
  77032. }
  77033. 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);
  77034. var subMeshes = mesh.subMeshes;
  77035. for (var sm = 0, sml = subMeshes.length; sm < sml; sm++) {
  77036. for (var i = subMeshes[sm].indexStart, il = subMeshes[sm].indexCount + subMeshes[sm].indexStart; i < il; i += 3) {
  77037. vertices = [];
  77038. for (var j = 0; j < 3; j++) {
  77039. 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]);
  77040. uv = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uvs[indices[i + j] * 2], uvs[indices[i + j] * 2 + 1]);
  77041. 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]);
  77042. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(sourcePosition, matrix);
  77043. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(sourceNormal, matrix);
  77044. vertex = new Vertex(position, normal, uv);
  77045. vertices.push(vertex);
  77046. }
  77047. polygon = new Polygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });
  77048. // To handle the case of degenerated triangle
  77049. // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated
  77050. if (polygon.plane) {
  77051. polygons.push(polygon);
  77052. }
  77053. }
  77054. }
  77055. var csg = CSG.FromPolygons(polygons);
  77056. csg.matrix = matrix;
  77057. csg.position = meshPosition;
  77058. csg.rotation = meshRotation;
  77059. csg.scaling = meshScaling;
  77060. csg.rotationQuaternion = meshRotationQuaternion;
  77061. currentCSGMeshId++;
  77062. return csg;
  77063. };
  77064. /**
  77065. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  77066. * @param polygons Polygons used to construct a CSG solid
  77067. */
  77068. CSG.FromPolygons = function (polygons) {
  77069. var csg = new CSG();
  77070. csg.polygons = polygons;
  77071. return csg;
  77072. };
  77073. /**
  77074. * Clones, or makes a deep copy, of the CSG
  77075. * @returns A new CSG
  77076. */
  77077. CSG.prototype.clone = function () {
  77078. var csg = new CSG();
  77079. csg.polygons = this.polygons.map(function (p) { return p.clone(); });
  77080. csg.copyTransformAttributes(this);
  77081. return csg;
  77082. };
  77083. /**
  77084. * Unions this CSG with another CSG
  77085. * @param csg The CSG to union against this CSG
  77086. * @returns The unioned CSG
  77087. */
  77088. CSG.prototype.union = function (csg) {
  77089. var a = new Node(this.clone().polygons);
  77090. var b = new Node(csg.clone().polygons);
  77091. a.clipTo(b);
  77092. b.clipTo(a);
  77093. b.invert();
  77094. b.clipTo(a);
  77095. b.invert();
  77096. a.build(b.allPolygons());
  77097. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  77098. };
  77099. /**
  77100. * Unions this CSG with another CSG in place
  77101. * @param csg The CSG to union against this CSG
  77102. */
  77103. CSG.prototype.unionInPlace = function (csg) {
  77104. var a = new Node(this.polygons);
  77105. var b = new Node(csg.polygons);
  77106. a.clipTo(b);
  77107. b.clipTo(a);
  77108. b.invert();
  77109. b.clipTo(a);
  77110. b.invert();
  77111. a.build(b.allPolygons());
  77112. this.polygons = a.allPolygons();
  77113. };
  77114. /**
  77115. * Subtracts this CSG with another CSG
  77116. * @param csg The CSG to subtract against this CSG
  77117. * @returns A new CSG
  77118. */
  77119. CSG.prototype.subtract = function (csg) {
  77120. var a = new Node(this.clone().polygons);
  77121. var b = new Node(csg.clone().polygons);
  77122. a.invert();
  77123. a.clipTo(b);
  77124. b.clipTo(a);
  77125. b.invert();
  77126. b.clipTo(a);
  77127. b.invert();
  77128. a.build(b.allPolygons());
  77129. a.invert();
  77130. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  77131. };
  77132. /**
  77133. * Subtracts this CSG with another CSG in place
  77134. * @param csg The CSG to subtact against this CSG
  77135. */
  77136. CSG.prototype.subtractInPlace = function (csg) {
  77137. var a = new Node(this.polygons);
  77138. var b = new Node(csg.polygons);
  77139. a.invert();
  77140. a.clipTo(b);
  77141. b.clipTo(a);
  77142. b.invert();
  77143. b.clipTo(a);
  77144. b.invert();
  77145. a.build(b.allPolygons());
  77146. a.invert();
  77147. this.polygons = a.allPolygons();
  77148. };
  77149. /**
  77150. * Intersect this CSG with another CSG
  77151. * @param csg The CSG to intersect against this CSG
  77152. * @returns A new CSG
  77153. */
  77154. CSG.prototype.intersect = function (csg) {
  77155. var a = new Node(this.clone().polygons);
  77156. var b = new Node(csg.clone().polygons);
  77157. a.invert();
  77158. b.clipTo(a);
  77159. b.invert();
  77160. a.clipTo(b);
  77161. b.clipTo(a);
  77162. a.build(b.allPolygons());
  77163. a.invert();
  77164. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  77165. };
  77166. /**
  77167. * Intersects this CSG with another CSG in place
  77168. * @param csg The CSG to intersect against this CSG
  77169. */
  77170. CSG.prototype.intersectInPlace = function (csg) {
  77171. var a = new Node(this.polygons);
  77172. var b = new Node(csg.polygons);
  77173. a.invert();
  77174. b.clipTo(a);
  77175. b.invert();
  77176. a.clipTo(b);
  77177. b.clipTo(a);
  77178. a.build(b.allPolygons());
  77179. a.invert();
  77180. this.polygons = a.allPolygons();
  77181. };
  77182. /**
  77183. * Return a new CSG solid with solid and empty space switched. This solid is
  77184. * not modified.
  77185. * @returns A new CSG solid with solid and empty space switched
  77186. */
  77187. CSG.prototype.inverse = function () {
  77188. var csg = this.clone();
  77189. csg.inverseInPlace();
  77190. return csg;
  77191. };
  77192. /**
  77193. * Inverses the CSG in place
  77194. */
  77195. CSG.prototype.inverseInPlace = function () {
  77196. this.polygons.map(function (p) { p.flip(); });
  77197. };
  77198. /**
  77199. * This is used to keep meshes transformations so they can be restored
  77200. * when we build back a Babylon Mesh
  77201. * NB : All CSG operations are performed in world coordinates
  77202. * @param csg The CSG to copy the transform attributes from
  77203. * @returns This CSG
  77204. */
  77205. CSG.prototype.copyTransformAttributes = function (csg) {
  77206. this.matrix = csg.matrix;
  77207. this.position = csg.position;
  77208. this.rotation = csg.rotation;
  77209. this.scaling = csg.scaling;
  77210. this.rotationQuaternion = csg.rotationQuaternion;
  77211. return this;
  77212. };
  77213. /**
  77214. * Build Raw mesh from CSG
  77215. * Coordinates here are in world space
  77216. * @param name The name of the mesh geometry
  77217. * @param scene The Scene
  77218. * @param keepSubMeshes Specifies if the submeshes should be kept
  77219. * @returns A new Mesh
  77220. */
  77221. CSG.prototype.buildMeshGeometry = function (name, scene, keepSubMeshes) {
  77222. var matrix = this.matrix.clone();
  77223. matrix.invert();
  77224. 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;
  77225. if (keepSubMeshes) {
  77226. // Sort Polygons, since subMeshes are indices range
  77227. polygons.sort(function (a, b) {
  77228. if (a.shared.meshId === b.shared.meshId) {
  77229. return a.shared.subMeshId - b.shared.subMeshId;
  77230. }
  77231. else {
  77232. return a.shared.meshId - b.shared.meshId;
  77233. }
  77234. });
  77235. }
  77236. for (var i = 0, il = polygons.length; i < il; i++) {
  77237. polygon = polygons[i];
  77238. // Building SubMeshes
  77239. if (!subMesh_dict[polygon.shared.meshId]) {
  77240. subMesh_dict[polygon.shared.meshId] = {};
  77241. }
  77242. if (!subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId]) {
  77243. subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId] = {
  77244. indexStart: +Infinity,
  77245. indexEnd: -Infinity,
  77246. materialIndex: polygon.shared.materialIndex
  77247. };
  77248. }
  77249. subMesh_obj = subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId];
  77250. for (var j = 2, jl = polygon.vertices.length; j < jl; j++) {
  77251. polygonIndices[0] = 0;
  77252. polygonIndices[1] = j - 1;
  77253. polygonIndices[2] = j;
  77254. for (var k = 0; k < 3; k++) {
  77255. vertex.copyFrom(polygon.vertices[polygonIndices[k]].pos);
  77256. normal.copyFrom(polygon.vertices[polygonIndices[k]].normal);
  77257. uv.copyFrom(polygon.vertices[polygonIndices[k]].uv);
  77258. var localVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(vertex, matrix);
  77259. var localNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, matrix);
  77260. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z];
  77261. // Check if 2 points can be merged
  77262. if (!(typeof vertex_idx !== 'undefined' &&
  77263. normals[vertex_idx * 3] === localNormal.x &&
  77264. normals[vertex_idx * 3 + 1] === localNormal.y &&
  77265. normals[vertex_idx * 3 + 2] === localNormal.z &&
  77266. uvs[vertex_idx * 2] === uv.x &&
  77267. uvs[vertex_idx * 2 + 1] === uv.y)) {
  77268. vertices.push(localVertex.x, localVertex.y, localVertex.z);
  77269. uvs.push(uv.x, uv.y);
  77270. normals.push(normal.x, normal.y, normal.z);
  77271. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z] = (vertices.length / 3) - 1;
  77272. }
  77273. indices.push(vertex_idx);
  77274. subMesh_obj.indexStart = Math.min(currentIndex, subMesh_obj.indexStart);
  77275. subMesh_obj.indexEnd = Math.max(currentIndex, subMesh_obj.indexEnd);
  77276. currentIndex++;
  77277. }
  77278. }
  77279. }
  77280. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, vertices);
  77281. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals);
  77282. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs);
  77283. mesh.setIndices(indices, null);
  77284. if (keepSubMeshes) {
  77285. // We offset the materialIndex by the previous number of materials in the CSG mixed meshes
  77286. var materialIndexOffset = 0, materialMaxIndex;
  77287. mesh.subMeshes = new Array();
  77288. for (var m in subMesh_dict) {
  77289. materialMaxIndex = -1;
  77290. for (var sm in subMesh_dict[m]) {
  77291. subMesh_obj = subMesh_dict[m][sm];
  77292. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].CreateFromIndices(subMesh_obj.materialIndex + materialIndexOffset, subMesh_obj.indexStart, subMesh_obj.indexEnd - subMesh_obj.indexStart + 1, mesh);
  77293. materialMaxIndex = Math.max(subMesh_obj.materialIndex, materialMaxIndex);
  77294. }
  77295. materialIndexOffset += ++materialMaxIndex;
  77296. }
  77297. }
  77298. return mesh;
  77299. };
  77300. /**
  77301. * Build Mesh from CSG taking material and transforms into account
  77302. * @param name The name of the Mesh
  77303. * @param material The material of the Mesh
  77304. * @param scene The Scene
  77305. * @param keepSubMeshes Specifies if submeshes should be kept
  77306. * @returns The new Mesh
  77307. */
  77308. CSG.prototype.toMesh = function (name, material, scene, keepSubMeshes) {
  77309. var mesh = this.buildMeshGeometry(name, scene, keepSubMeshes);
  77310. mesh.material = material;
  77311. mesh.position.copyFrom(this.position);
  77312. mesh.rotation.copyFrom(this.rotation);
  77313. if (this.rotationQuaternion) {
  77314. mesh.rotationQuaternion = this.rotationQuaternion.clone();
  77315. }
  77316. mesh.scaling.copyFrom(this.scaling);
  77317. mesh.computeWorldMatrix(true);
  77318. return mesh;
  77319. };
  77320. return CSG;
  77321. }());
  77322. /***/ }),
  77323. /***/ "./Meshes/geometry.ts":
  77324. /*!****************************!*\
  77325. !*** ./Meshes/geometry.ts ***!
  77326. \****************************/
  77327. /*! exports provided: Geometry, _PrimitiveGeometry, RibbonGeometry, BoxGeometry, SphereGeometry, DiscGeometry, CylinderGeometry, TorusGeometry, GroundGeometry, TiledGroundGeometry, PlaneGeometry, TorusKnotGeometry */
  77328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77329. "use strict";
  77330. __webpack_require__.r(__webpack_exports__);
  77331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return Geometry; });
  77332. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_PrimitiveGeometry", function() { return _PrimitiveGeometry; });
  77333. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RibbonGeometry", function() { return RibbonGeometry; });
  77334. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxGeometry", function() { return BoxGeometry; });
  77335. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereGeometry", function() { return SphereGeometry; });
  77336. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiscGeometry", function() { return DiscGeometry; });
  77337. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderGeometry", function() { return CylinderGeometry; });
  77338. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusGeometry", function() { return TorusGeometry; });
  77339. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundGeometry", function() { return GroundGeometry; });
  77340. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TiledGroundGeometry", function() { return TiledGroundGeometry; });
  77341. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneGeometry", function() { return PlaneGeometry; });
  77342. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusKnotGeometry", function() { return TorusKnotGeometry; });
  77343. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  77344. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  77345. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77346. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  77347. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  77348. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  77349. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  77350. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  77351. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  77352. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  77353. /**
  77354. * Class used to store geometry data (vertex buffers + index buffer)
  77355. */
  77356. var Geometry = /** @class */ (function () {
  77357. /**
  77358. * Creates a new geometry
  77359. * @param id defines the unique ID
  77360. * @param scene defines the hosting scene
  77361. * @param vertexData defines the VertexData used to get geometry data
  77362. * @param updatable defines if geometry must be updatable (false by default)
  77363. * @param mesh defines the mesh that will be associated with the geometry
  77364. */
  77365. function Geometry(id, scene, vertexData, updatable, mesh) {
  77366. if (updatable === void 0) { updatable = false; }
  77367. if (mesh === void 0) { mesh = null; }
  77368. /**
  77369. * Gets the delay loading state of the geometry (none by default which means not delayed)
  77370. */
  77371. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  77372. this._totalVertices = 0;
  77373. this._isDisposed = false;
  77374. this._indexBufferIsUpdatable = false;
  77375. this.id = id;
  77376. this.uniqueId = scene.getUniqueId();
  77377. this._engine = scene.getEngine();
  77378. this._meshes = [];
  77379. this._scene = scene;
  77380. //Init vertex buffer cache
  77381. this._vertexBuffers = {};
  77382. this._indices = [];
  77383. this._updatable = updatable;
  77384. // vertexData
  77385. if (vertexData) {
  77386. this.setAllVerticesData(vertexData, updatable);
  77387. }
  77388. else {
  77389. this._totalVertices = 0;
  77390. this._indices = [];
  77391. }
  77392. if (this._engine.getCaps().vertexArrayObject) {
  77393. this._vertexArrayObjects = {};
  77394. }
  77395. // applyToMesh
  77396. if (mesh) {
  77397. this.applyToMesh(mesh);
  77398. mesh.computeWorldMatrix(true);
  77399. }
  77400. }
  77401. Object.defineProperty(Geometry.prototype, "boundingBias", {
  77402. /**
  77403. * 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
  77404. */
  77405. get: function () {
  77406. return this._boundingBias;
  77407. },
  77408. /**
  77409. * 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
  77410. */
  77411. set: function (value) {
  77412. if (this._boundingBias) {
  77413. this._boundingBias.copyFrom(value);
  77414. }
  77415. else {
  77416. this._boundingBias = value.clone();
  77417. }
  77418. this._updateBoundingInfo(true, null);
  77419. },
  77420. enumerable: true,
  77421. configurable: true
  77422. });
  77423. /**
  77424. * Static function used to attach a new empty geometry to a mesh
  77425. * @param mesh defines the mesh to attach the geometry to
  77426. * @returns the new Geometry
  77427. */
  77428. Geometry.CreateGeometryForMesh = function (mesh) {
  77429. var geometry = new Geometry(Geometry.RandomId(), mesh.getScene());
  77430. geometry.applyToMesh(mesh);
  77431. return geometry;
  77432. };
  77433. Object.defineProperty(Geometry.prototype, "extend", {
  77434. /**
  77435. * Gets the current extend of the geometry
  77436. */
  77437. get: function () {
  77438. return this._extend;
  77439. },
  77440. enumerable: true,
  77441. configurable: true
  77442. });
  77443. /**
  77444. * Gets the hosting scene
  77445. * @returns the hosting Scene
  77446. */
  77447. Geometry.prototype.getScene = function () {
  77448. return this._scene;
  77449. };
  77450. /**
  77451. * Gets the hosting engine
  77452. * @returns the hosting Engine
  77453. */
  77454. Geometry.prototype.getEngine = function () {
  77455. return this._engine;
  77456. };
  77457. /**
  77458. * Defines if the geometry is ready to use
  77459. * @returns true if the geometry is ready to be used
  77460. */
  77461. Geometry.prototype.isReady = function () {
  77462. return this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_LOADED || this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  77463. };
  77464. Object.defineProperty(Geometry.prototype, "doNotSerialize", {
  77465. /**
  77466. * Gets a value indicating that the geometry should not be serialized
  77467. */
  77468. get: function () {
  77469. for (var index = 0; index < this._meshes.length; index++) {
  77470. if (!this._meshes[index].doNotSerialize) {
  77471. return false;
  77472. }
  77473. }
  77474. return true;
  77475. },
  77476. enumerable: true,
  77477. configurable: true
  77478. });
  77479. /** @hidden */
  77480. Geometry.prototype._rebuild = function () {
  77481. if (this._vertexArrayObjects) {
  77482. this._vertexArrayObjects = {};
  77483. }
  77484. // Index buffer
  77485. if (this._meshes.length !== 0 && this._indices) {
  77486. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  77487. }
  77488. // Vertex buffers
  77489. for (var key in this._vertexBuffers) {
  77490. var vertexBuffer = this._vertexBuffers[key];
  77491. vertexBuffer._rebuild();
  77492. }
  77493. };
  77494. /**
  77495. * Affects all geometry data in one call
  77496. * @param vertexData defines the geometry data
  77497. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  77498. */
  77499. Geometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  77500. vertexData.applyToGeometry(this, updatable);
  77501. this.notifyUpdate();
  77502. };
  77503. /**
  77504. * Set specific vertex data
  77505. * @param kind defines the data kind (Position, normal, etc...)
  77506. * @param data defines the vertex data to use
  77507. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  77508. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  77509. */
  77510. Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
  77511. if (updatable === void 0) { updatable = false; }
  77512. var buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](this._engine, data, kind, updatable, this._meshes.length === 0, stride);
  77513. this.setVerticesBuffer(buffer);
  77514. };
  77515. /**
  77516. * Removes a specific vertex data
  77517. * @param kind defines the data kind (Position, normal, etc...)
  77518. */
  77519. Geometry.prototype.removeVerticesData = function (kind) {
  77520. if (this._vertexBuffers[kind]) {
  77521. this._vertexBuffers[kind].dispose();
  77522. delete this._vertexBuffers[kind];
  77523. }
  77524. };
  77525. /**
  77526. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  77527. * @param buffer defines the vertex buffer to use
  77528. * @param totalVertices defines the total number of vertices for position kind (could be null)
  77529. */
  77530. Geometry.prototype.setVerticesBuffer = function (buffer, totalVertices) {
  77531. if (totalVertices === void 0) { totalVertices = null; }
  77532. var kind = buffer.getKind();
  77533. if (this._vertexBuffers[kind]) {
  77534. this._vertexBuffers[kind].dispose();
  77535. }
  77536. this._vertexBuffers[kind] = buffer;
  77537. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind) {
  77538. var data = buffer.getData();
  77539. if (totalVertices != null) {
  77540. this._totalVertices = totalVertices;
  77541. }
  77542. else {
  77543. if (data != null) {
  77544. this._totalVertices = data.length / (buffer.byteStride / 4);
  77545. }
  77546. }
  77547. this._updateExtend(data);
  77548. this._resetPointsArrayCache();
  77549. var meshes = this._meshes;
  77550. var numOfMeshes = meshes.length;
  77551. for (var index = 0; index < numOfMeshes; index++) {
  77552. var mesh = meshes[index];
  77553. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  77554. mesh._createGlobalSubMesh(false);
  77555. mesh.computeWorldMatrix(true);
  77556. }
  77557. }
  77558. this.notifyUpdate(kind);
  77559. if (this._vertexArrayObjects) {
  77560. this._disposeVertexArrayObjects();
  77561. this._vertexArrayObjects = {}; // Will trigger a rebuild of the VAO if supported
  77562. }
  77563. };
  77564. /**
  77565. * Update a specific vertex buffer
  77566. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  77567. * It will do nothing if the buffer is not updatable
  77568. * @param kind defines the data kind (Position, normal, etc...)
  77569. * @param data defines the data to use
  77570. * @param offset defines the offset in the target buffer where to store the data
  77571. * @param useBytes set to true if the offset is in bytes
  77572. */
  77573. Geometry.prototype.updateVerticesDataDirectly = function (kind, data, offset, useBytes) {
  77574. if (useBytes === void 0) { useBytes = false; }
  77575. var vertexBuffer = this.getVertexBuffer(kind);
  77576. if (!vertexBuffer) {
  77577. return;
  77578. }
  77579. vertexBuffer.updateDirectly(data, offset, useBytes);
  77580. this.notifyUpdate(kind);
  77581. };
  77582. /**
  77583. * Update a specific vertex buffer
  77584. * This function will create a new buffer if the current one is not updatable
  77585. * @param kind defines the data kind (Position, normal, etc...)
  77586. * @param data defines the data to use
  77587. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  77588. */
  77589. Geometry.prototype.updateVerticesData = function (kind, data, updateExtends) {
  77590. if (updateExtends === void 0) { updateExtends = false; }
  77591. var vertexBuffer = this.getVertexBuffer(kind);
  77592. if (!vertexBuffer) {
  77593. return;
  77594. }
  77595. vertexBuffer.update(data);
  77596. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind) {
  77597. this._updateBoundingInfo(updateExtends, data);
  77598. }
  77599. this.notifyUpdate(kind);
  77600. };
  77601. Geometry.prototype._updateBoundingInfo = function (updateExtends, data) {
  77602. if (updateExtends) {
  77603. this._updateExtend(data);
  77604. }
  77605. this._resetPointsArrayCache();
  77606. if (updateExtends) {
  77607. var meshes = this._meshes;
  77608. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  77609. var mesh = meshes_1[_i];
  77610. if (mesh._boundingInfo) {
  77611. mesh._boundingInfo.reConstruct(this._extend.minimum, this._extend.maximum);
  77612. }
  77613. else {
  77614. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  77615. }
  77616. var subMeshes = mesh.subMeshes;
  77617. for (var _a = 0, subMeshes_1 = subMeshes; _a < subMeshes_1.length; _a++) {
  77618. var subMesh = subMeshes_1[_a];
  77619. subMesh.refreshBoundingInfo();
  77620. }
  77621. }
  77622. }
  77623. };
  77624. /** @hidden */
  77625. Geometry.prototype._bind = function (effect, indexToBind) {
  77626. if (!effect) {
  77627. return;
  77628. }
  77629. if (indexToBind === undefined) {
  77630. indexToBind = this._indexBuffer;
  77631. }
  77632. var vbs = this.getVertexBuffers();
  77633. if (!vbs) {
  77634. return;
  77635. }
  77636. if (indexToBind != this._indexBuffer || !this._vertexArrayObjects) {
  77637. this._engine.bindBuffers(vbs, indexToBind, effect);
  77638. return;
  77639. }
  77640. // Using VAO
  77641. if (!this._vertexArrayObjects[effect.key]) {
  77642. this._vertexArrayObjects[effect.key] = this._engine.recordVertexArrayObject(vbs, indexToBind, effect);
  77643. }
  77644. this._engine.bindVertexArrayObject(this._vertexArrayObjects[effect.key], indexToBind);
  77645. };
  77646. /**
  77647. * Gets total number of vertices
  77648. * @returns the total number of vertices
  77649. */
  77650. Geometry.prototype.getTotalVertices = function () {
  77651. if (!this.isReady()) {
  77652. return 0;
  77653. }
  77654. return this._totalVertices;
  77655. };
  77656. /**
  77657. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  77658. * @param kind defines the data kind (Position, normal, etc...)
  77659. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77660. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77661. * @returns a float array containing vertex data
  77662. */
  77663. Geometry.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  77664. var vertexBuffer = this.getVertexBuffer(kind);
  77665. if (!vertexBuffer) {
  77666. return null;
  77667. }
  77668. var data = vertexBuffer.getData();
  77669. if (!data) {
  77670. return null;
  77671. }
  77672. var tightlyPackedByteStride = vertexBuffer.getSize() * _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].GetTypeByteLength(vertexBuffer.type);
  77673. var count = this._totalVertices * vertexBuffer.getSize();
  77674. if (vertexBuffer.type !== _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].FLOAT || vertexBuffer.byteStride !== tightlyPackedByteStride) {
  77675. var copy_1 = [];
  77676. vertexBuffer.forEach(count, function (value) { return copy_1.push(value); });
  77677. return copy_1;
  77678. }
  77679. if (!((data instanceof Array) || (data instanceof Float32Array)) || vertexBuffer.byteOffset !== 0 || data.length !== count) {
  77680. if (data instanceof Array) {
  77681. var offset = vertexBuffer.byteOffset / 4;
  77682. return _Misc_tools__WEBPACK_IMPORTED_MODULE_8__["Tools"].Slice(data, offset, offset + count);
  77683. }
  77684. else if (data instanceof ArrayBuffer) {
  77685. return new Float32Array(data, vertexBuffer.byteOffset, count);
  77686. }
  77687. else {
  77688. var offset = data.byteOffset + vertexBuffer.byteOffset;
  77689. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  77690. var result = new Float32Array(count);
  77691. var source = new Float32Array(data.buffer, offset, count);
  77692. result.set(source);
  77693. return result;
  77694. }
  77695. return new Float32Array(data.buffer, offset, count);
  77696. }
  77697. }
  77698. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  77699. return _Misc_tools__WEBPACK_IMPORTED_MODULE_8__["Tools"].Slice(data);
  77700. }
  77701. return data;
  77702. };
  77703. /**
  77704. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  77705. * @param kind defines the data kind (Position, normal, etc...)
  77706. * @returns true if the vertex buffer with the specified kind is updatable
  77707. */
  77708. Geometry.prototype.isVertexBufferUpdatable = function (kind) {
  77709. var vb = this._vertexBuffers[kind];
  77710. if (!vb) {
  77711. return false;
  77712. }
  77713. return vb.isUpdatable();
  77714. };
  77715. /**
  77716. * Gets a specific vertex buffer
  77717. * @param kind defines the data kind (Position, normal, etc...)
  77718. * @returns a VertexBuffer
  77719. */
  77720. Geometry.prototype.getVertexBuffer = function (kind) {
  77721. if (!this.isReady()) {
  77722. return null;
  77723. }
  77724. return this._vertexBuffers[kind];
  77725. };
  77726. /**
  77727. * Returns all vertex buffers
  77728. * @return an object holding all vertex buffers indexed by kind
  77729. */
  77730. Geometry.prototype.getVertexBuffers = function () {
  77731. if (!this.isReady()) {
  77732. return null;
  77733. }
  77734. return this._vertexBuffers;
  77735. };
  77736. /**
  77737. * Gets a boolean indicating if specific vertex buffer is present
  77738. * @param kind defines the data kind (Position, normal, etc...)
  77739. * @returns true if data is present
  77740. */
  77741. Geometry.prototype.isVerticesDataPresent = function (kind) {
  77742. if (!this._vertexBuffers) {
  77743. if (this._delayInfo) {
  77744. return this._delayInfo.indexOf(kind) !== -1;
  77745. }
  77746. return false;
  77747. }
  77748. return this._vertexBuffers[kind] !== undefined;
  77749. };
  77750. /**
  77751. * Gets a list of all attached data kinds (Position, normal, etc...)
  77752. * @returns a list of string containing all kinds
  77753. */
  77754. Geometry.prototype.getVerticesDataKinds = function () {
  77755. var result = [];
  77756. var kind;
  77757. if (!this._vertexBuffers && this._delayInfo) {
  77758. for (kind in this._delayInfo) {
  77759. result.push(kind);
  77760. }
  77761. }
  77762. else {
  77763. for (kind in this._vertexBuffers) {
  77764. result.push(kind);
  77765. }
  77766. }
  77767. return result;
  77768. };
  77769. /**
  77770. * Update index buffer
  77771. * @param indices defines the indices to store in the index buffer
  77772. * @param offset defines the offset in the target buffer where to store the data
  77773. */
  77774. Geometry.prototype.updateIndices = function (indices, offset) {
  77775. if (!this._indexBuffer) {
  77776. return;
  77777. }
  77778. if (!this._indexBufferIsUpdatable) {
  77779. this.setIndices(indices, null, true);
  77780. }
  77781. else {
  77782. var needToUpdateSubMeshes = indices.length !== this._indices.length;
  77783. this._indices = indices;
  77784. this._engine.updateDynamicIndexBuffer(this._indexBuffer, indices, offset);
  77785. if (needToUpdateSubMeshes) {
  77786. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  77787. var mesh = _a[_i];
  77788. mesh._createGlobalSubMesh(true);
  77789. }
  77790. }
  77791. }
  77792. };
  77793. /**
  77794. * Creates a new index buffer
  77795. * @param indices defines the indices to store in the index buffer
  77796. * @param totalVertices defines the total number of vertices (could be null)
  77797. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  77798. */
  77799. Geometry.prototype.setIndices = function (indices, totalVertices, updatable) {
  77800. if (totalVertices === void 0) { totalVertices = null; }
  77801. if (updatable === void 0) { updatable = false; }
  77802. if (this._indexBuffer) {
  77803. this._engine._releaseBuffer(this._indexBuffer);
  77804. }
  77805. this._disposeVertexArrayObjects();
  77806. this._indices = indices;
  77807. this._indexBufferIsUpdatable = updatable;
  77808. if (this._meshes.length !== 0 && this._indices) {
  77809. this._indexBuffer = this._engine.createIndexBuffer(this._indices, updatable);
  77810. }
  77811. if (totalVertices != undefined) { // including null and undefined
  77812. this._totalVertices = totalVertices;
  77813. }
  77814. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  77815. var mesh = _a[_i];
  77816. mesh._createGlobalSubMesh(true);
  77817. }
  77818. this.notifyUpdate();
  77819. };
  77820. /**
  77821. * Return the total number of indices
  77822. * @returns the total number of indices
  77823. */
  77824. Geometry.prototype.getTotalIndices = function () {
  77825. if (!this.isReady()) {
  77826. return 0;
  77827. }
  77828. return this._indices.length;
  77829. };
  77830. /**
  77831. * Gets the index buffer array
  77832. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77833. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77834. * @returns the index buffer array
  77835. */
  77836. Geometry.prototype.getIndices = function (copyWhenShared, forceCopy) {
  77837. if (!this.isReady()) {
  77838. return null;
  77839. }
  77840. var orig = this._indices;
  77841. if (!forceCopy && (!copyWhenShared || this._meshes.length === 1)) {
  77842. return orig;
  77843. }
  77844. else {
  77845. var len = orig.length;
  77846. var copy = [];
  77847. for (var i = 0; i < len; i++) {
  77848. copy.push(orig[i]);
  77849. }
  77850. return copy;
  77851. }
  77852. };
  77853. /**
  77854. * Gets the index buffer
  77855. * @return the index buffer
  77856. */
  77857. Geometry.prototype.getIndexBuffer = function () {
  77858. if (!this.isReady()) {
  77859. return null;
  77860. }
  77861. return this._indexBuffer;
  77862. };
  77863. /** @hidden */
  77864. Geometry.prototype._releaseVertexArrayObject = function (effect) {
  77865. if (effect === void 0) { effect = null; }
  77866. if (!effect || !this._vertexArrayObjects) {
  77867. return;
  77868. }
  77869. if (this._vertexArrayObjects[effect.key]) {
  77870. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[effect.key]);
  77871. delete this._vertexArrayObjects[effect.key];
  77872. }
  77873. };
  77874. /**
  77875. * Release the associated resources for a specific mesh
  77876. * @param mesh defines the source mesh
  77877. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  77878. */
  77879. Geometry.prototype.releaseForMesh = function (mesh, shouldDispose) {
  77880. var meshes = this._meshes;
  77881. var index = meshes.indexOf(mesh);
  77882. if (index === -1) {
  77883. return;
  77884. }
  77885. meshes.splice(index, 1);
  77886. mesh._geometry = null;
  77887. if (meshes.length === 0 && shouldDispose) {
  77888. this.dispose();
  77889. }
  77890. };
  77891. /**
  77892. * Apply current geometry to a given mesh
  77893. * @param mesh defines the mesh to apply geometry to
  77894. */
  77895. Geometry.prototype.applyToMesh = function (mesh) {
  77896. if (mesh._geometry === this) {
  77897. return;
  77898. }
  77899. var previousGeometry = mesh._geometry;
  77900. if (previousGeometry) {
  77901. previousGeometry.releaseForMesh(mesh);
  77902. }
  77903. var meshes = this._meshes;
  77904. // must be done before setting vertexBuffers because of mesh._createGlobalSubMesh()
  77905. mesh._geometry = this;
  77906. this._scene.pushGeometry(this);
  77907. meshes.push(mesh);
  77908. if (this.isReady()) {
  77909. this._applyToMesh(mesh);
  77910. }
  77911. else {
  77912. mesh._boundingInfo = this._boundingInfo;
  77913. }
  77914. };
  77915. Geometry.prototype._updateExtend = function (data) {
  77916. if (data === void 0) { data = null; }
  77917. if (!data) {
  77918. data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind);
  77919. }
  77920. this._extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_8__["Tools"].ExtractMinAndMax(data, 0, this._totalVertices, this.boundingBias, 3);
  77921. };
  77922. Geometry.prototype._applyToMesh = function (mesh) {
  77923. var numOfMeshes = this._meshes.length;
  77924. // vertexBuffers
  77925. for (var kind in this._vertexBuffers) {
  77926. if (numOfMeshes === 1) {
  77927. this._vertexBuffers[kind].create();
  77928. }
  77929. var buffer = this._vertexBuffers[kind].getBuffer();
  77930. if (buffer) {
  77931. buffer.references = numOfMeshes;
  77932. }
  77933. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind) {
  77934. if (!this._extend) {
  77935. this._updateExtend();
  77936. }
  77937. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  77938. mesh._createGlobalSubMesh(false);
  77939. //bounding info was just created again, world matrix should be applied again.
  77940. mesh._updateBoundingInfo();
  77941. }
  77942. }
  77943. // indexBuffer
  77944. if (numOfMeshes === 1 && this._indices && this._indices.length > 0) {
  77945. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  77946. }
  77947. if (this._indexBuffer) {
  77948. this._indexBuffer.references = numOfMeshes;
  77949. }
  77950. // morphTargets
  77951. mesh._syncGeometryWithMorphTargetManager();
  77952. // instances
  77953. mesh.synchronizeInstances();
  77954. };
  77955. Geometry.prototype.notifyUpdate = function (kind) {
  77956. if (this.onGeometryUpdated) {
  77957. this.onGeometryUpdated(this, kind);
  77958. }
  77959. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  77960. var mesh = _a[_i];
  77961. mesh._markSubMeshesAsAttributesDirty();
  77962. }
  77963. };
  77964. /**
  77965. * Load the geometry if it was flagged as delay loaded
  77966. * @param scene defines the hosting scene
  77967. * @param onLoaded defines a callback called when the geometry is loaded
  77968. */
  77969. Geometry.prototype.load = function (scene, onLoaded) {
  77970. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_LOADING) {
  77971. return;
  77972. }
  77973. if (this.isReady()) {
  77974. if (onLoaded) {
  77975. onLoaded();
  77976. }
  77977. return;
  77978. }
  77979. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_LOADING;
  77980. this._queueLoad(scene, onLoaded);
  77981. };
  77982. Geometry.prototype._queueLoad = function (scene, onLoaded) {
  77983. var _this = this;
  77984. if (!this.delayLoadingFile) {
  77985. return;
  77986. }
  77987. scene._addPendingData(this);
  77988. scene._loadFile(this.delayLoadingFile, function (data) {
  77989. if (!_this._delayLoadingFunction) {
  77990. return;
  77991. }
  77992. _this._delayLoadingFunction(JSON.parse(data), _this);
  77993. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_LOADED;
  77994. _this._delayInfo = [];
  77995. scene._removePendingData(_this);
  77996. var meshes = _this._meshes;
  77997. var numOfMeshes = meshes.length;
  77998. for (var index = 0; index < numOfMeshes; index++) {
  77999. _this._applyToMesh(meshes[index]);
  78000. }
  78001. if (onLoaded) {
  78002. onLoaded();
  78003. }
  78004. }, undefined, true);
  78005. };
  78006. /**
  78007. * Invert the geometry to move from a right handed system to a left handed one.
  78008. */
  78009. Geometry.prototype.toLeftHanded = function () {
  78010. // Flip faces
  78011. var tIndices = this.getIndices(false);
  78012. if (tIndices != null && tIndices.length > 0) {
  78013. for (var i = 0; i < tIndices.length; i += 3) {
  78014. var tTemp = tIndices[i + 0];
  78015. tIndices[i + 0] = tIndices[i + 2];
  78016. tIndices[i + 2] = tTemp;
  78017. }
  78018. this.setIndices(tIndices);
  78019. }
  78020. // Negate position.z
  78021. var tPositions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false);
  78022. if (tPositions != null && tPositions.length > 0) {
  78023. for (var i = 0; i < tPositions.length; i += 3) {
  78024. tPositions[i + 2] = -tPositions[i + 2];
  78025. }
  78026. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, tPositions, false);
  78027. }
  78028. // Negate normal.z
  78029. var tNormals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, false);
  78030. if (tNormals != null && tNormals.length > 0) {
  78031. for (var i = 0; i < tNormals.length; i += 3) {
  78032. tNormals[i + 2] = -tNormals[i + 2];
  78033. }
  78034. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, tNormals, false);
  78035. }
  78036. };
  78037. // Cache
  78038. /** @hidden */
  78039. Geometry.prototype._resetPointsArrayCache = function () {
  78040. this._positions = null;
  78041. };
  78042. /** @hidden */
  78043. Geometry.prototype._generatePointsArray = function () {
  78044. if (this._positions) {
  78045. return true;
  78046. }
  78047. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind);
  78048. if (!data || data.length === 0) {
  78049. return false;
  78050. }
  78051. this._positions = [];
  78052. for (var index = 0; index < data.length; index += 3) {
  78053. this._positions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(data, index));
  78054. }
  78055. return true;
  78056. };
  78057. /**
  78058. * Gets a value indicating if the geometry is disposed
  78059. * @returns true if the geometry was disposed
  78060. */
  78061. Geometry.prototype.isDisposed = function () {
  78062. return this._isDisposed;
  78063. };
  78064. Geometry.prototype._disposeVertexArrayObjects = function () {
  78065. if (this._vertexArrayObjects) {
  78066. for (var kind in this._vertexArrayObjects) {
  78067. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[kind]);
  78068. }
  78069. this._vertexArrayObjects = {};
  78070. }
  78071. };
  78072. /**
  78073. * Free all associated resources
  78074. */
  78075. Geometry.prototype.dispose = function () {
  78076. var meshes = this._meshes;
  78077. var numOfMeshes = meshes.length;
  78078. var index;
  78079. for (index = 0; index < numOfMeshes; index++) {
  78080. this.releaseForMesh(meshes[index]);
  78081. }
  78082. this._meshes = [];
  78083. this._disposeVertexArrayObjects();
  78084. for (var kind in this._vertexBuffers) {
  78085. this._vertexBuffers[kind].dispose();
  78086. }
  78087. this._vertexBuffers = {};
  78088. this._totalVertices = 0;
  78089. if (this._indexBuffer) {
  78090. this._engine._releaseBuffer(this._indexBuffer);
  78091. }
  78092. this._indexBuffer = null;
  78093. this._indices = [];
  78094. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  78095. this.delayLoadingFile = null;
  78096. this._delayLoadingFunction = null;
  78097. this._delayInfo = [];
  78098. this._boundingInfo = null;
  78099. this._scene.removeGeometry(this);
  78100. this._isDisposed = true;
  78101. };
  78102. /**
  78103. * Clone the current geometry into a new geometry
  78104. * @param id defines the unique ID of the new geometry
  78105. * @returns a new geometry object
  78106. */
  78107. Geometry.prototype.copy = function (id) {
  78108. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78109. vertexData.indices = [];
  78110. var indices = this.getIndices();
  78111. if (indices) {
  78112. for (var index = 0; index < indices.length; index++) {
  78113. vertexData.indices.push(indices[index]);
  78114. }
  78115. }
  78116. var updatable = false;
  78117. var stopChecking = false;
  78118. var kind;
  78119. for (kind in this._vertexBuffers) {
  78120. // using slice() to make a copy of the array and not just reference it
  78121. var data = this.getVerticesData(kind);
  78122. if (data) {
  78123. if (data instanceof Float32Array) {
  78124. vertexData.set(new Float32Array(data), kind);
  78125. }
  78126. else {
  78127. vertexData.set(data.slice(0), kind);
  78128. }
  78129. if (!stopChecking) {
  78130. var vb = this.getVertexBuffer(kind);
  78131. if (vb) {
  78132. updatable = vb.isUpdatable();
  78133. stopChecking = !updatable;
  78134. }
  78135. }
  78136. }
  78137. }
  78138. var geometry = new Geometry(id, this._scene, vertexData, updatable);
  78139. geometry.delayLoadState = this.delayLoadState;
  78140. geometry.delayLoadingFile = this.delayLoadingFile;
  78141. geometry._delayLoadingFunction = this._delayLoadingFunction;
  78142. for (kind in this._delayInfo) {
  78143. geometry._delayInfo = geometry._delayInfo || [];
  78144. geometry._delayInfo.push(kind);
  78145. }
  78146. // Bounding info
  78147. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  78148. return geometry;
  78149. };
  78150. /**
  78151. * Serialize the current geometry info (and not the vertices data) into a JSON object
  78152. * @return a JSON representation of the current geometry data (without the vertices data)
  78153. */
  78154. Geometry.prototype.serialize = function () {
  78155. var serializationObject = {};
  78156. serializationObject.id = this.id;
  78157. serializationObject.updatable = this._updatable;
  78158. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].HasTags(this)) {
  78159. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].GetTags(this);
  78160. }
  78161. return serializationObject;
  78162. };
  78163. Geometry.prototype.toNumberArray = function (origin) {
  78164. if (Array.isArray(origin)) {
  78165. return origin;
  78166. }
  78167. else {
  78168. return Array.prototype.slice.call(origin);
  78169. }
  78170. };
  78171. /**
  78172. * Serialize all vertices data into a JSON oject
  78173. * @returns a JSON representation of the current geometry data
  78174. */
  78175. Geometry.prototype.serializeVerticeData = function () {
  78176. var serializationObject = this.serialize();
  78177. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind)) {
  78178. serializationObject.positions = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  78179. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind)) {
  78180. serializationObject.positions._updatable = true;
  78181. }
  78182. }
  78183. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  78184. serializationObject.normals = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  78185. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  78186. serializationObject.normals._updatable = true;
  78187. }
  78188. }
  78189. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  78190. serializationObject.tangets = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  78191. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  78192. serializationObject.tangets._updatable = true;
  78193. }
  78194. }
  78195. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind)) {
  78196. serializationObject.uvs = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind));
  78197. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind)) {
  78198. serializationObject.uvs._updatable = true;
  78199. }
  78200. }
  78201. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind)) {
  78202. serializationObject.uv2s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind));
  78203. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind)) {
  78204. serializationObject.uv2s._updatable = true;
  78205. }
  78206. }
  78207. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind)) {
  78208. serializationObject.uv3s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind));
  78209. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind)) {
  78210. serializationObject.uv3s._updatable = true;
  78211. }
  78212. }
  78213. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind)) {
  78214. serializationObject.uv4s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind));
  78215. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind)) {
  78216. serializationObject.uv4s._updatable = true;
  78217. }
  78218. }
  78219. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind)) {
  78220. serializationObject.uv5s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind));
  78221. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind)) {
  78222. serializationObject.uv5s._updatable = true;
  78223. }
  78224. }
  78225. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind)) {
  78226. serializationObject.uv6s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind));
  78227. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind)) {
  78228. serializationObject.uv6s._updatable = true;
  78229. }
  78230. }
  78231. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  78232. serializationObject.colors = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind));
  78233. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  78234. serializationObject.colors._updatable = true;
  78235. }
  78236. }
  78237. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind)) {
  78238. serializationObject.matricesIndices = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind));
  78239. serializationObject.matricesIndices._isExpanded = true;
  78240. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind)) {
  78241. serializationObject.matricesIndices._updatable = true;
  78242. }
  78243. }
  78244. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind)) {
  78245. serializationObject.matricesWeights = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind));
  78246. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind)) {
  78247. serializationObject.matricesWeights._updatable = true;
  78248. }
  78249. }
  78250. serializationObject.indices = this.toNumberArray(this.getIndices());
  78251. return serializationObject;
  78252. };
  78253. // Statics
  78254. /**
  78255. * Extracts a clone of a mesh geometry
  78256. * @param mesh defines the source mesh
  78257. * @param id defines the unique ID of the new geometry object
  78258. * @returns the new geometry object
  78259. */
  78260. Geometry.ExtractFromMesh = function (mesh, id) {
  78261. var geometry = mesh._geometry;
  78262. if (!geometry) {
  78263. return null;
  78264. }
  78265. return geometry.copy(id);
  78266. };
  78267. /**
  78268. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  78269. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  78270. * Be aware Math.random() could cause collisions, but:
  78271. * "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"
  78272. * @returns a string containing a new GUID
  78273. */
  78274. Geometry.RandomId = function () {
  78275. return _Misc_tools__WEBPACK_IMPORTED_MODULE_8__["Tools"].RandomId();
  78276. };
  78277. /** @hidden */
  78278. Geometry._ImportGeometry = function (parsedGeometry, mesh) {
  78279. var scene = mesh.getScene();
  78280. // Geometry
  78281. var geometryId = parsedGeometry.geometryId;
  78282. if (geometryId) {
  78283. var geometry = scene.getGeometryByID(geometryId);
  78284. if (geometry) {
  78285. geometry.applyToMesh(mesh);
  78286. }
  78287. }
  78288. else if (parsedGeometry instanceof ArrayBuffer) {
  78289. var binaryInfo = mesh._binaryInfo;
  78290. if (binaryInfo.positionsAttrDesc && binaryInfo.positionsAttrDesc.count > 0) {
  78291. var positionsData = new Float32Array(parsedGeometry, binaryInfo.positionsAttrDesc.offset, binaryInfo.positionsAttrDesc.count);
  78292. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positionsData, false);
  78293. }
  78294. if (binaryInfo.normalsAttrDesc && binaryInfo.normalsAttrDesc.count > 0) {
  78295. var normalsData = new Float32Array(parsedGeometry, binaryInfo.normalsAttrDesc.offset, binaryInfo.normalsAttrDesc.count);
  78296. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normalsData, false);
  78297. }
  78298. if (binaryInfo.tangetsAttrDesc && binaryInfo.tangetsAttrDesc.count > 0) {
  78299. var tangentsData = new Float32Array(parsedGeometry, binaryInfo.tangetsAttrDesc.offset, binaryInfo.tangetsAttrDesc.count);
  78300. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind, tangentsData, false);
  78301. }
  78302. if (binaryInfo.uvsAttrDesc && binaryInfo.uvsAttrDesc.count > 0) {
  78303. var uvsData = new Float32Array(parsedGeometry, binaryInfo.uvsAttrDesc.offset, binaryInfo.uvsAttrDesc.count);
  78304. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, uvsData, false);
  78305. }
  78306. if (binaryInfo.uvs2AttrDesc && binaryInfo.uvs2AttrDesc.count > 0) {
  78307. var uvs2Data = new Float32Array(parsedGeometry, binaryInfo.uvs2AttrDesc.offset, binaryInfo.uvs2AttrDesc.count);
  78308. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind, uvs2Data, false);
  78309. }
  78310. if (binaryInfo.uvs3AttrDesc && binaryInfo.uvs3AttrDesc.count > 0) {
  78311. var uvs3Data = new Float32Array(parsedGeometry, binaryInfo.uvs3AttrDesc.offset, binaryInfo.uvs3AttrDesc.count);
  78312. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind, uvs3Data, false);
  78313. }
  78314. if (binaryInfo.uvs4AttrDesc && binaryInfo.uvs4AttrDesc.count > 0) {
  78315. var uvs4Data = new Float32Array(parsedGeometry, binaryInfo.uvs4AttrDesc.offset, binaryInfo.uvs4AttrDesc.count);
  78316. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind, uvs4Data, false);
  78317. }
  78318. if (binaryInfo.uvs5AttrDesc && binaryInfo.uvs5AttrDesc.count > 0) {
  78319. var uvs5Data = new Float32Array(parsedGeometry, binaryInfo.uvs5AttrDesc.offset, binaryInfo.uvs5AttrDesc.count);
  78320. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind, uvs5Data, false);
  78321. }
  78322. if (binaryInfo.uvs6AttrDesc && binaryInfo.uvs6AttrDesc.count > 0) {
  78323. var uvs6Data = new Float32Array(parsedGeometry, binaryInfo.uvs6AttrDesc.offset, binaryInfo.uvs6AttrDesc.count);
  78324. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind, uvs6Data, false);
  78325. }
  78326. if (binaryInfo.colorsAttrDesc && binaryInfo.colorsAttrDesc.count > 0) {
  78327. var colorsData = new Float32Array(parsedGeometry, binaryInfo.colorsAttrDesc.offset, binaryInfo.colorsAttrDesc.count);
  78328. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind, colorsData, false, binaryInfo.colorsAttrDesc.stride);
  78329. }
  78330. if (binaryInfo.matricesIndicesAttrDesc && binaryInfo.matricesIndicesAttrDesc.count > 0) {
  78331. var matricesIndicesData = new Int32Array(parsedGeometry, binaryInfo.matricesIndicesAttrDesc.offset, binaryInfo.matricesIndicesAttrDesc.count);
  78332. var floatIndices = [];
  78333. for (var i = 0; i < matricesIndicesData.length; i++) {
  78334. var index = matricesIndicesData[i];
  78335. floatIndices.push(index & 0x000000FF);
  78336. floatIndices.push((index & 0x0000FF00) >> 8);
  78337. floatIndices.push((index & 0x00FF0000) >> 16);
  78338. floatIndices.push(index >> 24);
  78339. }
  78340. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind, floatIndices, false);
  78341. }
  78342. if (binaryInfo.matricesWeightsAttrDesc && binaryInfo.matricesWeightsAttrDesc.count > 0) {
  78343. var matricesWeightsData = new Float32Array(parsedGeometry, binaryInfo.matricesWeightsAttrDesc.offset, binaryInfo.matricesWeightsAttrDesc.count);
  78344. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind, matricesWeightsData, false);
  78345. }
  78346. if (binaryInfo.indicesAttrDesc && binaryInfo.indicesAttrDesc.count > 0) {
  78347. var indicesData = new Int32Array(parsedGeometry, binaryInfo.indicesAttrDesc.offset, binaryInfo.indicesAttrDesc.count);
  78348. mesh.setIndices(indicesData, null);
  78349. }
  78350. if (binaryInfo.subMeshesAttrDesc && binaryInfo.subMeshesAttrDesc.count > 0) {
  78351. var subMeshesData = new Int32Array(parsedGeometry, binaryInfo.subMeshesAttrDesc.offset, binaryInfo.subMeshesAttrDesc.count * 5);
  78352. mesh.subMeshes = [];
  78353. for (var i = 0; i < binaryInfo.subMeshesAttrDesc.count; i++) {
  78354. var materialIndex = subMeshesData[(i * 5) + 0];
  78355. var verticesStart = subMeshesData[(i * 5) + 1];
  78356. var verticesCount = subMeshesData[(i * 5) + 2];
  78357. var indexStart = subMeshesData[(i * 5) + 3];
  78358. var indexCount = subMeshesData[(i * 5) + 4];
  78359. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_4__["SubMesh"].AddToMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh);
  78360. }
  78361. }
  78362. }
  78363. else if (parsedGeometry.positions && parsedGeometry.normals && parsedGeometry.indices) {
  78364. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, parsedGeometry.positions, parsedGeometry.positions._updatable);
  78365. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, parsedGeometry.normals, parsedGeometry.normals._updatable);
  78366. if (parsedGeometry.tangents) {
  78367. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind, parsedGeometry.tangents, parsedGeometry.tangents._updatable);
  78368. }
  78369. if (parsedGeometry.uvs) {
  78370. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, parsedGeometry.uvs, parsedGeometry.uvs._updatable);
  78371. }
  78372. if (parsedGeometry.uvs2) {
  78373. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind, parsedGeometry.uvs2, parsedGeometry.uvs2._updatable);
  78374. }
  78375. if (parsedGeometry.uvs3) {
  78376. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind, parsedGeometry.uvs3, parsedGeometry.uvs3._updatable);
  78377. }
  78378. if (parsedGeometry.uvs4) {
  78379. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind, parsedGeometry.uvs4, parsedGeometry.uvs4._updatable);
  78380. }
  78381. if (parsedGeometry.uvs5) {
  78382. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind, parsedGeometry.uvs5, parsedGeometry.uvs5._updatable);
  78383. }
  78384. if (parsedGeometry.uvs6) {
  78385. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind, parsedGeometry.uvs6, parsedGeometry.uvs6._updatable);
  78386. }
  78387. if (parsedGeometry.colors) {
  78388. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].CheckColors4(parsedGeometry.colors, parsedGeometry.positions.length / 3), parsedGeometry.colors._updatable);
  78389. }
  78390. if (parsedGeometry.matricesIndices) {
  78391. if (!parsedGeometry.matricesIndices._isExpanded) {
  78392. var floatIndices = [];
  78393. for (var i = 0; i < parsedGeometry.matricesIndices.length; i++) {
  78394. var matricesIndex = parsedGeometry.matricesIndices[i];
  78395. floatIndices.push(matricesIndex & 0x000000FF);
  78396. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  78397. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  78398. floatIndices.push(matricesIndex >> 24);
  78399. }
  78400. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind, floatIndices, parsedGeometry.matricesIndices._updatable);
  78401. }
  78402. else {
  78403. delete parsedGeometry.matricesIndices._isExpanded;
  78404. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind, parsedGeometry.matricesIndices, parsedGeometry.matricesIndices._updatable);
  78405. }
  78406. }
  78407. if (parsedGeometry.matricesIndicesExtra) {
  78408. if (!parsedGeometry.matricesIndicesExtra._isExpanded) {
  78409. var floatIndices = [];
  78410. for (var i = 0; i < parsedGeometry.matricesIndicesExtra.length; i++) {
  78411. var matricesIndex = parsedGeometry.matricesIndicesExtra[i];
  78412. floatIndices.push(matricesIndex & 0x000000FF);
  78413. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  78414. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  78415. floatIndices.push(matricesIndex >> 24);
  78416. }
  78417. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind, floatIndices, parsedGeometry.matricesIndicesExtra._updatable);
  78418. }
  78419. else {
  78420. delete parsedGeometry.matricesIndices._isExpanded;
  78421. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind, parsedGeometry.matricesIndicesExtra, parsedGeometry.matricesIndicesExtra._updatable);
  78422. }
  78423. }
  78424. if (parsedGeometry.matricesWeights) {
  78425. Geometry._CleanMatricesWeights(parsedGeometry, mesh);
  78426. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind, parsedGeometry.matricesWeights, parsedGeometry.matricesWeights._updatable);
  78427. }
  78428. if (parsedGeometry.matricesWeightsExtra) {
  78429. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind, parsedGeometry.matricesWeightsExtra, parsedGeometry.matricesWeights._updatable);
  78430. }
  78431. mesh.setIndices(parsedGeometry.indices, null);
  78432. }
  78433. // SubMeshes
  78434. if (parsedGeometry.subMeshes) {
  78435. mesh.subMeshes = [];
  78436. for (var subIndex = 0; subIndex < parsedGeometry.subMeshes.length; subIndex++) {
  78437. var parsedSubMesh = parsedGeometry.subMeshes[subIndex];
  78438. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_4__["SubMesh"].AddToMesh(parsedSubMesh.materialIndex, parsedSubMesh.verticesStart, parsedSubMesh.verticesCount, parsedSubMesh.indexStart, parsedSubMesh.indexCount, mesh);
  78439. }
  78440. }
  78441. // Flat shading
  78442. if (mesh._shouldGenerateFlatShading) {
  78443. mesh.convertToFlatShadedMesh();
  78444. delete mesh._shouldGenerateFlatShading;
  78445. }
  78446. // Update
  78447. mesh.computeWorldMatrix(true);
  78448. scene.onMeshImportedObservable.notifyObservers(mesh);
  78449. };
  78450. Geometry._CleanMatricesWeights = function (parsedGeometry, mesh) {
  78451. var epsilon = 1e-3;
  78452. if (!_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_5__["SceneLoaderFlags"].CleanBoneMatrixWeights) {
  78453. return;
  78454. }
  78455. var noInfluenceBoneIndex = 0.0;
  78456. if (parsedGeometry.skeletonId > -1) {
  78457. var skeleton = mesh.getScene().getLastSkeletonByID(parsedGeometry.skeletonId);
  78458. if (!skeleton) {
  78459. return;
  78460. }
  78461. noInfluenceBoneIndex = skeleton.bones.length;
  78462. }
  78463. else {
  78464. return;
  78465. }
  78466. var matricesIndices = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  78467. var matricesIndicesExtra = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  78468. var matricesWeights = parsedGeometry.matricesWeights;
  78469. var matricesWeightsExtra = parsedGeometry.matricesWeightsExtra;
  78470. var influencers = parsedGeometry.numBoneInfluencer;
  78471. var size = matricesWeights.length;
  78472. for (var i = 0; i < size; i += 4) {
  78473. var weight = 0.0;
  78474. var firstZeroWeight = -1;
  78475. for (var j = 0; j < 4; j++) {
  78476. var w = matricesWeights[i + j];
  78477. weight += w;
  78478. if (w < epsilon && firstZeroWeight < 0) {
  78479. firstZeroWeight = j;
  78480. }
  78481. }
  78482. if (matricesWeightsExtra) {
  78483. for (var j = 0; j < 4; j++) {
  78484. var w = matricesWeightsExtra[i + j];
  78485. weight += w;
  78486. if (w < epsilon && firstZeroWeight < 0) {
  78487. firstZeroWeight = j + 4;
  78488. }
  78489. }
  78490. }
  78491. if (firstZeroWeight < 0 || firstZeroWeight > (influencers - 1)) {
  78492. firstZeroWeight = influencers - 1;
  78493. }
  78494. if (weight > epsilon) {
  78495. var mweight = 1.0 / weight;
  78496. for (var j = 0; j < 4; j++) {
  78497. matricesWeights[i + j] *= mweight;
  78498. }
  78499. if (matricesWeightsExtra) {
  78500. for (var j = 0; j < 4; j++) {
  78501. matricesWeightsExtra[i + j] *= mweight;
  78502. }
  78503. }
  78504. }
  78505. else {
  78506. if (firstZeroWeight >= 4) {
  78507. matricesWeightsExtra[i + firstZeroWeight - 4] = 1.0 - weight;
  78508. matricesIndicesExtra[i + firstZeroWeight - 4] = noInfluenceBoneIndex;
  78509. }
  78510. else {
  78511. matricesWeights[i + firstZeroWeight] = 1.0 - weight;
  78512. matricesIndices[i + firstZeroWeight] = noInfluenceBoneIndex;
  78513. }
  78514. }
  78515. }
  78516. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind, matricesIndices);
  78517. if (parsedGeometry.matricesWeightsExtra) {
  78518. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind, matricesIndicesExtra);
  78519. }
  78520. };
  78521. /**
  78522. * Create a new geometry from persisted data (Using .babylon file format)
  78523. * @param parsedVertexData defines the persisted data
  78524. * @param scene defines the hosting scene
  78525. * @param rootUrl defines the root url to use to load assets (like delayed data)
  78526. * @returns the new geometry object
  78527. */
  78528. Geometry.Parse = function (parsedVertexData, scene, rootUrl) {
  78529. if (scene.getGeometryByID(parsedVertexData.id)) {
  78530. return null; // null since geometry could be something else than a box...
  78531. }
  78532. var geometry = new Geometry(parsedVertexData.id, scene, undefined, parsedVertexData.updatable);
  78533. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  78534. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(geometry, parsedVertexData.tags);
  78535. }
  78536. if (parsedVertexData.delayLoadingFile) {
  78537. geometry.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED;
  78538. geometry.delayLoadingFile = rootUrl + parsedVertexData.delayLoadingFile;
  78539. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_6__["BoundingInfo"](_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedVertexData.boundingBoxMinimum), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedVertexData.boundingBoxMaximum));
  78540. geometry._delayInfo = [];
  78541. if (parsedVertexData.hasUVs) {
  78542. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind);
  78543. }
  78544. if (parsedVertexData.hasUVs2) {
  78545. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV2Kind);
  78546. }
  78547. if (parsedVertexData.hasUVs3) {
  78548. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV3Kind);
  78549. }
  78550. if (parsedVertexData.hasUVs4) {
  78551. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV4Kind);
  78552. }
  78553. if (parsedVertexData.hasUVs5) {
  78554. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV5Kind);
  78555. }
  78556. if (parsedVertexData.hasUVs6) {
  78557. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UV6Kind);
  78558. }
  78559. if (parsedVertexData.hasColors) {
  78560. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  78561. }
  78562. if (parsedVertexData.hasMatricesIndices) {
  78563. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  78564. }
  78565. if (parsedVertexData.hasMatricesWeights) {
  78566. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  78567. }
  78568. geometry._delayLoadingFunction = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ImportVertexData;
  78569. }
  78570. else {
  78571. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ImportVertexData(parsedVertexData, geometry);
  78572. }
  78573. scene.pushGeometry(geometry, true);
  78574. return geometry;
  78575. };
  78576. return Geometry;
  78577. }());
  78578. // Primitives
  78579. /// Abstract class
  78580. /**
  78581. * Abstract class used to provide common services for all typed geometries
  78582. * @hidden
  78583. */
  78584. var _PrimitiveGeometry = /** @class */ (function (_super) {
  78585. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_PrimitiveGeometry, _super);
  78586. /**
  78587. * Creates a new typed geometry
  78588. * @param id defines the unique ID of the geometry
  78589. * @param scene defines the hosting scene
  78590. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78591. * @param mesh defines the hosting mesh (can be null)
  78592. */
  78593. function _PrimitiveGeometry(id, scene, _canBeRegenerated, mesh) {
  78594. if (_canBeRegenerated === void 0) { _canBeRegenerated = false; }
  78595. if (mesh === void 0) { mesh = null; }
  78596. var _this = _super.call(this, id, scene, undefined, false, mesh) || this;
  78597. _this._canBeRegenerated = _canBeRegenerated;
  78598. _this._beingRegenerated = true;
  78599. _this.regenerate();
  78600. _this._beingRegenerated = false;
  78601. return _this;
  78602. }
  78603. /**
  78604. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  78605. * @returns true if the geometry can be regenerated
  78606. */
  78607. _PrimitiveGeometry.prototype.canBeRegenerated = function () {
  78608. return this._canBeRegenerated;
  78609. };
  78610. /**
  78611. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  78612. */
  78613. _PrimitiveGeometry.prototype.regenerate = function () {
  78614. if (!this._canBeRegenerated) {
  78615. return;
  78616. }
  78617. this._beingRegenerated = true;
  78618. this.setAllVerticesData(this._regenerateVertexData(), false);
  78619. this._beingRegenerated = false;
  78620. };
  78621. /**
  78622. * Clone the geometry
  78623. * @param id defines the unique ID of the new geometry
  78624. * @returns the new geometry
  78625. */
  78626. _PrimitiveGeometry.prototype.asNewGeometry = function (id) {
  78627. return _super.prototype.copy.call(this, id);
  78628. };
  78629. // overrides
  78630. _PrimitiveGeometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  78631. if (!this._beingRegenerated) {
  78632. return;
  78633. }
  78634. _super.prototype.setAllVerticesData.call(this, vertexData, false);
  78635. };
  78636. _PrimitiveGeometry.prototype.setVerticesData = function (kind, data, updatable) {
  78637. if (!this._beingRegenerated) {
  78638. return;
  78639. }
  78640. _super.prototype.setVerticesData.call(this, kind, data, false);
  78641. };
  78642. // to override
  78643. /** @hidden */
  78644. _PrimitiveGeometry.prototype._regenerateVertexData = function () {
  78645. throw new Error("Abstract method");
  78646. };
  78647. _PrimitiveGeometry.prototype.copy = function (id) {
  78648. throw new Error("Must be overriden in sub-classes.");
  78649. };
  78650. _PrimitiveGeometry.prototype.serialize = function () {
  78651. var serializationObject = _super.prototype.serialize.call(this);
  78652. serializationObject.canBeRegenerated = this.canBeRegenerated();
  78653. return serializationObject;
  78654. };
  78655. return _PrimitiveGeometry;
  78656. }(Geometry));
  78657. /**
  78658. * Creates a ribbon geometry
  78659. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  78660. */
  78661. var RibbonGeometry = /** @class */ (function (_super) {
  78662. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RibbonGeometry, _super);
  78663. /**
  78664. * Creates a ribbon geometry
  78665. * @param id defines the unique ID of the geometry
  78666. * @param scene defines the hosting scene
  78667. * @param pathArray defines the array of paths to use
  78668. * @param closeArray defines if the last path and the first path must be joined
  78669. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  78670. * @param offset defines the offset between points
  78671. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78672. * @param mesh defines the hosting mesh (can be null)
  78673. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78674. */
  78675. function RibbonGeometry(id, scene,
  78676. /**
  78677. * Defines the array of paths to use
  78678. */
  78679. pathArray,
  78680. /**
  78681. * Defines if the last and first points of each path in your pathArray must be joined
  78682. */
  78683. closeArray,
  78684. /**
  78685. * Defines if the last and first points of each path in your pathArray must be joined
  78686. */
  78687. closePath,
  78688. /**
  78689. * Defines the offset between points
  78690. */
  78691. offset, canBeRegenerated, mesh,
  78692. /**
  78693. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78694. */
  78695. side) {
  78696. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  78697. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  78698. _this.pathArray = pathArray;
  78699. _this.closeArray = closeArray;
  78700. _this.closePath = closePath;
  78701. _this.offset = offset;
  78702. _this.side = side;
  78703. return _this;
  78704. }
  78705. /** @hidden */
  78706. RibbonGeometry.prototype._regenerateVertexData = function () {
  78707. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateRibbon({ pathArray: this.pathArray, closeArray: this.closeArray, closePath: this.closePath, offset: this.offset, sideOrientation: this.side });
  78708. };
  78709. RibbonGeometry.prototype.copy = function (id) {
  78710. return new RibbonGeometry(id, this.getScene(), this.pathArray, this.closeArray, this.closePath, this.offset, this.canBeRegenerated(), undefined, this.side);
  78711. };
  78712. return RibbonGeometry;
  78713. }(_PrimitiveGeometry));
  78714. /**
  78715. * Creates a box geometry
  78716. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  78717. */
  78718. var BoxGeometry = /** @class */ (function (_super) {
  78719. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoxGeometry, _super);
  78720. /**
  78721. * Creates a box geometry
  78722. * @param id defines the unique ID of the geometry
  78723. * @param scene defines the hosting scene
  78724. * @param size defines the zise of the box (width, height and depth are the same)
  78725. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78726. * @param mesh defines the hosting mesh (can be null)
  78727. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78728. */
  78729. function BoxGeometry(id, scene,
  78730. /**
  78731. * Defines the zise of the box (width, height and depth are the same)
  78732. */
  78733. size, canBeRegenerated, mesh,
  78734. /**
  78735. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78736. */
  78737. side) {
  78738. if (mesh === void 0) { mesh = null; }
  78739. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  78740. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  78741. _this.size = size;
  78742. _this.side = side;
  78743. return _this;
  78744. }
  78745. /** @hidden */
  78746. BoxGeometry.prototype._regenerateVertexData = function () {
  78747. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox({ size: this.size, sideOrientation: this.side });
  78748. };
  78749. BoxGeometry.prototype.copy = function (id) {
  78750. return new BoxGeometry(id, this.getScene(), this.size, this.canBeRegenerated(), undefined, this.side);
  78751. };
  78752. BoxGeometry.prototype.serialize = function () {
  78753. var serializationObject = _super.prototype.serialize.call(this);
  78754. serializationObject.size = this.size;
  78755. return serializationObject;
  78756. };
  78757. BoxGeometry.Parse = function (parsedBox, scene) {
  78758. if (scene.getGeometryByID(parsedBox.id)) {
  78759. return null; // null since geometry could be something else than a box...
  78760. }
  78761. var box = new BoxGeometry(parsedBox.id, scene, parsedBox.size, parsedBox.canBeRegenerated, null);
  78762. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  78763. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(box, parsedBox.tags);
  78764. }
  78765. scene.pushGeometry(box, true);
  78766. return box;
  78767. };
  78768. return BoxGeometry;
  78769. }(_PrimitiveGeometry));
  78770. /**
  78771. * Creates a sphere geometry
  78772. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  78773. */
  78774. var SphereGeometry = /** @class */ (function (_super) {
  78775. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SphereGeometry, _super);
  78776. /**
  78777. * Create a new sphere geometry
  78778. * @param id defines the unique ID of the geometry
  78779. * @param scene defines the hosting scene
  78780. * @param segments defines the number of segments to use to create the sphere
  78781. * @param diameter defines the diameter of the sphere
  78782. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78783. * @param mesh defines the hosting mesh (can be null)
  78784. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78785. */
  78786. function SphereGeometry(id, scene,
  78787. /**
  78788. * Defines the number of segments to use to create the sphere
  78789. */
  78790. segments,
  78791. /**
  78792. * Defines the diameter of the sphere
  78793. */
  78794. diameter, canBeRegenerated, mesh,
  78795. /**
  78796. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78797. */
  78798. side) {
  78799. if (mesh === void 0) { mesh = null; }
  78800. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  78801. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  78802. _this.segments = segments;
  78803. _this.diameter = diameter;
  78804. _this.side = side;
  78805. return _this;
  78806. }
  78807. /** @hidden */
  78808. SphereGeometry.prototype._regenerateVertexData = function () {
  78809. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere({ segments: this.segments, diameter: this.diameter, sideOrientation: this.side });
  78810. };
  78811. SphereGeometry.prototype.copy = function (id) {
  78812. return new SphereGeometry(id, this.getScene(), this.segments, this.diameter, this.canBeRegenerated(), null, this.side);
  78813. };
  78814. SphereGeometry.prototype.serialize = function () {
  78815. var serializationObject = _super.prototype.serialize.call(this);
  78816. serializationObject.segments = this.segments;
  78817. serializationObject.diameter = this.diameter;
  78818. return serializationObject;
  78819. };
  78820. SphereGeometry.Parse = function (parsedSphere, scene) {
  78821. if (scene.getGeometryByID(parsedSphere.id)) {
  78822. return null; // null since geometry could be something else than a sphere...
  78823. }
  78824. var sphere = new SphereGeometry(parsedSphere.id, scene, parsedSphere.segments, parsedSphere.diameter, parsedSphere.canBeRegenerated, null);
  78825. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  78826. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(sphere, parsedSphere.tags);
  78827. }
  78828. scene.pushGeometry(sphere, true);
  78829. return sphere;
  78830. };
  78831. return SphereGeometry;
  78832. }(_PrimitiveGeometry));
  78833. /**
  78834. * Creates a disc geometry
  78835. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  78836. */
  78837. var DiscGeometry = /** @class */ (function (_super) {
  78838. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DiscGeometry, _super);
  78839. /**
  78840. * Creates a new disc geometry
  78841. * @param id defines the unique ID of the geometry
  78842. * @param scene defines the hosting scene
  78843. * @param radius defines the radius of the disc
  78844. * @param tessellation defines the tesselation factor to apply to the disc
  78845. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78846. * @param mesh defines the hosting mesh (can be null)
  78847. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78848. */
  78849. function DiscGeometry(id, scene,
  78850. /**
  78851. * Defines the radius of the disc
  78852. */
  78853. radius,
  78854. /**
  78855. * Defines the tesselation factor to apply to the disc
  78856. */
  78857. tessellation, canBeRegenerated, mesh,
  78858. /**
  78859. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78860. */
  78861. side) {
  78862. if (mesh === void 0) { mesh = null; }
  78863. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  78864. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  78865. _this.radius = radius;
  78866. _this.tessellation = tessellation;
  78867. _this.side = side;
  78868. return _this;
  78869. }
  78870. /** @hidden */
  78871. DiscGeometry.prototype._regenerateVertexData = function () {
  78872. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDisc({ radius: this.radius, tessellation: this.tessellation, sideOrientation: this.side });
  78873. };
  78874. DiscGeometry.prototype.copy = function (id) {
  78875. return new DiscGeometry(id, this.getScene(), this.radius, this.tessellation, this.canBeRegenerated(), null, this.side);
  78876. };
  78877. return DiscGeometry;
  78878. }(_PrimitiveGeometry));
  78879. /**
  78880. * Creates a new cylinder geometry
  78881. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  78882. */
  78883. var CylinderGeometry = /** @class */ (function (_super) {
  78884. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderGeometry, _super);
  78885. /**
  78886. * Creates a new cylinder geometry
  78887. * @param id defines the unique ID of the geometry
  78888. * @param scene defines the hosting scene
  78889. * @param height defines the height of the cylinder
  78890. * @param diameterTop defines the diameter of the cylinder's top cap
  78891. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  78892. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  78893. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  78894. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78895. * @param mesh defines the hosting mesh (can be null)
  78896. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78897. */
  78898. function CylinderGeometry(id, scene,
  78899. /**
  78900. * Defines the height of the cylinder
  78901. */
  78902. height,
  78903. /**
  78904. * Defines the diameter of the cylinder's top cap
  78905. */
  78906. diameterTop,
  78907. /**
  78908. * Defines the diameter of the cylinder's bottom cap
  78909. */
  78910. diameterBottom,
  78911. /**
  78912. * Defines the tessellation factor to apply to the cylinder
  78913. */
  78914. tessellation,
  78915. /**
  78916. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  78917. */
  78918. subdivisions, canBeRegenerated, mesh,
  78919. /**
  78920. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78921. */
  78922. side) {
  78923. if (subdivisions === void 0) { subdivisions = 1; }
  78924. if (mesh === void 0) { mesh = null; }
  78925. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  78926. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  78927. _this.height = height;
  78928. _this.diameterTop = diameterTop;
  78929. _this.diameterBottom = diameterBottom;
  78930. _this.tessellation = tessellation;
  78931. _this.subdivisions = subdivisions;
  78932. _this.side = side;
  78933. return _this;
  78934. }
  78935. /** @hidden */
  78936. CylinderGeometry.prototype._regenerateVertexData = function () {
  78937. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder({ height: this.height, diameterTop: this.diameterTop, diameterBottom: this.diameterBottom, tessellation: this.tessellation, subdivisions: this.subdivisions, sideOrientation: this.side });
  78938. };
  78939. CylinderGeometry.prototype.copy = function (id) {
  78940. return new CylinderGeometry(id, this.getScene(), this.height, this.diameterTop, this.diameterBottom, this.tessellation, this.subdivisions, this.canBeRegenerated(), null, this.side);
  78941. };
  78942. CylinderGeometry.prototype.serialize = function () {
  78943. var serializationObject = _super.prototype.serialize.call(this);
  78944. serializationObject.height = this.height;
  78945. serializationObject.diameterTop = this.diameterTop;
  78946. serializationObject.diameterBottom = this.diameterBottom;
  78947. serializationObject.tessellation = this.tessellation;
  78948. return serializationObject;
  78949. };
  78950. CylinderGeometry.Parse = function (parsedCylinder, scene) {
  78951. if (scene.getGeometryByID(parsedCylinder.id)) {
  78952. return null; // null since geometry could be something else than a cylinder...
  78953. }
  78954. var cylinder = new CylinderGeometry(parsedCylinder.id, scene, parsedCylinder.height, parsedCylinder.diameterTop, parsedCylinder.diameterBottom, parsedCylinder.tessellation, parsedCylinder.subdivisions, parsedCylinder.canBeRegenerated, null);
  78955. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  78956. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(cylinder, parsedCylinder.tags);
  78957. }
  78958. scene.pushGeometry(cylinder, true);
  78959. return cylinder;
  78960. };
  78961. return CylinderGeometry;
  78962. }(_PrimitiveGeometry));
  78963. /**
  78964. * Creates a new torus geometry
  78965. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  78966. */
  78967. var TorusGeometry = /** @class */ (function (_super) {
  78968. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TorusGeometry, _super);
  78969. /**
  78970. * Creates a new torus geometry
  78971. * @param id defines the unique ID of the geometry
  78972. * @param scene defines the hosting scene
  78973. * @param diameter defines the diameter of the torus
  78974. * @param thickness defines the thickness of the torus (ie. internal diameter)
  78975. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  78976. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78977. * @param mesh defines the hosting mesh (can be null)
  78978. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78979. */
  78980. function TorusGeometry(id, scene,
  78981. /**
  78982. * Defines the diameter of the torus
  78983. */
  78984. diameter,
  78985. /**
  78986. * Defines the thickness of the torus (ie. internal diameter)
  78987. */
  78988. thickness,
  78989. /**
  78990. * Defines the tesselation factor to apply to the torus
  78991. */
  78992. tessellation, canBeRegenerated, mesh,
  78993. /**
  78994. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78995. */
  78996. side) {
  78997. if (mesh === void 0) { mesh = null; }
  78998. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  78999. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  79000. _this.diameter = diameter;
  79001. _this.thickness = thickness;
  79002. _this.tessellation = tessellation;
  79003. _this.side = side;
  79004. return _this;
  79005. }
  79006. /** @hidden */
  79007. TorusGeometry.prototype._regenerateVertexData = function () {
  79008. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus({ diameter: this.diameter, thickness: this.thickness, tessellation: this.tessellation, sideOrientation: this.side });
  79009. };
  79010. TorusGeometry.prototype.copy = function (id) {
  79011. return new TorusGeometry(id, this.getScene(), this.diameter, this.thickness, this.tessellation, this.canBeRegenerated(), null, this.side);
  79012. };
  79013. TorusGeometry.prototype.serialize = function () {
  79014. var serializationObject = _super.prototype.serialize.call(this);
  79015. serializationObject.diameter = this.diameter;
  79016. serializationObject.thickness = this.thickness;
  79017. serializationObject.tessellation = this.tessellation;
  79018. return serializationObject;
  79019. };
  79020. TorusGeometry.Parse = function (parsedTorus, scene) {
  79021. if (scene.getGeometryByID(parsedTorus.id)) {
  79022. return null; // null since geometry could be something else than a torus...
  79023. }
  79024. var torus = new TorusGeometry(parsedTorus.id, scene, parsedTorus.diameter, parsedTorus.thickness, parsedTorus.tessellation, parsedTorus.canBeRegenerated, null);
  79025. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  79026. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(torus, parsedTorus.tags);
  79027. }
  79028. scene.pushGeometry(torus, true);
  79029. return torus;
  79030. };
  79031. return TorusGeometry;
  79032. }(_PrimitiveGeometry));
  79033. /**
  79034. * Creates a new ground geometry
  79035. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  79036. */
  79037. var GroundGeometry = /** @class */ (function (_super) {
  79038. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GroundGeometry, _super);
  79039. /**
  79040. * Creates a new ground geometry
  79041. * @param id defines the unique ID of the geometry
  79042. * @param scene defines the hosting scene
  79043. * @param width defines the width of the ground
  79044. * @param height defines the height of the ground
  79045. * @param subdivisions defines the subdivisions to apply to the ground
  79046. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  79047. * @param mesh defines the hosting mesh (can be null)
  79048. */
  79049. function GroundGeometry(id, scene,
  79050. /**
  79051. * Defines the width of the ground
  79052. */
  79053. width,
  79054. /**
  79055. * Defines the height of the ground
  79056. */
  79057. height,
  79058. /**
  79059. * Defines the subdivisions to apply to the ground
  79060. */
  79061. subdivisions, canBeRegenerated, mesh) {
  79062. if (mesh === void 0) { mesh = null; }
  79063. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  79064. _this.width = width;
  79065. _this.height = height;
  79066. _this.subdivisions = subdivisions;
  79067. return _this;
  79068. }
  79069. /** @hidden */
  79070. GroundGeometry.prototype._regenerateVertexData = function () {
  79071. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround({ width: this.width, height: this.height, subdivisions: this.subdivisions });
  79072. };
  79073. GroundGeometry.prototype.copy = function (id) {
  79074. return new GroundGeometry(id, this.getScene(), this.width, this.height, this.subdivisions, this.canBeRegenerated(), null);
  79075. };
  79076. GroundGeometry.prototype.serialize = function () {
  79077. var serializationObject = _super.prototype.serialize.call(this);
  79078. serializationObject.width = this.width;
  79079. serializationObject.height = this.height;
  79080. serializationObject.subdivisions = this.subdivisions;
  79081. return serializationObject;
  79082. };
  79083. GroundGeometry.Parse = function (parsedGround, scene) {
  79084. if (scene.getGeometryByID(parsedGround.id)) {
  79085. return null; // null since geometry could be something else than a ground...
  79086. }
  79087. var ground = new GroundGeometry(parsedGround.id, scene, parsedGround.width, parsedGround.height, parsedGround.subdivisions, parsedGround.canBeRegenerated, null);
  79088. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  79089. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(ground, parsedGround.tags);
  79090. }
  79091. scene.pushGeometry(ground, true);
  79092. return ground;
  79093. };
  79094. return GroundGeometry;
  79095. }(_PrimitiveGeometry));
  79096. /**
  79097. * Creates a tiled ground geometry
  79098. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  79099. */
  79100. var TiledGroundGeometry = /** @class */ (function (_super) {
  79101. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TiledGroundGeometry, _super);
  79102. /**
  79103. * Creates a tiled ground geometry
  79104. * @param id defines the unique ID of the geometry
  79105. * @param scene defines the hosting scene
  79106. * @param xmin defines the minimum value on X axis
  79107. * @param zmin defines the minimum value on Z axis
  79108. * @param xmax defines the maximum value on X axis
  79109. * @param zmax defines the maximum value on Z axis
  79110. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  79111. * @param precision defines the precision to use when computing the tiles
  79112. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  79113. * @param mesh defines the hosting mesh (can be null)
  79114. */
  79115. function TiledGroundGeometry(id, scene,
  79116. /**
  79117. * Defines the minimum value on X axis
  79118. */
  79119. xmin,
  79120. /**
  79121. * Defines the minimum value on Z axis
  79122. */
  79123. zmin,
  79124. /**
  79125. * Defines the maximum value on X axis
  79126. */
  79127. xmax,
  79128. /**
  79129. * Defines the maximum value on Z axis
  79130. */
  79131. zmax,
  79132. /**
  79133. * Defines the subdivisions to apply to the ground
  79134. */
  79135. subdivisions,
  79136. /**
  79137. * Defines the precision to use when computing the tiles
  79138. */
  79139. precision, canBeRegenerated, mesh) {
  79140. if (mesh === void 0) { mesh = null; }
  79141. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  79142. _this.xmin = xmin;
  79143. _this.zmin = zmin;
  79144. _this.xmax = xmax;
  79145. _this.zmax = zmax;
  79146. _this.subdivisions = subdivisions;
  79147. _this.precision = precision;
  79148. return _this;
  79149. }
  79150. /** @hidden */
  79151. TiledGroundGeometry.prototype._regenerateVertexData = function () {
  79152. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround({ xmin: this.xmin, zmin: this.zmin, xmax: this.xmax, zmax: this.zmax, subdivisions: this.subdivisions, precision: this.precision });
  79153. };
  79154. TiledGroundGeometry.prototype.copy = function (id) {
  79155. return new TiledGroundGeometry(id, this.getScene(), this.xmin, this.zmin, this.xmax, this.zmax, this.subdivisions, this.precision, this.canBeRegenerated(), null);
  79156. };
  79157. return TiledGroundGeometry;
  79158. }(_PrimitiveGeometry));
  79159. /**
  79160. * Creates a plane geometry
  79161. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  79162. */
  79163. var PlaneGeometry = /** @class */ (function (_super) {
  79164. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneGeometry, _super);
  79165. /**
  79166. * Creates a plane geometry
  79167. * @param id defines the unique ID of the geometry
  79168. * @param scene defines the hosting scene
  79169. * @param size defines the size of the plane (width === height)
  79170. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  79171. * @param mesh defines the hosting mesh (can be null)
  79172. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  79173. */
  79174. function PlaneGeometry(id, scene,
  79175. /**
  79176. * Defines the size of the plane (width === height)
  79177. */
  79178. size, canBeRegenerated, mesh,
  79179. /**
  79180. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  79181. */
  79182. side) {
  79183. if (mesh === void 0) { mesh = null; }
  79184. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  79185. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  79186. _this.size = size;
  79187. _this.side = side;
  79188. return _this;
  79189. }
  79190. /** @hidden */
  79191. PlaneGeometry.prototype._regenerateVertexData = function () {
  79192. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePlane({ size: this.size, sideOrientation: this.side });
  79193. };
  79194. PlaneGeometry.prototype.copy = function (id) {
  79195. return new PlaneGeometry(id, this.getScene(), this.size, this.canBeRegenerated(), null, this.side);
  79196. };
  79197. PlaneGeometry.prototype.serialize = function () {
  79198. var serializationObject = _super.prototype.serialize.call(this);
  79199. serializationObject.size = this.size;
  79200. return serializationObject;
  79201. };
  79202. PlaneGeometry.Parse = function (parsedPlane, scene) {
  79203. if (scene.getGeometryByID(parsedPlane.id)) {
  79204. return null; // null since geometry could be something else than a ground...
  79205. }
  79206. var plane = new PlaneGeometry(parsedPlane.id, scene, parsedPlane.size, parsedPlane.canBeRegenerated, null);
  79207. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  79208. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(plane, parsedPlane.tags);
  79209. }
  79210. scene.pushGeometry(plane, true);
  79211. return plane;
  79212. };
  79213. return PlaneGeometry;
  79214. }(_PrimitiveGeometry));
  79215. /**
  79216. * Creates a torus knot geometry
  79217. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  79218. */
  79219. var TorusKnotGeometry = /** @class */ (function (_super) {
  79220. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TorusKnotGeometry, _super);
  79221. /**
  79222. * Creates a torus knot geometry
  79223. * @param id defines the unique ID of the geometry
  79224. * @param scene defines the hosting scene
  79225. * @param radius defines the radius of the torus knot
  79226. * @param tube defines the thickness of the torus knot tube
  79227. * @param radialSegments defines the number of radial segments
  79228. * @param tubularSegments defines the number of tubular segments
  79229. * @param p defines the first number of windings
  79230. * @param q defines the second number of windings
  79231. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  79232. * @param mesh defines the hosting mesh (can be null)
  79233. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  79234. */
  79235. function TorusKnotGeometry(id, scene,
  79236. /**
  79237. * Defines the radius of the torus knot
  79238. */
  79239. radius,
  79240. /**
  79241. * Defines the thickness of the torus knot tube
  79242. */
  79243. tube,
  79244. /**
  79245. * Defines the number of radial segments
  79246. */
  79247. radialSegments,
  79248. /**
  79249. * Defines the number of tubular segments
  79250. */
  79251. tubularSegments,
  79252. /**
  79253. * Defines the first number of windings
  79254. */
  79255. p,
  79256. /**
  79257. * Defines the second number of windings
  79258. */
  79259. q, canBeRegenerated, mesh,
  79260. /**
  79261. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  79262. */
  79263. side) {
  79264. if (mesh === void 0) { mesh = null; }
  79265. if (side === void 0) { side = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE; }
  79266. var _this = _super.call(this, id, scene, canBeRegenerated, mesh) || this;
  79267. _this.radius = radius;
  79268. _this.tube = tube;
  79269. _this.radialSegments = radialSegments;
  79270. _this.tubularSegments = tubularSegments;
  79271. _this.p = p;
  79272. _this.q = q;
  79273. _this.side = side;
  79274. return _this;
  79275. }
  79276. /** @hidden */
  79277. TorusKnotGeometry.prototype._regenerateVertexData = function () {
  79278. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot({ radius: this.radius, tube: this.tube, radialSegments: this.radialSegments, tubularSegments: this.tubularSegments, p: this.p, q: this.q, sideOrientation: this.side });
  79279. };
  79280. TorusKnotGeometry.prototype.copy = function (id) {
  79281. return new TorusKnotGeometry(id, this.getScene(), this.radius, this.tube, this.radialSegments, this.tubularSegments, this.p, this.q, this.canBeRegenerated(), null, this.side);
  79282. };
  79283. TorusKnotGeometry.prototype.serialize = function () {
  79284. var serializationObject = _super.prototype.serialize.call(this);
  79285. serializationObject.radius = this.radius;
  79286. serializationObject.tube = this.tube;
  79287. serializationObject.radialSegments = this.radialSegments;
  79288. serializationObject.tubularSegments = this.tubularSegments;
  79289. serializationObject.p = this.p;
  79290. serializationObject.q = this.q;
  79291. return serializationObject;
  79292. };
  79293. TorusKnotGeometry.Parse = function (parsedTorusKnot, scene) {
  79294. if (scene.getGeometryByID(parsedTorusKnot.id)) {
  79295. return null; // null since geometry could be something else than a ground...
  79296. }
  79297. var torusKnot = new TorusKnotGeometry(parsedTorusKnot.id, scene, parsedTorusKnot.radius, parsedTorusKnot.tube, parsedTorusKnot.radialSegments, parsedTorusKnot.tubularSegments, parsedTorusKnot.p, parsedTorusKnot.q, parsedTorusKnot.canBeRegenerated, null);
  79298. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"]) {
  79299. _Misc_tags__WEBPACK_IMPORTED_MODULE_9__["Tags"].AddTagsTo(torusKnot, parsedTorusKnot.tags);
  79300. }
  79301. scene.pushGeometry(torusKnot, true);
  79302. return torusKnot;
  79303. };
  79304. return TorusKnotGeometry;
  79305. }(_PrimitiveGeometry));
  79306. //}
  79307. /***/ }),
  79308. /***/ "./Meshes/groundMesh.ts":
  79309. /*!******************************!*\
  79310. !*** ./Meshes/groundMesh.ts ***!
  79311. \******************************/
  79312. /*! exports provided: GroundMesh */
  79313. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79314. "use strict";
  79315. __webpack_require__.r(__webpack_exports__);
  79316. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return GroundMesh; });
  79317. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  79318. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  79319. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  79320. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  79321. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._GroundMeshParser = function (parsedMesh, scene) {
  79322. return GroundMesh.Parse(parsedMesh, scene);
  79323. };
  79324. /**
  79325. * Mesh representing the gorund
  79326. */
  79327. var GroundMesh = /** @class */ (function (_super) {
  79328. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GroundMesh, _super);
  79329. function GroundMesh(name, scene) {
  79330. var _this = _super.call(this, name, scene) || this;
  79331. /** If octree should be generated */
  79332. _this.generateOctree = false;
  79333. return _this;
  79334. }
  79335. /**
  79336. * "GroundMesh"
  79337. * @returns "GroundMesh"
  79338. */
  79339. GroundMesh.prototype.getClassName = function () {
  79340. return "GroundMesh";
  79341. };
  79342. Object.defineProperty(GroundMesh.prototype, "subdivisions", {
  79343. /**
  79344. * The minimum of x and y subdivisions
  79345. */
  79346. get: function () {
  79347. return Math.min(this._subdivisionsX, this._subdivisionsY);
  79348. },
  79349. enumerable: true,
  79350. configurable: true
  79351. });
  79352. Object.defineProperty(GroundMesh.prototype, "subdivisionsX", {
  79353. /**
  79354. * X subdivisions
  79355. */
  79356. get: function () {
  79357. return this._subdivisionsX;
  79358. },
  79359. enumerable: true,
  79360. configurable: true
  79361. });
  79362. Object.defineProperty(GroundMesh.prototype, "subdivisionsY", {
  79363. /**
  79364. * Y subdivisions
  79365. */
  79366. get: function () {
  79367. return this._subdivisionsY;
  79368. },
  79369. enumerable: true,
  79370. configurable: true
  79371. });
  79372. /**
  79373. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  79374. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  79375. * @param chunksCount the number of subdivisions for x and y
  79376. * @param octreeBlocksSize (Default: 32)
  79377. */
  79378. GroundMesh.prototype.optimize = function (chunksCount, octreeBlocksSize) {
  79379. if (octreeBlocksSize === void 0) { octreeBlocksSize = 32; }
  79380. this._subdivisionsX = chunksCount;
  79381. this._subdivisionsY = chunksCount;
  79382. this.subdivide(chunksCount);
  79383. // Call the octree system optimization if it is defined.
  79384. var thisAsAny = this;
  79385. if (thisAsAny.createOrUpdateSubmeshesOctree) {
  79386. thisAsAny.createOrUpdateSubmeshesOctree(octreeBlocksSize);
  79387. }
  79388. };
  79389. /**
  79390. * Returns a height (y) value in the Worl system :
  79391. * the ground altitude at the coordinates (x, z) expressed in the World system.
  79392. * @param x x coordinate
  79393. * @param z z coordinate
  79394. * @returns the ground y position if (x, z) are outside the ground surface.
  79395. */
  79396. GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
  79397. var world = this.getWorldMatrix();
  79398. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  79399. world.invertToRef(invMat);
  79400. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  79401. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, invMat, tmpVect); // transform x,z in the mesh local space
  79402. x = tmpVect.x;
  79403. z = tmpVect.z;
  79404. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  79405. return this.position.y;
  79406. }
  79407. if (!this._heightQuads || this._heightQuads.length == 0) {
  79408. this._initHeightQuads();
  79409. this._computeHeightQuads();
  79410. }
  79411. var facet = this._getFacetAt(x, z);
  79412. var y = -(facet.x * x + facet.z * z + facet.w) / facet.y;
  79413. // return y in the World system
  79414. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0.0, y, 0.0, world, tmpVect);
  79415. return tmpVect.y;
  79416. };
  79417. /**
  79418. * Returns a normalized vector (Vector3) orthogonal to the ground
  79419. * at the ground coordinates (x, z) expressed in the World system.
  79420. * @param x x coordinate
  79421. * @param z z coordinate
  79422. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  79423. */
  79424. GroundMesh.prototype.getNormalAtCoordinates = function (x, z) {
  79425. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.0, 1.0, 0.0);
  79426. this.getNormalAtCoordinatesToRef(x, z, normal);
  79427. return normal;
  79428. };
  79429. /**
  79430. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  79431. * at the ground coordinates (x, z) expressed in the World system.
  79432. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  79433. * @param x x coordinate
  79434. * @param z z coordinate
  79435. * @param ref vector to store the result
  79436. * @returns the GroundMesh.
  79437. */
  79438. GroundMesh.prototype.getNormalAtCoordinatesToRef = function (x, z, ref) {
  79439. var world = this.getWorldMatrix();
  79440. var tmpMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  79441. world.invertToRef(tmpMat);
  79442. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  79443. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, tmpMat, tmpVect); // transform x,z in the mesh local space
  79444. x = tmpVect.x;
  79445. z = tmpVect.z;
  79446. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  79447. return this;
  79448. }
  79449. if (!this._heightQuads || this._heightQuads.length == 0) {
  79450. this._initHeightQuads();
  79451. this._computeHeightQuads();
  79452. }
  79453. var facet = this._getFacetAt(x, z);
  79454. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(facet.x, facet.y, facet.z, world, ref);
  79455. return this;
  79456. };
  79457. /**
  79458. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  79459. * if the ground has been updated.
  79460. * This can be used in the render loop.
  79461. * @returns the GroundMesh.
  79462. */
  79463. GroundMesh.prototype.updateCoordinateHeights = function () {
  79464. if (!this._heightQuads || this._heightQuads.length == 0) {
  79465. this._initHeightQuads();
  79466. }
  79467. this._computeHeightQuads();
  79468. return this;
  79469. };
  79470. // Returns the element "facet" from the heightQuads array relative to (x, z) local coordinates
  79471. GroundMesh.prototype._getFacetAt = function (x, z) {
  79472. // retrieve col and row from x, z coordinates in the ground local system
  79473. var col = Math.floor((x + this._maxX) * this._subdivisionsX / this._width);
  79474. var row = Math.floor(-(z + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY);
  79475. var quad = this._heightQuads[row * this._subdivisionsX + col];
  79476. var facet;
  79477. if (z < quad.slope.x * x + quad.slope.y) {
  79478. facet = quad.facet1;
  79479. }
  79480. else {
  79481. facet = quad.facet2;
  79482. }
  79483. return facet;
  79484. };
  79485. // Creates and populates the heightMap array with "facet" elements :
  79486. // a quad is two triangular facets separated by a slope, so a "facet" element is 1 slope + 2 facets
  79487. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  79488. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  79489. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  79490. // Returns the GroundMesh.
  79491. GroundMesh.prototype._initHeightQuads = function () {
  79492. var subdivisionsX = this._subdivisionsX;
  79493. var subdivisionsY = this._subdivisionsY;
  79494. this._heightQuads = new Array();
  79495. for (var row = 0; row < subdivisionsY; row++) {
  79496. for (var col = 0; col < subdivisionsX; col++) {
  79497. 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) };
  79498. this._heightQuads[row * subdivisionsX + col] = quad;
  79499. }
  79500. }
  79501. return this;
  79502. };
  79503. // Compute each quad element values and update the the heightMap array :
  79504. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  79505. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  79506. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  79507. // Returns the GroundMesh.
  79508. GroundMesh.prototype._computeHeightQuads = function () {
  79509. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  79510. if (!positions) {
  79511. return this;
  79512. }
  79513. var v1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  79514. var v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  79515. var v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  79516. var v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  79517. var v1v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  79518. var v1v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  79519. var v1v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  79520. var norm1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[7];
  79521. var norm2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  79522. var i = 0;
  79523. var j = 0;
  79524. var k = 0;
  79525. var cd = 0; // 2D slope coefficient : z = cd * x + h
  79526. var h = 0;
  79527. var d1 = 0; // facet plane equation : ax + by + cz + d = 0
  79528. var d2 = 0;
  79529. var subdivisionsX = this._subdivisionsX;
  79530. var subdivisionsY = this._subdivisionsY;
  79531. for (var row = 0; row < subdivisionsY; row++) {
  79532. for (var col = 0; col < subdivisionsX; col++) {
  79533. i = col * 3;
  79534. j = row * (subdivisionsX + 1) * 3;
  79535. k = (row + 1) * (subdivisionsX + 1) * 3;
  79536. v1.x = positions[j + i];
  79537. v1.y = positions[j + i + 1];
  79538. v1.z = positions[j + i + 2];
  79539. v2.x = positions[j + i + 3];
  79540. v2.y = positions[j + i + 4];
  79541. v2.z = positions[j + i + 5];
  79542. v3.x = positions[k + i];
  79543. v3.y = positions[k + i + 1];
  79544. v3.z = positions[k + i + 2];
  79545. v4.x = positions[k + i + 3];
  79546. v4.y = positions[k + i + 4];
  79547. v4.z = positions[k + i + 5];
  79548. // 2D slope V1V4
  79549. cd = (v4.z - v1.z) / (v4.x - v1.x);
  79550. h = v1.z - cd * v1.x; // v1 belongs to the slope
  79551. // facet equations :
  79552. // we compute each facet normal vector
  79553. // the equation of the facet plane is : norm.x * x + norm.y * y + norm.z * z + d = 0
  79554. // we compute the value d by applying the equation to v1 which belongs to the plane
  79555. // then we store the facet equation in a Vector4
  79556. v2.subtractToRef(v1, v1v2);
  79557. v3.subtractToRef(v1, v1v3);
  79558. v4.subtractToRef(v1, v1v4);
  79559. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v4, v1v3, norm1); // caution : CrossToRef uses the Tmp class
  79560. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v2, v1v4, norm2);
  79561. norm1.normalize();
  79562. norm2.normalize();
  79563. d1 = -(norm1.x * v1.x + norm1.y * v1.y + norm1.z * v1.z);
  79564. d2 = -(norm2.x * v2.x + norm2.y * v2.y + norm2.z * v2.z);
  79565. var quad = this._heightQuads[row * subdivisionsX + col];
  79566. quad.slope.copyFromFloats(cd, h);
  79567. quad.facet1.copyFromFloats(norm1.x, norm1.y, norm1.z, d1);
  79568. quad.facet2.copyFromFloats(norm2.x, norm2.y, norm2.z, d2);
  79569. }
  79570. }
  79571. return this;
  79572. };
  79573. /**
  79574. * Serializes this ground mesh
  79575. * @param serializationObject object to write serialization to
  79576. */
  79577. GroundMesh.prototype.serialize = function (serializationObject) {
  79578. _super.prototype.serialize.call(this, serializationObject);
  79579. serializationObject.subdivisionsX = this._subdivisionsX;
  79580. serializationObject.subdivisionsY = this._subdivisionsY;
  79581. serializationObject.minX = this._minX;
  79582. serializationObject.maxX = this._maxX;
  79583. serializationObject.minZ = this._minZ;
  79584. serializationObject.maxZ = this._maxZ;
  79585. serializationObject.width = this._width;
  79586. serializationObject.height = this._height;
  79587. };
  79588. /**
  79589. * Parses a serialized ground mesh
  79590. * @param parsedMesh the serialized mesh
  79591. * @param scene the scene to create the ground mesh in
  79592. * @returns the created ground mesh
  79593. */
  79594. GroundMesh.Parse = function (parsedMesh, scene) {
  79595. var result = new GroundMesh(parsedMesh.name, scene);
  79596. result._subdivisionsX = parsedMesh.subdivisionsX || 1;
  79597. result._subdivisionsY = parsedMesh.subdivisionsY || 1;
  79598. result._minX = parsedMesh.minX;
  79599. result._maxX = parsedMesh.maxX;
  79600. result._minZ = parsedMesh.minZ;
  79601. result._maxZ = parsedMesh.maxZ;
  79602. result._width = parsedMesh.width;
  79603. result._height = parsedMesh.height;
  79604. return result;
  79605. };
  79606. return GroundMesh;
  79607. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  79608. /***/ }),
  79609. /***/ "./Meshes/index.ts":
  79610. /*!*************************!*\
  79611. !*** ./Meshes/index.ts ***!
  79612. \*************************/
  79613. /*! exports provided: AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, _PrimitiveGeometry, RibbonGeometry, BoxGeometry, SphereGeometry, DiscGeometry, CylinderGeometry, TorusGeometry, GroundGeometry, TiledGroundGeometry, PlaneGeometry, TorusKnotGeometry, GroundMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, DracoCompression */
  79614. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79615. "use strict";
  79616. __webpack_require__.r(__webpack_exports__);
  79617. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  79618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  79619. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  79620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["Buffer"]; });
  79621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"]; });
  79622. /* harmony import */ var _Compression_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Compression/index */ "./Meshes/Compression/index.ts");
  79623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Compression_index__WEBPACK_IMPORTED_MODULE_2__["DracoCompression"]; });
  79624. /* harmony import */ var _csg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./csg */ "./Meshes/csg.ts");
  79625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _csg__WEBPACK_IMPORTED_MODULE_3__["CSG"]; });
  79626. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  79627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"]; });
  79628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_PrimitiveGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["_PrimitiveGeometry"]; });
  79629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["RibbonGeometry"]; });
  79630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["BoxGeometry"]; });
  79631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["SphereGeometry"]; });
  79632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["DiscGeometry"]; });
  79633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["CylinderGeometry"]; });
  79634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["TorusGeometry"]; });
  79635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["GroundGeometry"]; });
  79636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TiledGroundGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["TiledGroundGeometry"]; });
  79637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["PlaneGeometry"]; });
  79638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotGeometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["TorusKnotGeometry"]; });
  79639. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./groundMesh */ "./Meshes/groundMesh.ts");
  79640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _groundMesh__WEBPACK_IMPORTED_MODULE_5__["GroundMesh"]; });
  79641. /* harmony import */ var _instancedMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./instancedMesh */ "./Meshes/instancedMesh.ts");
  79642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _instancedMesh__WEBPACK_IMPORTED_MODULE_6__["InstancedMesh"]; });
  79643. /* harmony import */ var _linesMesh__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./linesMesh */ "./Meshes/linesMesh.ts");
  79644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_7__["LinesMesh"]; });
  79645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_7__["InstancedLinesMesh"]; });
  79646. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  79647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["MeshLODLevel"]; });
  79648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["_CreationDataStorage"]; });
  79649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["_InstancesBatch"]; });
  79650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _mesh__WEBPACK_IMPORTED_MODULE_8__["Mesh"]; });
  79651. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _mesh_vertexData__WEBPACK_IMPORTED_MODULE_9__["VertexData"]; });
  79653. /* harmony import */ var _meshBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./meshBuilder */ "./Meshes/meshBuilder.ts");
  79654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _meshBuilder__WEBPACK_IMPORTED_MODULE_10__["MeshBuilder"]; });
  79655. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  79656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationSettings"]; });
  79657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationQueue"]; });
  79658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_11__["SimplificationType"]; });
  79659. /* harmony import */ var _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./meshSimplificationSceneComponent */ "./Meshes/meshSimplificationSceneComponent.ts");
  79660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_12__["SimplicationQueueSceneComponent"]; });
  79661. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./polygonMesh */ "./Meshes/polygonMesh.ts");
  79662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_13__["Polygon"]; });
  79663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_13__["PolygonMeshBuilder"]; });
  79664. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  79665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_14__["BaseSubMesh"]; });
  79666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_14__["SubMesh"]; });
  79667. /* harmony import */ var _transformNode__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./transformNode */ "./Meshes/transformNode.ts");
  79668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _transformNode__WEBPACK_IMPORTED_MODULE_15__["TransformNode"]; });
  79669. /***/ }),
  79670. /***/ "./Meshes/instancedMesh.ts":
  79671. /*!*********************************!*\
  79672. !*** ./Meshes/instancedMesh.ts ***!
  79673. \*********************************/
  79674. /*! exports provided: InstancedMesh */
  79675. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79676. "use strict";
  79677. __webpack_require__.r(__webpack_exports__);
  79678. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return InstancedMesh; });
  79679. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  79680. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  79681. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  79682. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  79683. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  79684. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._instancedMeshFactory = function (name, mesh) {
  79685. return new InstancedMesh(name, mesh);
  79686. };
  79687. /**
  79688. * Creates an instance based on a source mesh.
  79689. */
  79690. var InstancedMesh = /** @class */ (function (_super) {
  79691. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedMesh, _super);
  79692. function InstancedMesh(name, source) {
  79693. var _this = _super.call(this, name, source.getScene()) || this;
  79694. /** @hidden */
  79695. _this._indexInSourceMeshInstanceArray = -1;
  79696. source.addInstance(_this);
  79697. _this._sourceMesh = source;
  79698. _this.position.copyFrom(source.position);
  79699. _this.rotation.copyFrom(source.rotation);
  79700. _this.scaling.copyFrom(source.scaling);
  79701. if (source.rotationQuaternion) {
  79702. _this.rotationQuaternion = source.rotationQuaternion.clone();
  79703. }
  79704. _this.infiniteDistance = source.infiniteDistance;
  79705. _this.setPivotMatrix(source.getPivotMatrix());
  79706. _this.refreshBoundingInfo();
  79707. _this._syncSubMeshes();
  79708. return _this;
  79709. }
  79710. /**
  79711. * Returns the string "InstancedMesh".
  79712. */
  79713. InstancedMesh.prototype.getClassName = function () {
  79714. return "InstancedMesh";
  79715. };
  79716. Object.defineProperty(InstancedMesh.prototype, "receiveShadows", {
  79717. // Methods
  79718. /**
  79719. * If the source mesh receives shadows
  79720. */
  79721. get: function () {
  79722. return this._sourceMesh.receiveShadows;
  79723. },
  79724. enumerable: true,
  79725. configurable: true
  79726. });
  79727. Object.defineProperty(InstancedMesh.prototype, "material", {
  79728. /**
  79729. * The material of the source mesh
  79730. */
  79731. get: function () {
  79732. return this._sourceMesh.material;
  79733. },
  79734. enumerable: true,
  79735. configurable: true
  79736. });
  79737. Object.defineProperty(InstancedMesh.prototype, "visibility", {
  79738. /**
  79739. * Visibility of the source mesh
  79740. */
  79741. get: function () {
  79742. return this._sourceMesh.visibility;
  79743. },
  79744. enumerable: true,
  79745. configurable: true
  79746. });
  79747. Object.defineProperty(InstancedMesh.prototype, "skeleton", {
  79748. /**
  79749. * Skeleton of the source mesh
  79750. */
  79751. get: function () {
  79752. return this._sourceMesh.skeleton;
  79753. },
  79754. enumerable: true,
  79755. configurable: true
  79756. });
  79757. Object.defineProperty(InstancedMesh.prototype, "renderingGroupId", {
  79758. /**
  79759. * Rendering ground id of the source mesh
  79760. */
  79761. get: function () {
  79762. return this._sourceMesh.renderingGroupId;
  79763. },
  79764. set: function (value) {
  79765. if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {
  79766. return;
  79767. }
  79768. //no-op with warning
  79769. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene");
  79770. },
  79771. enumerable: true,
  79772. configurable: true
  79773. });
  79774. /**
  79775. * Returns the total number of vertices (integer).
  79776. */
  79777. InstancedMesh.prototype.getTotalVertices = function () {
  79778. return this._sourceMesh.getTotalVertices();
  79779. };
  79780. /**
  79781. * Returns a positive integer : the total number of indices in this mesh geometry.
  79782. * @returns the numner of indices or zero if the mesh has no geometry.
  79783. */
  79784. InstancedMesh.prototype.getTotalIndices = function () {
  79785. return this._sourceMesh.getTotalIndices();
  79786. };
  79787. Object.defineProperty(InstancedMesh.prototype, "sourceMesh", {
  79788. /**
  79789. * The source mesh of the instance
  79790. */
  79791. get: function () {
  79792. return this._sourceMesh;
  79793. },
  79794. enumerable: true,
  79795. configurable: true
  79796. });
  79797. /**
  79798. * Is this node ready to be used/rendered
  79799. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  79800. * @return {boolean} is it ready
  79801. */
  79802. InstancedMesh.prototype.isReady = function (completeCheck) {
  79803. if (completeCheck === void 0) { completeCheck = false; }
  79804. return this._sourceMesh.isReady(completeCheck, true);
  79805. };
  79806. /**
  79807. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79808. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  79809. * @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.
  79810. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  79811. */
  79812. InstancedMesh.prototype.getVerticesData = function (kind, copyWhenShared) {
  79813. return this._sourceMesh.getVerticesData(kind, copyWhenShared);
  79814. };
  79815. /**
  79816. * Sets the vertex data of the mesh geometry for the requested `kind`.
  79817. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  79818. * The `data` are either a numeric array either a Float32Array.
  79819. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  79820. * 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).
  79821. * Note that a new underlying VertexBuffer object is created each call.
  79822. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  79823. *
  79824. * Possible `kind` values :
  79825. * - VertexBuffer.PositionKind
  79826. * - VertexBuffer.UVKind
  79827. * - VertexBuffer.UV2Kind
  79828. * - VertexBuffer.UV3Kind
  79829. * - VertexBuffer.UV4Kind
  79830. * - VertexBuffer.UV5Kind
  79831. * - VertexBuffer.UV6Kind
  79832. * - VertexBuffer.ColorKind
  79833. * - VertexBuffer.MatricesIndicesKind
  79834. * - VertexBuffer.MatricesIndicesExtraKind
  79835. * - VertexBuffer.MatricesWeightsKind
  79836. * - VertexBuffer.MatricesWeightsExtraKind
  79837. *
  79838. * Returns the Mesh.
  79839. */
  79840. InstancedMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  79841. if (this.sourceMesh) {
  79842. this.sourceMesh.setVerticesData(kind, data, updatable, stride);
  79843. }
  79844. return this.sourceMesh;
  79845. };
  79846. /**
  79847. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  79848. * If the mesh has no geometry, it is simply returned as it is.
  79849. * The `data` are either a numeric array either a Float32Array.
  79850. * No new underlying VertexBuffer object is created.
  79851. * 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.
  79852. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  79853. *
  79854. * Possible `kind` values :
  79855. * - VertexBuffer.PositionKind
  79856. * - VertexBuffer.UVKind
  79857. * - VertexBuffer.UV2Kind
  79858. * - VertexBuffer.UV3Kind
  79859. * - VertexBuffer.UV4Kind
  79860. * - VertexBuffer.UV5Kind
  79861. * - VertexBuffer.UV6Kind
  79862. * - VertexBuffer.ColorKind
  79863. * - VertexBuffer.MatricesIndicesKind
  79864. * - VertexBuffer.MatricesIndicesExtraKind
  79865. * - VertexBuffer.MatricesWeightsKind
  79866. * - VertexBuffer.MatricesWeightsExtraKind
  79867. *
  79868. * Returns the Mesh.
  79869. */
  79870. InstancedMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  79871. if (this.sourceMesh) {
  79872. this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);
  79873. }
  79874. return this.sourceMesh;
  79875. };
  79876. /**
  79877. * Sets the mesh indices.
  79878. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  79879. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  79880. * This method creates a new index buffer each call.
  79881. * Returns the Mesh.
  79882. */
  79883. InstancedMesh.prototype.setIndices = function (indices, totalVertices) {
  79884. if (totalVertices === void 0) { totalVertices = null; }
  79885. if (this.sourceMesh) {
  79886. this.sourceMesh.setIndices(indices, totalVertices);
  79887. }
  79888. return this.sourceMesh;
  79889. };
  79890. /**
  79891. * Boolean : True if the mesh owns the requested kind of data.
  79892. */
  79893. InstancedMesh.prototype.isVerticesDataPresent = function (kind) {
  79894. return this._sourceMesh.isVerticesDataPresent(kind);
  79895. };
  79896. /**
  79897. * Returns an array of indices (IndicesArray).
  79898. */
  79899. InstancedMesh.prototype.getIndices = function () {
  79900. return this._sourceMesh.getIndices();
  79901. };
  79902. Object.defineProperty(InstancedMesh.prototype, "_positions", {
  79903. get: function () {
  79904. return this._sourceMesh._positions;
  79905. },
  79906. enumerable: true,
  79907. configurable: true
  79908. });
  79909. /**
  79910. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79911. * This means the mesh underlying bounding box and sphere are recomputed.
  79912. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79913. * @returns the current mesh
  79914. */
  79915. InstancedMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  79916. if (applySkeleton === void 0) { applySkeleton = false; }
  79917. if (this._boundingInfo && this._boundingInfo.isLocked) {
  79918. return this;
  79919. }
  79920. var bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
  79921. this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton), bias);
  79922. return this;
  79923. };
  79924. /** @hidden */
  79925. InstancedMesh.prototype._preActivate = function () {
  79926. if (this._currentLOD) {
  79927. this._currentLOD._preActivate();
  79928. }
  79929. return this;
  79930. };
  79931. /** @hidden */
  79932. InstancedMesh.prototype._activate = function (renderId) {
  79933. if (this._currentLOD) {
  79934. this._currentLOD._registerInstanceForRenderId(this, renderId);
  79935. }
  79936. return this;
  79937. };
  79938. /**
  79939. * Returns the current associated LOD AbstractMesh.
  79940. */
  79941. InstancedMesh.prototype.getLOD = function (camera) {
  79942. if (!camera) {
  79943. return this;
  79944. }
  79945. var boundingInfo = this.getBoundingInfo();
  79946. this._currentLOD = this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);
  79947. if (this._currentLOD === this.sourceMesh) {
  79948. return this;
  79949. }
  79950. return this._currentLOD;
  79951. };
  79952. /** @hidden */
  79953. InstancedMesh.prototype._syncSubMeshes = function () {
  79954. this.releaseSubMeshes();
  79955. if (this._sourceMesh.subMeshes) {
  79956. for (var index = 0; index < this._sourceMesh.subMeshes.length; index++) {
  79957. this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);
  79958. }
  79959. }
  79960. return this;
  79961. };
  79962. /** @hidden */
  79963. InstancedMesh.prototype._generatePointsArray = function () {
  79964. return this._sourceMesh._generatePointsArray();
  79965. };
  79966. /**
  79967. * Creates a new InstancedMesh from the current mesh.
  79968. * - name (string) : the cloned mesh name
  79969. * - newParent (optional Node) : the optional Node to parent the clone to.
  79970. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  79971. *
  79972. * Returns the clone.
  79973. */
  79974. InstancedMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  79975. var result = this._sourceMesh.createInstance(name);
  79976. // Deep copy
  79977. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__["DeepCopier"].DeepCopy(this, result, ["name", "subMeshes", "uniqueId"], []);
  79978. // Bounding info
  79979. this.refreshBoundingInfo();
  79980. // Parent
  79981. if (newParent) {
  79982. result.parent = newParent;
  79983. }
  79984. if (!doNotCloneChildren) {
  79985. // Children
  79986. for (var index = 0; index < this.getScene().meshes.length; index++) {
  79987. var mesh = this.getScene().meshes[index];
  79988. if (mesh.parent === this) {
  79989. mesh.clone(mesh.name, result);
  79990. }
  79991. }
  79992. }
  79993. result.computeWorldMatrix(true);
  79994. return result;
  79995. };
  79996. /**
  79997. * Disposes the InstancedMesh.
  79998. * Returns nothing.
  79999. */
  80000. InstancedMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  80001. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  80002. // Remove from mesh
  80003. this._sourceMesh.removeInstance(this);
  80004. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  80005. };
  80006. return InstancedMesh;
  80007. }(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]));
  80008. /***/ }),
  80009. /***/ "./Meshes/linesMesh.ts":
  80010. /*!*****************************!*\
  80011. !*** ./Meshes/linesMesh.ts ***!
  80012. \*****************************/
  80013. /*! exports provided: LinesMesh, InstancedLinesMesh */
  80014. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80015. "use strict";
  80016. __webpack_require__.r(__webpack_exports__);
  80017. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return LinesMesh; });
  80018. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return InstancedLinesMesh; });
  80019. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  80020. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  80021. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  80022. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  80023. /* harmony import */ var _Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/instancedMesh */ "./Meshes/instancedMesh.ts");
  80024. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  80025. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  80026. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  80027. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  80028. /**
  80029. * Line mesh
  80030. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  80031. */
  80032. var LinesMesh = /** @class */ (function (_super) {
  80033. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LinesMesh, _super);
  80034. /**
  80035. * Creates a new LinesMesh
  80036. * @param name defines the name
  80037. * @param scene defines the hosting scene
  80038. * @param parent defines the parent mesh if any
  80039. * @param source defines the optional source LinesMesh used to clone data from
  80040. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  80041. * When false, achieved by calling a clone(), also passing False.
  80042. * This will make creation of children, recursive.
  80043. * @param useVertexColor defines if this LinesMesh supports vertex color
  80044. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  80045. */
  80046. function LinesMesh(name, scene, parent, source, doNotCloneChildren,
  80047. /**
  80048. * If vertex color should be applied to the mesh
  80049. */
  80050. useVertexColor,
  80051. /**
  80052. * If vertex alpha should be applied to the mesh
  80053. */
  80054. useVertexAlpha) {
  80055. if (scene === void 0) { scene = null; }
  80056. if (parent === void 0) { parent = null; }
  80057. var _this = _super.call(this, name, scene, parent, source, doNotCloneChildren) || this;
  80058. _this.useVertexColor = useVertexColor;
  80059. _this.useVertexAlpha = useVertexAlpha;
  80060. /**
  80061. * Color of the line (Default: White)
  80062. */
  80063. _this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
  80064. /**
  80065. * Alpha of the line (Default: 1)
  80066. */
  80067. _this.alpha = 1;
  80068. if (source) {
  80069. _this.color = source.color.clone();
  80070. _this.alpha = source.alpha;
  80071. _this.useVertexColor = source.useVertexColor;
  80072. _this.useVertexAlpha = source.useVertexAlpha;
  80073. }
  80074. _this.intersectionThreshold = 0.1;
  80075. var defines = [];
  80076. var options = {
  80077. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, "world0", "world1", "world2", "world3"],
  80078. uniforms: ["world", "viewProjection"],
  80079. needAlphaBlending: true,
  80080. defines: defines
  80081. };
  80082. if (useVertexAlpha === false) {
  80083. options.needAlphaBlending = false;
  80084. }
  80085. if (!useVertexColor) {
  80086. options.uniforms.push("color");
  80087. }
  80088. else {
  80089. options.defines.push("#define VERTEXCOLOR");
  80090. options.attributes.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  80091. }
  80092. _this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("colorShader", _this.getScene(), "color", options);
  80093. return _this;
  80094. }
  80095. /**
  80096. * Returns the string "LineMesh"
  80097. */
  80098. LinesMesh.prototype.getClassName = function () {
  80099. return "LinesMesh";
  80100. };
  80101. Object.defineProperty(LinesMesh.prototype, "material", {
  80102. /**
  80103. * @hidden
  80104. */
  80105. get: function () {
  80106. return this._colorShader;
  80107. },
  80108. /**
  80109. * @hidden
  80110. */
  80111. set: function (value) {
  80112. // Do nothing
  80113. },
  80114. enumerable: true,
  80115. configurable: true
  80116. });
  80117. Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
  80118. /**
  80119. * @hidden
  80120. */
  80121. get: function () {
  80122. return false;
  80123. },
  80124. enumerable: true,
  80125. configurable: true
  80126. });
  80127. /** @hidden */
  80128. LinesMesh.prototype._bind = function (subMesh, effect, fillMode) {
  80129. if (!this._geometry) {
  80130. return this;
  80131. }
  80132. // VBOs
  80133. this._geometry._bind(this._colorShader.getEffect());
  80134. // Color
  80135. if (!this.useVertexColor) {
  80136. this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
  80137. }
  80138. return this;
  80139. };
  80140. /** @hidden */
  80141. LinesMesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  80142. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  80143. return this;
  80144. }
  80145. var engine = this.getScene().getEngine();
  80146. // Draw order
  80147. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].LineListDrawMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  80148. return this;
  80149. };
  80150. /**
  80151. * Disposes of the line mesh
  80152. * @param doNotRecurse If children should be disposed
  80153. */
  80154. LinesMesh.prototype.dispose = function (doNotRecurse) {
  80155. this._colorShader.dispose(false, false, true);
  80156. _super.prototype.dispose.call(this, doNotRecurse);
  80157. };
  80158. /**
  80159. * Returns a new LineMesh object cloned from the current one.
  80160. */
  80161. LinesMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  80162. return new LinesMesh(name, this.getScene(), newParent, this, doNotCloneChildren);
  80163. };
  80164. /**
  80165. * Creates a new InstancedLinesMesh object from the mesh model.
  80166. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80167. * @param name defines the name of the new instance
  80168. * @returns a new InstancedLinesMesh
  80169. */
  80170. LinesMesh.prototype.createInstance = function (name) {
  80171. return new InstancedLinesMesh(name, this);
  80172. };
  80173. return LinesMesh;
  80174. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  80175. /**
  80176. * Creates an instance based on a source LinesMesh
  80177. */
  80178. var InstancedLinesMesh = /** @class */ (function (_super) {
  80179. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedLinesMesh, _super);
  80180. function InstancedLinesMesh(name, source) {
  80181. var _this = _super.call(this, name, source) || this;
  80182. _this.intersectionThreshold = source.intersectionThreshold;
  80183. return _this;
  80184. }
  80185. /**
  80186. * Returns the string "InstancedLinesMesh".
  80187. */
  80188. InstancedLinesMesh.prototype.getClassName = function () {
  80189. return "InstancedLinesMesh";
  80190. };
  80191. return InstancedLinesMesh;
  80192. }(_Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__["InstancedMesh"]));
  80193. /***/ }),
  80194. /***/ "./Meshes/mesh.ts":
  80195. /*!************************!*\
  80196. !*** ./Meshes/mesh.ts ***!
  80197. \************************/
  80198. /*! exports provided: MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh */
  80199. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80200. "use strict";
  80201. __webpack_require__.r(__webpack_exports__);
  80202. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return MeshLODLevel; });
  80203. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _CreationDataStorage; });
  80204. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _InstancesBatch; });
  80205. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return Mesh; });
  80206. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  80207. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  80208. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  80209. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  80210. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  80211. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  80212. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  80213. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  80214. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80215. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  80216. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  80217. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  80218. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  80219. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  80220. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  80221. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  80222. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  80223. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  80224. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  80225. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  80226. /**
  80227. * Class used to represent a specific level of detail of a mesh
  80228. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  80229. */
  80230. var MeshLODLevel = /** @class */ (function () {
  80231. /**
  80232. * Creates a new LOD level
  80233. * @param distance defines the distance where this level should star being displayed
  80234. * @param mesh defines the mesh to use to render this level
  80235. */
  80236. function MeshLODLevel(
  80237. /** Defines the distance where this level should star being displayed */
  80238. distance,
  80239. /** Defines the mesh to use to render this level */
  80240. mesh) {
  80241. this.distance = distance;
  80242. this.mesh = mesh;
  80243. }
  80244. return MeshLODLevel;
  80245. }());
  80246. /**
  80247. * @hidden
  80248. **/
  80249. var _CreationDataStorage = /** @class */ (function () {
  80250. function _CreationDataStorage() {
  80251. }
  80252. return _CreationDataStorage;
  80253. }());
  80254. /**
  80255. * @hidden
  80256. **/
  80257. var _InstanceDataStorage = /** @class */ (function () {
  80258. function _InstanceDataStorage() {
  80259. this.visibleInstances = {};
  80260. this.renderIdForInstances = new Array();
  80261. this.batchCache = new _InstancesBatch();
  80262. this.instancesBufferSize = 32 * 16 * 4; // let's start with a maximum of 32 instances
  80263. }
  80264. return _InstanceDataStorage;
  80265. }());
  80266. /**
  80267. * @hidden
  80268. **/
  80269. var _InstancesBatch = /** @class */ (function () {
  80270. function _InstancesBatch() {
  80271. this.mustReturn = false;
  80272. this.visibleInstances = new Array();
  80273. this.renderSelf = new Array();
  80274. }
  80275. return _InstancesBatch;
  80276. }());
  80277. /**
  80278. * Class used to represent renderable models
  80279. */
  80280. var Mesh = /** @class */ (function (_super) {
  80281. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Mesh, _super);
  80282. /**
  80283. * @constructor
  80284. * @param name The value used by scene.getMeshByName() to do a lookup.
  80285. * @param scene The scene to add this mesh to.
  80286. * @param parent The parent of this mesh, if it has one
  80287. * @param source An optional Mesh from which geometry is shared, cloned.
  80288. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  80289. * When false, achieved by calling a clone(), also passing False.
  80290. * This will make creation of children, recursive.
  80291. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  80292. */
  80293. function Mesh(name, scene, parent, source, doNotCloneChildren, clonePhysicsImpostor) {
  80294. if (scene === void 0) { scene = null; }
  80295. if (parent === void 0) { parent = null; }
  80296. if (source === void 0) { source = null; }
  80297. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  80298. var _this = _super.call(this, name, scene) || this;
  80299. // Members
  80300. /**
  80301. * Gets the delay loading state of the mesh (when delay loading is turned on)
  80302. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  80303. */
  80304. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_NONE;
  80305. /**
  80306. * Gets the list of instances created from this mesh
  80307. * it is not supposed to be modified manually.
  80308. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  80309. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80310. */
  80311. _this.instances = new Array();
  80312. _this._LODLevels = new Array();
  80313. /** @hidden */
  80314. _this._instanceDataStorage = new _InstanceDataStorage();
  80315. // Use by builder only to know what orientation were the mesh build in.
  80316. /** @hidden */
  80317. _this._originalBuilderSideOrientation = Mesh.DEFAULTSIDE;
  80318. /**
  80319. * Use this property to change the original side orientation defined at construction time
  80320. */
  80321. _this.overrideMaterialSideOrientation = null;
  80322. _this._areNormalsFrozen = false; // Will be used by ribbons mainly
  80323. // Will be used to save a source mesh reference, If any
  80324. _this._source = null;
  80325. /** @hidden */
  80326. _this._isMesh = true;
  80327. scene = _this.getScene();
  80328. if (source) {
  80329. // Geometry
  80330. if (source._geometry) {
  80331. source._geometry.applyToMesh(_this);
  80332. }
  80333. // Deep copy
  80334. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(source, _this, ["name", "material", "skeleton", "instances", "parent", "uniqueId",
  80335. "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
  80336. "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw",
  80337. "onAfterWorldMatrixUpdateObservable", "onCollideObservable", "onCollisionPositionChangeObservable", "onRebuildObservable",
  80338. "onDisposeObservable"
  80339. ], ["_poseMatrix"]);
  80340. // Source mesh
  80341. _this._source = source;
  80342. if (scene.useClonedMeshhMap) {
  80343. if (!source.meshMap) {
  80344. source.meshMap = {};
  80345. }
  80346. source.meshMap[_this.uniqueId] = _this;
  80347. }
  80348. // Construction Params
  80349. // Clone parameters allowing mesh to be updated in case of parametric shapes.
  80350. _this._originalBuilderSideOrientation = source._originalBuilderSideOrientation;
  80351. _this._creationDataStorage = source._creationDataStorage;
  80352. // Animation ranges
  80353. if (_this._source._ranges) {
  80354. var ranges = _this._source._ranges;
  80355. for (var name in ranges) {
  80356. if (!ranges.hasOwnProperty(name)) {
  80357. continue;
  80358. }
  80359. if (!ranges[name]) {
  80360. continue;
  80361. }
  80362. _this.createAnimationRange(name, ranges[name].from, ranges[name].to);
  80363. }
  80364. }
  80365. // Metadata
  80366. if (source.metadata && source.metadata.clone) {
  80367. _this.metadata = source.metadata.clone();
  80368. }
  80369. else {
  80370. _this.metadata = source.metadata;
  80371. }
  80372. // Tags
  80373. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(source)) {
  80374. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(_this, _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(source, true));
  80375. }
  80376. // Parent
  80377. _this.parent = source.parent;
  80378. // Pivot
  80379. _this.setPivotMatrix(source.getPivotMatrix());
  80380. _this.id = name + "." + source.id;
  80381. // Material
  80382. _this.material = source.material;
  80383. var index;
  80384. if (!doNotCloneChildren) {
  80385. // Children
  80386. var directDescendants = source.getDescendants(true);
  80387. for (var index_1 = 0; index_1 < directDescendants.length; index_1++) {
  80388. var child = directDescendants[index_1];
  80389. if (child.clone) {
  80390. child.clone(name + "." + child.name, _this);
  80391. }
  80392. }
  80393. }
  80394. // Physics clone
  80395. var physicsEngine = _this.getScene().getPhysicsEngine();
  80396. if (clonePhysicsImpostor && physicsEngine) {
  80397. var impostor = physicsEngine.getImpostorForPhysicsObject(source);
  80398. if (impostor) {
  80399. _this.physicsImpostor = impostor.clone(_this);
  80400. }
  80401. }
  80402. // Particles
  80403. for (index = 0; index < scene.particleSystems.length; index++) {
  80404. var system = scene.particleSystems[index];
  80405. if (system.emitter === source) {
  80406. system.clone(system.name, _this);
  80407. }
  80408. }
  80409. _this.refreshBoundingInfo();
  80410. _this.computeWorldMatrix(true);
  80411. }
  80412. // Parent
  80413. if (parent !== null) {
  80414. _this.parent = parent;
  80415. }
  80416. return _this;
  80417. }
  80418. Object.defineProperty(Mesh.prototype, "onBeforeRenderObservable", {
  80419. /**
  80420. * An event triggered before rendering the mesh
  80421. */
  80422. get: function () {
  80423. if (!this._onBeforeRenderObservable) {
  80424. this._onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  80425. }
  80426. return this._onBeforeRenderObservable;
  80427. },
  80428. enumerable: true,
  80429. configurable: true
  80430. });
  80431. Object.defineProperty(Mesh.prototype, "onAfterRenderObservable", {
  80432. /**
  80433. * An event triggered after rendering the mesh
  80434. */
  80435. get: function () {
  80436. if (!this._onAfterRenderObservable) {
  80437. this._onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  80438. }
  80439. return this._onAfterRenderObservable;
  80440. },
  80441. enumerable: true,
  80442. configurable: true
  80443. });
  80444. Object.defineProperty(Mesh.prototype, "onBeforeDrawObservable", {
  80445. /**
  80446. * An event triggered before drawing the mesh
  80447. */
  80448. get: function () {
  80449. if (!this._onBeforeDrawObservable) {
  80450. this._onBeforeDrawObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  80451. }
  80452. return this._onBeforeDrawObservable;
  80453. },
  80454. enumerable: true,
  80455. configurable: true
  80456. });
  80457. Object.defineProperty(Mesh.prototype, "onBeforeDraw", {
  80458. /**
  80459. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  80460. */
  80461. set: function (callback) {
  80462. if (this._onBeforeDrawObserver) {
  80463. this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver);
  80464. }
  80465. this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(callback);
  80466. },
  80467. enumerable: true,
  80468. configurable: true
  80469. });
  80470. Object.defineProperty(Mesh.prototype, "morphTargetManager", {
  80471. /**
  80472. * Gets or sets the morph target manager
  80473. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  80474. */
  80475. get: function () {
  80476. return this._morphTargetManager;
  80477. },
  80478. set: function (value) {
  80479. if (this._morphTargetManager === value) {
  80480. return;
  80481. }
  80482. this._morphTargetManager = value;
  80483. this._syncGeometryWithMorphTargetManager();
  80484. },
  80485. enumerable: true,
  80486. configurable: true
  80487. });
  80488. Object.defineProperty(Mesh.prototype, "source", {
  80489. /**
  80490. * Gets the source mesh (the one used to clone this one from)
  80491. */
  80492. get: function () {
  80493. return this._source;
  80494. },
  80495. enumerable: true,
  80496. configurable: true
  80497. });
  80498. Object.defineProperty(Mesh.prototype, "isUnIndexed", {
  80499. /**
  80500. * Gets or sets a boolean indicating that this mesh does not use index buffer
  80501. */
  80502. get: function () {
  80503. return this._unIndexed;
  80504. },
  80505. set: function (value) {
  80506. if (this._unIndexed !== value) {
  80507. this._unIndexed = value;
  80508. this._markSubMeshesAsAttributesDirty();
  80509. }
  80510. },
  80511. enumerable: true,
  80512. configurable: true
  80513. });
  80514. // Methods
  80515. /**
  80516. * Gets the class name
  80517. * @returns the string "Mesh".
  80518. */
  80519. Mesh.prototype.getClassName = function () {
  80520. return "Mesh";
  80521. };
  80522. /**
  80523. * Returns a description of this mesh
  80524. * @param fullDetails define if full details about this mesh must be used
  80525. * @returns a descriptive string representing this mesh
  80526. */
  80527. Mesh.prototype.toString = function (fullDetails) {
  80528. var ret = _super.prototype.toString.call(this, fullDetails);
  80529. ret += ", n vertices: " + this.getTotalVertices();
  80530. ret += ", parent: " + (this._waitingParentId ? this._waitingParentId : (this.parent ? this.parent.name : "NONE"));
  80531. if (this.animations) {
  80532. for (var i = 0; i < this.animations.length; i++) {
  80533. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  80534. }
  80535. }
  80536. if (fullDetails) {
  80537. if (this._geometry) {
  80538. var ib = this.getIndices();
  80539. var vb = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  80540. if (vb && ib) {
  80541. ret += ", flat shading: " + (vb.length / 3 === ib.length ? "YES" : "NO");
  80542. }
  80543. }
  80544. else {
  80545. ret += ", flat shading: UNKNOWN";
  80546. }
  80547. }
  80548. return ret;
  80549. };
  80550. /** @hidden */
  80551. Mesh.prototype._unBindEffect = function () {
  80552. _super.prototype._unBindEffect.call(this);
  80553. for (var _i = 0, _a = this.instances; _i < _a.length; _i++) {
  80554. var instance = _a[_i];
  80555. instance._unBindEffect();
  80556. }
  80557. };
  80558. Object.defineProperty(Mesh.prototype, "hasLODLevels", {
  80559. /**
  80560. * Gets a boolean indicating if this mesh has LOD
  80561. */
  80562. get: function () {
  80563. return this._LODLevels.length > 0;
  80564. },
  80565. enumerable: true,
  80566. configurable: true
  80567. });
  80568. /**
  80569. * Gets the list of MeshLODLevel associated with the current mesh
  80570. * @returns an array of MeshLODLevel
  80571. */
  80572. Mesh.prototype.getLODLevels = function () {
  80573. return this._LODLevels;
  80574. };
  80575. Mesh.prototype._sortLODLevels = function () {
  80576. this._LODLevels.sort(function (a, b) {
  80577. if (a.distance < b.distance) {
  80578. return 1;
  80579. }
  80580. if (a.distance > b.distance) {
  80581. return -1;
  80582. }
  80583. return 0;
  80584. });
  80585. };
  80586. /**
  80587. * Add a mesh as LOD level triggered at the given distance.
  80588. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80589. * @param distance The distance from the center of the object to show this level
  80590. * @param mesh The mesh to be added as LOD level (can be null)
  80591. * @return This mesh (for chaining)
  80592. */
  80593. Mesh.prototype.addLODLevel = function (distance, mesh) {
  80594. if (mesh && mesh._masterMesh) {
  80595. _Misc_logger__WEBPACK_IMPORTED_MODULE_19__["Logger"].Warn("You cannot use a mesh as LOD level twice");
  80596. return this;
  80597. }
  80598. var level = new MeshLODLevel(distance, mesh);
  80599. this._LODLevels.push(level);
  80600. if (mesh) {
  80601. mesh._masterMesh = this;
  80602. }
  80603. this._sortLODLevels();
  80604. return this;
  80605. };
  80606. /**
  80607. * Returns the LOD level mesh at the passed distance or null if not found.
  80608. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80609. * @param distance The distance from the center of the object to show this level
  80610. * @returns a Mesh or `null`
  80611. */
  80612. Mesh.prototype.getLODLevelAtDistance = function (distance) {
  80613. for (var index = 0; index < this._LODLevels.length; index++) {
  80614. var level = this._LODLevels[index];
  80615. if (level.distance === distance) {
  80616. return level.mesh;
  80617. }
  80618. }
  80619. return null;
  80620. };
  80621. /**
  80622. * Remove a mesh from the LOD array
  80623. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80624. * @param mesh defines the mesh to be removed
  80625. * @return This mesh (for chaining)
  80626. */
  80627. Mesh.prototype.removeLODLevel = function (mesh) {
  80628. for (var index = 0; index < this._LODLevels.length; index++) {
  80629. if (this._LODLevels[index].mesh === mesh) {
  80630. this._LODLevels.splice(index, 1);
  80631. if (mesh) {
  80632. mesh._masterMesh = null;
  80633. }
  80634. }
  80635. }
  80636. this._sortLODLevels();
  80637. return this;
  80638. };
  80639. /**
  80640. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  80641. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80642. * @param camera defines the camera to use to compute distance
  80643. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  80644. * @return This mesh (for chaining)
  80645. */
  80646. Mesh.prototype.getLOD = function (camera, boundingSphere) {
  80647. if (!this._LODLevels || this._LODLevels.length === 0) {
  80648. return this;
  80649. }
  80650. var bSphere;
  80651. if (boundingSphere) {
  80652. bSphere = boundingSphere;
  80653. }
  80654. else {
  80655. var boundingInfo = this.getBoundingInfo();
  80656. bSphere = boundingInfo.boundingSphere;
  80657. }
  80658. var distanceToCamera = bSphere.centerWorld.subtract(camera.globalPosition).length();
  80659. if (this._LODLevels[this._LODLevels.length - 1].distance > distanceToCamera) {
  80660. if (this.onLODLevelSelection) {
  80661. this.onLODLevelSelection(distanceToCamera, this, this._LODLevels[this._LODLevels.length - 1].mesh);
  80662. }
  80663. return this;
  80664. }
  80665. for (var index = 0; index < this._LODLevels.length; index++) {
  80666. var level = this._LODLevels[index];
  80667. if (level.distance < distanceToCamera) {
  80668. if (level.mesh) {
  80669. level.mesh._preActivate();
  80670. level.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
  80671. }
  80672. if (this.onLODLevelSelection) {
  80673. this.onLODLevelSelection(distanceToCamera, this, level.mesh);
  80674. }
  80675. return level.mesh;
  80676. }
  80677. }
  80678. if (this.onLODLevelSelection) {
  80679. this.onLODLevelSelection(distanceToCamera, this, this);
  80680. }
  80681. return this;
  80682. };
  80683. Object.defineProperty(Mesh.prototype, "geometry", {
  80684. /**
  80685. * Gets the mesh internal Geometry object
  80686. */
  80687. get: function () {
  80688. return this._geometry;
  80689. },
  80690. enumerable: true,
  80691. configurable: true
  80692. });
  80693. /**
  80694. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  80695. * @returns the total number of vertices
  80696. */
  80697. Mesh.prototype.getTotalVertices = function () {
  80698. if (this._geometry === null || this._geometry === undefined) {
  80699. return 0;
  80700. }
  80701. return this._geometry.getTotalVertices();
  80702. };
  80703. /**
  80704. * Returns the content of an associated vertex buffer
  80705. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80706. * - VertexBuffer.PositionKind
  80707. * - VertexBuffer.UVKind
  80708. * - VertexBuffer.UV2Kind
  80709. * - VertexBuffer.UV3Kind
  80710. * - VertexBuffer.UV4Kind
  80711. * - VertexBuffer.UV5Kind
  80712. * - VertexBuffer.UV6Kind
  80713. * - VertexBuffer.ColorKind
  80714. * - VertexBuffer.MatricesIndicesKind
  80715. * - VertexBuffer.MatricesIndicesExtraKind
  80716. * - VertexBuffer.MatricesWeightsKind
  80717. * - VertexBuffer.MatricesWeightsExtraKind
  80718. * @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
  80719. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  80720. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  80721. */
  80722. Mesh.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  80723. if (!this._geometry) {
  80724. return null;
  80725. }
  80726. return this._geometry.getVerticesData(kind, copyWhenShared, forceCopy);
  80727. };
  80728. /**
  80729. * Returns the mesh VertexBuffer object from the requested `kind`
  80730. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80731. * - VertexBuffer.PositionKind
  80732. * - VertexBuffer.UVKind
  80733. * - VertexBuffer.UV2Kind
  80734. * - VertexBuffer.UV3Kind
  80735. * - VertexBuffer.UV4Kind
  80736. * - VertexBuffer.UV5Kind
  80737. * - VertexBuffer.UV6Kind
  80738. * - VertexBuffer.ColorKind
  80739. * - VertexBuffer.MatricesIndicesKind
  80740. * - VertexBuffer.MatricesIndicesExtraKind
  80741. * - VertexBuffer.MatricesWeightsKind
  80742. * - VertexBuffer.MatricesWeightsExtraKind
  80743. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  80744. */
  80745. Mesh.prototype.getVertexBuffer = function (kind) {
  80746. if (!this._geometry) {
  80747. return null;
  80748. }
  80749. return this._geometry.getVertexBuffer(kind);
  80750. };
  80751. /**
  80752. * Tests if a specific vertex buffer is associated with this mesh
  80753. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80754. * - VertexBuffer.PositionKind
  80755. * - VertexBuffer.UVKind
  80756. * - VertexBuffer.UV2Kind
  80757. * - VertexBuffer.UV3Kind
  80758. * - VertexBuffer.UV4Kind
  80759. * - VertexBuffer.UV5Kind
  80760. * - VertexBuffer.UV6Kind
  80761. * - VertexBuffer.ColorKind
  80762. * - VertexBuffer.MatricesIndicesKind
  80763. * - VertexBuffer.MatricesIndicesExtraKind
  80764. * - VertexBuffer.MatricesWeightsKind
  80765. * - VertexBuffer.MatricesWeightsExtraKind
  80766. * @returns a boolean
  80767. */
  80768. Mesh.prototype.isVerticesDataPresent = function (kind) {
  80769. if (!this._geometry) {
  80770. if (this._delayInfo) {
  80771. return this._delayInfo.indexOf(kind) !== -1;
  80772. }
  80773. return false;
  80774. }
  80775. return this._geometry.isVerticesDataPresent(kind);
  80776. };
  80777. /**
  80778. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  80779. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80780. * - VertexBuffer.PositionKind
  80781. * - VertexBuffer.UVKind
  80782. * - VertexBuffer.UV2Kind
  80783. * - VertexBuffer.UV3Kind
  80784. * - VertexBuffer.UV4Kind
  80785. * - VertexBuffer.UV5Kind
  80786. * - VertexBuffer.UV6Kind
  80787. * - VertexBuffer.ColorKind
  80788. * - VertexBuffer.MatricesIndicesKind
  80789. * - VertexBuffer.MatricesIndicesExtraKind
  80790. * - VertexBuffer.MatricesWeightsKind
  80791. * - VertexBuffer.MatricesWeightsExtraKind
  80792. * @returns a boolean
  80793. */
  80794. Mesh.prototype.isVertexBufferUpdatable = function (kind) {
  80795. if (!this._geometry) {
  80796. if (this._delayInfo) {
  80797. return this._delayInfo.indexOf(kind) !== -1;
  80798. }
  80799. return false;
  80800. }
  80801. return this._geometry.isVertexBufferUpdatable(kind);
  80802. };
  80803. /**
  80804. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  80805. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80806. * - VertexBuffer.PositionKind
  80807. * - VertexBuffer.UVKind
  80808. * - VertexBuffer.UV2Kind
  80809. * - VertexBuffer.UV3Kind
  80810. * - VertexBuffer.UV4Kind
  80811. * - VertexBuffer.UV5Kind
  80812. * - VertexBuffer.UV6Kind
  80813. * - VertexBuffer.ColorKind
  80814. * - VertexBuffer.MatricesIndicesKind
  80815. * - VertexBuffer.MatricesIndicesExtraKind
  80816. * - VertexBuffer.MatricesWeightsKind
  80817. * - VertexBuffer.MatricesWeightsExtraKind
  80818. * @returns an array of strings
  80819. */
  80820. Mesh.prototype.getVerticesDataKinds = function () {
  80821. if (!this._geometry) {
  80822. var result = new Array();
  80823. if (this._delayInfo) {
  80824. this._delayInfo.forEach(function (kind) {
  80825. result.push(kind);
  80826. });
  80827. }
  80828. return result;
  80829. }
  80830. return this._geometry.getVerticesDataKinds();
  80831. };
  80832. /**
  80833. * Returns a positive integer : the total number of indices in this mesh geometry.
  80834. * @returns the numner of indices or zero if the mesh has no geometry.
  80835. */
  80836. Mesh.prototype.getTotalIndices = function () {
  80837. if (!this._geometry) {
  80838. return 0;
  80839. }
  80840. return this._geometry.getTotalIndices();
  80841. };
  80842. /**
  80843. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  80844. * @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.
  80845. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80846. * @returns the indices array or an empty array if the mesh has no geometry
  80847. */
  80848. Mesh.prototype.getIndices = function (copyWhenShared, forceCopy) {
  80849. if (!this._geometry) {
  80850. return [];
  80851. }
  80852. return this._geometry.getIndices(copyWhenShared, forceCopy);
  80853. };
  80854. Object.defineProperty(Mesh.prototype, "isBlocked", {
  80855. get: function () {
  80856. return this._masterMesh !== null && this._masterMesh !== undefined;
  80857. },
  80858. enumerable: true,
  80859. configurable: true
  80860. });
  80861. /**
  80862. * Determine if the current mesh is ready to be rendered
  80863. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  80864. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  80865. * @returns true if all associated assets are ready (material, textures, shaders)
  80866. */
  80867. Mesh.prototype.isReady = function (completeCheck, forceInstanceSupport) {
  80868. if (completeCheck === void 0) { completeCheck = false; }
  80869. if (forceInstanceSupport === void 0) { forceInstanceSupport = false; }
  80870. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_LOADING) {
  80871. return false;
  80872. }
  80873. if (!_super.prototype.isReady.call(this, completeCheck)) {
  80874. return false;
  80875. }
  80876. if (!this.subMeshes || this.subMeshes.length === 0) {
  80877. return true;
  80878. }
  80879. if (!completeCheck) {
  80880. return true;
  80881. }
  80882. var engine = this.getEngine();
  80883. var scene = this.getScene();
  80884. var hardwareInstancedRendering = forceInstanceSupport || engine.getCaps().instancedArrays && this.instances.length > 0;
  80885. this.computeWorldMatrix();
  80886. var mat = this.material || scene.defaultMaterial;
  80887. if (mat) {
  80888. if (mat._storeEffectOnSubMeshes) {
  80889. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  80890. var subMesh = _a[_i];
  80891. var effectiveMaterial = subMesh.getMaterial();
  80892. if (effectiveMaterial) {
  80893. if (effectiveMaterial._storeEffectOnSubMeshes) {
  80894. if (!effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  80895. return false;
  80896. }
  80897. }
  80898. else {
  80899. if (!effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  80900. return false;
  80901. }
  80902. }
  80903. }
  80904. }
  80905. }
  80906. else {
  80907. if (!mat.isReady(this, hardwareInstancedRendering)) {
  80908. return false;
  80909. }
  80910. }
  80911. }
  80912. // Shadows
  80913. for (var _b = 0, _c = this._lightSources; _b < _c.length; _b++) {
  80914. var light = _c[_b];
  80915. var generator = light.getShadowGenerator();
  80916. if (generator) {
  80917. for (var _d = 0, _e = this.subMeshes; _d < _e.length; _d++) {
  80918. var subMesh = _e[_d];
  80919. if (!generator.isReady(subMesh, hardwareInstancedRendering)) {
  80920. return false;
  80921. }
  80922. }
  80923. }
  80924. }
  80925. // LOD
  80926. for (var _f = 0, _g = this._LODLevels; _f < _g.length; _f++) {
  80927. var lod = _g[_f];
  80928. if (lod.mesh && !lod.mesh.isReady(hardwareInstancedRendering)) {
  80929. return false;
  80930. }
  80931. }
  80932. return true;
  80933. };
  80934. Object.defineProperty(Mesh.prototype, "areNormalsFrozen", {
  80935. /**
  80936. * 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.
  80937. */
  80938. get: function () {
  80939. return this._areNormalsFrozen;
  80940. },
  80941. enumerable: true,
  80942. configurable: true
  80943. });
  80944. /**
  80945. * 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.
  80946. * @returns the current mesh
  80947. */
  80948. Mesh.prototype.freezeNormals = function () {
  80949. this._areNormalsFrozen = true;
  80950. return this;
  80951. };
  80952. /**
  80953. * 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
  80954. * @returns the current mesh
  80955. */
  80956. Mesh.prototype.unfreezeNormals = function () {
  80957. this._areNormalsFrozen = false;
  80958. return this;
  80959. };
  80960. Object.defineProperty(Mesh.prototype, "overridenInstanceCount", {
  80961. /**
  80962. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  80963. */
  80964. set: function (count) {
  80965. this._instanceDataStorage.overridenInstanceCount = count;
  80966. },
  80967. enumerable: true,
  80968. configurable: true
  80969. });
  80970. // Methods
  80971. /** @hidden */
  80972. Mesh.prototype._preActivate = function () {
  80973. var sceneRenderId = this.getScene().getRenderId();
  80974. if (this._preActivateId === sceneRenderId) {
  80975. return this;
  80976. }
  80977. this._preActivateId = sceneRenderId;
  80978. this._instanceDataStorage.visibleInstances = null;
  80979. return this;
  80980. };
  80981. /** @hidden */
  80982. Mesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  80983. if (this._instanceDataStorage.visibleInstances) {
  80984. this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = renderId;
  80985. }
  80986. return this;
  80987. };
  80988. /** @hidden */
  80989. Mesh.prototype._registerInstanceForRenderId = function (instance, renderId) {
  80990. if (!this._instanceDataStorage.visibleInstances) {
  80991. this._instanceDataStorage.visibleInstances = {
  80992. defaultRenderId: renderId,
  80993. selfDefaultRenderId: this._renderId
  80994. };
  80995. }
  80996. if (!this._instanceDataStorage.visibleInstances[renderId]) {
  80997. this._instanceDataStorage.visibleInstances[renderId] = new Array();
  80998. }
  80999. this._instanceDataStorage.visibleInstances[renderId].push(instance);
  81000. return this;
  81001. };
  81002. /**
  81003. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81004. * This means the mesh underlying bounding box and sphere are recomputed.
  81005. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81006. * @returns the current mesh
  81007. */
  81008. Mesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  81009. if (applySkeleton === void 0) { applySkeleton = false; }
  81010. if (this._boundingInfo && this._boundingInfo.isLocked) {
  81011. return this;
  81012. }
  81013. var bias = this.geometry ? this.geometry.boundingBias : null;
  81014. this._refreshBoundingInfo(this._getPositionData(applySkeleton), bias);
  81015. return this;
  81016. };
  81017. /** @hidden */
  81018. Mesh.prototype._createGlobalSubMesh = function (force) {
  81019. var totalVertices = this.getTotalVertices();
  81020. if (!totalVertices || !this.getIndices()) {
  81021. return null;
  81022. }
  81023. // Check if we need to recreate the submeshes
  81024. if (this.subMeshes && this.subMeshes.length > 0) {
  81025. var ib = this.getIndices();
  81026. if (!ib) {
  81027. return null;
  81028. }
  81029. var totalIndices = ib.length;
  81030. var needToRecreate = false;
  81031. if (force) {
  81032. needToRecreate = true;
  81033. }
  81034. else {
  81035. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  81036. var submesh = _a[_i];
  81037. if (submesh.indexStart + submesh.indexCount >= totalIndices) {
  81038. needToRecreate = true;
  81039. break;
  81040. }
  81041. if (submesh.verticesStart + submesh.verticesCount >= totalVertices) {
  81042. needToRecreate = true;
  81043. break;
  81044. }
  81045. }
  81046. }
  81047. if (!needToRecreate) {
  81048. return this.subMeshes[0];
  81049. }
  81050. }
  81051. this.releaseSubMeshes();
  81052. return new _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"](0, 0, totalVertices, 0, this.getTotalIndices(), this);
  81053. };
  81054. /**
  81055. * This function will subdivide the mesh into multiple submeshes
  81056. * @param count defines the expected number of submeshes
  81057. */
  81058. Mesh.prototype.subdivide = function (count) {
  81059. if (count < 1) {
  81060. return;
  81061. }
  81062. var totalIndices = this.getTotalIndices();
  81063. var subdivisionSize = (totalIndices / count) | 0;
  81064. var offset = 0;
  81065. // Ensure that subdivisionSize is a multiple of 3
  81066. while (subdivisionSize % 3 !== 0) {
  81067. subdivisionSize++;
  81068. }
  81069. this.releaseSubMeshes();
  81070. for (var index = 0; index < count; index++) {
  81071. if (offset >= totalIndices) {
  81072. break;
  81073. }
  81074. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, Math.min(subdivisionSize, totalIndices - offset), this);
  81075. offset += subdivisionSize;
  81076. }
  81077. this.synchronizeInstances();
  81078. };
  81079. /**
  81080. * Copy a FloatArray into a specific associated vertex buffer
  81081. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81082. * - VertexBuffer.PositionKind
  81083. * - VertexBuffer.UVKind
  81084. * - VertexBuffer.UV2Kind
  81085. * - VertexBuffer.UV3Kind
  81086. * - VertexBuffer.UV4Kind
  81087. * - VertexBuffer.UV5Kind
  81088. * - VertexBuffer.UV6Kind
  81089. * - VertexBuffer.ColorKind
  81090. * - VertexBuffer.MatricesIndicesKind
  81091. * - VertexBuffer.MatricesIndicesExtraKind
  81092. * - VertexBuffer.MatricesWeightsKind
  81093. * - VertexBuffer.MatricesWeightsExtraKind
  81094. * @param data defines the data source
  81095. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81096. * @param stride defines the data stride size (can be null)
  81097. * @returns the current mesh
  81098. */
  81099. Mesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  81100. if (updatable === void 0) { updatable = false; }
  81101. if (!this._geometry) {
  81102. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  81103. vertexData.set(data, kind);
  81104. var scene = this.getScene();
  81105. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  81106. }
  81107. else {
  81108. this._geometry.setVerticesData(kind, data, updatable, stride);
  81109. }
  81110. return this;
  81111. };
  81112. /**
  81113. * Flags an associated vertex buffer as updatable
  81114. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  81115. * - VertexBuffer.PositionKind
  81116. * - VertexBuffer.UVKind
  81117. * - VertexBuffer.UV2Kind
  81118. * - VertexBuffer.UV3Kind
  81119. * - VertexBuffer.UV4Kind
  81120. * - VertexBuffer.UV5Kind
  81121. * - VertexBuffer.UV6Kind
  81122. * - VertexBuffer.ColorKind
  81123. * - VertexBuffer.MatricesIndicesKind
  81124. * - VertexBuffer.MatricesIndicesExtraKind
  81125. * - VertexBuffer.MatricesWeightsKind
  81126. * - VertexBuffer.MatricesWeightsExtraKind
  81127. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81128. */
  81129. Mesh.prototype.markVerticesDataAsUpdatable = function (kind, updatable) {
  81130. if (updatable === void 0) { updatable = true; }
  81131. var vb = this.getVertexBuffer(kind);
  81132. if (!vb || vb.isUpdatable() === updatable) {
  81133. return;
  81134. }
  81135. this.setVerticesData(kind, this.getVerticesData(kind), updatable);
  81136. };
  81137. /**
  81138. * Sets the mesh global Vertex Buffer
  81139. * @param buffer defines the buffer to use
  81140. * @returns the current mesh
  81141. */
  81142. Mesh.prototype.setVerticesBuffer = function (buffer) {
  81143. if (!this._geometry) {
  81144. this._geometry = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].CreateGeometryForMesh(this);
  81145. }
  81146. this._geometry.setVerticesBuffer(buffer);
  81147. return this;
  81148. };
  81149. /**
  81150. * Update a specific associated vertex buffer
  81151. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81152. * - VertexBuffer.PositionKind
  81153. * - VertexBuffer.UVKind
  81154. * - VertexBuffer.UV2Kind
  81155. * - VertexBuffer.UV3Kind
  81156. * - VertexBuffer.UV4Kind
  81157. * - VertexBuffer.UV5Kind
  81158. * - VertexBuffer.UV6Kind
  81159. * - VertexBuffer.ColorKind
  81160. * - VertexBuffer.MatricesIndicesKind
  81161. * - VertexBuffer.MatricesIndicesExtraKind
  81162. * - VertexBuffer.MatricesWeightsKind
  81163. * - VertexBuffer.MatricesWeightsExtraKind
  81164. * @param data defines the data source
  81165. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  81166. * @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)
  81167. * @returns the current mesh
  81168. */
  81169. Mesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  81170. if (!this._geometry) {
  81171. return this;
  81172. }
  81173. if (!makeItUnique) {
  81174. this._geometry.updateVerticesData(kind, data, updateExtends);
  81175. }
  81176. else {
  81177. this.makeGeometryUnique();
  81178. this.updateVerticesData(kind, data, updateExtends, false);
  81179. }
  81180. return this;
  81181. };
  81182. /**
  81183. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  81184. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  81185. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  81186. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  81187. * @returns the current mesh
  81188. */
  81189. Mesh.prototype.updateMeshPositions = function (positionFunction, computeNormals) {
  81190. if (computeNormals === void 0) { computeNormals = true; }
  81191. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  81192. if (!positions) {
  81193. return this;
  81194. }
  81195. positionFunction(positions);
  81196. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions, false, false);
  81197. if (computeNormals) {
  81198. var indices = this.getIndices();
  81199. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  81200. if (!normals) {
  81201. return this;
  81202. }
  81203. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  81204. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, false, false);
  81205. }
  81206. return this;
  81207. };
  81208. /**
  81209. * Creates a un-shared specific occurence of the geometry for the mesh.
  81210. * @returns the current mesh
  81211. */
  81212. Mesh.prototype.makeGeometryUnique = function () {
  81213. if (!this._geometry) {
  81214. return this;
  81215. }
  81216. var oldGeometry = this._geometry;
  81217. var geometry = this._geometry.copy(_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId());
  81218. oldGeometry.releaseForMesh(this, true);
  81219. geometry.applyToMesh(this);
  81220. return this;
  81221. };
  81222. /**
  81223. * Set the index buffer of this mesh
  81224. * @param indices defines the source data
  81225. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  81226. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  81227. * @returns the current mesh
  81228. */
  81229. Mesh.prototype.setIndices = function (indices, totalVertices, updatable) {
  81230. if (totalVertices === void 0) { totalVertices = null; }
  81231. if (updatable === void 0) { updatable = false; }
  81232. if (!this._geometry) {
  81233. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  81234. vertexData.indices = indices;
  81235. var scene = this.getScene();
  81236. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  81237. }
  81238. else {
  81239. this._geometry.setIndices(indices, totalVertices, updatable);
  81240. }
  81241. return this;
  81242. };
  81243. /**
  81244. * Update the current index buffer
  81245. * @param indices defines the source data
  81246. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81247. * @returns the current mesh
  81248. */
  81249. Mesh.prototype.updateIndices = function (indices, offset) {
  81250. if (!this._geometry) {
  81251. return this;
  81252. }
  81253. this._geometry.updateIndices(indices, offset);
  81254. return this;
  81255. };
  81256. /**
  81257. * Invert the geometry to move from a right handed system to a left handed one.
  81258. * @returns the current mesh
  81259. */
  81260. Mesh.prototype.toLeftHanded = function () {
  81261. if (!this._geometry) {
  81262. return this;
  81263. }
  81264. this._geometry.toLeftHanded();
  81265. return this;
  81266. };
  81267. /** @hidden */
  81268. Mesh.prototype._bind = function (subMesh, effect, fillMode) {
  81269. if (!this._geometry) {
  81270. return this;
  81271. }
  81272. var engine = this.getScene().getEngine();
  81273. // Wireframe
  81274. var indexToBind;
  81275. if (this._unIndexed) {
  81276. indexToBind = null;
  81277. }
  81278. else {
  81279. switch (fillMode) {
  81280. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode:
  81281. indexToBind = null;
  81282. break;
  81283. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode:
  81284. indexToBind = subMesh._getLinesIndexBuffer(this.getIndices(), engine);
  81285. break;
  81286. default:
  81287. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].TriangleFillMode:
  81288. indexToBind = this._unIndexed ? null : this._geometry.getIndexBuffer();
  81289. break;
  81290. }
  81291. }
  81292. // VBOs
  81293. this._geometry._bind(effect, indexToBind);
  81294. return this;
  81295. };
  81296. /** @hidden */
  81297. Mesh.prototype._draw = function (subMesh, fillMode, instancesCount, alternate) {
  81298. if (alternate === void 0) { alternate = false; }
  81299. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  81300. return this;
  81301. }
  81302. if (this._onBeforeDrawObservable) {
  81303. this._onBeforeDrawObservable.notifyObservers(this);
  81304. }
  81305. var scene = this.getScene();
  81306. var engine = scene.getEngine();
  81307. if (this._unIndexed || fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode) {
  81308. // or triangles as points
  81309. engine.drawArraysType(fillMode, subMesh.verticesStart, subMesh.verticesCount, instancesCount);
  81310. }
  81311. else if (fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode) {
  81312. // Triangles as wireframe
  81313. engine.drawElementsType(fillMode, 0, subMesh._linesIndexCount, instancesCount);
  81314. }
  81315. else {
  81316. engine.drawElementsType(fillMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  81317. }
  81318. if (scene._isAlternateRenderingEnabled && !alternate) {
  81319. var effect = subMesh.effect || this._effectiveMaterial.getEffect();
  81320. if (!effect || !scene.activeCamera) {
  81321. return this;
  81322. }
  81323. scene._switchToAlternateCameraConfiguration(true);
  81324. this._effectiveMaterial.bindView(effect);
  81325. this._effectiveMaterial.bindViewProjection(effect);
  81326. engine.setViewport(scene.activeCamera._alternateCamera.viewport);
  81327. this._draw(subMesh, fillMode, instancesCount, true);
  81328. engine.setViewport(scene.activeCamera.viewport);
  81329. scene._switchToAlternateCameraConfiguration(false);
  81330. this._effectiveMaterial.bindView(effect);
  81331. this._effectiveMaterial.bindViewProjection(effect);
  81332. }
  81333. return this;
  81334. };
  81335. /**
  81336. * Registers for this mesh a javascript function called just before the rendering process
  81337. * @param func defines the function to call before rendering this mesh
  81338. * @returns the current mesh
  81339. */
  81340. Mesh.prototype.registerBeforeRender = function (func) {
  81341. this.onBeforeRenderObservable.add(func);
  81342. return this;
  81343. };
  81344. /**
  81345. * Disposes a previously registered javascript function called before the rendering
  81346. * @param func defines the function to remove
  81347. * @returns the current mesh
  81348. */
  81349. Mesh.prototype.unregisterBeforeRender = function (func) {
  81350. this.onBeforeRenderObservable.removeCallback(func);
  81351. return this;
  81352. };
  81353. /**
  81354. * Registers for this mesh a javascript function called just after the rendering is complete
  81355. * @param func defines the function to call after rendering this mesh
  81356. * @returns the current mesh
  81357. */
  81358. Mesh.prototype.registerAfterRender = function (func) {
  81359. this.onAfterRenderObservable.add(func);
  81360. return this;
  81361. };
  81362. /**
  81363. * Disposes a previously registered javascript function called after the rendering.
  81364. * @param func defines the function to remove
  81365. * @returns the current mesh
  81366. */
  81367. Mesh.prototype.unregisterAfterRender = function (func) {
  81368. this.onAfterRenderObservable.removeCallback(func);
  81369. return this;
  81370. };
  81371. /** @hidden */
  81372. Mesh.prototype._getInstancesRenderList = function (subMeshId) {
  81373. var scene = this.getScene();
  81374. var batchCache = this._instanceDataStorage.batchCache;
  81375. batchCache.mustReturn = false;
  81376. batchCache.renderSelf[subMeshId] = this.isEnabled() && this.isVisible;
  81377. batchCache.visibleInstances[subMeshId] = null;
  81378. if (this._instanceDataStorage.visibleInstances) {
  81379. var visibleInstances = this._instanceDataStorage.visibleInstances;
  81380. var currentRenderId = scene.getRenderId();
  81381. var defaultRenderId = (scene._isInIntermediateRendering() ? visibleInstances.intermediateDefaultRenderId : visibleInstances.defaultRenderId);
  81382. batchCache.visibleInstances[subMeshId] = visibleInstances[currentRenderId];
  81383. var selfRenderId = this._renderId;
  81384. if (!batchCache.visibleInstances[subMeshId] && defaultRenderId) {
  81385. batchCache.visibleInstances[subMeshId] = visibleInstances[defaultRenderId];
  81386. currentRenderId = Math.max(defaultRenderId, currentRenderId);
  81387. selfRenderId = Math.max(visibleInstances.selfDefaultRenderId, currentRenderId);
  81388. }
  81389. var visibleInstancesForSubMesh = batchCache.visibleInstances[subMeshId];
  81390. if (visibleInstancesForSubMesh && visibleInstancesForSubMesh.length) {
  81391. if (this._instanceDataStorage.renderIdForInstances[subMeshId] === currentRenderId) {
  81392. batchCache.mustReturn = true;
  81393. return batchCache;
  81394. }
  81395. if (currentRenderId !== selfRenderId) {
  81396. batchCache.renderSelf[subMeshId] = false;
  81397. }
  81398. }
  81399. this._instanceDataStorage.renderIdForInstances[subMeshId] = currentRenderId;
  81400. }
  81401. return batchCache;
  81402. };
  81403. /** @hidden */
  81404. Mesh.prototype._renderWithInstances = function (subMesh, fillMode, batch, effect, engine) {
  81405. var visibleInstances = batch.visibleInstances[subMesh._id];
  81406. if (!visibleInstances) {
  81407. return this;
  81408. }
  81409. var matricesCount = visibleInstances.length + 1;
  81410. var bufferSize = matricesCount * 16 * 4;
  81411. var instanceStorage = this._instanceDataStorage;
  81412. var currentInstancesBufferSize = instanceStorage.instancesBufferSize;
  81413. var instancesBuffer = instanceStorage.instancesBuffer;
  81414. while (instanceStorage.instancesBufferSize < bufferSize) {
  81415. instanceStorage.instancesBufferSize *= 2;
  81416. }
  81417. if (!instanceStorage.instancesData || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  81418. instanceStorage.instancesData = new Float32Array(instanceStorage.instancesBufferSize / 4);
  81419. }
  81420. var offset = 0;
  81421. var instancesCount = 0;
  81422. var world = this.getWorldMatrix();
  81423. if (batch.renderSelf[subMesh._id]) {
  81424. world.copyToArray(instanceStorage.instancesData, offset);
  81425. offset += 16;
  81426. instancesCount++;
  81427. }
  81428. if (visibleInstances) {
  81429. for (var instanceIndex = 0; instanceIndex < visibleInstances.length; instanceIndex++) {
  81430. var instance = visibleInstances[instanceIndex];
  81431. instance.getWorldMatrix().copyToArray(instanceStorage.instancesData, offset);
  81432. offset += 16;
  81433. instancesCount++;
  81434. }
  81435. }
  81436. if (!instancesBuffer || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  81437. if (instancesBuffer) {
  81438. instancesBuffer.dispose();
  81439. }
  81440. instancesBuffer = new _buffer__WEBPACK_IMPORTED_MODULE_7__["Buffer"](engine, instanceStorage.instancesData, true, 16, false, true);
  81441. instanceStorage.instancesBuffer = instancesBuffer;
  81442. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world0", 0, 4));
  81443. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world1", 4, 4));
  81444. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world2", 8, 4));
  81445. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world3", 12, 4));
  81446. }
  81447. else {
  81448. instancesBuffer.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
  81449. }
  81450. this._bind(subMesh, effect, fillMode);
  81451. this._draw(subMesh, fillMode, instancesCount);
  81452. engine.unbindInstanceAttributes();
  81453. return this;
  81454. };
  81455. /** @hidden */
  81456. Mesh.prototype._processRendering = function (subMesh, effect, fillMode, batch, hardwareInstancedRendering, onBeforeDraw, effectiveMaterial) {
  81457. var scene = this.getScene();
  81458. var engine = scene.getEngine();
  81459. if (hardwareInstancedRendering) {
  81460. this._renderWithInstances(subMesh, fillMode, batch, effect, engine);
  81461. }
  81462. else {
  81463. if (batch.renderSelf[subMesh._id]) {
  81464. // Draw
  81465. if (onBeforeDraw) {
  81466. onBeforeDraw(false, this.getWorldMatrix(), effectiveMaterial);
  81467. }
  81468. this._draw(subMesh, fillMode, this._instanceDataStorage.overridenInstanceCount);
  81469. }
  81470. var visibleInstancesForSubMesh = batch.visibleInstances[subMesh._id];
  81471. if (visibleInstancesForSubMesh) {
  81472. for (var instanceIndex = 0; instanceIndex < visibleInstancesForSubMesh.length; instanceIndex++) {
  81473. var instance = visibleInstancesForSubMesh[instanceIndex];
  81474. // World
  81475. var world = instance.getWorldMatrix();
  81476. if (onBeforeDraw) {
  81477. onBeforeDraw(true, world, effectiveMaterial);
  81478. }
  81479. // Draw
  81480. this._draw(subMesh, fillMode);
  81481. }
  81482. }
  81483. }
  81484. return this;
  81485. };
  81486. /**
  81487. * 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
  81488. * @param subMesh defines the subMesh to render
  81489. * @param enableAlphaMode defines if alpha mode can be changed
  81490. * @returns the current mesh
  81491. */
  81492. Mesh.prototype.render = function (subMesh, enableAlphaMode) {
  81493. if (this._checkOcclusionQuery()) {
  81494. return this;
  81495. }
  81496. var scene = this.getScene();
  81497. // Managing instances
  81498. var batch = this._getInstancesRenderList(subMesh._id);
  81499. if (batch.mustReturn) {
  81500. return this;
  81501. }
  81502. // Checking geometry state
  81503. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  81504. return this;
  81505. }
  81506. if (this._onBeforeRenderObservable) {
  81507. this._onBeforeRenderObservable.notifyObservers(this);
  81508. }
  81509. var engine = scene.getEngine();
  81510. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  81511. // Material
  81512. var material = subMesh.getMaterial();
  81513. if (!material) {
  81514. return this;
  81515. }
  81516. this._effectiveMaterial = material;
  81517. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  81518. if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  81519. return this;
  81520. }
  81521. }
  81522. else if (!this._effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  81523. return this;
  81524. }
  81525. // Alpha mode
  81526. if (enableAlphaMode) {
  81527. engine.setAlphaMode(this._effectiveMaterial.alphaMode);
  81528. }
  81529. for (var _i = 0, _a = scene._beforeRenderingMeshStage; _i < _a.length; _i++) {
  81530. var step = _a[_i];
  81531. step.action(this, subMesh, batch);
  81532. }
  81533. var effect;
  81534. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  81535. effect = subMesh.effect;
  81536. }
  81537. else {
  81538. effect = this._effectiveMaterial.getEffect();
  81539. }
  81540. if (!effect) {
  81541. return this;
  81542. }
  81543. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  81544. var sideOrientation = this.overrideMaterialSideOrientation;
  81545. if (sideOrientation == null) {
  81546. sideOrientation = this._effectiveMaterial.sideOrientation;
  81547. if (effectiveMesh._getWorldMatrixDeterminant() < 0) {
  81548. 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);
  81549. }
  81550. }
  81551. var reverse = this._effectiveMaterial._preBind(effect, sideOrientation);
  81552. if (this._effectiveMaterial.forceDepthWrite) {
  81553. engine.setDepthWrite(true);
  81554. }
  81555. // Bind
  81556. 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);
  81557. if (!hardwareInstancedRendering) { // Binding will be done later because we need to add more info to the VB
  81558. this._bind(subMesh, effect, fillMode);
  81559. }
  81560. var world = effectiveMesh.getWorldMatrix();
  81561. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  81562. this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
  81563. }
  81564. else {
  81565. this._effectiveMaterial.bind(world, this);
  81566. }
  81567. if (!this._effectiveMaterial.backFaceCulling && this._effectiveMaterial.separateCullingPass) {
  81568. engine.setState(true, this._effectiveMaterial.zOffset, false, !reverse);
  81569. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  81570. engine.setState(true, this._effectiveMaterial.zOffset, false, reverse);
  81571. }
  81572. // Draw
  81573. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  81574. // Unbind
  81575. this._effectiveMaterial.unbind();
  81576. for (var _b = 0, _c = scene._afterRenderingMeshStage; _b < _c.length; _b++) {
  81577. var step = _c[_b];
  81578. step.action(this, subMesh, batch);
  81579. }
  81580. if (this._onAfterRenderObservable) {
  81581. this._onAfterRenderObservable.notifyObservers(this);
  81582. }
  81583. return this;
  81584. };
  81585. Mesh.prototype._onBeforeDraw = function (isInstance, world, effectiveMaterial) {
  81586. if (isInstance && effectiveMaterial) {
  81587. effectiveMaterial.bindOnlyWorldMatrix(world);
  81588. }
  81589. };
  81590. /**
  81591. * Renormalize the mesh and patch it up if there are no weights
  81592. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  81593. * However in the case of zero weights then we set just a single influence to 1.
  81594. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  81595. */
  81596. Mesh.prototype.cleanMatrixWeights = function () {
  81597. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  81598. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind)) {
  81599. this.normalizeSkinWeightsAndExtra();
  81600. }
  81601. else {
  81602. this.normalizeSkinFourWeights();
  81603. }
  81604. }
  81605. };
  81606. // faster 4 weight version.
  81607. Mesh.prototype.normalizeSkinFourWeights = function () {
  81608. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  81609. var numWeights = matricesWeights.length;
  81610. for (var a = 0; a < numWeights; a += 4) {
  81611. // accumulate weights
  81612. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  81613. // check for invalid weight and just set it to 1.
  81614. if (t === 0) {
  81615. matricesWeights[a] = 1;
  81616. }
  81617. else {
  81618. // renormalize so everything adds to 1 use reciprical
  81619. var recip = 1 / t;
  81620. matricesWeights[a] *= recip;
  81621. matricesWeights[a + 1] *= recip;
  81622. matricesWeights[a + 2] *= recip;
  81623. matricesWeights[a + 3] *= recip;
  81624. }
  81625. }
  81626. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  81627. };
  81628. // handle special case of extra verts. (in theory gltf can handle 12 influences)
  81629. Mesh.prototype.normalizeSkinWeightsAndExtra = function () {
  81630. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  81631. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  81632. var numWeights = matricesWeights.length;
  81633. for (var a = 0; a < numWeights; a += 4) {
  81634. // accumulate weights
  81635. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  81636. t += matricesWeightsExtra[a] + matricesWeightsExtra[a + 1] + matricesWeightsExtra[a + 2] + matricesWeightsExtra[a + 3];
  81637. // check for invalid weight and just set it to 1.
  81638. if (t === 0) {
  81639. matricesWeights[a] = 1;
  81640. }
  81641. else {
  81642. // renormalize so everything adds to 1 use reciprical
  81643. var recip = 1 / t;
  81644. matricesWeights[a] *= recip;
  81645. matricesWeights[a + 1] *= recip;
  81646. matricesWeights[a + 2] *= recip;
  81647. matricesWeights[a + 3] *= recip;
  81648. // same goes for extras
  81649. matricesWeightsExtra[a] *= recip;
  81650. matricesWeightsExtra[a + 1] *= recip;
  81651. matricesWeightsExtra[a + 2] *= recip;
  81652. matricesWeightsExtra[a + 3] *= recip;
  81653. }
  81654. }
  81655. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  81656. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeightsExtra);
  81657. };
  81658. /**
  81659. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  81660. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  81661. * the user know there was an issue with importing the mesh
  81662. * @returns a validation object with skinned, valid and report string
  81663. */
  81664. Mesh.prototype.validateSkinning = function () {
  81665. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  81666. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  81667. if (matricesWeights === null || this.skeleton == null) {
  81668. return { skinned: false, valid: true, report: "not skinned" };
  81669. }
  81670. var numWeights = matricesWeights.length;
  81671. var numberNotSorted = 0;
  81672. var missingWeights = 0;
  81673. var maxUsedWeights = 0;
  81674. var numberNotNormalized = 0;
  81675. var numInfluences = matricesWeightsExtra === null ? 4 : 8;
  81676. var usedWeightCounts = new Array();
  81677. for (var a = 0; a <= numInfluences; a++) {
  81678. usedWeightCounts[a] = 0;
  81679. }
  81680. var toleranceEpsilon = 0.001;
  81681. for (var a = 0; a < numWeights; a += 4) {
  81682. var lastWeight = matricesWeights[a];
  81683. var t = lastWeight;
  81684. var usedWeights = t === 0 ? 0 : 1;
  81685. for (var b = 1; b < numInfluences; b++) {
  81686. var d = b < 4 ? matricesWeights[a + b] : matricesWeightsExtra[a + b - 4];
  81687. if (d > lastWeight) {
  81688. numberNotSorted++;
  81689. }
  81690. if (d !== 0) {
  81691. usedWeights++;
  81692. }
  81693. t += d;
  81694. lastWeight = d;
  81695. }
  81696. // count the buffer weights usage
  81697. usedWeightCounts[usedWeights]++;
  81698. // max influences
  81699. if (usedWeights > maxUsedWeights) {
  81700. maxUsedWeights = usedWeights;
  81701. }
  81702. // check for invalid weight and just set it to 1.
  81703. if (t === 0) {
  81704. missingWeights++;
  81705. }
  81706. else {
  81707. // renormalize so everything adds to 1 use reciprical
  81708. var recip = 1 / t;
  81709. var tolerance = 0;
  81710. for (b = 0; b < numInfluences; b++) {
  81711. if (b < 4) {
  81712. tolerance += Math.abs(matricesWeights[a + b] - (matricesWeights[a + b] * recip));
  81713. }
  81714. else {
  81715. tolerance += Math.abs(matricesWeightsExtra[a + b - 4] - (matricesWeightsExtra[a + b - 4] * recip));
  81716. }
  81717. }
  81718. // arbitary epsilon value for dicdating not normalized
  81719. if (tolerance > toleranceEpsilon) {
  81720. numberNotNormalized++;
  81721. }
  81722. }
  81723. }
  81724. // validate bone indices are in range of the skeleton
  81725. var numBones = this.skeleton.bones.length;
  81726. var matricesIndices = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  81727. var matricesIndicesExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind);
  81728. var numBadBoneIndices = 0;
  81729. for (var a = 0; a < numWeights; a++) {
  81730. for (var b = 0; b < numInfluences; b++) {
  81731. var index = b < 4 ? matricesIndices[b] : matricesIndicesExtra[b - 4];
  81732. if (index >= numBones || index < 0) {
  81733. numBadBoneIndices++;
  81734. }
  81735. }
  81736. }
  81737. // log mesh stats
  81738. var output = "Number of Weights = " + numWeights / 4 + "\nMaximum influences = " + maxUsedWeights +
  81739. "\nMissing Weights = " + missingWeights + "\nNot Sorted = " + numberNotSorted +
  81740. "\nNot Normalized = " + numberNotNormalized + "\nWeightCounts = [" + usedWeightCounts + "]" +
  81741. "\nNumber of bones = " + numBones + "\nBad Bone Indices = " + numBadBoneIndices;
  81742. return { skinned: true, valid: missingWeights === 0 && numberNotNormalized === 0 && numBadBoneIndices === 0, report: output };
  81743. };
  81744. /** @hidden */
  81745. Mesh.prototype._checkDelayState = function () {
  81746. var scene = this.getScene();
  81747. if (this._geometry) {
  81748. this._geometry.load(scene);
  81749. }
  81750. else if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  81751. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_LOADING;
  81752. this._queueLoad(scene);
  81753. }
  81754. return this;
  81755. };
  81756. Mesh.prototype._queueLoad = function (scene) {
  81757. var _this = this;
  81758. scene._addPendingData(this);
  81759. var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1);
  81760. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadFile(this.delayLoadingFile, function (data) {
  81761. if (data instanceof ArrayBuffer) {
  81762. _this._delayLoadingFunction(data, _this);
  81763. }
  81764. else {
  81765. _this._delayLoadingFunction(JSON.parse(data), _this);
  81766. }
  81767. _this.instances.forEach(function (instance) {
  81768. instance._syncSubMeshes();
  81769. });
  81770. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_LOADED;
  81771. scene._removePendingData(_this);
  81772. }, function () { }, scene.offlineProvider, getBinaryData);
  81773. return this;
  81774. };
  81775. /**
  81776. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81777. * A mesh is in the frustum if its bounding box intersects the frustum
  81778. * @param frustumPlanes defines the frustum to test
  81779. * @returns true if the mesh is in the frustum planes
  81780. */
  81781. Mesh.prototype.isInFrustum = function (frustumPlanes) {
  81782. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_LOADING) {
  81783. return false;
  81784. }
  81785. if (!_super.prototype.isInFrustum.call(this, frustumPlanes)) {
  81786. return false;
  81787. }
  81788. this._checkDelayState();
  81789. return true;
  81790. };
  81791. /**
  81792. * Sets the mesh material by the material or multiMaterial `id` property
  81793. * @param id is a string identifying the material or the multiMaterial
  81794. * @returns the current mesh
  81795. */
  81796. Mesh.prototype.setMaterialByID = function (id) {
  81797. var materials = this.getScene().materials;
  81798. var index;
  81799. for (index = materials.length - 1; index > -1; index--) {
  81800. if (materials[index].id === id) {
  81801. this.material = materials[index];
  81802. return this;
  81803. }
  81804. }
  81805. // Multi
  81806. var multiMaterials = this.getScene().multiMaterials;
  81807. for (index = multiMaterials.length - 1; index > -1; index--) {
  81808. if (multiMaterials[index].id === id) {
  81809. this.material = multiMaterials[index];
  81810. return this;
  81811. }
  81812. }
  81813. return this;
  81814. };
  81815. /**
  81816. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  81817. * @returns an array of IAnimatable
  81818. */
  81819. Mesh.prototype.getAnimatables = function () {
  81820. var results = new Array();
  81821. if (this.material) {
  81822. results.push(this.material);
  81823. }
  81824. if (this.skeleton) {
  81825. results.push(this.skeleton);
  81826. }
  81827. return results;
  81828. };
  81829. /**
  81830. * Modifies the mesh geometry according to the passed transformation matrix.
  81831. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  81832. * The mesh normals are modified using the same transformation.
  81833. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81834. * @param transform defines the transform matrix to use
  81835. * @see http://doc.babylonjs.com/resources/baking_transformations
  81836. * @returns the current mesh
  81837. */
  81838. Mesh.prototype.bakeTransformIntoVertices = function (transform) {
  81839. // Position
  81840. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  81841. return this;
  81842. }
  81843. var submeshes = this.subMeshes.splice(0);
  81844. this._resetPointsArrayCache();
  81845. var data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  81846. var temp = new Array();
  81847. var index;
  81848. for (index = 0; index < data.length; index += 3) {
  81849. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).toArray(temp, index);
  81850. }
  81851. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind).isUpdatable());
  81852. // Normals
  81853. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  81854. data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  81855. temp = [];
  81856. for (index = 0; index < data.length; index += 3) {
  81857. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).normalize().toArray(temp, index);
  81858. }
  81859. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind).isUpdatable());
  81860. }
  81861. // flip faces?
  81862. if (transform.m[0] * transform.m[5] * transform.m[10] < 0) {
  81863. this.flipFaces();
  81864. }
  81865. // Restore submeshes
  81866. this.releaseSubMeshes();
  81867. this.subMeshes = submeshes;
  81868. return this;
  81869. };
  81870. /**
  81871. * Modifies the mesh geometry according to its own current World Matrix.
  81872. * The mesh World Matrix is then reset.
  81873. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  81874. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81875. * @see http://doc.babylonjs.com/resources/baking_transformations
  81876. * @returns the current mesh
  81877. */
  81878. Mesh.prototype.bakeCurrentTransformIntoVertices = function () {
  81879. this.bakeTransformIntoVertices(this.computeWorldMatrix(true));
  81880. this.scaling.copyFromFloats(1, 1, 1);
  81881. this.position.copyFromFloats(0, 0, 0);
  81882. this.rotation.copyFromFloats(0, 0, 0);
  81883. //only if quaternion is already set
  81884. if (this.rotationQuaternion) {
  81885. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].Identity();
  81886. }
  81887. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  81888. return this;
  81889. };
  81890. Object.defineProperty(Mesh.prototype, "_positions", {
  81891. // Cache
  81892. /** @hidden */
  81893. get: function () {
  81894. if (this._geometry) {
  81895. return this._geometry._positions;
  81896. }
  81897. return null;
  81898. },
  81899. enumerable: true,
  81900. configurable: true
  81901. });
  81902. /** @hidden */
  81903. Mesh.prototype._resetPointsArrayCache = function () {
  81904. if (this._geometry) {
  81905. this._geometry._resetPointsArrayCache();
  81906. }
  81907. return this;
  81908. };
  81909. /** @hidden */
  81910. Mesh.prototype._generatePointsArray = function () {
  81911. if (this._geometry) {
  81912. return this._geometry._generatePointsArray();
  81913. }
  81914. return false;
  81915. };
  81916. /**
  81917. * Returns a new Mesh object generated from the current mesh properties.
  81918. * This method must not get confused with createInstance()
  81919. * @param name is a string, the name given to the new mesh
  81920. * @param newParent can be any Node object (default `null`)
  81921. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  81922. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  81923. * @returns a new mesh
  81924. */
  81925. Mesh.prototype.clone = function (name, newParent, doNotCloneChildren, clonePhysicsImpostor) {
  81926. if (name === void 0) { name = ""; }
  81927. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  81928. return new Mesh(name, this.getScene(), newParent, this, doNotCloneChildren, clonePhysicsImpostor);
  81929. };
  81930. /**
  81931. * Releases resources associated with this mesh.
  81932. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81933. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81934. */
  81935. Mesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  81936. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  81937. this.morphTargetManager = null;
  81938. if (this._geometry) {
  81939. this._geometry.releaseForMesh(this, true);
  81940. }
  81941. if (this._onBeforeDrawObservable) {
  81942. this._onBeforeDrawObservable.clear();
  81943. }
  81944. if (this._onBeforeRenderObservable) {
  81945. this._onBeforeRenderObservable.clear();
  81946. }
  81947. if (this._onAfterRenderObservable) {
  81948. this._onAfterRenderObservable.clear();
  81949. }
  81950. // Sources
  81951. if (this._scene.useClonedMeshhMap) {
  81952. if (this.meshMap) {
  81953. for (var uniqueId in this.meshMap) {
  81954. var mesh = this.meshMap[uniqueId];
  81955. if (mesh) {
  81956. mesh._source = null;
  81957. this.meshMap[uniqueId] = undefined;
  81958. }
  81959. }
  81960. }
  81961. if (this._source && this._source.meshMap) {
  81962. this._source.meshMap[this.uniqueId] = undefined;
  81963. }
  81964. }
  81965. else {
  81966. var meshes = this.getScene().meshes;
  81967. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  81968. var abstractMesh = meshes_1[_i];
  81969. var mesh = abstractMesh;
  81970. if (mesh._source && mesh._source === this) {
  81971. mesh._source = null;
  81972. }
  81973. }
  81974. }
  81975. this._source = null;
  81976. // Instances
  81977. if (this._instanceDataStorage.instancesBuffer) {
  81978. this._instanceDataStorage.instancesBuffer.dispose();
  81979. this._instanceDataStorage.instancesBuffer = null;
  81980. }
  81981. while (this.instances.length) {
  81982. this.instances[0].dispose();
  81983. }
  81984. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  81985. };
  81986. /**
  81987. * Modifies the mesh geometry according to a displacement map.
  81988. * 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.
  81989. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81990. * @param url is a string, the URL from the image file is to be downloaded.
  81991. * @param minHeight is the lower limit of the displacement.
  81992. * @param maxHeight is the upper limit of the displacement.
  81993. * @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.
  81994. * @param uvOffset is an optional vector2 used to offset UV.
  81995. * @param uvScale is an optional vector2 used to scale UV.
  81996. * @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.
  81997. * @returns the Mesh.
  81998. */
  81999. Mesh.prototype.applyDisplacementMap = function (url, minHeight, maxHeight, onSuccess, uvOffset, uvScale, forceUpdate) {
  82000. var _this = this;
  82001. if (forceUpdate === void 0) { forceUpdate = false; }
  82002. var scene = this.getScene();
  82003. var onload = function (img) {
  82004. // Getting height map data
  82005. var canvas = document.createElement("canvas");
  82006. var context = canvas.getContext("2d");
  82007. var heightMapWidth = img.width;
  82008. var heightMapHeight = img.height;
  82009. canvas.width = heightMapWidth;
  82010. canvas.height = heightMapHeight;
  82011. context.drawImage(img, 0, 0);
  82012. // Create VertexData from map data
  82013. //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  82014. var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
  82015. _this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate);
  82016. //execute success callback, if set
  82017. if (onSuccess) {
  82018. onSuccess(_this);
  82019. }
  82020. };
  82021. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  82022. return this;
  82023. };
  82024. /**
  82025. * Modifies the mesh geometry according to a displacementMap buffer.
  82026. * 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.
  82027. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  82028. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  82029. * @param heightMapWidth is the width of the buffer image.
  82030. * @param heightMapHeight is the height of the buffer image.
  82031. * @param minHeight is the lower limit of the displacement.
  82032. * @param maxHeight is the upper limit of the displacement.
  82033. * @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.
  82034. * @param uvOffset is an optional vector2 used to offset UV.
  82035. * @param uvScale is an optional vector2 used to scale UV.
  82036. * @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.
  82037. * @returns the Mesh.
  82038. */
  82039. Mesh.prototype.applyDisplacementMapFromBuffer = function (buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate) {
  82040. if (forceUpdate === void 0) { forceUpdate = false; }
  82041. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)
  82042. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)
  82043. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind)) {
  82044. _Misc_logger__WEBPACK_IMPORTED_MODULE_19__["Logger"].Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");
  82045. return this;
  82046. }
  82047. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, true, true);
  82048. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  82049. var uvs = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  82050. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  82051. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  82052. var uv = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  82053. uvOffset = uvOffset || _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  82054. uvScale = uvScale || new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](1, 1);
  82055. for (var index = 0; index < positions.length; index += 3) {
  82056. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(positions, index, position);
  82057. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(normals, index, normal);
  82058. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].FromArrayToRef(uvs, (index / 3) * 2, uv);
  82059. // Compute height
  82060. var u = ((Math.abs(uv.x * uvScale.x + uvOffset.x) * heightMapWidth) % heightMapWidth) | 0;
  82061. var v = ((Math.abs(uv.y * uvScale.y + uvOffset.y) * heightMapHeight) % heightMapHeight) | 0;
  82062. var pos = (u + v * heightMapWidth) * 4;
  82063. var r = buffer[pos] / 255.0;
  82064. var g = buffer[pos + 1] / 255.0;
  82065. var b = buffer[pos + 2] / 255.0;
  82066. var gradient = r * 0.3 + g * 0.59 + b * 0.11;
  82067. normal.normalize();
  82068. normal.scaleInPlace(minHeight + (maxHeight - minHeight) * gradient);
  82069. position = position.add(normal);
  82070. position.toArray(positions, index);
  82071. }
  82072. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, this.getIndices(), normals);
  82073. if (forceUpdate) {
  82074. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  82075. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  82076. }
  82077. else {
  82078. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  82079. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  82080. }
  82081. return this;
  82082. };
  82083. /**
  82084. * Modify the mesh to get a flat shading rendering.
  82085. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  82086. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  82087. * @returns current mesh
  82088. */
  82089. Mesh.prototype.convertToFlatShadedMesh = function () {
  82090. var kinds = this.getVerticesDataKinds();
  82091. var vbs = {};
  82092. var data = {};
  82093. var newdata = {};
  82094. var updatableNormals = false;
  82095. var kindIndex;
  82096. var kind;
  82097. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  82098. kind = kinds[kindIndex];
  82099. var vertexBuffer = this.getVertexBuffer(kind);
  82100. if (kind === _buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) {
  82101. updatableNormals = vertexBuffer.isUpdatable();
  82102. kinds.splice(kindIndex, 1);
  82103. kindIndex--;
  82104. continue;
  82105. }
  82106. vbs[kind] = vertexBuffer;
  82107. data[kind] = vbs[kind].getData();
  82108. newdata[kind] = [];
  82109. }
  82110. // Save previous submeshes
  82111. var previousSubmeshes = this.subMeshes.slice(0);
  82112. var indices = this.getIndices();
  82113. var totalIndices = this.getTotalIndices();
  82114. // Generating unique vertices per face
  82115. var index;
  82116. for (index = 0; index < totalIndices; index++) {
  82117. var vertexIndex = indices[index];
  82118. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  82119. kind = kinds[kindIndex];
  82120. var stride = vbs[kind].getStrideSize();
  82121. for (var offset = 0; offset < stride; offset++) {
  82122. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  82123. }
  82124. }
  82125. }
  82126. // Updating faces & normal
  82127. var normals = [];
  82128. var positions = newdata[_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  82129. for (index = 0; index < totalIndices; index += 3) {
  82130. indices[index] = index;
  82131. indices[index + 1] = index + 1;
  82132. indices[index + 2] = index + 2;
  82133. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, index * 3);
  82134. var p2 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 1) * 3);
  82135. var p3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 2) * 3);
  82136. var p1p2 = p1.subtract(p2);
  82137. var p3p2 = p3.subtract(p2);
  82138. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Cross(p1p2, p3p2));
  82139. // Store same normals for every vertex
  82140. for (var localIndex = 0; localIndex < 3; localIndex++) {
  82141. normals.push(normal.x);
  82142. normals.push(normal.y);
  82143. normals.push(normal.z);
  82144. }
  82145. }
  82146. this.setIndices(indices);
  82147. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, updatableNormals);
  82148. // Updating vertex buffers
  82149. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  82150. kind = kinds[kindIndex];
  82151. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  82152. }
  82153. // Updating submeshes
  82154. this.releaseSubMeshes();
  82155. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  82156. var previousOne = previousSubmeshes[submeshIndex];
  82157. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  82158. }
  82159. this.synchronizeInstances();
  82160. return this;
  82161. };
  82162. /**
  82163. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  82164. * In other words, more vertices, no more indices and a single bigger VBO.
  82165. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  82166. * @returns current mesh
  82167. */
  82168. Mesh.prototype.convertToUnIndexedMesh = function () {
  82169. var kinds = this.getVerticesDataKinds();
  82170. var vbs = {};
  82171. var data = {};
  82172. var newdata = {};
  82173. var kindIndex;
  82174. var kind;
  82175. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  82176. kind = kinds[kindIndex];
  82177. var vertexBuffer = this.getVertexBuffer(kind);
  82178. vbs[kind] = vertexBuffer;
  82179. data[kind] = vbs[kind].getData();
  82180. newdata[kind] = [];
  82181. }
  82182. // Save previous submeshes
  82183. var previousSubmeshes = this.subMeshes.slice(0);
  82184. var indices = this.getIndices();
  82185. var totalIndices = this.getTotalIndices();
  82186. // Generating unique vertices per face
  82187. var index;
  82188. for (index = 0; index < totalIndices; index++) {
  82189. var vertexIndex = indices[index];
  82190. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  82191. kind = kinds[kindIndex];
  82192. var stride = vbs[kind].getStrideSize();
  82193. for (var offset = 0; offset < stride; offset++) {
  82194. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  82195. }
  82196. }
  82197. }
  82198. // Updating indices
  82199. for (index = 0; index < totalIndices; index += 3) {
  82200. indices[index] = index;
  82201. indices[index + 1] = index + 1;
  82202. indices[index + 2] = index + 2;
  82203. }
  82204. this.setIndices(indices);
  82205. // Updating vertex buffers
  82206. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  82207. kind = kinds[kindIndex];
  82208. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  82209. }
  82210. // Updating submeshes
  82211. this.releaseSubMeshes();
  82212. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  82213. var previousOne = previousSubmeshes[submeshIndex];
  82214. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  82215. }
  82216. this._unIndexed = true;
  82217. this.synchronizeInstances();
  82218. return this;
  82219. };
  82220. /**
  82221. * Inverses facet orientations.
  82222. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  82223. * @param flipNormals will also inverts the normals
  82224. * @returns current mesh
  82225. */
  82226. Mesh.prototype.flipFaces = function (flipNormals) {
  82227. if (flipNormals === void 0) { flipNormals = false; }
  82228. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  82229. var i;
  82230. if (flipNormals && this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) && vertex_data.normals) {
  82231. for (i = 0; i < vertex_data.normals.length; i++) {
  82232. vertex_data.normals[i] *= -1;
  82233. }
  82234. }
  82235. if (vertex_data.indices) {
  82236. var temp;
  82237. for (i = 0; i < vertex_data.indices.length; i += 3) {
  82238. // reassign indices
  82239. temp = vertex_data.indices[i + 1];
  82240. vertex_data.indices[i + 1] = vertex_data.indices[i + 2];
  82241. vertex_data.indices[i + 2] = temp;
  82242. }
  82243. }
  82244. vertex_data.applyToMesh(this);
  82245. return this;
  82246. };
  82247. /**
  82248. * Creates a new InstancedMesh object from the mesh model.
  82249. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  82250. * @param name defines the name of the new instance
  82251. * @returns a new InstancedMesh
  82252. */
  82253. Mesh.prototype.createInstance = function (name) {
  82254. return Mesh._instancedMeshFactory(name, this);
  82255. };
  82256. /**
  82257. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  82258. * After this call, all the mesh instances have the same submeshes than the current mesh.
  82259. * @returns the current mesh
  82260. */
  82261. Mesh.prototype.synchronizeInstances = function () {
  82262. for (var instanceIndex = 0; instanceIndex < this.instances.length; instanceIndex++) {
  82263. var instance = this.instances[instanceIndex];
  82264. instance._syncSubMeshes();
  82265. }
  82266. return this;
  82267. };
  82268. /**
  82269. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  82270. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  82271. * This should be used together with the simplification to avoid disappearing triangles.
  82272. * @param successCallback an optional success callback to be called after the optimization finished.
  82273. * @returns the current mesh
  82274. */
  82275. Mesh.prototype.optimizeIndices = function (successCallback) {
  82276. var _this = this;
  82277. var indices = this.getIndices();
  82278. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  82279. if (!positions || !indices) {
  82280. return this;
  82281. }
  82282. var vectorPositions = new Array();
  82283. for (var pos = 0; pos < positions.length; pos = pos + 3) {
  82284. vectorPositions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, pos));
  82285. }
  82286. var dupes = new Array();
  82287. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["AsyncLoop"].SyncAsyncForLoop(vectorPositions.length, 40, function (iteration) {
  82288. var realPos = vectorPositions.length - 1 - iteration;
  82289. var testedPosition = vectorPositions[realPos];
  82290. for (var j = 0; j < realPos; ++j) {
  82291. var againstPosition = vectorPositions[j];
  82292. if (testedPosition.equals(againstPosition)) {
  82293. dupes[realPos] = j;
  82294. break;
  82295. }
  82296. }
  82297. }, function () {
  82298. for (var i = 0; i < indices.length; ++i) {
  82299. indices[i] = dupes[indices[i]] || indices[i];
  82300. }
  82301. //indices are now reordered
  82302. var originalSubMeshes = _this.subMeshes.slice(0);
  82303. _this.setIndices(indices);
  82304. _this.subMeshes = originalSubMeshes;
  82305. if (successCallback) {
  82306. successCallback(_this);
  82307. }
  82308. });
  82309. return this;
  82310. };
  82311. /**
  82312. * Serialize current mesh
  82313. * @param serializationObject defines the object which will receive the serialization data
  82314. */
  82315. Mesh.prototype.serialize = function (serializationObject) {
  82316. serializationObject.name = this.name;
  82317. serializationObject.id = this.id;
  82318. serializationObject.type = this.getClassName();
  82319. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(this)) {
  82320. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(this);
  82321. }
  82322. serializationObject.position = this.position.asArray();
  82323. if (this.rotationQuaternion) {
  82324. serializationObject.rotationQuaternion = this.rotationQuaternion.asArray();
  82325. }
  82326. else if (this.rotation) {
  82327. serializationObject.rotation = this.rotation.asArray();
  82328. }
  82329. serializationObject.scaling = this.scaling.asArray();
  82330. if (this._postMultiplyPivotMatrix) {
  82331. serializationObject.pivotMatrix = this.getPivotMatrix().asArray();
  82332. }
  82333. else {
  82334. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  82335. }
  82336. serializationObject.isEnabled = this.isEnabled(false);
  82337. serializationObject.isVisible = this.isVisible;
  82338. serializationObject.infiniteDistance = this.infiniteDistance;
  82339. serializationObject.pickable = this.isPickable;
  82340. serializationObject.receiveShadows = this.receiveShadows;
  82341. serializationObject.billboardMode = this.billboardMode;
  82342. serializationObject.visibility = this.visibility;
  82343. serializationObject.checkCollisions = this.checkCollisions;
  82344. serializationObject.isBlocker = this.isBlocker;
  82345. // Parent
  82346. if (this.parent) {
  82347. serializationObject.parentId = this.parent.id;
  82348. }
  82349. // Geometry
  82350. serializationObject.isUnIndexed = this.isUnIndexed;
  82351. var geometry = this._geometry;
  82352. if (geometry) {
  82353. var geometryId = geometry.id;
  82354. serializationObject.geometryId = geometryId;
  82355. // SubMeshes
  82356. serializationObject.subMeshes = [];
  82357. for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
  82358. var subMesh = this.subMeshes[subIndex];
  82359. serializationObject.subMeshes.push({
  82360. materialIndex: subMesh.materialIndex,
  82361. verticesStart: subMesh.verticesStart,
  82362. verticesCount: subMesh.verticesCount,
  82363. indexStart: subMesh.indexStart,
  82364. indexCount: subMesh.indexCount
  82365. });
  82366. }
  82367. }
  82368. // Material
  82369. if (this.material) {
  82370. serializationObject.materialId = this.material.id;
  82371. }
  82372. else {
  82373. this.material = null;
  82374. }
  82375. // Morph targets
  82376. if (this.morphTargetManager) {
  82377. serializationObject.morphTargetManagerId = this.morphTargetManager.uniqueId;
  82378. }
  82379. // Skeleton
  82380. if (this.skeleton) {
  82381. serializationObject.skeletonId = this.skeleton.id;
  82382. }
  82383. // Physics
  82384. //TODO implement correct serialization for physics impostors.
  82385. var impostor = this.getPhysicsImpostor();
  82386. if (impostor) {
  82387. serializationObject.physicsMass = impostor.getParam("mass");
  82388. serializationObject.physicsFriction = impostor.getParam("friction");
  82389. serializationObject.physicsRestitution = impostor.getParam("mass");
  82390. serializationObject.physicsImpostor = impostor.type;
  82391. }
  82392. // Metadata
  82393. if (this.metadata) {
  82394. serializationObject.metadata = this.metadata;
  82395. }
  82396. // Instances
  82397. serializationObject.instances = [];
  82398. for (var index = 0; index < this.instances.length; index++) {
  82399. var instance = this.instances[index];
  82400. if (instance.doNotSerialize) {
  82401. continue;
  82402. }
  82403. var serializationInstance = {
  82404. name: instance.name,
  82405. id: instance.id,
  82406. position: instance.position.asArray(),
  82407. scaling: instance.scaling.asArray()
  82408. };
  82409. if (instance.parent) {
  82410. serializationInstance.parentId = instance.parent.id;
  82411. }
  82412. if (instance.rotationQuaternion) {
  82413. serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
  82414. }
  82415. else if (instance.rotation) {
  82416. serializationInstance.rotation = instance.rotation.asArray();
  82417. }
  82418. serializationObject.instances.push(serializationInstance);
  82419. // Animations
  82420. _Misc_decorators__WEBPACK_IMPORTED_MODULE_18__["SerializationHelper"].AppendSerializedAnimations(instance, serializationInstance);
  82421. serializationInstance.ranges = instance.serializeAnimationRanges();
  82422. }
  82423. //
  82424. // Animations
  82425. _Misc_decorators__WEBPACK_IMPORTED_MODULE_18__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  82426. serializationObject.ranges = this.serializeAnimationRanges();
  82427. // Layer mask
  82428. serializationObject.layerMask = this.layerMask;
  82429. // Alpha
  82430. serializationObject.alphaIndex = this.alphaIndex;
  82431. serializationObject.hasVertexAlpha = this.hasVertexAlpha;
  82432. // Overlay
  82433. serializationObject.overlayAlpha = this.overlayAlpha;
  82434. serializationObject.overlayColor = this.overlayColor.asArray();
  82435. serializationObject.renderOverlay = this.renderOverlay;
  82436. // Fog
  82437. serializationObject.applyFog = this.applyFog;
  82438. // Action Manager
  82439. if (this.actionManager) {
  82440. serializationObject.actions = this.actionManager.serialize(this.name);
  82441. }
  82442. };
  82443. /** @hidden */
  82444. Mesh.prototype._syncGeometryWithMorphTargetManager = function () {
  82445. if (!this.geometry) {
  82446. return;
  82447. }
  82448. this._markSubMeshesAsAttributesDirty();
  82449. var morphTargetManager = this._morphTargetManager;
  82450. if (morphTargetManager && morphTargetManager.vertexCount) {
  82451. if (morphTargetManager.vertexCount !== this.getTotalVertices()) {
  82452. _Misc_logger__WEBPACK_IMPORTED_MODULE_19__["Logger"].Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count.");
  82453. this.morphTargetManager = null;
  82454. return;
  82455. }
  82456. for (var index = 0; index < morphTargetManager.numInfluencers; index++) {
  82457. var morphTarget = morphTargetManager.getActiveTarget(index);
  82458. var positions = morphTarget.getPositions();
  82459. if (!positions) {
  82460. _Misc_logger__WEBPACK_IMPORTED_MODULE_19__["Logger"].Error("Invalid morph target. Target must have positions.");
  82461. return;
  82462. }
  82463. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index, positions, false, 3);
  82464. var normals = morphTarget.getNormals();
  82465. if (normals) {
  82466. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index, normals, false, 3);
  82467. }
  82468. var tangents = morphTarget.getTangents();
  82469. if (tangents) {
  82470. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index, tangents, false, 3);
  82471. }
  82472. }
  82473. }
  82474. else {
  82475. var index = 0;
  82476. // Positions
  82477. while (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index)) {
  82478. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index);
  82479. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index)) {
  82480. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index);
  82481. }
  82482. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index)) {
  82483. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index);
  82484. }
  82485. index++;
  82486. }
  82487. }
  82488. };
  82489. /**
  82490. * Returns a new Mesh object parsed from the source provided.
  82491. * @param parsedMesh is the source
  82492. * @param scene defines the hosting scene
  82493. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  82494. * @returns a new Mesh
  82495. */
  82496. Mesh.Parse = function (parsedMesh, scene, rootUrl) {
  82497. var mesh;
  82498. if (parsedMesh.type && parsedMesh.type === "GroundMesh") {
  82499. mesh = Mesh._GroundMeshParser(parsedMesh, scene);
  82500. }
  82501. else {
  82502. mesh = new Mesh(parsedMesh.name, scene);
  82503. }
  82504. mesh.id = parsedMesh.id;
  82505. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  82506. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(mesh, parsedMesh.tags);
  82507. }
  82508. mesh.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.position);
  82509. if (parsedMesh.metadata !== undefined) {
  82510. mesh.metadata = parsedMesh.metadata;
  82511. }
  82512. if (parsedMesh.rotationQuaternion) {
  82513. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedMesh.rotationQuaternion);
  82514. }
  82515. else if (parsedMesh.rotation) {
  82516. mesh.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.rotation);
  82517. }
  82518. mesh.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.scaling);
  82519. if (parsedMesh.localMatrix) {
  82520. mesh.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.localMatrix));
  82521. }
  82522. else if (parsedMesh.pivotMatrix) {
  82523. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.pivotMatrix));
  82524. }
  82525. mesh.setEnabled(parsedMesh.isEnabled);
  82526. mesh.isVisible = parsedMesh.isVisible;
  82527. mesh.infiniteDistance = parsedMesh.infiniteDistance;
  82528. mesh.showBoundingBox = parsedMesh.showBoundingBox;
  82529. mesh.showSubMeshesBoundingBox = parsedMesh.showSubMeshesBoundingBox;
  82530. if (parsedMesh.applyFog !== undefined) {
  82531. mesh.applyFog = parsedMesh.applyFog;
  82532. }
  82533. if (parsedMesh.pickable !== undefined) {
  82534. mesh.isPickable = parsedMesh.pickable;
  82535. }
  82536. if (parsedMesh.alphaIndex !== undefined) {
  82537. mesh.alphaIndex = parsedMesh.alphaIndex;
  82538. }
  82539. mesh.receiveShadows = parsedMesh.receiveShadows;
  82540. mesh.billboardMode = parsedMesh.billboardMode;
  82541. if (parsedMesh.visibility !== undefined) {
  82542. mesh.visibility = parsedMesh.visibility;
  82543. }
  82544. mesh.checkCollisions = parsedMesh.checkCollisions;
  82545. if (parsedMesh.isBlocker !== undefined) {
  82546. mesh.isBlocker = parsedMesh.isBlocker;
  82547. }
  82548. mesh._shouldGenerateFlatShading = parsedMesh.useFlatShading;
  82549. // freezeWorldMatrix
  82550. if (parsedMesh.freezeWorldMatrix) {
  82551. mesh._waitingFreezeWorldMatrix = parsedMesh.freezeWorldMatrix;
  82552. }
  82553. // Parent
  82554. if (parsedMesh.parentId) {
  82555. mesh._waitingParentId = parsedMesh.parentId;
  82556. }
  82557. // Actions
  82558. if (parsedMesh.actions !== undefined) {
  82559. mesh._waitingActions = parsedMesh.actions;
  82560. }
  82561. // Overlay
  82562. if (parsedMesh.overlayAlpha !== undefined) {
  82563. mesh.overlayAlpha = parsedMesh.overlayAlpha;
  82564. }
  82565. if (parsedMesh.overlayColor !== undefined) {
  82566. mesh.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].FromArray(parsedMesh.overlayColor);
  82567. }
  82568. if (parsedMesh.renderOverlay !== undefined) {
  82569. mesh.renderOverlay = parsedMesh.renderOverlay;
  82570. }
  82571. // Geometry
  82572. mesh.isUnIndexed = !!parsedMesh.isUnIndexed;
  82573. mesh.hasVertexAlpha = parsedMesh.hasVertexAlpha;
  82574. if (parsedMesh.delayLoadingFile) {
  82575. mesh.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].DELAYLOADSTATE_NOTLOADED;
  82576. mesh.delayLoadingFile = rootUrl + parsedMesh.delayLoadingFile;
  82577. 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));
  82578. if (parsedMesh._binaryInfo) {
  82579. mesh._binaryInfo = parsedMesh._binaryInfo;
  82580. }
  82581. mesh._delayInfo = [];
  82582. if (parsedMesh.hasUVs) {
  82583. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  82584. }
  82585. if (parsedMesh.hasUVs2) {
  82586. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  82587. }
  82588. if (parsedMesh.hasUVs3) {
  82589. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV3Kind);
  82590. }
  82591. if (parsedMesh.hasUVs4) {
  82592. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV4Kind);
  82593. }
  82594. if (parsedMesh.hasUVs5) {
  82595. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV5Kind);
  82596. }
  82597. if (parsedMesh.hasUVs6) {
  82598. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV6Kind);
  82599. }
  82600. if (parsedMesh.hasColors) {
  82601. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  82602. }
  82603. if (parsedMesh.hasMatricesIndices) {
  82604. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  82605. }
  82606. if (parsedMesh.hasMatricesWeights) {
  82607. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  82608. }
  82609. mesh._delayLoadingFunction = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry;
  82610. if (_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental) {
  82611. mesh._checkDelayState();
  82612. }
  82613. }
  82614. else {
  82615. _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry(parsedMesh, mesh);
  82616. }
  82617. // Material
  82618. if (parsedMesh.materialId) {
  82619. mesh.setMaterialByID(parsedMesh.materialId);
  82620. }
  82621. else {
  82622. mesh.material = null;
  82623. }
  82624. // Morph targets
  82625. if (parsedMesh.morphTargetManagerId > -1) {
  82626. mesh.morphTargetManager = scene.getMorphTargetManagerById(parsedMesh.morphTargetManagerId);
  82627. }
  82628. // Skeleton
  82629. if (parsedMesh.skeletonId > -1) {
  82630. mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
  82631. if (parsedMesh.numBoneInfluencers) {
  82632. mesh.numBoneInfluencers = parsedMesh.numBoneInfluencers;
  82633. }
  82634. }
  82635. // Animations
  82636. if (parsedMesh.animations) {
  82637. for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
  82638. var parsedAnimation = parsedMesh.animations[animationIndex];
  82639. mesh.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_14__["Animation"].Parse(parsedAnimation));
  82640. }
  82641. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(mesh, parsedMesh, scene);
  82642. }
  82643. if (parsedMesh.autoAnimate) {
  82644. scene.beginAnimation(mesh, parsedMesh.autoAnimateFrom, parsedMesh.autoAnimateTo, parsedMesh.autoAnimateLoop, parsedMesh.autoAnimateSpeed || 1.0);
  82645. }
  82646. // Layer Mask
  82647. if (parsedMesh.layerMask && (!isNaN(parsedMesh.layerMask))) {
  82648. mesh.layerMask = Math.abs(parseInt(parsedMesh.layerMask));
  82649. }
  82650. else {
  82651. mesh.layerMask = 0x0FFFFFFF;
  82652. }
  82653. // Physics
  82654. if (parsedMesh.physicsImpostor) {
  82655. mesh.physicsImpostor = new _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_16__["PhysicsImpostor"](mesh, parsedMesh.physicsImpostor, {
  82656. mass: parsedMesh.physicsMass,
  82657. friction: parsedMesh.physicsFriction,
  82658. restitution: parsedMesh.physicsRestitution
  82659. }, scene);
  82660. }
  82661. // Instances
  82662. if (parsedMesh.instances) {
  82663. for (var index = 0; index < parsedMesh.instances.length; index++) {
  82664. var parsedInstance = parsedMesh.instances[index];
  82665. var instance = mesh.createInstance(parsedInstance.name);
  82666. if (parsedInstance.id) {
  82667. instance.id = parsedInstance.id;
  82668. }
  82669. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  82670. if (parsedInstance.tags) {
  82671. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedInstance.tags);
  82672. }
  82673. else {
  82674. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedMesh.tags);
  82675. }
  82676. }
  82677. instance.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.position);
  82678. if (parsedInstance.parentId) {
  82679. instance._waitingParentId = parsedInstance.parentId;
  82680. }
  82681. if (parsedInstance.rotationQuaternion) {
  82682. instance.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedInstance.rotationQuaternion);
  82683. }
  82684. else if (parsedInstance.rotation) {
  82685. instance.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.rotation);
  82686. }
  82687. instance.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.scaling);
  82688. if (parsedInstance.checkCollisions != undefined && parsedInstance.checkCollisions != null) {
  82689. instance.checkCollisions = parsedInstance.checkCollisions;
  82690. }
  82691. if (parsedInstance.pickable != undefined && parsedInstance.pickable != null) {
  82692. instance.isPickable = parsedInstance.pickable;
  82693. }
  82694. if (parsedInstance.showBoundingBox != undefined && parsedInstance.showBoundingBox != null) {
  82695. instance.showBoundingBox = parsedInstance.showBoundingBox;
  82696. }
  82697. if (parsedInstance.showSubMeshesBoundingBox != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  82698. instance.showSubMeshesBoundingBox = parsedInstance.showSubMeshesBoundingBox;
  82699. }
  82700. if (parsedInstance.alphaIndex != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  82701. instance.alphaIndex = parsedInstance.alphaIndex;
  82702. }
  82703. // Physics
  82704. if (parsedInstance.physicsImpostor) {
  82705. instance.physicsImpostor = new _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_16__["PhysicsImpostor"](instance, parsedInstance.physicsImpostor, {
  82706. mass: parsedInstance.physicsMass,
  82707. friction: parsedInstance.physicsFriction,
  82708. restitution: parsedInstance.physicsRestitution
  82709. }, scene);
  82710. }
  82711. // Animation
  82712. if (parsedInstance.animations) {
  82713. for (animationIndex = 0; animationIndex < parsedInstance.animations.length; animationIndex++) {
  82714. parsedAnimation = parsedInstance.animations[animationIndex];
  82715. instance.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_14__["Animation"].Parse(parsedAnimation));
  82716. }
  82717. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(instance, parsedInstance, scene);
  82718. if (parsedInstance.autoAnimate) {
  82719. scene.beginAnimation(instance, parsedInstance.autoAnimateFrom, parsedInstance.autoAnimateTo, parsedInstance.autoAnimateLoop, parsedInstance.autoAnimateSpeed || 1.0);
  82720. }
  82721. }
  82722. }
  82723. }
  82724. return mesh;
  82725. };
  82726. /**
  82727. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  82728. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  82729. * @param name defines the name of the mesh to create
  82730. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  82731. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  82732. * @param closePath creates a seam between the first and the last points of each path of the path array
  82733. * @param offset is taken in account only if the `pathArray` is containing a single path
  82734. * @param scene defines the hosting scene
  82735. * @param updatable defines if the mesh must be flagged as updatable
  82736. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82737. * @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)
  82738. * @returns a new Mesh
  82739. */
  82740. Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  82741. throw "Import MeshBuilder before creating meshes.";
  82742. };
  82743. /**
  82744. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  82745. * @param name defines the name of the mesh to create
  82746. * @param radius sets the radius size (float) of the polygon (default 0.5)
  82747. * @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
  82748. * @param scene defines the hosting scene
  82749. * @param updatable defines if the mesh must be flagged as updatable
  82750. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82751. * @returns a new Mesh
  82752. */
  82753. Mesh.CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  82754. if (scene === void 0) { scene = null; }
  82755. throw "Import MeshBuilder before creating meshes.";
  82756. };
  82757. /**
  82758. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  82759. * @param name defines the name of the mesh to create
  82760. * @param size sets the size (float) of each box side (default 1)
  82761. * @param scene defines the hosting scene
  82762. * @param updatable defines if the mesh must be flagged as updatable
  82763. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82764. * @returns a new Mesh
  82765. */
  82766. Mesh.CreateBox = function (name, size, scene, updatable, sideOrientation) {
  82767. if (scene === void 0) { scene = null; }
  82768. throw "Import MeshBuilder before creating meshes.";
  82769. };
  82770. /**
  82771. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  82772. * @param name defines the name of the mesh to create
  82773. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  82774. * @param diameter sets the diameter size (float) of the sphere (default 1)
  82775. * @param scene defines the hosting scene
  82776. * @param updatable defines if the mesh must be flagged as updatable
  82777. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82778. * @returns a new Mesh
  82779. */
  82780. Mesh.CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  82781. throw "Import MeshBuilder before creating meshes.";
  82782. };
  82783. /**
  82784. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  82785. * @param name defines the name of the mesh to create
  82786. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  82787. * @param diameterTop set the top cap diameter (floats, default 1)
  82788. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  82789. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  82790. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  82791. * @param scene defines the hosting scene
  82792. * @param updatable defines if the mesh must be flagged as updatable
  82793. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82794. * @returns a new Mesh
  82795. */
  82796. Mesh.CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  82797. throw "Import MeshBuilder before creating meshes.";
  82798. };
  82799. // Torus (Code from SharpDX.org)
  82800. /**
  82801. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  82802. * @param name defines the name of the mesh to create
  82803. * @param diameter sets the diameter size (float) of the torus (default 1)
  82804. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  82805. * @param tessellation sets the number of torus sides (postive integer, default 16)
  82806. * @param scene defines the hosting scene
  82807. * @param updatable defines if the mesh must be flagged as updatable
  82808. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82809. * @returns a new Mesh
  82810. */
  82811. Mesh.CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  82812. throw "Import MeshBuilder before creating meshes.";
  82813. };
  82814. /**
  82815. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  82816. * @param name defines the name of the mesh to create
  82817. * @param radius sets the global radius size (float) of the torus knot (default 2)
  82818. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  82819. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  82820. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  82821. * @param p the number of windings on X axis (positive integers, default 2)
  82822. * @param q the number of windings on Y axis (positive integers, default 3)
  82823. * @param scene defines the hosting scene
  82824. * @param updatable defines if the mesh must be flagged as updatable
  82825. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82826. * @returns a new Mesh
  82827. */
  82828. Mesh.CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  82829. throw "Import MeshBuilder before creating meshes.";
  82830. };
  82831. /**
  82832. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  82833. * @param name defines the name of the mesh to create
  82834. * @param points is an array successive Vector3
  82835. * @param scene defines the hosting scene
  82836. * @param updatable defines if the mesh must be flagged as updatable
  82837. * @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).
  82838. * @returns a new Mesh
  82839. */
  82840. Mesh.CreateLines = function (name, points, scene, updatable, instance) {
  82841. if (scene === void 0) { scene = null; }
  82842. if (updatable === void 0) { updatable = false; }
  82843. if (instance === void 0) { instance = null; }
  82844. throw "Import MeshBuilder before creating meshes.";
  82845. };
  82846. /**
  82847. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  82848. * @param name defines the name of the mesh to create
  82849. * @param points is an array successive Vector3
  82850. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  82851. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  82852. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  82853. * @param scene defines the hosting scene
  82854. * @param updatable defines if the mesh must be flagged as updatable
  82855. * @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)
  82856. * @returns a new Mesh
  82857. */
  82858. Mesh.CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  82859. if (scene === void 0) { scene = null; }
  82860. throw "Import MeshBuilder before creating meshes.";
  82861. };
  82862. /**
  82863. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  82864. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  82865. * 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.
  82866. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82867. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  82868. * Remember you can only change the shape positions, not their number when updating a polygon.
  82869. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  82870. * @param name defines the name of the mesh to create
  82871. * @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
  82872. * @param scene defines the hosting scene
  82873. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  82874. * @param updatable defines if the mesh must be flagged as updatable
  82875. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82876. * @returns a new Mesh
  82877. */
  82878. Mesh.CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation) {
  82879. throw "Import MeshBuilder before creating meshes.";
  82880. };
  82881. /**
  82882. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  82883. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  82884. * @param name defines the name of the mesh to create
  82885. * @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
  82886. * @param depth defines the height of extrusion
  82887. * @param scene defines the hosting scene
  82888. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  82889. * @param updatable defines if the mesh must be flagged as updatable
  82890. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82891. * @returns a new Mesh
  82892. */
  82893. Mesh.ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation) {
  82894. throw "Import MeshBuilder before creating meshes.";
  82895. };
  82896. /**
  82897. * Creates an extruded shape mesh.
  82898. * 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
  82899. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  82900. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  82901. * @param name defines the name of the mesh to create
  82902. * @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
  82903. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  82904. * @param scale is the value to scale the shape
  82905. * @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
  82906. * @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
  82907. * @param scene defines the hosting scene
  82908. * @param updatable defines if the mesh must be flagged as updatable
  82909. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82910. * @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)
  82911. * @returns a new Mesh
  82912. */
  82913. Mesh.ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  82914. if (scene === void 0) { scene = null; }
  82915. throw "Import MeshBuilder before creating meshes.";
  82916. };
  82917. /**
  82918. * Creates an custom extruded shape mesh.
  82919. * The custom extrusion is a parametric shape.
  82920. * It has no predefined shape. Its final shape will depend on the input parameters.
  82921. * Please consider using the same method from the MeshBuilder class instead
  82922. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  82923. * @param name defines the name of the mesh to create
  82924. * @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
  82925. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  82926. * @param scaleFunction is a custom Javascript function called on each path point
  82927. * @param rotationFunction is a custom Javascript function called on each path point
  82928. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  82929. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  82930. * @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
  82931. * @param scene defines the hosting scene
  82932. * @param updatable defines if the mesh must be flagged as updatable
  82933. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82934. * @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)
  82935. * @returns a new Mesh
  82936. */
  82937. Mesh.ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  82938. throw "Import MeshBuilder before creating meshes.";
  82939. };
  82940. /**
  82941. * Creates lathe mesh.
  82942. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  82943. * Please consider using the same method from the MeshBuilder class instead
  82944. * @param name defines the name of the mesh to create
  82945. * @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
  82946. * @param radius is the radius value of the lathe
  82947. * @param tessellation is the side number of the lathe.
  82948. * @param scene defines the hosting scene
  82949. * @param updatable defines if the mesh must be flagged as updatable
  82950. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82951. * @returns a new Mesh
  82952. */
  82953. Mesh.CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  82954. throw "Import MeshBuilder before creating meshes.";
  82955. };
  82956. /**
  82957. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  82958. * @param name defines the name of the mesh to create
  82959. * @param size sets the size (float) of both sides of the plane at once (default 1)
  82960. * @param scene defines the hosting scene
  82961. * @param updatable defines if the mesh must be flagged as updatable
  82962. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  82963. * @returns a new Mesh
  82964. */
  82965. Mesh.CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  82966. throw "Import MeshBuilder before creating meshes.";
  82967. };
  82968. /**
  82969. * Creates a ground mesh.
  82970. * Please consider using the same method from the MeshBuilder class instead
  82971. * @param name defines the name of the mesh to create
  82972. * @param width set the width of the ground
  82973. * @param height set the height of the ground
  82974. * @param subdivisions sets the number of subdivisions per side
  82975. * @param scene defines the hosting scene
  82976. * @param updatable defines if the mesh must be flagged as updatable
  82977. * @returns a new Mesh
  82978. */
  82979. Mesh.CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  82980. throw "Import MeshBuilder before creating meshes.";
  82981. };
  82982. /**
  82983. * Creates a tiled ground mesh.
  82984. * Please consider using the same method from the MeshBuilder class instead
  82985. * @param name defines the name of the mesh to create
  82986. * @param xmin set the ground minimum X coordinate
  82987. * @param zmin set the ground minimum Y coordinate
  82988. * @param xmax set the ground maximum X coordinate
  82989. * @param zmax set the ground maximum Z coordinate
  82990. * @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
  82991. * @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
  82992. * @param scene defines the hosting scene
  82993. * @param updatable defines if the mesh must be flagged as updatable
  82994. * @returns a new Mesh
  82995. */
  82996. Mesh.CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  82997. throw "Import MeshBuilder before creating meshes.";
  82998. };
  82999. /**
  83000. * Creates a ground mesh from a height map.
  83001. * Please consider using the same method from the MeshBuilder class instead
  83002. * @see http://doc.babylonjs.com/babylon101/height_map
  83003. * @param name defines the name of the mesh to create
  83004. * @param url sets the URL of the height map image resource
  83005. * @param width set the ground width size
  83006. * @param height set the ground height size
  83007. * @param subdivisions sets the number of subdivision per side
  83008. * @param minHeight is the minimum altitude on the ground
  83009. * @param maxHeight is the maximum altitude on the ground
  83010. * @param scene defines the hosting scene
  83011. * @param updatable defines if the mesh must be flagged as updatable
  83012. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  83013. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  83014. * @returns a new Mesh
  83015. */
  83016. Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  83017. throw "Import MeshBuilder before creating meshes.";
  83018. };
  83019. /**
  83020. * Creates a tube mesh.
  83021. * The tube is a parametric shape.
  83022. * It has no predefined shape. Its final shape will depend on the input parameters.
  83023. * Please consider using the same method from the MeshBuilder class instead
  83024. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  83025. * @param name defines the name of the mesh to create
  83026. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  83027. * @param radius sets the tube radius size
  83028. * @param tessellation is the number of sides on the tubular surface
  83029. * @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
  83030. * @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
  83031. * @param scene defines the hosting scene
  83032. * @param updatable defines if the mesh must be flagged as updatable
  83033. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83034. * @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)
  83035. * @returns a new Mesh
  83036. */
  83037. Mesh.CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  83038. throw "Import MeshBuilder before creating meshes.";
  83039. };
  83040. /**
  83041. * Creates a polyhedron mesh.
  83042. * Please consider using the same method from the MeshBuilder class instead.
  83043. * * 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
  83044. * * The parameter `size` (positive float, default 1) sets the polygon size
  83045. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  83046. * * 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`
  83047. * * 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
  83048. * * 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)`)
  83049. * * 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
  83050. * * 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
  83051. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83052. * * 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
  83053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83054. * @param name defines the name of the mesh to create
  83055. * @param options defines the options used to create the mesh
  83056. * @param scene defines the hosting scene
  83057. * @returns a new Mesh
  83058. */
  83059. Mesh.CreatePolyhedron = function (name, options, scene) {
  83060. throw "Import MeshBuilder before creating meshes.";
  83061. };
  83062. /**
  83063. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  83064. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  83065. * * 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`)
  83066. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  83067. * * 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
  83068. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83069. * * 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
  83070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83071. * @param name defines the name of the mesh
  83072. * @param options defines the options used to create the mesh
  83073. * @param scene defines the hosting scene
  83074. * @returns a new Mesh
  83075. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  83076. */
  83077. Mesh.CreateIcoSphere = function (name, options, scene) {
  83078. throw "Import MeshBuilder before creating meshes.";
  83079. };
  83080. /**
  83081. * Creates a decal mesh.
  83082. * Please consider using the same method from the MeshBuilder class instead.
  83083. * A decal is a mesh usually applied as a model onto the surface of another mesh
  83084. * @param name defines the name of the mesh
  83085. * @param sourceMesh defines the mesh receiving the decal
  83086. * @param position sets the position of the decal in world coordinates
  83087. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  83088. * @param size sets the decal scaling
  83089. * @param angle sets the angle to rotate the decal
  83090. * @returns a new Mesh
  83091. */
  83092. Mesh.CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  83093. throw "Import MeshBuilder before creating meshes.";
  83094. };
  83095. // Skeletons
  83096. /**
  83097. * Prepare internal position array for software CPU skinning
  83098. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  83099. */
  83100. Mesh.prototype.setPositionsForCPUSkinning = function () {
  83101. if (!this._sourcePositions) {
  83102. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  83103. if (!source) {
  83104. return this._sourcePositions;
  83105. }
  83106. this._sourcePositions = new Float32Array(source);
  83107. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  83108. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, source, true);
  83109. }
  83110. }
  83111. return this._sourcePositions;
  83112. };
  83113. /**
  83114. * Prepare internal normal array for software CPU skinning
  83115. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  83116. */
  83117. Mesh.prototype.setNormalsForCPUSkinning = function () {
  83118. if (!this._sourceNormals) {
  83119. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  83120. if (!source) {
  83121. return this._sourceNormals;
  83122. }
  83123. this._sourceNormals = new Float32Array(source);
  83124. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  83125. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, source, true);
  83126. }
  83127. }
  83128. return this._sourceNormals;
  83129. };
  83130. /**
  83131. * Updates the vertex buffer by applying transformation from the bones
  83132. * @param skeleton defines the skeleton to apply to current mesh
  83133. * @returns the current mesh
  83134. */
  83135. Mesh.prototype.applySkeleton = function (skeleton) {
  83136. if (!this.geometry) {
  83137. return this;
  83138. }
  83139. if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId()) {
  83140. return this;
  83141. }
  83142. this.geometry._softwareSkinningFrameId = this.getScene().getFrameId();
  83143. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  83144. return this;
  83145. }
  83146. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  83147. return this;
  83148. }
  83149. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind)) {
  83150. return this;
  83151. }
  83152. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  83153. return this;
  83154. }
  83155. if (!this._sourcePositions) {
  83156. var submeshes = this.subMeshes.slice();
  83157. this.setPositionsForCPUSkinning();
  83158. this.subMeshes = submeshes;
  83159. }
  83160. if (!this._sourceNormals) {
  83161. this.setNormalsForCPUSkinning();
  83162. }
  83163. // positionsData checks for not being Float32Array will only pass at most once
  83164. var positionsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  83165. if (!positionsData) {
  83166. return this;
  83167. }
  83168. if (!(positionsData instanceof Float32Array)) {
  83169. positionsData = new Float32Array(positionsData);
  83170. }
  83171. // normalsData checks for not being Float32Array will only pass at most once
  83172. var normalsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  83173. if (!normalsData) {
  83174. return this;
  83175. }
  83176. if (!(normalsData instanceof Float32Array)) {
  83177. normalsData = new Float32Array(normalsData);
  83178. }
  83179. var matricesIndicesData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  83180. var matricesWeightsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  83181. if (!matricesWeightsData || !matricesIndicesData) {
  83182. return this;
  83183. }
  83184. var needExtras = this.numBoneInfluencers > 4;
  83185. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  83186. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  83187. var skeletonMatrices = skeleton.getTransformMatrices(this);
  83188. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  83189. var finalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  83190. var tempMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  83191. var matWeightIdx = 0;
  83192. var inf;
  83193. for (var index = 0; index < positionsData.length; index += 3, matWeightIdx += 4) {
  83194. var weight;
  83195. for (inf = 0; inf < 4; inf++) {
  83196. weight = matricesWeightsData[matWeightIdx + inf];
  83197. if (weight > 0) {
  83198. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  83199. finalMatrix.addToSelf(tempMatrix);
  83200. }
  83201. }
  83202. if (needExtras) {
  83203. for (inf = 0; inf < 4; inf++) {
  83204. weight = matricesWeightsExtraData[matWeightIdx + inf];
  83205. if (weight > 0) {
  83206. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  83207. finalMatrix.addToSelf(tempMatrix);
  83208. }
  83209. }
  83210. }
  83211. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinatesFromFloatsToRef(this._sourcePositions[index], this._sourcePositions[index + 1], this._sourcePositions[index + 2], finalMatrix, tempVector3);
  83212. tempVector3.toArray(positionsData, index);
  83213. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalFromFloatsToRef(this._sourceNormals[index], this._sourceNormals[index + 1], this._sourceNormals[index + 2], finalMatrix, tempVector3);
  83214. tempVector3.toArray(normalsData, index);
  83215. finalMatrix.reset();
  83216. }
  83217. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positionsData);
  83218. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normalsData);
  83219. return this;
  83220. };
  83221. // Tools
  83222. /**
  83223. * 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
  83224. * @param meshes defines the list of meshes to scan
  83225. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  83226. */
  83227. Mesh.MinMax = function (meshes) {
  83228. var minVector = null;
  83229. var maxVector = null;
  83230. meshes.forEach(function (mesh) {
  83231. var boundingInfo = mesh.getBoundingInfo();
  83232. var boundingBox = boundingInfo.boundingBox;
  83233. if (!minVector || !maxVector) {
  83234. minVector = boundingBox.minimumWorld;
  83235. maxVector = boundingBox.maximumWorld;
  83236. }
  83237. else {
  83238. minVector.minimizeInPlace(boundingBox.minimumWorld);
  83239. maxVector.maximizeInPlace(boundingBox.maximumWorld);
  83240. }
  83241. });
  83242. if (!minVector || !maxVector) {
  83243. return {
  83244. min: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero(),
  83245. max: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero()
  83246. };
  83247. }
  83248. return {
  83249. min: minVector,
  83250. max: maxVector
  83251. };
  83252. };
  83253. /**
  83254. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  83255. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  83256. * @returns a vector3
  83257. */
  83258. Mesh.Center = function (meshesOrMinMaxVector) {
  83259. var minMaxVector = (meshesOrMinMaxVector instanceof Array) ? Mesh.MinMax(meshesOrMinMaxVector) : meshesOrMinMaxVector;
  83260. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Center(minMaxVector.min, minMaxVector.max);
  83261. };
  83262. /**
  83263. * Merge the array of meshes into a single mesh for performance reasons.
  83264. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  83265. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  83266. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  83267. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  83268. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  83269. * @returns a new mesh
  83270. */
  83271. Mesh.MergeMeshes = function (meshes, disposeSource, allow32BitsIndices, meshSubclass, subdivideWithSubMeshes) {
  83272. if (disposeSource === void 0) { disposeSource = true; }
  83273. var index;
  83274. if (!allow32BitsIndices) {
  83275. var totalVertices = 0;
  83276. // Counting vertices
  83277. for (index = 0; index < meshes.length; index++) {
  83278. if (meshes[index]) {
  83279. totalVertices += meshes[index].getTotalVertices();
  83280. if (totalVertices > 65536) {
  83281. _Misc_logger__WEBPACK_IMPORTED_MODULE_19__["Logger"].Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices");
  83282. return null;
  83283. }
  83284. }
  83285. }
  83286. }
  83287. // Merge
  83288. var vertexData = null;
  83289. var otherVertexData;
  83290. var indiceArray = new Array();
  83291. var source = null;
  83292. for (index = 0; index < meshes.length; index++) {
  83293. if (meshes[index]) {
  83294. var wm = meshes[index].computeWorldMatrix(true);
  83295. otherVertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(meshes[index], true, true);
  83296. otherVertexData.transform(wm);
  83297. if (vertexData) {
  83298. vertexData.merge(otherVertexData, allow32BitsIndices);
  83299. }
  83300. else {
  83301. vertexData = otherVertexData;
  83302. source = meshes[index];
  83303. }
  83304. if (subdivideWithSubMeshes) {
  83305. indiceArray.push(meshes[index].getTotalIndices());
  83306. }
  83307. }
  83308. }
  83309. source = source;
  83310. if (!meshSubclass) {
  83311. meshSubclass = new Mesh(source.name + "_merged", source.getScene());
  83312. }
  83313. vertexData.applyToMesh(meshSubclass);
  83314. // Setting properties
  83315. meshSubclass.material = source.material;
  83316. meshSubclass.checkCollisions = source.checkCollisions;
  83317. // Cleaning
  83318. if (disposeSource) {
  83319. for (index = 0; index < meshes.length; index++) {
  83320. if (meshes[index]) {
  83321. meshes[index].dispose();
  83322. }
  83323. }
  83324. }
  83325. // Subdivide
  83326. if (subdivideWithSubMeshes) {
  83327. //-- removal of global submesh
  83328. meshSubclass.releaseSubMeshes();
  83329. index = 0;
  83330. var offset = 0;
  83331. //-- apply subdivision according to index table
  83332. while (index < indiceArray.length) {
  83333. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, indiceArray[index], meshSubclass);
  83334. offset += indiceArray[index];
  83335. index++;
  83336. }
  83337. }
  83338. return meshSubclass;
  83339. };
  83340. /** @hidden */
  83341. Mesh.prototype.addInstance = function (instance) {
  83342. instance._indexInSourceMeshInstanceArray = this.instances.length;
  83343. this.instances.push(instance);
  83344. };
  83345. /** @hidden */
  83346. Mesh.prototype.removeInstance = function (instance) {
  83347. // Remove from mesh
  83348. var index = instance._indexInSourceMeshInstanceArray;
  83349. if (index != -1) {
  83350. if (index !== this.instances.length - 1) {
  83351. var last = this.instances[this.instances.length - 1];
  83352. this.instances[index] = last;
  83353. last._indexInSourceMeshInstanceArray = index;
  83354. }
  83355. instance._indexInSourceMeshInstanceArray = -1;
  83356. this.instances.pop();
  83357. }
  83358. };
  83359. // Consts
  83360. /**
  83361. * Mesh side orientation : usually the external or front surface
  83362. */
  83363. Mesh.FRONTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].FRONTSIDE;
  83364. /**
  83365. * Mesh side orientation : usually the internal or back surface
  83366. */
  83367. Mesh.BACKSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].BACKSIDE;
  83368. /**
  83369. * Mesh side orientation : both internal and external or front and back surfaces
  83370. */
  83371. Mesh.DOUBLESIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DOUBLESIDE;
  83372. /**
  83373. * Mesh side orientation : by default, `FRONTSIDE`
  83374. */
  83375. Mesh.DEFAULTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DEFAULTSIDE;
  83376. /**
  83377. * Mesh cap setting : no cap
  83378. */
  83379. Mesh.NO_CAP = 0;
  83380. /**
  83381. * Mesh cap setting : one cap at the beginning of the mesh
  83382. */
  83383. Mesh.CAP_START = 1;
  83384. /**
  83385. * Mesh cap setting : one cap at the end of the mesh
  83386. */
  83387. Mesh.CAP_END = 2;
  83388. /**
  83389. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  83390. */
  83391. Mesh.CAP_ALL = 3;
  83392. // Instances
  83393. /** @hidden */
  83394. Mesh._instancedMeshFactory = function (name, mesh) {
  83395. throw "Import InstancedMesh before creating instances.";
  83396. };
  83397. // Statics
  83398. /** @hidden */
  83399. Mesh._GroundMeshParser = function (parsedMesh, scene) {
  83400. throw "Import GroundMesh before trying to parse it.";
  83401. };
  83402. return Mesh;
  83403. }(_abstractMesh__WEBPACK_IMPORTED_MODULE_10__["AbstractMesh"]));
  83404. //import { MeshBuilder } from "./meshBuilder";
  83405. /***/ }),
  83406. /***/ "./Meshes/mesh.vertexData.ts":
  83407. /*!***********************************!*\
  83408. !*** ./Meshes/mesh.vertexData.ts ***!
  83409. \***********************************/
  83410. /*! exports provided: VertexData */
  83411. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83412. "use strict";
  83413. __webpack_require__.r(__webpack_exports__);
  83414. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return VertexData; });
  83415. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  83416. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  83417. /**
  83418. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  83419. */
  83420. var VertexData = /** @class */ (function () {
  83421. function VertexData() {
  83422. }
  83423. /**
  83424. * Uses the passed data array to set the set the values for the specified kind of data
  83425. * @param data a linear array of floating numbers
  83426. * @param kind the type of data that is being set, eg positions, colors etc
  83427. */
  83428. VertexData.prototype.set = function (data, kind) {
  83429. switch (kind) {
  83430. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind:
  83431. this.positions = data;
  83432. break;
  83433. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind:
  83434. this.normals = data;
  83435. break;
  83436. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind:
  83437. this.tangents = data;
  83438. break;
  83439. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind:
  83440. this.uvs = data;
  83441. break;
  83442. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind:
  83443. this.uvs2 = data;
  83444. break;
  83445. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind:
  83446. this.uvs3 = data;
  83447. break;
  83448. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind:
  83449. this.uvs4 = data;
  83450. break;
  83451. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind:
  83452. this.uvs5 = data;
  83453. break;
  83454. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind:
  83455. this.uvs6 = data;
  83456. break;
  83457. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind:
  83458. this.colors = data;
  83459. break;
  83460. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind:
  83461. this.matricesIndices = data;
  83462. break;
  83463. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind:
  83464. this.matricesWeights = data;
  83465. break;
  83466. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind:
  83467. this.matricesIndicesExtra = data;
  83468. break;
  83469. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind:
  83470. this.matricesWeightsExtra = data;
  83471. break;
  83472. }
  83473. };
  83474. /**
  83475. * Associates the vertexData to the passed Mesh.
  83476. * Sets it as updatable or not (default `false`)
  83477. * @param mesh the mesh the vertexData is applied to
  83478. * @param updatable when used and having the value true allows new data to update the vertexData
  83479. * @returns the VertexData
  83480. */
  83481. VertexData.prototype.applyToMesh = function (mesh, updatable) {
  83482. this._applyTo(mesh, updatable);
  83483. return this;
  83484. };
  83485. /**
  83486. * Associates the vertexData to the passed Geometry.
  83487. * Sets it as updatable or not (default `false`)
  83488. * @param geometry the geometry the vertexData is applied to
  83489. * @param updatable when used and having the value true allows new data to update the vertexData
  83490. * @returns VertexData
  83491. */
  83492. VertexData.prototype.applyToGeometry = function (geometry, updatable) {
  83493. this._applyTo(geometry, updatable);
  83494. return this;
  83495. };
  83496. /**
  83497. * Updates the associated mesh
  83498. * @param mesh the mesh to be updated
  83499. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83500. * @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
  83501. * @returns VertexData
  83502. */
  83503. VertexData.prototype.updateMesh = function (mesh) {
  83504. this._update(mesh);
  83505. return this;
  83506. };
  83507. /**
  83508. * Updates the associated geometry
  83509. * @param geometry the geometry to be updated
  83510. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83511. * @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
  83512. * @returns VertexData.
  83513. */
  83514. VertexData.prototype.updateGeometry = function (geometry) {
  83515. this._update(geometry);
  83516. return this;
  83517. };
  83518. VertexData.prototype._applyTo = function (meshOrGeometry, updatable) {
  83519. if (updatable === void 0) { updatable = false; }
  83520. if (this.positions) {
  83521. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updatable);
  83522. }
  83523. if (this.normals) {
  83524. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updatable);
  83525. }
  83526. if (this.tangents) {
  83527. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updatable);
  83528. }
  83529. if (this.uvs) {
  83530. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updatable);
  83531. }
  83532. if (this.uvs2) {
  83533. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updatable);
  83534. }
  83535. if (this.uvs3) {
  83536. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updatable);
  83537. }
  83538. if (this.uvs4) {
  83539. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updatable);
  83540. }
  83541. if (this.uvs5) {
  83542. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updatable);
  83543. }
  83544. if (this.uvs6) {
  83545. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updatable);
  83546. }
  83547. if (this.colors) {
  83548. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updatable);
  83549. }
  83550. if (this.matricesIndices) {
  83551. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updatable);
  83552. }
  83553. if (this.matricesWeights) {
  83554. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updatable);
  83555. }
  83556. if (this.matricesIndicesExtra) {
  83557. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
  83558. }
  83559. if (this.matricesWeightsExtra) {
  83560. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
  83561. }
  83562. if (this.indices) {
  83563. meshOrGeometry.setIndices(this.indices, null, updatable);
  83564. }
  83565. else {
  83566. meshOrGeometry.setIndices([], null);
  83567. }
  83568. return this;
  83569. };
  83570. VertexData.prototype._update = function (meshOrGeometry, updateExtends, makeItUnique) {
  83571. if (this.positions) {
  83572. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updateExtends, makeItUnique);
  83573. }
  83574. if (this.normals) {
  83575. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updateExtends, makeItUnique);
  83576. }
  83577. if (this.tangents) {
  83578. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updateExtends, makeItUnique);
  83579. }
  83580. if (this.uvs) {
  83581. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updateExtends, makeItUnique);
  83582. }
  83583. if (this.uvs2) {
  83584. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updateExtends, makeItUnique);
  83585. }
  83586. if (this.uvs3) {
  83587. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updateExtends, makeItUnique);
  83588. }
  83589. if (this.uvs4) {
  83590. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updateExtends, makeItUnique);
  83591. }
  83592. if (this.uvs5) {
  83593. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updateExtends, makeItUnique);
  83594. }
  83595. if (this.uvs6) {
  83596. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updateExtends, makeItUnique);
  83597. }
  83598. if (this.colors) {
  83599. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updateExtends, makeItUnique);
  83600. }
  83601. if (this.matricesIndices) {
  83602. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updateExtends, makeItUnique);
  83603. }
  83604. if (this.matricesWeights) {
  83605. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updateExtends, makeItUnique);
  83606. }
  83607. if (this.matricesIndicesExtra) {
  83608. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updateExtends, makeItUnique);
  83609. }
  83610. if (this.matricesWeightsExtra) {
  83611. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updateExtends, makeItUnique);
  83612. }
  83613. if (this.indices) {
  83614. meshOrGeometry.setIndices(this.indices, null);
  83615. }
  83616. return this;
  83617. };
  83618. /**
  83619. * Transforms each position and each normal of the vertexData according to the passed Matrix
  83620. * @param matrix the transforming matrix
  83621. * @returns the VertexData
  83622. */
  83623. VertexData.prototype.transform = function (matrix) {
  83624. var flip = matrix.m[0] * matrix.m[5] * matrix.m[10] < 0;
  83625. var transformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  83626. var index;
  83627. if (this.positions) {
  83628. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  83629. for (index = 0; index < this.positions.length; index += 3) {
  83630. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.positions, index, position);
  83631. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(position, matrix, transformed);
  83632. this.positions[index] = transformed.x;
  83633. this.positions[index + 1] = transformed.y;
  83634. this.positions[index + 2] = transformed.z;
  83635. }
  83636. }
  83637. if (this.normals) {
  83638. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  83639. for (index = 0; index < this.normals.length; index += 3) {
  83640. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.normals, index, normal);
  83641. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(normal, matrix, transformed);
  83642. this.normals[index] = transformed.x;
  83643. this.normals[index + 1] = transformed.y;
  83644. this.normals[index + 2] = transformed.z;
  83645. }
  83646. }
  83647. if (this.tangents) {
  83648. var tangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  83649. var tangentTransformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  83650. for (index = 0; index < this.tangents.length; index += 4) {
  83651. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].FromArrayToRef(this.tangents, index, tangent);
  83652. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].TransformNormalToRef(tangent, matrix, tangentTransformed);
  83653. this.tangents[index] = tangentTransformed.x;
  83654. this.tangents[index + 1] = tangentTransformed.y;
  83655. this.tangents[index + 2] = tangentTransformed.z;
  83656. this.tangents[index + 3] = tangentTransformed.w;
  83657. }
  83658. }
  83659. if (flip && this.indices) {
  83660. for (index = 0; index < this.indices.length; index += 3) {
  83661. var tmp = this.indices[index + 1];
  83662. this.indices[index + 1] = this.indices[index + 2];
  83663. this.indices[index + 2] = tmp;
  83664. }
  83665. }
  83666. return this;
  83667. };
  83668. /**
  83669. * Merges the passed VertexData into the current one
  83670. * @param other the VertexData to be merged into the current one
  83671. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  83672. * @returns the modified VertexData
  83673. */
  83674. VertexData.prototype.merge = function (other, use32BitsIndices) {
  83675. if (use32BitsIndices === void 0) { use32BitsIndices = false; }
  83676. this._validate();
  83677. other._validate();
  83678. if (!this.normals !== !other.normals ||
  83679. !this.tangents !== !other.tangents ||
  83680. !this.uvs !== !other.uvs ||
  83681. !this.uvs2 !== !other.uvs2 ||
  83682. !this.uvs3 !== !other.uvs3 ||
  83683. !this.uvs4 !== !other.uvs4 ||
  83684. !this.uvs5 !== !other.uvs5 ||
  83685. !this.uvs6 !== !other.uvs6 ||
  83686. !this.colors !== !other.colors ||
  83687. !this.matricesIndices !== !other.matricesIndices ||
  83688. !this.matricesWeights !== !other.matricesWeights ||
  83689. !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
  83690. !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
  83691. throw new Error("Cannot merge vertex data that do not have the same set of attributes");
  83692. }
  83693. if (other.indices) {
  83694. if (!this.indices) {
  83695. this.indices = [];
  83696. }
  83697. var offset = this.positions ? this.positions.length / 3 : 0;
  83698. var isSrcTypedArray = this.indices.BYTES_PER_ELEMENT !== undefined;
  83699. if (isSrcTypedArray) {
  83700. var len = this.indices.length + other.indices.length;
  83701. var temp = use32BitsIndices || this.indices instanceof Uint32Array ? new Uint32Array(len) : new Uint16Array(len);
  83702. temp.set(this.indices);
  83703. var decal = this.indices.length;
  83704. for (var index = 0; index < other.indices.length; index++) {
  83705. temp[decal + index] = other.indices[index] + offset;
  83706. }
  83707. this.indices = temp;
  83708. }
  83709. else {
  83710. for (var index = 0; index < other.indices.length; index++) {
  83711. this.indices.push(other.indices[index] + offset);
  83712. }
  83713. }
  83714. }
  83715. this.positions = this._mergeElement(this.positions, other.positions);
  83716. this.normals = this._mergeElement(this.normals, other.normals);
  83717. this.tangents = this._mergeElement(this.tangents, other.tangents);
  83718. this.uvs = this._mergeElement(this.uvs, other.uvs);
  83719. this.uvs2 = this._mergeElement(this.uvs2, other.uvs2);
  83720. this.uvs3 = this._mergeElement(this.uvs3, other.uvs3);
  83721. this.uvs4 = this._mergeElement(this.uvs4, other.uvs4);
  83722. this.uvs5 = this._mergeElement(this.uvs5, other.uvs5);
  83723. this.uvs6 = this._mergeElement(this.uvs6, other.uvs6);
  83724. this.colors = this._mergeElement(this.colors, other.colors);
  83725. this.matricesIndices = this._mergeElement(this.matricesIndices, other.matricesIndices);
  83726. this.matricesWeights = this._mergeElement(this.matricesWeights, other.matricesWeights);
  83727. this.matricesIndicesExtra = this._mergeElement(this.matricesIndicesExtra, other.matricesIndicesExtra);
  83728. this.matricesWeightsExtra = this._mergeElement(this.matricesWeightsExtra, other.matricesWeightsExtra);
  83729. return this;
  83730. };
  83731. VertexData.prototype._mergeElement = function (source, other) {
  83732. if (!source) {
  83733. return other;
  83734. }
  83735. if (!other) {
  83736. return source;
  83737. }
  83738. var len = other.length + source.length;
  83739. var isSrcTypedArray = source instanceof Float32Array;
  83740. var isOthTypedArray = other instanceof Float32Array;
  83741. // use non-loop method when the source is Float32Array
  83742. if (isSrcTypedArray) {
  83743. var ret32 = new Float32Array(len);
  83744. ret32.set(source);
  83745. ret32.set(other, source.length);
  83746. return ret32;
  83747. // source is number[], when other is also use concat
  83748. }
  83749. else if (!isOthTypedArray) {
  83750. return source.concat(other);
  83751. // source is a number[], but other is a Float32Array, loop required
  83752. }
  83753. else {
  83754. var ret = source.slice(0); // copy source to a separate array
  83755. for (var i = 0, len = other.length; i < len; i++) {
  83756. ret.push(other[i]);
  83757. }
  83758. return ret;
  83759. }
  83760. };
  83761. VertexData.prototype._validate = function () {
  83762. if (!this.positions) {
  83763. throw new Error("Positions are required");
  83764. }
  83765. var getElementCount = function (kind, values) {
  83766. var stride = _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].DeduceStride(kind);
  83767. if ((values.length % stride) !== 0) {
  83768. throw new Error("The " + kind + "s array count must be a multiple of " + stride);
  83769. }
  83770. return values.length / stride;
  83771. };
  83772. var positionsElementCount = getElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions);
  83773. var validateElementCount = function (kind, values) {
  83774. var elementCount = getElementCount(kind, values);
  83775. if (elementCount !== positionsElementCount) {
  83776. throw new Error("The " + kind + "s element count (" + elementCount + ") does not match the positions count (" + positionsElementCount + ")");
  83777. }
  83778. };
  83779. if (this.normals) {
  83780. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals);
  83781. }
  83782. if (this.tangents) {
  83783. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents);
  83784. }
  83785. if (this.uvs) {
  83786. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs);
  83787. }
  83788. if (this.uvs2) {
  83789. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2);
  83790. }
  83791. if (this.uvs3) {
  83792. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3);
  83793. }
  83794. if (this.uvs4) {
  83795. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4);
  83796. }
  83797. if (this.uvs5) {
  83798. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5);
  83799. }
  83800. if (this.uvs6) {
  83801. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6);
  83802. }
  83803. if (this.colors) {
  83804. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors);
  83805. }
  83806. if (this.matricesIndices) {
  83807. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices);
  83808. }
  83809. if (this.matricesWeights) {
  83810. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights);
  83811. }
  83812. if (this.matricesIndicesExtra) {
  83813. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra);
  83814. }
  83815. if (this.matricesWeightsExtra) {
  83816. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra);
  83817. }
  83818. };
  83819. /**
  83820. * Serializes the VertexData
  83821. * @returns a serialized object
  83822. */
  83823. VertexData.prototype.serialize = function () {
  83824. var serializationObject = this.serialize();
  83825. if (this.positions) {
  83826. serializationObject.positions = this.positions;
  83827. }
  83828. if (this.normals) {
  83829. serializationObject.normals = this.normals;
  83830. }
  83831. if (this.tangents) {
  83832. serializationObject.tangents = this.tangents;
  83833. }
  83834. if (this.uvs) {
  83835. serializationObject.uvs = this.uvs;
  83836. }
  83837. if (this.uvs2) {
  83838. serializationObject.uvs2 = this.uvs2;
  83839. }
  83840. if (this.uvs3) {
  83841. serializationObject.uvs3 = this.uvs3;
  83842. }
  83843. if (this.uvs4) {
  83844. serializationObject.uvs4 = this.uvs4;
  83845. }
  83846. if (this.uvs5) {
  83847. serializationObject.uvs5 = this.uvs5;
  83848. }
  83849. if (this.uvs6) {
  83850. serializationObject.uvs6 = this.uvs6;
  83851. }
  83852. if (this.colors) {
  83853. serializationObject.colors = this.colors;
  83854. }
  83855. if (this.matricesIndices) {
  83856. serializationObject.matricesIndices = this.matricesIndices;
  83857. serializationObject.matricesIndices._isExpanded = true;
  83858. }
  83859. if (this.matricesWeights) {
  83860. serializationObject.matricesWeights = this.matricesWeights;
  83861. }
  83862. if (this.matricesIndicesExtra) {
  83863. serializationObject.matricesIndicesExtra = this.matricesIndicesExtra;
  83864. serializationObject.matricesIndicesExtra._isExpanded = true;
  83865. }
  83866. if (this.matricesWeightsExtra) {
  83867. serializationObject.matricesWeightsExtra = this.matricesWeightsExtra;
  83868. }
  83869. serializationObject.indices = this.indices;
  83870. return serializationObject;
  83871. };
  83872. // Statics
  83873. /**
  83874. * Extracts the vertexData from a mesh
  83875. * @param mesh the mesh from which to extract the VertexData
  83876. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  83877. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83878. * @returns the object VertexData associated to the passed mesh
  83879. */
  83880. VertexData.ExtractFromMesh = function (mesh, copyWhenShared, forceCopy) {
  83881. return VertexData._ExtractFrom(mesh, copyWhenShared, forceCopy);
  83882. };
  83883. /**
  83884. * Extracts the vertexData from the geometry
  83885. * @param geometry the geometry from which to extract the VertexData
  83886. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  83887. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83888. * @returns the object VertexData associated to the passed mesh
  83889. */
  83890. VertexData.ExtractFromGeometry = function (geometry, copyWhenShared, forceCopy) {
  83891. return VertexData._ExtractFrom(geometry, copyWhenShared, forceCopy);
  83892. };
  83893. VertexData._ExtractFrom = function (meshOrGeometry, copyWhenShared, forceCopy) {
  83894. var result = new VertexData();
  83895. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind)) {
  83896. result.positions = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, copyWhenShared, forceCopy);
  83897. }
  83898. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  83899. result.normals = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, copyWhenShared, forceCopy);
  83900. }
  83901. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind)) {
  83902. result.tangents = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, copyWhenShared, forceCopy);
  83903. }
  83904. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  83905. result.uvs = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, copyWhenShared, forceCopy);
  83906. }
  83907. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  83908. result.uvs2 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, copyWhenShared, forceCopy);
  83909. }
  83910. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind)) {
  83911. result.uvs3 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, copyWhenShared, forceCopy);
  83912. }
  83913. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind)) {
  83914. result.uvs4 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, copyWhenShared, forceCopy);
  83915. }
  83916. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind)) {
  83917. result.uvs5 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, copyWhenShared, forceCopy);
  83918. }
  83919. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind)) {
  83920. result.uvs6 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, copyWhenShared, forceCopy);
  83921. }
  83922. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind)) {
  83923. result.colors = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, copyWhenShared, forceCopy);
  83924. }
  83925. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind)) {
  83926. result.matricesIndices = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, copyWhenShared, forceCopy);
  83927. }
  83928. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind)) {
  83929. result.matricesWeights = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, copyWhenShared, forceCopy);
  83930. }
  83931. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind)) {
  83932. result.matricesIndicesExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, copyWhenShared, forceCopy);
  83933. }
  83934. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind)) {
  83935. result.matricesWeightsExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, copyWhenShared, forceCopy);
  83936. }
  83937. result.indices = meshOrGeometry.getIndices(copyWhenShared, forceCopy);
  83938. return result;
  83939. };
  83940. /**
  83941. * Creates the VertexData for a Ribbon
  83942. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  83943. * * pathArray array of paths, each of which an array of successive Vector3
  83944. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  83945. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  83946. * * 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
  83947. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83948. * * 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)
  83949. * * 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)
  83950. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  83951. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  83952. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  83953. * @returns the VertexData of the ribbon
  83954. */
  83955. VertexData.CreateRibbon = function (options) {
  83956. var pathArray = options.pathArray;
  83957. var closeArray = options.closeArray || false;
  83958. var closePath = options.closePath || false;
  83959. var invertUV = options.invertUV || false;
  83960. var defaultOffset = Math.floor(pathArray[0].length / 2);
  83961. var offset = options.offset || defaultOffset;
  83962. offset = offset > defaultOffset ? defaultOffset : Math.floor(offset); // offset max allowed : defaultOffset
  83963. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  83964. var customUV = options.uvs;
  83965. var customColors = options.colors;
  83966. var positions = [];
  83967. var indices = [];
  83968. var normals = [];
  83969. var uvs = [];
  83970. var us = []; // us[path_id] = [uDist1, uDist2, uDist3 ... ] distances between points on path path_id
  83971. var vs = []; // vs[i] = [vDist1, vDist2, vDist3, ... ] distances between points i of consecutives paths from pathArray
  83972. var uTotalDistance = []; // uTotalDistance[p] : total distance of path p
  83973. var vTotalDistance = []; // vTotalDistance[i] : total distance between points i of first and last path from pathArray
  83974. var minlg; // minimal length among all paths from pathArray
  83975. var lg = []; // array of path lengths : nb of vertex per path
  83976. var idx = []; // array of path indexes : index of each path (first vertex) in the total vertex number
  83977. var p; // path iterator
  83978. var i; // point iterator
  83979. var j; // point iterator
  83980. // if single path in pathArray
  83981. if (pathArray.length < 2) {
  83982. var ar1 = [];
  83983. var ar2 = [];
  83984. for (i = 0; i < pathArray[0].length - offset; i++) {
  83985. ar1.push(pathArray[0][i]);
  83986. ar2.push(pathArray[0][i + offset]);
  83987. }
  83988. pathArray = [ar1, ar2];
  83989. }
  83990. // positions and horizontal distances (u)
  83991. var idc = 0;
  83992. var closePathCorr = (closePath) ? 1 : 0; // the final index will be +1 if closePath
  83993. var path;
  83994. var l;
  83995. minlg = pathArray[0].length;
  83996. var vectlg;
  83997. var dist;
  83998. for (p = 0; p < pathArray.length; p++) {
  83999. uTotalDistance[p] = 0;
  84000. us[p] = [0];
  84001. path = pathArray[p];
  84002. l = path.length;
  84003. minlg = (minlg < l) ? minlg : l;
  84004. j = 0;
  84005. while (j < l) {
  84006. positions.push(path[j].x, path[j].y, path[j].z);
  84007. if (j > 0) {
  84008. vectlg = path[j].subtract(path[j - 1]).length();
  84009. dist = vectlg + uTotalDistance[p];
  84010. us[p].push(dist);
  84011. uTotalDistance[p] = dist;
  84012. }
  84013. j++;
  84014. }
  84015. if (closePath) { // an extra hidden vertex is added in the "positions" array
  84016. j--;
  84017. positions.push(path[0].x, path[0].y, path[0].z);
  84018. vectlg = path[j].subtract(path[0]).length();
  84019. dist = vectlg + uTotalDistance[p];
  84020. us[p].push(dist);
  84021. uTotalDistance[p] = dist;
  84022. }
  84023. lg[p] = l + closePathCorr;
  84024. idx[p] = idc;
  84025. idc += (l + closePathCorr);
  84026. }
  84027. // vertical distances (v)
  84028. var path1;
  84029. var path2;
  84030. var vertex1 = null;
  84031. var vertex2 = null;
  84032. for (i = 0; i < minlg + closePathCorr; i++) {
  84033. vTotalDistance[i] = 0;
  84034. vs[i] = [0];
  84035. for (p = 0; p < pathArray.length - 1; p++) {
  84036. path1 = pathArray[p];
  84037. path2 = pathArray[p + 1];
  84038. if (i === minlg) { // closePath
  84039. vertex1 = path1[0];
  84040. vertex2 = path2[0];
  84041. }
  84042. else {
  84043. vertex1 = path1[i];
  84044. vertex2 = path2[i];
  84045. }
  84046. vectlg = vertex2.subtract(vertex1).length();
  84047. dist = vectlg + vTotalDistance[i];
  84048. vs[i].push(dist);
  84049. vTotalDistance[i] = dist;
  84050. }
  84051. if (closeArray && vertex2 && vertex1) {
  84052. path1 = pathArray[p];
  84053. path2 = pathArray[0];
  84054. if (i === minlg) { // closePath
  84055. vertex2 = path2[0];
  84056. }
  84057. vectlg = vertex2.subtract(vertex1).length();
  84058. dist = vectlg + vTotalDistance[i];
  84059. vTotalDistance[i] = dist;
  84060. }
  84061. }
  84062. // uvs
  84063. var u;
  84064. var v;
  84065. if (customUV) {
  84066. for (p = 0; p < customUV.length; p++) {
  84067. uvs.push(customUV[p].x, customUV[p].y);
  84068. }
  84069. }
  84070. else {
  84071. for (p = 0; p < pathArray.length; p++) {
  84072. for (i = 0; i < minlg + closePathCorr; i++) {
  84073. u = (uTotalDistance[p] != 0.0) ? us[p][i] / uTotalDistance[p] : 0.0;
  84074. v = (vTotalDistance[i] != 0.0) ? vs[i][p] / vTotalDistance[i] : 0.0;
  84075. if (invertUV) {
  84076. uvs.push(v, u);
  84077. }
  84078. else {
  84079. uvs.push(u, v);
  84080. }
  84081. }
  84082. }
  84083. }
  84084. // indices
  84085. p = 0; // path index
  84086. var pi = 0; // positions array index
  84087. var l1 = lg[p] - 1; // path1 length
  84088. var l2 = lg[p + 1] - 1; // path2 length
  84089. var min = (l1 < l2) ? l1 : l2; // current path stop index
  84090. var shft = idx[1] - idx[0]; // shift
  84091. var path1nb = closeArray ? lg.length : lg.length - 1; // number of path1 to iterate on
  84092. while (pi <= min && p < path1nb) { // stay under min and don't go over next to last path
  84093. // 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
  84094. indices.push(pi, pi + shft, pi + 1);
  84095. indices.push(pi + shft + 1, pi + 1, pi + shft);
  84096. pi += 1;
  84097. if (pi === min) { // if end of one of two consecutive paths reached, go to next existing path
  84098. p++;
  84099. if (p === lg.length - 1) { // last path of pathArray reached <=> closeArray == true
  84100. shft = idx[0] - idx[p];
  84101. l1 = lg[p] - 1;
  84102. l2 = lg[0] - 1;
  84103. }
  84104. else {
  84105. shft = idx[p + 1] - idx[p];
  84106. l1 = lg[p] - 1;
  84107. l2 = lg[p + 1] - 1;
  84108. }
  84109. pi = idx[p];
  84110. min = (l1 < l2) ? l1 + pi : l2 + pi;
  84111. }
  84112. }
  84113. // normals
  84114. VertexData.ComputeNormals(positions, indices, normals);
  84115. if (closePath) { // update both the first and last vertex normals to their average value
  84116. var indexFirst = 0;
  84117. var indexLast = 0;
  84118. for (p = 0; p < pathArray.length; p++) {
  84119. indexFirst = idx[p] * 3;
  84120. if (p + 1 < pathArray.length) {
  84121. indexLast = (idx[p + 1] - 1) * 3;
  84122. }
  84123. else {
  84124. indexLast = normals.length - 3;
  84125. }
  84126. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  84127. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  84128. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  84129. normals[indexLast] = normals[indexFirst];
  84130. normals[indexLast + 1] = normals[indexFirst + 1];
  84131. normals[indexLast + 2] = normals[indexFirst + 2];
  84132. }
  84133. }
  84134. // sides
  84135. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  84136. // Colors
  84137. var colors = null;
  84138. if (customColors) {
  84139. colors = new Float32Array(customColors.length * 4);
  84140. for (var c = 0; c < customColors.length; c++) {
  84141. colors[c * 4] = customColors[c].r;
  84142. colors[c * 4 + 1] = customColors[c].g;
  84143. colors[c * 4 + 2] = customColors[c].b;
  84144. colors[c * 4 + 3] = customColors[c].a;
  84145. }
  84146. }
  84147. // Result
  84148. var vertexData = new VertexData();
  84149. var positions32 = new Float32Array(positions);
  84150. var normals32 = new Float32Array(normals);
  84151. var uvs32 = new Float32Array(uvs);
  84152. vertexData.indices = indices;
  84153. vertexData.positions = positions32;
  84154. vertexData.normals = normals32;
  84155. vertexData.uvs = uvs32;
  84156. if (colors) {
  84157. vertexData.set(colors, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  84158. }
  84159. if (closePath) {
  84160. vertexData._idx = idx;
  84161. }
  84162. return vertexData;
  84163. };
  84164. /**
  84165. * Creates the VertexData for a box
  84166. * @param options an object used to set the following optional parameters for the box, required but can be empty
  84167. * * size sets the width, height and depth of the box to the value of size, optional default 1
  84168. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  84169. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  84170. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  84171. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  84172. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  84173. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84174. * * 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)
  84175. * * 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)
  84176. * @returns the VertexData of the box
  84177. */
  84178. VertexData.CreateBox = function (options) {
  84179. var normalsSource = [
  84180. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1),
  84181. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1),
  84182. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0),
  84183. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0),
  84184. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0),
  84185. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)
  84186. ];
  84187. var indices = [];
  84188. var positions = [];
  84189. var normals = [];
  84190. var uvs = [];
  84191. var width = options.width || options.size || 1;
  84192. var height = options.height || options.size || 1;
  84193. var depth = options.depth || options.size || 1;
  84194. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  84195. var faceUV = options.faceUV || new Array(6);
  84196. var faceColors = options.faceColors;
  84197. var colors = [];
  84198. // default face colors and UV if undefined
  84199. for (var f = 0; f < 6; f++) {
  84200. if (faceUV[f] === undefined) {
  84201. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  84202. }
  84203. if (faceColors && faceColors[f] === undefined) {
  84204. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  84205. }
  84206. }
  84207. var scaleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](width / 2, height / 2, depth / 2);
  84208. // Create each face in turn.
  84209. for (var index = 0; index < normalsSource.length; index++) {
  84210. var normal = normalsSource[index];
  84211. // Get two vectors perpendicular to the face normal and to each other.
  84212. var side1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normal.y, normal.z, normal.x);
  84213. var side2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(normal, side1);
  84214. // Six indices (two triangles) per face.
  84215. var verticesLength = positions.length / 3;
  84216. indices.push(verticesLength);
  84217. indices.push(verticesLength + 1);
  84218. indices.push(verticesLength + 2);
  84219. indices.push(verticesLength);
  84220. indices.push(verticesLength + 2);
  84221. indices.push(verticesLength + 3);
  84222. // Four vertices per face.
  84223. var vertex = normal.subtract(side1).subtract(side2).multiply(scaleVector);
  84224. positions.push(vertex.x, vertex.y, vertex.z);
  84225. normals.push(normal.x, normal.y, normal.z);
  84226. uvs.push(faceUV[index].z, faceUV[index].w);
  84227. if (faceColors) {
  84228. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  84229. }
  84230. vertex = normal.subtract(side1).add(side2).multiply(scaleVector);
  84231. positions.push(vertex.x, vertex.y, vertex.z);
  84232. normals.push(normal.x, normal.y, normal.z);
  84233. uvs.push(faceUV[index].x, faceUV[index].w);
  84234. if (faceColors) {
  84235. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  84236. }
  84237. vertex = normal.add(side1).add(side2).multiply(scaleVector);
  84238. positions.push(vertex.x, vertex.y, vertex.z);
  84239. normals.push(normal.x, normal.y, normal.z);
  84240. uvs.push(faceUV[index].x, faceUV[index].y);
  84241. if (faceColors) {
  84242. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  84243. }
  84244. vertex = normal.add(side1).subtract(side2).multiply(scaleVector);
  84245. positions.push(vertex.x, vertex.y, vertex.z);
  84246. normals.push(normal.x, normal.y, normal.z);
  84247. uvs.push(faceUV[index].z, faceUV[index].y);
  84248. if (faceColors) {
  84249. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  84250. }
  84251. }
  84252. // sides
  84253. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  84254. // Result
  84255. var vertexData = new VertexData();
  84256. vertexData.indices = indices;
  84257. vertexData.positions = positions;
  84258. vertexData.normals = normals;
  84259. vertexData.uvs = uvs;
  84260. if (faceColors) {
  84261. var totalColors = (sideOrientation === VertexData.DOUBLESIDE) ? colors.concat(colors) : colors;
  84262. vertexData.colors = totalColors;
  84263. }
  84264. return vertexData;
  84265. };
  84266. /**
  84267. * Creates the VertexData for an ellipsoid, defaults to a sphere
  84268. * @param options an object used to set the following optional parameters for the box, required but can be empty
  84269. * * segments sets the number of horizontal strips optional, default 32
  84270. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  84271. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  84272. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  84273. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  84274. * * 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
  84275. * * 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
  84276. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84277. * * 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)
  84278. * * 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)
  84279. * @returns the VertexData of the ellipsoid
  84280. */
  84281. VertexData.CreateSphere = function (options) {
  84282. var segments = options.segments || 32;
  84283. var diameterX = options.diameterX || options.diameter || 1;
  84284. var diameterY = options.diameterY || options.diameter || 1;
  84285. var diameterZ = options.diameterZ || options.diameter || 1;
  84286. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  84287. var slice = options.slice && (options.slice <= 0) ? 1.0 : options.slice || 1.0;
  84288. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  84289. var radius = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](diameterX / 2, diameterY / 2, diameterZ / 2);
  84290. var totalZRotationSteps = 2 + segments;
  84291. var totalYRotationSteps = 2 * totalZRotationSteps;
  84292. var indices = [];
  84293. var positions = [];
  84294. var normals = [];
  84295. var uvs = [];
  84296. for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
  84297. var normalizedZ = zRotationStep / totalZRotationSteps;
  84298. var angleZ = normalizedZ * Math.PI * slice;
  84299. for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
  84300. var normalizedY = yRotationStep / totalYRotationSteps;
  84301. var angleY = normalizedY * Math.PI * 2 * arc;
  84302. var rotationZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationZ(-angleZ);
  84303. var rotationY = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(angleY);
  84304. var afterRotZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), rotationZ);
  84305. var complete = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(afterRotZ, rotationY);
  84306. var vertex = complete.multiply(radius);
  84307. var normal = complete.divide(radius).normalize();
  84308. positions.push(vertex.x, vertex.y, vertex.z);
  84309. normals.push(normal.x, normal.y, normal.z);
  84310. uvs.push(normalizedY, normalizedZ);
  84311. }
  84312. if (zRotationStep > 0) {
  84313. var verticesCount = positions.length / 3;
  84314. for (var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1); (firstIndex + totalYRotationSteps + 2) < verticesCount; firstIndex++) {
  84315. indices.push((firstIndex));
  84316. indices.push((firstIndex + 1));
  84317. indices.push(firstIndex + totalYRotationSteps + 1);
  84318. indices.push((firstIndex + totalYRotationSteps + 1));
  84319. indices.push((firstIndex + 1));
  84320. indices.push((firstIndex + totalYRotationSteps + 2));
  84321. }
  84322. }
  84323. }
  84324. // Sides
  84325. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  84326. // Result
  84327. var vertexData = new VertexData();
  84328. vertexData.indices = indices;
  84329. vertexData.positions = positions;
  84330. vertexData.normals = normals;
  84331. vertexData.uvs = uvs;
  84332. return vertexData;
  84333. };
  84334. /**
  84335. * Creates the VertexData for a cylinder, cone or prism
  84336. * @param options an object used to set the following optional parameters for the box, required but can be empty
  84337. * * height sets the height (y direction) of the cylinder, optional, default 2
  84338. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  84339. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  84340. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  84341. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  84342. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  84343. * * 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
  84344. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  84345. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  84346. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  84347. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  84348. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84349. * * 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)
  84350. * * 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)
  84351. * @returns the VertexData of the cylinder, cone or prism
  84352. */
  84353. VertexData.CreateCylinder = function (options) {
  84354. var height = options.height || 2;
  84355. var diameterTop = (options.diameterTop === 0) ? 0 : options.diameterTop || options.diameter || 1;
  84356. var diameterBottom = (options.diameterBottom === 0) ? 0 : options.diameterBottom || options.diameter || 1;
  84357. var tessellation = options.tessellation || 24;
  84358. var subdivisions = options.subdivisions || 1;
  84359. var hasRings = options.hasRings ? true : false;
  84360. var enclose = options.enclose ? true : false;
  84361. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  84362. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  84363. var faceUV = options.faceUV || new Array(3);
  84364. var faceColors = options.faceColors;
  84365. // default face colors and UV if undefined
  84366. var quadNb = (arc !== 1 && enclose) ? 2 : 0;
  84367. var ringNb = (hasRings) ? subdivisions : 1;
  84368. var surfaceNb = 2 + (1 + quadNb) * ringNb;
  84369. var f;
  84370. for (f = 0; f < surfaceNb; f++) {
  84371. if (faceColors && faceColors[f] === undefined) {
  84372. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  84373. }
  84374. }
  84375. for (f = 0; f < surfaceNb; f++) {
  84376. if (faceUV && faceUV[f] === undefined) {
  84377. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  84378. }
  84379. }
  84380. var indices = new Array();
  84381. var positions = new Array();
  84382. var normals = new Array();
  84383. var uvs = new Array();
  84384. var colors = new Array();
  84385. var angle_step = Math.PI * 2 * arc / tessellation;
  84386. var angle;
  84387. var h;
  84388. var radius;
  84389. var tan = (diameterBottom - diameterTop) / 2 / height;
  84390. var ringVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  84391. var ringNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  84392. var ringFirstVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  84393. var ringFirstNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  84394. var quadNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  84395. var Y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Y;
  84396. // positions, normals, uvs
  84397. var i;
  84398. var j;
  84399. var r;
  84400. var ringIdx = 1;
  84401. var s = 1; // surface index
  84402. var cs = 0;
  84403. var v = 0;
  84404. for (i = 0; i <= subdivisions; i++) {
  84405. h = i / subdivisions;
  84406. radius = (h * (diameterTop - diameterBottom) + diameterBottom) / 2;
  84407. ringIdx = (hasRings && i !== 0 && i !== subdivisions) ? 2 : 1;
  84408. for (r = 0; r < ringIdx; r++) {
  84409. if (hasRings) {
  84410. s += r;
  84411. }
  84412. if (enclose) {
  84413. s += 2 * r;
  84414. }
  84415. for (j = 0; j <= tessellation; j++) {
  84416. angle = j * angle_step;
  84417. // position
  84418. ringVertex.x = Math.cos(-angle) * radius;
  84419. ringVertex.y = -height / 2 + h * height;
  84420. ringVertex.z = Math.sin(-angle) * radius;
  84421. // normal
  84422. if (diameterTop === 0 && i === subdivisions) {
  84423. // if no top cap, reuse former normals
  84424. ringNormal.x = normals[normals.length - (tessellation + 1) * 3];
  84425. ringNormal.y = normals[normals.length - (tessellation + 1) * 3 + 1];
  84426. ringNormal.z = normals[normals.length - (tessellation + 1) * 3 + 2];
  84427. }
  84428. else {
  84429. ringNormal.x = ringVertex.x;
  84430. ringNormal.z = ringVertex.z;
  84431. ringNormal.y = Math.sqrt(ringNormal.x * ringNormal.x + ringNormal.z * ringNormal.z) * tan;
  84432. ringNormal.normalize();
  84433. }
  84434. // keep first ring vertex values for enclose
  84435. if (j === 0) {
  84436. ringFirstVertex.copyFrom(ringVertex);
  84437. ringFirstNormal.copyFrom(ringNormal);
  84438. }
  84439. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  84440. normals.push(ringNormal.x, ringNormal.y, ringNormal.z);
  84441. if (hasRings) {
  84442. v = (cs !== s) ? faceUV[s].y : faceUV[s].w;
  84443. }
  84444. else {
  84445. v = faceUV[s].y + (faceUV[s].w - faceUV[s].y) * h;
  84446. }
  84447. uvs.push(faceUV[s].x + (faceUV[s].z - faceUV[s].x) * j / tessellation, v);
  84448. if (faceColors) {
  84449. colors.push(faceColors[s].r, faceColors[s].g, faceColors[s].b, faceColors[s].a);
  84450. }
  84451. }
  84452. // if enclose, add four vertices and their dedicated normals
  84453. if (arc !== 1 && enclose) {
  84454. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  84455. positions.push(0, ringVertex.y, 0);
  84456. positions.push(0, ringVertex.y, 0);
  84457. positions.push(ringFirstVertex.x, ringFirstVertex.y, ringFirstVertex.z);
  84458. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(Y, ringNormal, quadNormal);
  84459. quadNormal.normalize();
  84460. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  84461. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(ringFirstNormal, Y, quadNormal);
  84462. quadNormal.normalize();
  84463. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  84464. if (hasRings) {
  84465. v = (cs !== s) ? faceUV[s + 1].y : faceUV[s + 1].w;
  84466. }
  84467. else {
  84468. v = faceUV[s + 1].y + (faceUV[s + 1].w - faceUV[s + 1].y) * h;
  84469. }
  84470. uvs.push(faceUV[s + 1].x, v);
  84471. uvs.push(faceUV[s + 1].z, v);
  84472. if (hasRings) {
  84473. v = (cs !== s) ? faceUV[s + 2].y : faceUV[s + 2].w;
  84474. }
  84475. else {
  84476. v = faceUV[s + 2].y + (faceUV[s + 2].w - faceUV[s + 2].y) * h;
  84477. }
  84478. uvs.push(faceUV[s + 2].x, v);
  84479. uvs.push(faceUV[s + 2].z, v);
  84480. if (faceColors) {
  84481. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  84482. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  84483. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  84484. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  84485. }
  84486. }
  84487. if (cs !== s) {
  84488. cs = s;
  84489. }
  84490. }
  84491. }
  84492. // indices
  84493. var e = (arc !== 1 && enclose) ? tessellation + 4 : tessellation; // correction of number of iteration if enclose
  84494. var s;
  84495. i = 0;
  84496. for (s = 0; s < subdivisions; s++) {
  84497. var i0 = 0;
  84498. var i1 = 0;
  84499. var i2 = 0;
  84500. var i3 = 0;
  84501. for (j = 0; j < tessellation; j++) {
  84502. i0 = i * (e + 1) + j;
  84503. i1 = (i + 1) * (e + 1) + j;
  84504. i2 = i * (e + 1) + (j + 1);
  84505. i3 = (i + 1) * (e + 1) + (j + 1);
  84506. indices.push(i0, i1, i2);
  84507. indices.push(i3, i2, i1);
  84508. }
  84509. if (arc !== 1 && enclose) { // if enclose, add two quads
  84510. indices.push(i0 + 2, i1 + 2, i2 + 2);
  84511. indices.push(i3 + 2, i2 + 2, i1 + 2);
  84512. indices.push(i0 + 4, i1 + 4, i2 + 4);
  84513. indices.push(i3 + 4, i2 + 4, i1 + 4);
  84514. }
  84515. i = (hasRings) ? (i + 2) : (i + 1);
  84516. }
  84517. // Caps
  84518. var createCylinderCap = function (isTop) {
  84519. var radius = isTop ? diameterTop / 2 : diameterBottom / 2;
  84520. if (radius === 0) {
  84521. return;
  84522. }
  84523. // Cap positions, normals & uvs
  84524. var angle;
  84525. var circleVector;
  84526. var i;
  84527. var u = (isTop) ? faceUV[surfaceNb - 1] : faceUV[0];
  84528. var c = null;
  84529. if (faceColors) {
  84530. c = (isTop) ? faceColors[surfaceNb - 1] : faceColors[0];
  84531. }
  84532. // cap center
  84533. var vbase = positions.length / 3;
  84534. var offset = isTop ? height / 2 : -height / 2;
  84535. var center = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, offset, 0);
  84536. positions.push(center.x, center.y, center.z);
  84537. normals.push(0, isTop ? 1 : -1, 0);
  84538. uvs.push(u.x + (u.z - u.x) * 0.5, u.y + (u.w - u.y) * 0.5);
  84539. if (c) {
  84540. colors.push(c.r, c.g, c.b, c.a);
  84541. }
  84542. var textureScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0.5, 0.5);
  84543. for (i = 0; i <= tessellation; i++) {
  84544. angle = Math.PI * 2 * i * arc / tessellation;
  84545. var cos = Math.cos(-angle);
  84546. var sin = Math.sin(-angle);
  84547. circleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](cos * radius, offset, sin * radius);
  84548. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](cos * textureScale.x + 0.5, sin * textureScale.y + 0.5);
  84549. positions.push(circleVector.x, circleVector.y, circleVector.z);
  84550. normals.push(0, isTop ? 1 : -1, 0);
  84551. uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, u.y + (u.w - u.y) * textureCoordinate.y);
  84552. if (c) {
  84553. colors.push(c.r, c.g, c.b, c.a);
  84554. }
  84555. }
  84556. // Cap indices
  84557. for (i = 0; i < tessellation; i++) {
  84558. if (!isTop) {
  84559. indices.push(vbase);
  84560. indices.push(vbase + (i + 1));
  84561. indices.push(vbase + (i + 2));
  84562. }
  84563. else {
  84564. indices.push(vbase);
  84565. indices.push(vbase + (i + 2));
  84566. indices.push(vbase + (i + 1));
  84567. }
  84568. }
  84569. };
  84570. // add caps to geometry
  84571. createCylinderCap(false);
  84572. createCylinderCap(true);
  84573. // Sides
  84574. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  84575. var vertexData = new VertexData();
  84576. vertexData.indices = indices;
  84577. vertexData.positions = positions;
  84578. vertexData.normals = normals;
  84579. vertexData.uvs = uvs;
  84580. if (faceColors) {
  84581. vertexData.colors = colors;
  84582. }
  84583. return vertexData;
  84584. };
  84585. /**
  84586. * Creates the VertexData for a torus
  84587. * @param options an object used to set the following optional parameters for the box, required but can be empty
  84588. * * diameter the diameter of the torus, optional default 1
  84589. * * thickness the diameter of the tube forming the torus, optional default 0.5
  84590. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  84591. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84592. * * 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)
  84593. * * 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)
  84594. * @returns the VertexData of the torus
  84595. */
  84596. VertexData.CreateTorus = function (options) {
  84597. var indices = [];
  84598. var positions = [];
  84599. var normals = [];
  84600. var uvs = [];
  84601. var diameter = options.diameter || 1;
  84602. var thickness = options.thickness || 0.5;
  84603. var tessellation = options.tessellation || 16;
  84604. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  84605. var stride = tessellation + 1;
  84606. for (var i = 0; i <= tessellation; i++) {
  84607. var u = i / tessellation;
  84608. var outerAngle = i * Math.PI * 2.0 / tessellation - Math.PI / 2.0;
  84609. 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));
  84610. for (var j = 0; j <= tessellation; j++) {
  84611. var v = 1 - j / tessellation;
  84612. var innerAngle = j * Math.PI * 2.0 / tessellation + Math.PI;
  84613. var dx = Math.cos(innerAngle);
  84614. var dy = Math.sin(innerAngle);
  84615. // Create a vertex.
  84616. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](dx, dy, 0);
  84617. var position = normal.scale(thickness / 2);
  84618. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](u, v);
  84619. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(position, transform);
  84620. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, transform);
  84621. positions.push(position.x, position.y, position.z);
  84622. normals.push(normal.x, normal.y, normal.z);
  84623. uvs.push(textureCoordinate.x, textureCoordinate.y);
  84624. // And create indices for two triangles.
  84625. var nextI = (i + 1) % stride;
  84626. var nextJ = (j + 1) % stride;
  84627. indices.push(i * stride + j);
  84628. indices.push(i * stride + nextJ);
  84629. indices.push(nextI * stride + j);
  84630. indices.push(i * stride + nextJ);
  84631. indices.push(nextI * stride + nextJ);
  84632. indices.push(nextI * stride + j);
  84633. }
  84634. }
  84635. // Sides
  84636. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  84637. // Result
  84638. var vertexData = new VertexData();
  84639. vertexData.indices = indices;
  84640. vertexData.positions = positions;
  84641. vertexData.normals = normals;
  84642. vertexData.uvs = uvs;
  84643. return vertexData;
  84644. };
  84645. /**
  84646. * Creates the VertexData of the LineSystem
  84647. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  84648. * - lines an array of lines, each line being an array of successive Vector3
  84649. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  84650. * @returns the VertexData of the LineSystem
  84651. */
  84652. VertexData.CreateLineSystem = function (options) {
  84653. var indices = [];
  84654. var positions = [];
  84655. var lines = options.lines;
  84656. var colors = options.colors;
  84657. var vertexColors = [];
  84658. var idx = 0;
  84659. for (var l = 0; l < lines.length; l++) {
  84660. var points = lines[l];
  84661. for (var index = 0; index < points.length; index++) {
  84662. positions.push(points[index].x, points[index].y, points[index].z);
  84663. if (colors) {
  84664. var color = colors[l];
  84665. vertexColors.push(color[index].r, color[index].g, color[index].b, color[index].a);
  84666. }
  84667. if (index > 0) {
  84668. indices.push(idx - 1);
  84669. indices.push(idx);
  84670. }
  84671. idx++;
  84672. }
  84673. }
  84674. var vertexData = new VertexData();
  84675. vertexData.indices = indices;
  84676. vertexData.positions = positions;
  84677. if (colors) {
  84678. vertexData.colors = vertexColors;
  84679. }
  84680. return vertexData;
  84681. };
  84682. /**
  84683. * Create the VertexData for a DashedLines
  84684. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  84685. * - points an array successive Vector3
  84686. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  84687. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  84688. * - dashNb the intended total number of dashes, optional, default 200
  84689. * @returns the VertexData for the DashedLines
  84690. */
  84691. VertexData.CreateDashedLines = function (options) {
  84692. var dashSize = options.dashSize || 3;
  84693. var gapSize = options.gapSize || 1;
  84694. var dashNb = options.dashNb || 200;
  84695. var points = options.points;
  84696. var positions = new Array();
  84697. var indices = new Array();
  84698. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  84699. var lg = 0;
  84700. var nb = 0;
  84701. var shft = 0;
  84702. var dashshft = 0;
  84703. var curshft = 0;
  84704. var idx = 0;
  84705. var i = 0;
  84706. for (i = 0; i < points.length - 1; i++) {
  84707. points[i + 1].subtractToRef(points[i], curvect);
  84708. lg += curvect.length();
  84709. }
  84710. shft = lg / dashNb;
  84711. dashshft = dashSize * shft / (dashSize + gapSize);
  84712. for (i = 0; i < points.length - 1; i++) {
  84713. points[i + 1].subtractToRef(points[i], curvect);
  84714. nb = Math.floor(curvect.length() / shft);
  84715. curvect.normalize();
  84716. for (var j = 0; j < nb; j++) {
  84717. curshft = shft * j;
  84718. positions.push(points[i].x + curshft * curvect.x, points[i].y + curshft * curvect.y, points[i].z + curshft * curvect.z);
  84719. positions.push(points[i].x + (curshft + dashshft) * curvect.x, points[i].y + (curshft + dashshft) * curvect.y, points[i].z + (curshft + dashshft) * curvect.z);
  84720. indices.push(idx, idx + 1);
  84721. idx += 2;
  84722. }
  84723. }
  84724. // Result
  84725. var vertexData = new VertexData();
  84726. vertexData.positions = positions;
  84727. vertexData.indices = indices;
  84728. return vertexData;
  84729. };
  84730. /**
  84731. * Creates the VertexData for a Ground
  84732. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  84733. * - width the width (x direction) of the ground, optional, default 1
  84734. * - height the height (z direction) of the ground, optional, default 1
  84735. * - subdivisions the number of subdivisions per side, optional, default 1
  84736. * @returns the VertexData of the Ground
  84737. */
  84738. VertexData.CreateGround = function (options) {
  84739. var indices = [];
  84740. var positions = [];
  84741. var normals = [];
  84742. var uvs = [];
  84743. var row, col;
  84744. var width = options.width || 1;
  84745. var height = options.height || 1;
  84746. var subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  84747. var subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  84748. for (row = 0; row <= subdivisionsY; row++) {
  84749. for (col = 0; col <= subdivisionsX; col++) {
  84750. var position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((col * width) / subdivisionsX - (width / 2.0), 0, ((subdivisionsY - row) * height) / subdivisionsY - (height / 2.0));
  84751. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  84752. positions.push(position.x, position.y, position.z);
  84753. normals.push(normal.x, normal.y, normal.z);
  84754. uvs.push(col / subdivisionsX, 1.0 - row / subdivisionsY);
  84755. }
  84756. }
  84757. for (row = 0; row < subdivisionsY; row++) {
  84758. for (col = 0; col < subdivisionsX; col++) {
  84759. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  84760. indices.push(col + 1 + row * (subdivisionsX + 1));
  84761. indices.push(col + row * (subdivisionsX + 1));
  84762. indices.push(col + (row + 1) * (subdivisionsX + 1));
  84763. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  84764. indices.push(col + row * (subdivisionsX + 1));
  84765. }
  84766. }
  84767. // Result
  84768. var vertexData = new VertexData();
  84769. vertexData.indices = indices;
  84770. vertexData.positions = positions;
  84771. vertexData.normals = normals;
  84772. vertexData.uvs = uvs;
  84773. return vertexData;
  84774. };
  84775. /**
  84776. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  84777. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  84778. * * xmin the ground minimum X coordinate, optional, default -1
  84779. * * zmin the ground minimum Z coordinate, optional, default -1
  84780. * * xmax the ground maximum X coordinate, optional, default 1
  84781. * * zmax the ground maximum Z coordinate, optional, default 1
  84782. * * 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}
  84783. * * 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}
  84784. * @returns the VertexData of the TiledGround
  84785. */
  84786. VertexData.CreateTiledGround = function (options) {
  84787. var xmin = (options.xmin !== undefined && options.xmin !== null) ? options.xmin : -1.0;
  84788. var zmin = (options.zmin !== undefined && options.zmin !== null) ? options.zmin : -1.0;
  84789. var xmax = (options.xmax !== undefined && options.xmax !== null) ? options.xmax : 1.0;
  84790. var zmax = (options.zmax !== undefined && options.zmax !== null) ? options.zmax : 1.0;
  84791. var subdivisions = options.subdivisions || { w: 1, h: 1 };
  84792. var precision = options.precision || { w: 1, h: 1 };
  84793. var indices = new Array();
  84794. var positions = new Array();
  84795. var normals = new Array();
  84796. var uvs = new Array();
  84797. var row, col, tileRow, tileCol;
  84798. subdivisions.h = (subdivisions.h < 1) ? 1 : subdivisions.h;
  84799. subdivisions.w = (subdivisions.w < 1) ? 1 : subdivisions.w;
  84800. precision.w = (precision.w < 1) ? 1 : precision.w;
  84801. precision.h = (precision.h < 1) ? 1 : precision.h;
  84802. var tileSize = {
  84803. 'w': (xmax - xmin) / subdivisions.w,
  84804. 'h': (zmax - zmin) / subdivisions.h
  84805. };
  84806. function applyTile(xTileMin, zTileMin, xTileMax, zTileMax) {
  84807. // Indices
  84808. var base = positions.length / 3;
  84809. var rowLength = precision.w + 1;
  84810. for (row = 0; row < precision.h; row++) {
  84811. for (col = 0; col < precision.w; col++) {
  84812. var square = [
  84813. base + col + row * rowLength,
  84814. base + (col + 1) + row * rowLength,
  84815. base + (col + 1) + (row + 1) * rowLength,
  84816. base + col + (row + 1) * rowLength
  84817. ];
  84818. indices.push(square[1]);
  84819. indices.push(square[2]);
  84820. indices.push(square[3]);
  84821. indices.push(square[0]);
  84822. indices.push(square[1]);
  84823. indices.push(square[3]);
  84824. }
  84825. }
  84826. // Position, normals and uvs
  84827. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  84828. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  84829. for (row = 0; row <= precision.h; row++) {
  84830. position.z = (row * (zTileMax - zTileMin)) / precision.h + zTileMin;
  84831. for (col = 0; col <= precision.w; col++) {
  84832. position.x = (col * (xTileMax - xTileMin)) / precision.w + xTileMin;
  84833. position.y = 0;
  84834. positions.push(position.x, position.y, position.z);
  84835. normals.push(normal.x, normal.y, normal.z);
  84836. uvs.push(col / precision.w, row / precision.h);
  84837. }
  84838. }
  84839. }
  84840. for (tileRow = 0; tileRow < subdivisions.h; tileRow++) {
  84841. for (tileCol = 0; tileCol < subdivisions.w; tileCol++) {
  84842. applyTile(xmin + tileCol * tileSize.w, zmin + tileRow * tileSize.h, xmin + (tileCol + 1) * tileSize.w, zmin + (tileRow + 1) * tileSize.h);
  84843. }
  84844. }
  84845. // Result
  84846. var vertexData = new VertexData();
  84847. vertexData.indices = indices;
  84848. vertexData.positions = positions;
  84849. vertexData.normals = normals;
  84850. vertexData.uvs = uvs;
  84851. return vertexData;
  84852. };
  84853. /**
  84854. * Creates the VertexData of the Ground designed from a heightmap
  84855. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  84856. * * width the width (x direction) of the ground
  84857. * * height the height (z direction) of the ground
  84858. * * subdivisions the number of subdivisions per side
  84859. * * minHeight the minimum altitude on the ground, optional, default 0
  84860. * * maxHeight the maximum altitude on the ground, optional default 1
  84861. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  84862. * * buffer the array holding the image color data
  84863. * * bufferWidth the width of image
  84864. * * bufferHeight the height of image
  84865. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  84866. * @returns the VertexData of the Ground designed from a heightmap
  84867. */
  84868. VertexData.CreateGroundFromHeightMap = function (options) {
  84869. var indices = [];
  84870. var positions = [];
  84871. var normals = [];
  84872. var uvs = [];
  84873. var row, col;
  84874. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  84875. var alphaFilter = options.alphaFilter || 0.0;
  84876. // Vertices
  84877. for (row = 0; row <= options.subdivisions; row++) {
  84878. for (col = 0; col <= options.subdivisions; col++) {
  84879. 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));
  84880. // Compute height
  84881. var heightMapX = (((position.x + options.width / 2) / options.width) * (options.bufferWidth - 1)) | 0;
  84882. var heightMapY = ((1.0 - (position.z + options.height / 2) / options.height) * (options.bufferHeight - 1)) | 0;
  84883. var pos = (heightMapX + heightMapY * options.bufferWidth) * 4;
  84884. var r = options.buffer[pos] / 255.0;
  84885. var g = options.buffer[pos + 1] / 255.0;
  84886. var b = options.buffer[pos + 2] / 255.0;
  84887. var a = options.buffer[pos + 3] / 255.0;
  84888. var gradient = r * filter.r + g * filter.g + b * filter.b;
  84889. // If our alpha channel is not within our filter then we will assign a 'special' height
  84890. // Then when building the indices, we will ignore any vertex that is using the special height
  84891. if (a >= alphaFilter) {
  84892. position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient;
  84893. }
  84894. else {
  84895. position.y = options.minHeight - _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; // We can't have a height below minHeight, normally.
  84896. }
  84897. // Add vertex
  84898. positions.push(position.x, position.y, position.z);
  84899. normals.push(0, 0, 0);
  84900. uvs.push(col / options.subdivisions, 1.0 - row / options.subdivisions);
  84901. }
  84902. }
  84903. // Indices
  84904. for (row = 0; row < options.subdivisions; row++) {
  84905. for (col = 0; col < options.subdivisions; col++) {
  84906. // Calculate Indices
  84907. var idx1 = (col + 1 + (row + 1) * (options.subdivisions + 1));
  84908. var idx2 = (col + 1 + row * (options.subdivisions + 1));
  84909. var idx3 = (col + row * (options.subdivisions + 1));
  84910. var idx4 = (col + (row + 1) * (options.subdivisions + 1));
  84911. // Check that all indices are visible (based on our special height)
  84912. // Only display the vertex if all Indices are visible
  84913. // Positions are stored x,y,z for each vertex, hence the * 3 and + 1 for height
  84914. var isVisibleIdx1 = positions[idx1 * 3 + 1] >= options.minHeight;
  84915. var isVisibleIdx2 = positions[idx2 * 3 + 1] >= options.minHeight;
  84916. var isVisibleIdx3 = positions[idx3 * 3 + 1] >= options.minHeight;
  84917. if (isVisibleIdx1 && isVisibleIdx2 && isVisibleIdx3) {
  84918. indices.push(idx1);
  84919. indices.push(idx2);
  84920. indices.push(idx3);
  84921. }
  84922. var isVisibleIdx4 = positions[idx4 * 3 + 1] >= options.minHeight;
  84923. if (isVisibleIdx4 && isVisibleIdx1 && isVisibleIdx3) {
  84924. indices.push(idx4);
  84925. indices.push(idx1);
  84926. indices.push(idx3);
  84927. }
  84928. }
  84929. }
  84930. // Normals
  84931. VertexData.ComputeNormals(positions, indices, normals);
  84932. // Result
  84933. var vertexData = new VertexData();
  84934. vertexData.indices = indices;
  84935. vertexData.positions = positions;
  84936. vertexData.normals = normals;
  84937. vertexData.uvs = uvs;
  84938. return vertexData;
  84939. };
  84940. /**
  84941. * Creates the VertexData for a Plane
  84942. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  84943. * * size sets the width and height of the plane to the value of size, optional default 1
  84944. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  84945. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  84946. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84947. * * 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)
  84948. * * 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)
  84949. * @returns the VertexData of the box
  84950. */
  84951. VertexData.CreatePlane = function (options) {
  84952. var indices = [];
  84953. var positions = [];
  84954. var normals = [];
  84955. var uvs = [];
  84956. var width = options.width || options.size || 1;
  84957. var height = options.height || options.size || 1;
  84958. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  84959. // Vertices
  84960. var halfWidth = width / 2.0;
  84961. var halfHeight = height / 2.0;
  84962. positions.push(-halfWidth, -halfHeight, 0);
  84963. normals.push(0, 0, -1.0);
  84964. uvs.push(0.0, 0.0);
  84965. positions.push(halfWidth, -halfHeight, 0);
  84966. normals.push(0, 0, -1.0);
  84967. uvs.push(1.0, 0.0);
  84968. positions.push(halfWidth, halfHeight, 0);
  84969. normals.push(0, 0, -1.0);
  84970. uvs.push(1.0, 1.0);
  84971. positions.push(-halfWidth, halfHeight, 0);
  84972. normals.push(0, 0, -1.0);
  84973. uvs.push(0.0, 1.0);
  84974. // Indices
  84975. indices.push(0);
  84976. indices.push(1);
  84977. indices.push(2);
  84978. indices.push(0);
  84979. indices.push(2);
  84980. indices.push(3);
  84981. // Sides
  84982. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  84983. // Result
  84984. var vertexData = new VertexData();
  84985. vertexData.indices = indices;
  84986. vertexData.positions = positions;
  84987. vertexData.normals = normals;
  84988. vertexData.uvs = uvs;
  84989. return vertexData;
  84990. };
  84991. /**
  84992. * Creates the VertexData of the Disc or regular Polygon
  84993. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  84994. * * radius the radius of the disc, optional default 0.5
  84995. * * tessellation the number of polygon sides, optional, default 64
  84996. * * 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
  84997. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84998. * * 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)
  84999. * * 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)
  85000. * @returns the VertexData of the box
  85001. */
  85002. VertexData.CreateDisc = function (options) {
  85003. var positions = new Array();
  85004. var indices = new Array();
  85005. var normals = new Array();
  85006. var uvs = new Array();
  85007. var radius = options.radius || 0.5;
  85008. var tessellation = options.tessellation || 64;
  85009. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  85010. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  85011. // positions and uvs
  85012. positions.push(0, 0, 0); // disc center first
  85013. uvs.push(0.5, 0.5);
  85014. var theta = Math.PI * 2 * arc;
  85015. var step = theta / tessellation;
  85016. for (var a = 0; a < theta; a += step) {
  85017. var x = Math.cos(a);
  85018. var y = Math.sin(a);
  85019. var u = (x + 1) / 2;
  85020. var v = (1 - y) / 2;
  85021. positions.push(radius * x, radius * y, 0);
  85022. uvs.push(u, v);
  85023. }
  85024. if (arc === 1) {
  85025. positions.push(positions[3], positions[4], positions[5]); // close the circle
  85026. uvs.push(uvs[2], uvs[3]);
  85027. }
  85028. //indices
  85029. var vertexNb = positions.length / 3;
  85030. for (var i = 1; i < vertexNb - 1; i++) {
  85031. indices.push(i + 1, 0, i);
  85032. }
  85033. // result
  85034. VertexData.ComputeNormals(positions, indices, normals);
  85035. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  85036. var vertexData = new VertexData();
  85037. vertexData.indices = indices;
  85038. vertexData.positions = positions;
  85039. vertexData.normals = normals;
  85040. vertexData.uvs = uvs;
  85041. return vertexData;
  85042. };
  85043. /**
  85044. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  85045. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  85046. * @param polygon a mesh built from polygonTriangulation.build()
  85047. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85048. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85049. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85050. * @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)
  85051. * @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)
  85052. * @returns the VertexData of the Polygon
  85053. */
  85054. VertexData.CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  85055. var faceUV = fUV || new Array(3);
  85056. var faceColors = fColors;
  85057. var colors = [];
  85058. // default face colors and UV if undefined
  85059. for (var f = 0; f < 3; f++) {
  85060. if (faceUV[f] === undefined) {
  85061. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  85062. }
  85063. if (faceColors && faceColors[f] === undefined) {
  85064. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  85065. }
  85066. }
  85067. var positions = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  85068. var normals = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  85069. var uvs = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  85070. var indices = polygon.getIndices();
  85071. // set face colours and textures
  85072. var idx = 0;
  85073. var face = 0;
  85074. for (var index = 0; index < normals.length; index += 3) {
  85075. //Edge Face no. 1
  85076. if (Math.abs(normals[index + 1]) < 0.001) {
  85077. face = 1;
  85078. }
  85079. //Top Face no. 0
  85080. if (Math.abs(normals[index + 1] - 1) < 0.001) {
  85081. face = 0;
  85082. }
  85083. //Bottom Face no. 2
  85084. if (Math.abs(normals[index + 1] + 1) < 0.001) {
  85085. face = 2;
  85086. }
  85087. idx = index / 3;
  85088. uvs[2 * idx] = (1 - uvs[2 * idx]) * faceUV[face].x + uvs[2 * idx] * faceUV[face].z;
  85089. uvs[2 * idx + 1] = (1 - uvs[2 * idx + 1]) * faceUV[face].y + uvs[2 * idx + 1] * faceUV[face].w;
  85090. if (faceColors) {
  85091. colors.push(faceColors[face].r, faceColors[face].g, faceColors[face].b, faceColors[face].a);
  85092. }
  85093. }
  85094. // sides
  85095. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs);
  85096. // Result
  85097. var vertexData = new VertexData();
  85098. vertexData.indices = indices;
  85099. vertexData.positions = positions;
  85100. vertexData.normals = normals;
  85101. vertexData.uvs = uvs;
  85102. if (faceColors) {
  85103. var totalColors = (sideOrientation === VertexData.DOUBLESIDE) ? colors.concat(colors) : colors;
  85104. vertexData.colors = totalColors;
  85105. }
  85106. return vertexData;
  85107. };
  85108. /**
  85109. * Creates the VertexData of the IcoSphere
  85110. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  85111. * * radius the radius of the IcoSphere, optional default 1
  85112. * * radiusX allows stretching in the x direction, optional, default radius
  85113. * * radiusY allows stretching in the y direction, optional, default radius
  85114. * * radiusZ allows stretching in the z direction, optional, default radius
  85115. * * flat when true creates a flat shaded mesh, optional, default true
  85116. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85117. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85118. * * 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)
  85119. * * 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)
  85120. * @returns the VertexData of the IcoSphere
  85121. */
  85122. VertexData.CreateIcoSphere = function (options) {
  85123. var sideOrientation = options.sideOrientation || VertexData.DEFAULTSIDE;
  85124. var radius = options.radius || 1;
  85125. var flat = (options.flat === undefined) ? true : options.flat;
  85126. var subdivisions = options.subdivisions || 4;
  85127. var radiusX = options.radiusX || radius;
  85128. var radiusY = options.radiusY || radius;
  85129. var radiusZ = options.radiusZ || radius;
  85130. var t = (1 + Math.sqrt(5)) / 2;
  85131. // 12 vertex x,y,z
  85132. var ico_vertices = [
  85133. -1, t, -0, 1, t, 0, -1, -t, 0, 1, -t, 0,
  85134. 0, -1, -t, 0, 1, -t, 0, -1, t, 0, 1, t,
  85135. t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, -1 // v8-11
  85136. ];
  85137. // index of 3 vertex makes a face of icopshere
  85138. var ico_indices = [
  85139. 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23,
  85140. 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8,
  85141. 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9,
  85142. 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1
  85143. ];
  85144. // vertex for uv have aliased position, not for UV
  85145. var vertices_unalias_id = [
  85146. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  85147. // vertex alias
  85148. 0,
  85149. 2,
  85150. 3,
  85151. 3,
  85152. 3,
  85153. 4,
  85154. 7,
  85155. 8,
  85156. 9,
  85157. 9,
  85158. 10,
  85159. 11 // 23: B + 12
  85160. ];
  85161. // uv as integer step (not pixels !)
  85162. var ico_vertexuv = [
  85163. 5, 1, 3, 1, 6, 4, 0, 0,
  85164. 5, 3, 4, 2, 2, 2, 4, 0,
  85165. 2, 0, 1, 1, 6, 0, 6, 2,
  85166. // vertex alias (for same vertex on different faces)
  85167. 0, 4,
  85168. 3, 3,
  85169. 4, 4,
  85170. 3, 1,
  85171. 4, 2,
  85172. 4, 4,
  85173. 0, 2,
  85174. 1, 1,
  85175. 2, 2,
  85176. 3, 3,
  85177. 1, 3,
  85178. 2, 4 // 23: B + 12
  85179. ];
  85180. // Vertices[0, 1, ...9, A, B] : position on UV plane
  85181. // '+' indicate duplicate position to be fixed (3,9:0,2,3,4,7,8,A,B)
  85182. // First island of uv mapping
  85183. // v = 4h 3+ 2
  85184. // v = 3h 9+ 4
  85185. // v = 2h 9+ 5 B
  85186. // v = 1h 9 1 0
  85187. // v = 0h 3 8 7 A
  85188. // u = 0 1 2 3 4 5 6 *a
  85189. // Second island of uv mapping
  85190. // v = 4h 0+ B+ 4+
  85191. // v = 3h A+ 2+
  85192. // v = 2h 7+ 6 3+
  85193. // v = 1h 8+ 3+
  85194. // v = 0h
  85195. // u = 0 1 2 3 4 5 6 *a
  85196. // Face layout on texture UV mapping
  85197. // ============
  85198. // \ 4 /\ 16 / ======
  85199. // \ / \ / /\ 11 /
  85200. // \/ 7 \/ / \ /
  85201. // ======= / 10 \/
  85202. // /\ 17 /\ =======
  85203. // / \ / \ \ 15 /\
  85204. // / 8 \/ 12 \ \ / \
  85205. // ============ \/ 6 \
  85206. // \ 18 /\ ============
  85207. // \ / \ \ 5 /\ 0 /
  85208. // \/ 13 \ \ / \ /
  85209. // ======= \/ 1 \/
  85210. // =============
  85211. // /\ 19 /\ 2 /\
  85212. // / \ / \ / \
  85213. // / 14 \/ 9 \/ 3 \
  85214. // ===================
  85215. // uv step is u:1 or 0.5, v:cos(30)=sqrt(3)/2, ratio approx is 84/97
  85216. var ustep = 138 / 1024;
  85217. var vstep = 239 / 1024;
  85218. var uoffset = 60 / 1024;
  85219. var voffset = 26 / 1024;
  85220. // Second island should have margin, not to touch the first island
  85221. // avoid any borderline artefact in pixel rounding
  85222. var island_u_offset = -40 / 1024;
  85223. var island_v_offset = +20 / 1024;
  85224. // face is either island 0 or 1 :
  85225. // second island is for faces : [4, 7, 8, 12, 13, 16, 17, 18]
  85226. var island = [
  85227. 0, 0, 0, 0, 1,
  85228. 0, 0, 1, 1, 0,
  85229. 0, 0, 1, 1, 0,
  85230. 0, 1, 1, 1, 0 // 15 - 19
  85231. ];
  85232. var indices = new Array();
  85233. var positions = new Array();
  85234. var normals = new Array();
  85235. var uvs = new Array();
  85236. var current_indice = 0;
  85237. // prepare array of 3 vector (empty) (to be worked in place, shared for each face)
  85238. var face_vertex_pos = new Array(3);
  85239. var face_vertex_uv = new Array(3);
  85240. var v012;
  85241. for (v012 = 0; v012 < 3; v012++) {
  85242. face_vertex_pos[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  85243. face_vertex_uv[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  85244. }
  85245. // create all with normals
  85246. for (var face = 0; face < 20; face++) {
  85247. // 3 vertex per face
  85248. for (v012 = 0; v012 < 3; v012++) {
  85249. // look up vertex 0,1,2 to its index in 0 to 11 (or 23 including alias)
  85250. var v_id = ico_indices[3 * face + v012];
  85251. // vertex have 3D position (x,y,z)
  85252. 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]);
  85253. // Normalize to get normal, then scale to radius
  85254. face_vertex_pos[v012].normalize().scaleInPlace(radius);
  85255. // uv Coordinates from vertex ID
  85256. 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);
  85257. }
  85258. // Subdivide the face (interpolate pos, norm, uv)
  85259. // - pos is linear interpolation, then projected to sphere (converge polyhedron to sphere)
  85260. // - norm is linear interpolation of vertex corner normal
  85261. // (to be checked if better to re-calc from face vertex, or if approximation is OK ??? )
  85262. // - uv is linear interpolation
  85263. //
  85264. // Topology is as below for sub-divide by 2
  85265. // vertex shown as v0,v1,v2
  85266. // interp index is i1 to progress in range [v0,v1[
  85267. // interp index is i2 to progress in range [v0,v2[
  85268. // face index as (i1,i2) for /\ : (i1,i2),(i1+1,i2),(i1,i2+1)
  85269. // and (i1,i2)' for \/ : (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  85270. //
  85271. //
  85272. // i2 v2
  85273. // ^ ^
  85274. // / / \
  85275. // / / \
  85276. // / / \
  85277. // / / (0,1) \
  85278. // / #---------\
  85279. // / / \ (0,0)'/ \
  85280. // / / \ / \
  85281. // / / \ / \
  85282. // / / (0,0) \ / (1,0) \
  85283. // / #---------#---------\
  85284. // v0 v1
  85285. //
  85286. // --------------------> i1
  85287. //
  85288. // interp of (i1,i2):
  85289. // along i2 : x0=lerp(v0,v2, i2/S) <---> x1=lerp(v1,v2, i2/S)
  85290. // along i1 : lerp(x0,x1, i1/(S-i2))
  85291. //
  85292. // centroid of triangle is needed to get help normal computation
  85293. // (c1,c2) are used for centroid location
  85294. var interp_vertex = function (i1, i2, c1, c2) {
  85295. // vertex is interpolated from
  85296. // - face_vertex_pos[0..2]
  85297. // - face_vertex_uv[0..2]
  85298. var pos_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], i2 / subdivisions);
  85299. var pos_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], i2 / subdivisions);
  85300. var pos_interp = (subdivisions === i2) ? face_vertex_pos[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(pos_x0, pos_x1, i1 / (subdivisions - i2));
  85301. pos_interp.normalize();
  85302. var vertex_normal;
  85303. if (flat) {
  85304. // in flat mode, recalculate normal as face centroid normal
  85305. var centroid_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], c2 / subdivisions);
  85306. var centroid_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], c2 / subdivisions);
  85307. vertex_normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(centroid_x0, centroid_x1, c1 / (subdivisions - c2));
  85308. }
  85309. else {
  85310. // in smooth mode, recalculate normal from each single vertex position
  85311. vertex_normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pos_interp.x, pos_interp.y, pos_interp.z);
  85312. }
  85313. // Vertex normal need correction due to X,Y,Z radius scaling
  85314. vertex_normal.x /= radiusX;
  85315. vertex_normal.y /= radiusY;
  85316. vertex_normal.z /= radiusZ;
  85317. vertex_normal.normalize();
  85318. var uv_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[0], face_vertex_uv[2], i2 / subdivisions);
  85319. var uv_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[1], face_vertex_uv[2], i2 / subdivisions);
  85320. var uv_interp = (subdivisions === i2) ? face_vertex_uv[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(uv_x0, uv_x1, i1 / (subdivisions - i2));
  85321. positions.push(pos_interp.x * radiusX, pos_interp.y * radiusY, pos_interp.z * radiusZ);
  85322. normals.push(vertex_normal.x, vertex_normal.y, vertex_normal.z);
  85323. uvs.push(uv_interp.x, uv_interp.y);
  85324. // push each vertex has member of a face
  85325. // Same vertex can bleong to multiple face, it is pushed multiple time (duplicate vertex are present)
  85326. indices.push(current_indice);
  85327. current_indice++;
  85328. };
  85329. for (var i2 = 0; i2 < subdivisions; i2++) {
  85330. for (var i1 = 0; i1 + i2 < subdivisions; i1++) {
  85331. // face : (i1,i2) for /\ :
  85332. // interp for : (i1,i2),(i1+1,i2),(i1,i2+1)
  85333. interp_vertex(i1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  85334. interp_vertex(i1 + 1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  85335. interp_vertex(i1, i2 + 1, i1 + 1.0 / 3, i2 + 1.0 / 3);
  85336. if (i1 + i2 + 1 < subdivisions) {
  85337. // face : (i1,i2)' for \/ :
  85338. // interp for (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  85339. interp_vertex(i1 + 1, i2, i1 + 2.0 / 3, i2 + 2.0 / 3);
  85340. interp_vertex(i1 + 1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  85341. interp_vertex(i1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  85342. }
  85343. }
  85344. }
  85345. }
  85346. // Sides
  85347. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  85348. // Result
  85349. var vertexData = new VertexData();
  85350. vertexData.indices = indices;
  85351. vertexData.positions = positions;
  85352. vertexData.normals = normals;
  85353. vertexData.uvs = uvs;
  85354. return vertexData;
  85355. };
  85356. // inspired from // http://stemkoski.github.io/Three.js/Polyhedra.html
  85357. /**
  85358. * Creates the VertexData for a Polyhedron
  85359. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  85360. * * type provided types are:
  85361. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  85362. * * 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)
  85363. * * size the size of the IcoSphere, optional default 1
  85364. * * sizeX allows stretching in the x direction, optional, default size
  85365. * * sizeY allows stretching in the y direction, optional, default size
  85366. * * sizeZ allows stretching in the z direction, optional, default size
  85367. * * 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
  85368. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85369. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85370. * * flat when true creates a flat shaded mesh, optional, default true
  85371. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85372. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85373. * * 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)
  85374. * * 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)
  85375. * @returns the VertexData of the Polyhedron
  85376. */
  85377. VertexData.CreatePolyhedron = function (options) {
  85378. // provided polyhedron types :
  85379. // 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  85380. // 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)
  85381. var polyhedra = [];
  85382. 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]] };
  85383. 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]] };
  85384. polyhedra[2] = {
  85385. 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]],
  85386. 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]]
  85387. };
  85388. polyhedra[3] = {
  85389. 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]],
  85390. 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]]
  85391. };
  85392. polyhedra[4] = {
  85393. 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]],
  85394. 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]]
  85395. };
  85396. 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]] };
  85397. 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]] };
  85398. 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]] };
  85399. 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]] };
  85400. 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]] };
  85401. 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]] };
  85402. 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]] };
  85403. 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]] };
  85404. 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]] };
  85405. polyhedra[14] = {
  85406. 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]],
  85407. 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]]
  85408. };
  85409. var type = options.type && (options.type < 0 || options.type >= polyhedra.length) ? 0 : options.type || 0;
  85410. var size = options.size;
  85411. var sizeX = options.sizeX || size || 1;
  85412. var sizeY = options.sizeY || size || 1;
  85413. var sizeZ = options.sizeZ || size || 1;
  85414. var data = options.custom || polyhedra[type];
  85415. var nbfaces = data.face.length;
  85416. var faceUV = options.faceUV || new Array(nbfaces);
  85417. var faceColors = options.faceColors;
  85418. var flat = (options.flat === undefined) ? true : options.flat;
  85419. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  85420. var positions = new Array();
  85421. var indices = new Array();
  85422. var normals = new Array();
  85423. var uvs = new Array();
  85424. var colors = new Array();
  85425. var index = 0;
  85426. var faceIdx = 0; // face cursor in the array "indexes"
  85427. var indexes = new Array();
  85428. var i = 0;
  85429. var f = 0;
  85430. var u, v, ang, x, y, tmp;
  85431. // default face colors and UV if undefined
  85432. if (flat) {
  85433. for (f = 0; f < nbfaces; f++) {
  85434. if (faceColors && faceColors[f] === undefined) {
  85435. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  85436. }
  85437. if (faceUV && faceUV[f] === undefined) {
  85438. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  85439. }
  85440. }
  85441. }
  85442. if (!flat) {
  85443. for (i = 0; i < data.vertex.length; i++) {
  85444. positions.push(data.vertex[i][0] * sizeX, data.vertex[i][1] * sizeY, data.vertex[i][2] * sizeZ);
  85445. uvs.push(0, 0);
  85446. }
  85447. for (f = 0; f < nbfaces; f++) {
  85448. for (i = 0; i < data.face[f].length - 2; i++) {
  85449. indices.push(data.face[f][0], data.face[f][i + 2], data.face[f][i + 1]);
  85450. }
  85451. }
  85452. }
  85453. else {
  85454. for (f = 0; f < nbfaces; f++) {
  85455. var fl = data.face[f].length; // number of vertices of the current face
  85456. ang = 2 * Math.PI / fl;
  85457. x = 0.5 * Math.tan(ang / 2);
  85458. y = 0.5;
  85459. // positions, uvs, colors
  85460. for (i = 0; i < fl; i++) {
  85461. // positions
  85462. 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);
  85463. indexes.push(index);
  85464. index++;
  85465. // uvs
  85466. u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
  85467. v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
  85468. uvs.push(u, v);
  85469. tmp = x * Math.cos(ang) - y * Math.sin(ang);
  85470. y = x * Math.sin(ang) + y * Math.cos(ang);
  85471. x = tmp;
  85472. // colors
  85473. if (faceColors) {
  85474. colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
  85475. }
  85476. }
  85477. // indices from indexes
  85478. for (i = 0; i < fl - 2; i++) {
  85479. indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
  85480. }
  85481. faceIdx += fl;
  85482. }
  85483. }
  85484. VertexData.ComputeNormals(positions, indices, normals);
  85485. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  85486. var vertexData = new VertexData();
  85487. vertexData.positions = positions;
  85488. vertexData.indices = indices;
  85489. vertexData.normals = normals;
  85490. vertexData.uvs = uvs;
  85491. if (faceColors && flat) {
  85492. vertexData.colors = colors;
  85493. }
  85494. return vertexData;
  85495. };
  85496. // based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
  85497. /**
  85498. * Creates the VertexData for a TorusKnot
  85499. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  85500. * * radius the radius of the torus knot, optional, default 2
  85501. * * tube the thickness of the tube, optional, default 0.5
  85502. * * radialSegments the number of sides on each tube segments, optional, default 32
  85503. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  85504. * * p the number of windings around the z axis, optional, default 2
  85505. * * q the number of windings around the x axis, optional, default 3
  85506. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85507. * * 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)
  85508. * * 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)
  85509. * @returns the VertexData of the Torus Knot
  85510. */
  85511. VertexData.CreateTorusKnot = function (options) {
  85512. var indices = new Array();
  85513. var positions = new Array();
  85514. var normals = new Array();
  85515. var uvs = new Array();
  85516. var radius = options.radius || 2;
  85517. var tube = options.tube || 0.5;
  85518. var radialSegments = options.radialSegments || 32;
  85519. var tubularSegments = options.tubularSegments || 32;
  85520. var p = options.p || 2;
  85521. var q = options.q || 3;
  85522. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
  85523. // Helper
  85524. var getPos = function (angle) {
  85525. var cu = Math.cos(angle);
  85526. var su = Math.sin(angle);
  85527. var quOverP = q / p * angle;
  85528. var cs = Math.cos(quOverP);
  85529. var tx = radius * (2 + cs) * 0.5 * cu;
  85530. var ty = radius * (2 + cs) * su * 0.5;
  85531. var tz = radius * Math.sin(quOverP) * 0.5;
  85532. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](tx, ty, tz);
  85533. };
  85534. // Vertices
  85535. var i;
  85536. var j;
  85537. for (i = 0; i <= radialSegments; i++) {
  85538. var modI = i % radialSegments;
  85539. var u = modI / radialSegments * 2 * p * Math.PI;
  85540. var p1 = getPos(u);
  85541. var p2 = getPos(u + 0.01);
  85542. var tang = p2.subtract(p1);
  85543. var n = p2.add(p1);
  85544. var bitan = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(tang, n);
  85545. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(bitan, tang);
  85546. bitan.normalize();
  85547. n.normalize();
  85548. for (j = 0; j < tubularSegments; j++) {
  85549. var modJ = j % tubularSegments;
  85550. var v = modJ / tubularSegments * 2 * Math.PI;
  85551. var cx = -tube * Math.cos(v);
  85552. var cy = tube * Math.sin(v);
  85553. positions.push(p1.x + cx * n.x + cy * bitan.x);
  85554. positions.push(p1.y + cx * n.y + cy * bitan.y);
  85555. positions.push(p1.z + cx * n.z + cy * bitan.z);
  85556. uvs.push(i / radialSegments);
  85557. uvs.push(j / tubularSegments);
  85558. }
  85559. }
  85560. for (i = 0; i < radialSegments; i++) {
  85561. for (j = 0; j < tubularSegments; j++) {
  85562. var jNext = (j + 1) % tubularSegments;
  85563. var a = i * tubularSegments + j;
  85564. var b = (i + 1) * tubularSegments + j;
  85565. var c = (i + 1) * tubularSegments + jNext;
  85566. var d = i * tubularSegments + jNext;
  85567. indices.push(d);
  85568. indices.push(b);
  85569. indices.push(a);
  85570. indices.push(d);
  85571. indices.push(c);
  85572. indices.push(b);
  85573. }
  85574. }
  85575. // Normals
  85576. VertexData.ComputeNormals(positions, indices, normals);
  85577. // Sides
  85578. VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  85579. // Result
  85580. var vertexData = new VertexData();
  85581. vertexData.indices = indices;
  85582. vertexData.positions = positions;
  85583. vertexData.normals = normals;
  85584. vertexData.uvs = uvs;
  85585. return vertexData;
  85586. };
  85587. // Tools
  85588. /**
  85589. * Compute normals for given positions and indices
  85590. * @param positions an array of vertex positions, [...., x, y, z, ......]
  85591. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  85592. * @param normals an array of vertex normals, [...., x, y, z, ......]
  85593. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  85594. * * facetNormals : optional array of facet normals (vector3)
  85595. * * facetPositions : optional array of facet positions (vector3)
  85596. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  85597. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  85598. * * bInfo : optional bounding info, required for facetPartitioning computation
  85599. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  85600. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  85601. * * useRightHandedSystem: optional boolean to for right handed system computation
  85602. * * depthSort : optional boolean to enable the facet depth sort computation
  85603. * * distanceTo : optional Vector3 to compute the facet depth from this location
  85604. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  85605. */
  85606. VertexData.ComputeNormals = function (positions, indices, normals, options) {
  85607. // temporary scalar variables
  85608. var index = 0; // facet index
  85609. var p1p2x = 0.0; // p1p2 vector x coordinate
  85610. var p1p2y = 0.0; // p1p2 vector y coordinate
  85611. var p1p2z = 0.0; // p1p2 vector z coordinate
  85612. var p3p2x = 0.0; // p3p2 vector x coordinate
  85613. var p3p2y = 0.0; // p3p2 vector y coordinate
  85614. var p3p2z = 0.0; // p3p2 vector z coordinate
  85615. var faceNormalx = 0.0; // facet normal x coordinate
  85616. var faceNormaly = 0.0; // facet normal y coordinate
  85617. var faceNormalz = 0.0; // facet normal z coordinate
  85618. var length = 0.0; // facet normal length before normalization
  85619. var v1x = 0; // vector1 x index in the positions array
  85620. var v1y = 0; // vector1 y index in the positions array
  85621. var v1z = 0; // vector1 z index in the positions array
  85622. var v2x = 0; // vector2 x index in the positions array
  85623. var v2y = 0; // vector2 y index in the positions array
  85624. var v2z = 0; // vector2 z index in the positions array
  85625. var v3x = 0; // vector3 x index in the positions array
  85626. var v3y = 0; // vector3 y index in the positions array
  85627. var v3z = 0; // vector3 z index in the positions array
  85628. var computeFacetNormals = false;
  85629. var computeFacetPositions = false;
  85630. var computeFacetPartitioning = false;
  85631. var computeDepthSort = false;
  85632. var faceNormalSign = 1;
  85633. var ratio = 0;
  85634. var distanceTo = null;
  85635. if (options) {
  85636. computeFacetNormals = (options.facetNormals) ? true : false;
  85637. computeFacetPositions = (options.facetPositions) ? true : false;
  85638. computeFacetPartitioning = (options.facetPartitioning) ? true : false;
  85639. faceNormalSign = (options.useRightHandedSystem === true) ? -1 : 1;
  85640. ratio = options.ratio || 0;
  85641. computeDepthSort = (options.depthSort) ? true : false;
  85642. distanceTo = (options.distanceTo);
  85643. if (computeDepthSort) {
  85644. if (distanceTo === undefined) {
  85645. distanceTo = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  85646. }
  85647. var depthSortedFacets = options.depthSortedFacets;
  85648. }
  85649. }
  85650. // facetPartitioning reinit if needed
  85651. var xSubRatio = 0;
  85652. var ySubRatio = 0;
  85653. var zSubRatio = 0;
  85654. var subSq = 0;
  85655. if (computeFacetPartitioning && options && options.bbSize) {
  85656. var ox = 0; // X partitioning index for facet position
  85657. var oy = 0; // Y partinioning index for facet position
  85658. var oz = 0; // Z partinioning index for facet position
  85659. var b1x = 0; // X partitioning index for facet v1 vertex
  85660. var b1y = 0; // Y partitioning index for facet v1 vertex
  85661. var b1z = 0; // z partitioning index for facet v1 vertex
  85662. var b2x = 0; // X partitioning index for facet v2 vertex
  85663. var b2y = 0; // Y partitioning index for facet v2 vertex
  85664. var b2z = 0; // Z partitioning index for facet v2 vertex
  85665. var b3x = 0; // X partitioning index for facet v3 vertex
  85666. var b3y = 0; // Y partitioning index for facet v3 vertex
  85667. var b3z = 0; // Z partitioning index for facet v3 vertex
  85668. var block_idx_o = 0; // facet barycenter block index
  85669. var block_idx_v1 = 0; // v1 vertex block index
  85670. var block_idx_v2 = 0; // v2 vertex block index
  85671. var block_idx_v3 = 0; // v3 vertex block index
  85672. var bbSizeMax = (options.bbSize.x > options.bbSize.y) ? options.bbSize.x : options.bbSize.y;
  85673. bbSizeMax = (bbSizeMax > options.bbSize.z) ? bbSizeMax : options.bbSize.z;
  85674. xSubRatio = options.subDiv.X * ratio / options.bbSize.x;
  85675. ySubRatio = options.subDiv.Y * ratio / options.bbSize.y;
  85676. zSubRatio = options.subDiv.Z * ratio / options.bbSize.z;
  85677. subSq = options.subDiv.max * options.subDiv.max;
  85678. options.facetPartitioning.length = 0;
  85679. }
  85680. // reset the normals
  85681. for (index = 0; index < positions.length; index++) {
  85682. normals[index] = 0.0;
  85683. }
  85684. // Loop : 1 indice triplet = 1 facet
  85685. var nbFaces = (indices.length / 3) | 0;
  85686. for (index = 0; index < nbFaces; index++) {
  85687. // get the indexes of the coordinates of each vertex of the facet
  85688. v1x = indices[index * 3] * 3;
  85689. v1y = v1x + 1;
  85690. v1z = v1x + 2;
  85691. v2x = indices[index * 3 + 1] * 3;
  85692. v2y = v2x + 1;
  85693. v2z = v2x + 2;
  85694. v3x = indices[index * 3 + 2] * 3;
  85695. v3y = v3x + 1;
  85696. v3z = v3x + 2;
  85697. p1p2x = positions[v1x] - positions[v2x]; // compute two vectors per facet : p1p2 and p3p2
  85698. p1p2y = positions[v1y] - positions[v2y];
  85699. p1p2z = positions[v1z] - positions[v2z];
  85700. p3p2x = positions[v3x] - positions[v2x];
  85701. p3p2y = positions[v3y] - positions[v2y];
  85702. p3p2z = positions[v3z] - positions[v2z];
  85703. // compute the face normal with the cross product
  85704. faceNormalx = faceNormalSign * (p1p2y * p3p2z - p1p2z * p3p2y);
  85705. faceNormaly = faceNormalSign * (p1p2z * p3p2x - p1p2x * p3p2z);
  85706. faceNormalz = faceNormalSign * (p1p2x * p3p2y - p1p2y * p3p2x);
  85707. // normalize this normal and store it in the array facetData
  85708. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  85709. length = (length === 0) ? 1.0 : length;
  85710. faceNormalx /= length;
  85711. faceNormaly /= length;
  85712. faceNormalz /= length;
  85713. if (computeFacetNormals && options) {
  85714. options.facetNormals[index].x = faceNormalx;
  85715. options.facetNormals[index].y = faceNormaly;
  85716. options.facetNormals[index].z = faceNormalz;
  85717. }
  85718. if (computeFacetPositions && options) {
  85719. // compute and the facet barycenter coordinates in the array facetPositions
  85720. options.facetPositions[index].x = (positions[v1x] + positions[v2x] + positions[v3x]) / 3.0;
  85721. options.facetPositions[index].y = (positions[v1y] + positions[v2y] + positions[v3y]) / 3.0;
  85722. options.facetPositions[index].z = (positions[v1z] + positions[v2z] + positions[v3z]) / 3.0;
  85723. }
  85724. if (computeFacetPartitioning && options) {
  85725. // store the facet indexes in arrays in the main facetPartitioning array :
  85726. // compute each facet vertex (+ facet barycenter) index in the partiniong array
  85727. ox = Math.floor((options.facetPositions[index].x - options.bInfo.minimum.x * ratio) * xSubRatio);
  85728. oy = Math.floor((options.facetPositions[index].y - options.bInfo.minimum.y * ratio) * ySubRatio);
  85729. oz = Math.floor((options.facetPositions[index].z - options.bInfo.minimum.z * ratio) * zSubRatio);
  85730. b1x = Math.floor((positions[v1x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  85731. b1y = Math.floor((positions[v1y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  85732. b1z = Math.floor((positions[v1z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  85733. b2x = Math.floor((positions[v2x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  85734. b2y = Math.floor((positions[v2y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  85735. b2z = Math.floor((positions[v2z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  85736. b3x = Math.floor((positions[v3x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  85737. b3y = Math.floor((positions[v3y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  85738. b3z = Math.floor((positions[v3z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  85739. block_idx_v1 = b1x + options.subDiv.max * b1y + subSq * b1z;
  85740. block_idx_v2 = b2x + options.subDiv.max * b2y + subSq * b2z;
  85741. block_idx_v3 = b3x + options.subDiv.max * b3y + subSq * b3z;
  85742. block_idx_o = ox + options.subDiv.max * oy + subSq * oz;
  85743. options.facetPartitioning[block_idx_o] = options.facetPartitioning[block_idx_o] ? options.facetPartitioning[block_idx_o] : new Array();
  85744. options.facetPartitioning[block_idx_v1] = options.facetPartitioning[block_idx_v1] ? options.facetPartitioning[block_idx_v1] : new Array();
  85745. options.facetPartitioning[block_idx_v2] = options.facetPartitioning[block_idx_v2] ? options.facetPartitioning[block_idx_v2] : new Array();
  85746. options.facetPartitioning[block_idx_v3] = options.facetPartitioning[block_idx_v3] ? options.facetPartitioning[block_idx_v3] : new Array();
  85747. // push each facet index in each block containing the vertex
  85748. options.facetPartitioning[block_idx_v1].push(index);
  85749. if (block_idx_v2 != block_idx_v1) {
  85750. options.facetPartitioning[block_idx_v2].push(index);
  85751. }
  85752. if (!(block_idx_v3 == block_idx_v2 || block_idx_v3 == block_idx_v1)) {
  85753. options.facetPartitioning[block_idx_v3].push(index);
  85754. }
  85755. if (!(block_idx_o == block_idx_v1 || block_idx_o == block_idx_v2 || block_idx_o == block_idx_v3)) {
  85756. options.facetPartitioning[block_idx_o].push(index);
  85757. }
  85758. }
  85759. if (computeDepthSort && options && options.facetPositions) {
  85760. var dsf = depthSortedFacets[index];
  85761. dsf.ind = index * 3;
  85762. dsf.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(options.facetPositions[index], distanceTo);
  85763. }
  85764. // compute the normals anyway
  85765. normals[v1x] += faceNormalx; // accumulate all the normals per face
  85766. normals[v1y] += faceNormaly;
  85767. normals[v1z] += faceNormalz;
  85768. normals[v2x] += faceNormalx;
  85769. normals[v2y] += faceNormaly;
  85770. normals[v2z] += faceNormalz;
  85771. normals[v3x] += faceNormalx;
  85772. normals[v3y] += faceNormaly;
  85773. normals[v3z] += faceNormalz;
  85774. }
  85775. // last normalization of each normal
  85776. for (index = 0; index < normals.length / 3; index++) {
  85777. faceNormalx = normals[index * 3];
  85778. faceNormaly = normals[index * 3 + 1];
  85779. faceNormalz = normals[index * 3 + 2];
  85780. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  85781. length = (length === 0) ? 1.0 : length;
  85782. faceNormalx /= length;
  85783. faceNormaly /= length;
  85784. faceNormalz /= length;
  85785. normals[index * 3] = faceNormalx;
  85786. normals[index * 3 + 1] = faceNormaly;
  85787. normals[index * 3 + 2] = faceNormalz;
  85788. }
  85789. };
  85790. VertexData._ComputeSides = function (sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs) {
  85791. var li = indices.length;
  85792. var ln = normals.length;
  85793. var i;
  85794. var n;
  85795. sideOrientation = sideOrientation || VertexData.DEFAULTSIDE;
  85796. switch (sideOrientation) {
  85797. case VertexData.FRONTSIDE:
  85798. // nothing changed
  85799. break;
  85800. case VertexData.BACKSIDE:
  85801. var tmp;
  85802. // indices
  85803. for (i = 0; i < li; i += 3) {
  85804. tmp = indices[i];
  85805. indices[i] = indices[i + 2];
  85806. indices[i + 2] = tmp;
  85807. }
  85808. // normals
  85809. for (n = 0; n < ln; n++) {
  85810. normals[n] = -normals[n];
  85811. }
  85812. break;
  85813. case VertexData.DOUBLESIDE:
  85814. // positions
  85815. var lp = positions.length;
  85816. var l = lp / 3;
  85817. for (var p = 0; p < lp; p++) {
  85818. positions[lp + p] = positions[p];
  85819. }
  85820. // indices
  85821. for (i = 0; i < li; i += 3) {
  85822. indices[i + li] = indices[i + 2] + l;
  85823. indices[i + 1 + li] = indices[i + 1] + l;
  85824. indices[i + 2 + li] = indices[i] + l;
  85825. }
  85826. // normals
  85827. for (n = 0; n < ln; n++) {
  85828. normals[ln + n] = -normals[n];
  85829. }
  85830. // uvs
  85831. var lu = uvs.length;
  85832. var u = 0;
  85833. for (u = 0; u < lu; u++) {
  85834. uvs[u + lu] = uvs[u];
  85835. }
  85836. frontUVs = frontUVs ? frontUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  85837. backUVs = backUVs ? backUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  85838. u = 0;
  85839. for (i = 0; i < lu / 2; i++) {
  85840. uvs[u] = frontUVs.x + (frontUVs.z - frontUVs.x) * uvs[u];
  85841. uvs[u + 1] = frontUVs.y + (frontUVs.w - frontUVs.y) * uvs[u + 1];
  85842. uvs[u + lu] = backUVs.x + (backUVs.z - backUVs.x) * uvs[u + lu];
  85843. uvs[u + lu + 1] = backUVs.y + (backUVs.w - backUVs.y) * uvs[u + lu + 1];
  85844. u += 2;
  85845. }
  85846. break;
  85847. }
  85848. };
  85849. /**
  85850. * Applies VertexData created from the imported parameters to the geometry
  85851. * @param parsedVertexData the parsed data from an imported file
  85852. * @param geometry the geometry to apply the VertexData to
  85853. */
  85854. VertexData.ImportVertexData = function (parsedVertexData, geometry) {
  85855. var vertexData = new VertexData();
  85856. // positions
  85857. var positions = parsedVertexData.positions;
  85858. if (positions) {
  85859. vertexData.set(positions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  85860. }
  85861. // normals
  85862. var normals = parsedVertexData.normals;
  85863. if (normals) {
  85864. vertexData.set(normals, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  85865. }
  85866. // tangents
  85867. var tangents = parsedVertexData.tangents;
  85868. if (tangents) {
  85869. vertexData.set(tangents, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind);
  85870. }
  85871. // uvs
  85872. var uvs = parsedVertexData.uvs;
  85873. if (uvs) {
  85874. vertexData.set(uvs, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  85875. }
  85876. // uv2s
  85877. var uv2s = parsedVertexData.uv2s;
  85878. if (uv2s) {
  85879. vertexData.set(uv2s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  85880. }
  85881. // uv3s
  85882. var uv3s = parsedVertexData.uv3s;
  85883. if (uv3s) {
  85884. vertexData.set(uv3s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind);
  85885. }
  85886. // uv4s
  85887. var uv4s = parsedVertexData.uv4s;
  85888. if (uv4s) {
  85889. vertexData.set(uv4s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind);
  85890. }
  85891. // uv5s
  85892. var uv5s = parsedVertexData.uv5s;
  85893. if (uv5s) {
  85894. vertexData.set(uv5s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind);
  85895. }
  85896. // uv6s
  85897. var uv6s = parsedVertexData.uv6s;
  85898. if (uv6s) {
  85899. vertexData.set(uv6s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind);
  85900. }
  85901. // colors
  85902. var colors = parsedVertexData.colors;
  85903. if (colors) {
  85904. vertexData.set(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].CheckColors4(colors, positions.length / 3), _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  85905. }
  85906. // matricesIndices
  85907. var matricesIndices = parsedVertexData.matricesIndices;
  85908. if (matricesIndices) {
  85909. vertexData.set(matricesIndices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  85910. }
  85911. // matricesWeights
  85912. var matricesWeights = parsedVertexData.matricesWeights;
  85913. if (matricesWeights) {
  85914. vertexData.set(matricesWeights, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  85915. }
  85916. // indices
  85917. var indices = parsedVertexData.indices;
  85918. if (indices) {
  85919. vertexData.indices = indices;
  85920. }
  85921. geometry.setAllVerticesData(vertexData, parsedVertexData.updatable);
  85922. };
  85923. /**
  85924. * Mesh side orientation : usually the external or front surface
  85925. */
  85926. VertexData.FRONTSIDE = 0;
  85927. /**
  85928. * Mesh side orientation : usually the internal or back surface
  85929. */
  85930. VertexData.BACKSIDE = 1;
  85931. /**
  85932. * Mesh side orientation : both internal and external or front and back surfaces
  85933. */
  85934. VertexData.DOUBLESIDE = 2;
  85935. /**
  85936. * Mesh side orientation : by default, `FRONTSIDE`
  85937. */
  85938. VertexData.DEFAULTSIDE = 0;
  85939. return VertexData;
  85940. }());
  85941. /***/ }),
  85942. /***/ "./Meshes/meshBuilder.ts":
  85943. /*!*******************************!*\
  85944. !*** ./Meshes/meshBuilder.ts ***!
  85945. \*******************************/
  85946. /*! exports provided: MeshBuilder */
  85947. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  85948. "use strict";
  85949. __webpack_require__.r(__webpack_exports__);
  85950. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return MeshBuilder; });
  85951. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  85952. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  85953. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  85954. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  85955. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  85956. /* harmony import */ var _linesMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./linesMesh */ "./Meshes/linesMesh.ts");
  85957. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  85958. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./groundMesh */ "./Meshes/groundMesh.ts");
  85959. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./polygonMesh */ "./Meshes/polygonMesh.ts");
  85960. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  85961. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  85962. if (closeArray === void 0) { closeArray = false; }
  85963. if (updatable === void 0) { updatable = false; }
  85964. return MeshBuilder.CreateRibbon(name, {
  85965. pathArray: pathArray,
  85966. closeArray: closeArray,
  85967. closePath: closePath,
  85968. offset: offset,
  85969. updatable: updatable,
  85970. sideOrientation: sideOrientation,
  85971. instance: instance
  85972. }, scene);
  85973. };
  85974. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  85975. if (scene === void 0) { scene = null; }
  85976. var options = {
  85977. radius: radius,
  85978. tessellation: tessellation,
  85979. sideOrientation: sideOrientation,
  85980. updatable: updatable
  85981. };
  85982. return MeshBuilder.CreateDisc(name, options, scene);
  85983. };
  85984. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateBox = function (name, size, scene, updatable, sideOrientation) {
  85985. if (scene === void 0) { scene = null; }
  85986. var options = {
  85987. size: size,
  85988. sideOrientation: sideOrientation,
  85989. updatable: updatable
  85990. };
  85991. return MeshBuilder.CreateBox(name, options, scene);
  85992. };
  85993. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  85994. var options = {
  85995. segments: segments,
  85996. diameterX: diameter,
  85997. diameterY: diameter,
  85998. diameterZ: diameter,
  85999. sideOrientation: sideOrientation,
  86000. updatable: updatable
  86001. };
  86002. return MeshBuilder.CreateSphere(name, options, scene);
  86003. };
  86004. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  86005. if (scene === undefined || !(scene instanceof _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"])) {
  86006. if (scene !== undefined) {
  86007. sideOrientation = updatable || _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].DEFAULTSIDE;
  86008. updatable = scene;
  86009. }
  86010. scene = subdivisions;
  86011. subdivisions = 1;
  86012. }
  86013. var options = {
  86014. height: height,
  86015. diameterTop: diameterTop,
  86016. diameterBottom: diameterBottom,
  86017. tessellation: tessellation,
  86018. subdivisions: subdivisions,
  86019. sideOrientation: sideOrientation,
  86020. updatable: updatable
  86021. };
  86022. return MeshBuilder.CreateCylinder(name, options, scene);
  86023. };
  86024. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  86025. var options = {
  86026. diameter: diameter,
  86027. thickness: thickness,
  86028. tessellation: tessellation,
  86029. sideOrientation: sideOrientation,
  86030. updatable: updatable
  86031. };
  86032. return MeshBuilder.CreateTorus(name, options, scene);
  86033. };
  86034. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  86035. var options = {
  86036. radius: radius,
  86037. tube: tube,
  86038. radialSegments: radialSegments,
  86039. tubularSegments: tubularSegments,
  86040. p: p,
  86041. q: q,
  86042. sideOrientation: sideOrientation,
  86043. updatable: updatable
  86044. };
  86045. return MeshBuilder.CreateTorusKnot(name, options, scene);
  86046. };
  86047. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateLines = function (name, points, scene, updatable, instance) {
  86048. if (scene === void 0) { scene = null; }
  86049. if (updatable === void 0) { updatable = false; }
  86050. if (instance === void 0) { instance = null; }
  86051. var options = {
  86052. points: points,
  86053. updatable: updatable,
  86054. instance: instance
  86055. };
  86056. return MeshBuilder.CreateLines(name, options, scene);
  86057. };
  86058. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  86059. if (scene === void 0) { scene = null; }
  86060. var options = {
  86061. points: points,
  86062. dashSize: dashSize,
  86063. gapSize: gapSize,
  86064. dashNb: dashNb,
  86065. updatable: updatable,
  86066. instance: instance
  86067. };
  86068. return MeshBuilder.CreateDashedLines(name, options, scene);
  86069. };
  86070. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation) {
  86071. var options = {
  86072. shape: shape,
  86073. holes: holes,
  86074. updatable: updatable,
  86075. sideOrientation: sideOrientation
  86076. };
  86077. return MeshBuilder.CreatePolygon(name, options, scene);
  86078. };
  86079. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation) {
  86080. var options = {
  86081. shape: shape,
  86082. holes: holes,
  86083. depth: depth,
  86084. updatable: updatable,
  86085. sideOrientation: sideOrientation
  86086. };
  86087. return MeshBuilder.ExtrudePolygon(name, options, scene);
  86088. };
  86089. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  86090. if (scene === void 0) { scene = null; }
  86091. var options = {
  86092. shape: shape,
  86093. path: path,
  86094. scale: scale,
  86095. rotation: rotation,
  86096. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP,
  86097. sideOrientation: sideOrientation,
  86098. instance: instance,
  86099. updatable: updatable
  86100. };
  86101. return MeshBuilder.ExtrudeShape(name, options, scene);
  86102. };
  86103. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  86104. var options = {
  86105. shape: shape,
  86106. path: path,
  86107. scaleFunction: scaleFunction,
  86108. rotationFunction: rotationFunction,
  86109. ribbonCloseArray: ribbonCloseArray,
  86110. ribbonClosePath: ribbonClosePath,
  86111. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP,
  86112. sideOrientation: sideOrientation,
  86113. instance: instance,
  86114. updatable: updatable
  86115. };
  86116. return MeshBuilder.ExtrudeShapeCustom(name, options, scene);
  86117. };
  86118. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  86119. var options = {
  86120. shape: shape,
  86121. radius: radius,
  86122. tessellation: tessellation,
  86123. sideOrientation: sideOrientation,
  86124. updatable: updatable
  86125. };
  86126. return MeshBuilder.CreateLathe(name, options, scene);
  86127. };
  86128. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  86129. var options = {
  86130. size: size,
  86131. width: size,
  86132. height: size,
  86133. sideOrientation: sideOrientation,
  86134. updatable: updatable
  86135. };
  86136. return MeshBuilder.CreatePlane(name, options, scene);
  86137. };
  86138. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  86139. var options = {
  86140. width: width,
  86141. height: height,
  86142. subdivisions: subdivisions,
  86143. updatable: updatable
  86144. };
  86145. return MeshBuilder.CreateGround(name, options, scene);
  86146. };
  86147. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  86148. var options = {
  86149. xmin: xmin,
  86150. zmin: zmin,
  86151. xmax: xmax,
  86152. zmax: zmax,
  86153. subdivisions: subdivisions,
  86154. precision: precision,
  86155. updatable: updatable
  86156. };
  86157. return MeshBuilder.CreateTiledGround(name, options, scene);
  86158. };
  86159. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  86160. var options = {
  86161. width: width,
  86162. height: height,
  86163. subdivisions: subdivisions,
  86164. minHeight: minHeight,
  86165. maxHeight: maxHeight,
  86166. updatable: updatable,
  86167. onReady: onReady,
  86168. alphaFilter: alphaFilter
  86169. };
  86170. return MeshBuilder.CreateGroundFromHeightMap(name, url, options, scene);
  86171. };
  86172. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  86173. var options = {
  86174. path: path,
  86175. radius: radius,
  86176. tessellation: tessellation,
  86177. radiusFunction: radiusFunction,
  86178. arc: 1,
  86179. cap: cap,
  86180. updatable: updatable,
  86181. sideOrientation: sideOrientation,
  86182. instance: instance
  86183. };
  86184. return MeshBuilder.CreateTube(name, options, scene);
  86185. };
  86186. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreatePolyhedron = function (name, options, scene) {
  86187. return MeshBuilder.CreatePolyhedron(name, options, scene);
  86188. };
  86189. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateIcoSphere = function (name, options, scene) {
  86190. return MeshBuilder.CreateIcoSphere(name, options, scene);
  86191. };
  86192. _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  86193. var options = {
  86194. position: position,
  86195. normal: normal,
  86196. size: size,
  86197. angle: angle
  86198. };
  86199. return MeshBuilder.CreateDecal(name, sourceMesh, options);
  86200. };
  86201. /**
  86202. * Class containing static functions to help procedurally build meshes
  86203. */
  86204. var MeshBuilder = /** @class */ (function () {
  86205. function MeshBuilder() {
  86206. }
  86207. MeshBuilder._UpdateSideOrientation = function (orientation) {
  86208. if (orientation == _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].DOUBLESIDE) {
  86209. return _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].DOUBLESIDE;
  86210. }
  86211. if (orientation === undefined || orientation === null) {
  86212. return _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].FRONTSIDE;
  86213. }
  86214. return orientation;
  86215. };
  86216. /**
  86217. * Creates a box mesh
  86218. * * The parameter `size` sets the size (float) of each box side (default 1)
  86219. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  86220. * * 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)
  86221. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  86222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86223. * * 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
  86224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86225. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  86226. * @param name defines the name of the mesh
  86227. * @param options defines the options used to create the mesh
  86228. * @param scene defines the hosting scene
  86229. * @returns the box mesh
  86230. */
  86231. MeshBuilder.CreateBox = function (name, options, scene) {
  86232. if (scene === void 0) { scene = null; }
  86233. var box = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86234. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86235. box._originalBuilderSideOrientation = options.sideOrientation;
  86236. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateBox(options);
  86237. vertexData.applyToMesh(box, options.updatable);
  86238. return box;
  86239. };
  86240. /**
  86241. * Creates a sphere mesh
  86242. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  86243. * * 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`)
  86244. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  86245. * * 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
  86246. * * 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)
  86247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86248. * * 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
  86249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86250. * @param name defines the name of the mesh
  86251. * @param options defines the options used to create the mesh
  86252. * @param scene defines the hosting scene
  86253. * @returns the sphere mesh
  86254. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  86255. */
  86256. MeshBuilder.CreateSphere = function (name, options, scene) {
  86257. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86258. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86259. sphere._originalBuilderSideOrientation = options.sideOrientation;
  86260. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateSphere(options);
  86261. vertexData.applyToMesh(sphere, options.updatable);
  86262. return sphere;
  86263. };
  86264. /**
  86265. * Creates a plane polygonal mesh. By default, this is a disc
  86266. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  86267. * * 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
  86268. * * 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
  86269. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86270. * * 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
  86271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86272. * @param name defines the name of the mesh
  86273. * @param options defines the options used to create the mesh
  86274. * @param scene defines the hosting scene
  86275. * @returns the plane polygonal mesh
  86276. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  86277. */
  86278. MeshBuilder.CreateDisc = function (name, options, scene) {
  86279. if (scene === void 0) { scene = null; }
  86280. var disc = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86281. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86282. disc._originalBuilderSideOrientation = options.sideOrientation;
  86283. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateDisc(options);
  86284. vertexData.applyToMesh(disc, options.updatable);
  86285. return disc;
  86286. };
  86287. /**
  86288. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  86289. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  86290. * * 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`)
  86291. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  86292. * * 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
  86293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86294. * * 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
  86295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86296. * @param name defines the name of the mesh
  86297. * @param options defines the options used to create the mesh
  86298. * @param scene defines the hosting scene
  86299. * @returns the icosahedron mesh
  86300. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  86301. */
  86302. MeshBuilder.CreateIcoSphere = function (name, options, scene) {
  86303. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86304. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86305. sphere._originalBuilderSideOrientation = options.sideOrientation;
  86306. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateIcoSphere(options);
  86307. vertexData.applyToMesh(sphere, options.updatable);
  86308. return sphere;
  86309. };
  86310. /**
  86311. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  86312. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  86313. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  86314. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  86315. * * 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
  86316. * * 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
  86317. * * 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
  86318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86319. * * 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
  86320. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  86321. * * 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
  86322. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  86323. * * 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
  86324. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  86325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86326. * @param name defines the name of the mesh
  86327. * @param options defines the options used to create the mesh
  86328. * @param scene defines the hosting scene
  86329. * @returns the ribbon mesh
  86330. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  86331. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  86332. */
  86333. MeshBuilder.CreateRibbon = function (name, options, scene) {
  86334. if (scene === void 0) { scene = null; }
  86335. var pathArray = options.pathArray;
  86336. var closeArray = options.closeArray;
  86337. var closePath = options.closePath;
  86338. var sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86339. var instance = options.instance;
  86340. var updatable = options.updatable;
  86341. if (instance) { // existing ribbon instance update
  86342. // positionFunction : ribbon case
  86343. // only pathArray and sideOrientation parameters are taken into account for positions update
  86344. var minimum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0].setAll(Number.MAX_VALUE);
  86345. var maximum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[1].setAll(-Number.MAX_VALUE);
  86346. var positionFunction = function (positions) {
  86347. var minlg = pathArray[0].length;
  86348. var mesh = instance;
  86349. var i = 0;
  86350. var ns = (mesh._originalBuilderSideOrientation === _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].DOUBLESIDE) ? 2 : 1;
  86351. for (var si = 1; si <= ns; ++si) {
  86352. for (var p = 0; p < pathArray.length; ++p) {
  86353. var path = pathArray[p];
  86354. var l = path.length;
  86355. minlg = (minlg < l) ? minlg : l;
  86356. for (var j = 0; j < minlg; ++j) {
  86357. var pathPoint = path[j];
  86358. positions[i] = pathPoint.x;
  86359. positions[i + 1] = pathPoint.y;
  86360. positions[i + 2] = pathPoint.z;
  86361. minimum_1.minimizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  86362. maximum_1.maximizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  86363. i += 3;
  86364. }
  86365. if (mesh._creationDataStorage && mesh._creationDataStorage.closePath) {
  86366. var pathPoint = path[0];
  86367. positions[i] = pathPoint.x;
  86368. positions[i + 1] = pathPoint.y;
  86369. positions[i + 2] = pathPoint.z;
  86370. i += 3;
  86371. }
  86372. }
  86373. }
  86374. };
  86375. var positions = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  86376. positionFunction(positions);
  86377. if (instance._boundingInfo) {
  86378. instance._boundingInfo.reConstruct(minimum_1, maximum_1, instance._worldMatrix);
  86379. }
  86380. else {
  86381. instance._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](minimum_1, maximum_1, instance._worldMatrix);
  86382. }
  86383. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, positions, false, false);
  86384. if (options.colors) {
  86385. var colors = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  86386. for (var c = 0, colorIndex = 0; c < options.colors.length; c++, colorIndex += 4) {
  86387. var color = options.colors[c];
  86388. colors[colorIndex] = color.r;
  86389. colors[colorIndex + 1] = color.g;
  86390. colors[colorIndex + 2] = color.b;
  86391. colors[colorIndex + 3] = color.a;
  86392. }
  86393. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind, colors, false, false);
  86394. }
  86395. if (options.uvs) {
  86396. var uvs = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  86397. for (var i = 0; i < options.uvs.length; i++) {
  86398. uvs[i * 2] = options.uvs[i].x;
  86399. uvs[i * 2 + 1] = options.uvs[i].y;
  86400. }
  86401. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind, uvs, false, false);
  86402. }
  86403. if (!instance.areNormalsFrozen || instance.isFacetDataEnabled) {
  86404. var indices = instance.getIndices();
  86405. var normals = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  86406. var params = instance.isFacetDataEnabled ? instance.getFacetDataParameters() : null;
  86407. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, params);
  86408. if (instance._creationDataStorage && instance._creationDataStorage.closePath) {
  86409. var indexFirst = 0;
  86410. var indexLast = 0;
  86411. for (var p = 0; p < pathArray.length; p++) {
  86412. indexFirst = instance._creationDataStorage.idx[p] * 3;
  86413. if (p + 1 < pathArray.length) {
  86414. indexLast = (instance._creationDataStorage.idx[p + 1] - 1) * 3;
  86415. }
  86416. else {
  86417. indexLast = normals.length - 3;
  86418. }
  86419. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  86420. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  86421. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  86422. normals[indexLast] = normals[indexFirst];
  86423. normals[indexLast + 1] = normals[indexFirst + 1];
  86424. normals[indexLast + 2] = normals[indexFirst + 2];
  86425. }
  86426. }
  86427. if (!(instance.areNormalsFrozen)) {
  86428. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind, normals, false, false);
  86429. }
  86430. }
  86431. return instance;
  86432. }
  86433. else { // new ribbon creation
  86434. var ribbon = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86435. ribbon._originalBuilderSideOrientation = sideOrientation;
  86436. ribbon._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_3__["_CreationDataStorage"]();
  86437. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateRibbon(options);
  86438. if (closePath) {
  86439. ribbon._creationDataStorage.idx = vertexData._idx;
  86440. }
  86441. ribbon._creationDataStorage.closePath = closePath;
  86442. ribbon._creationDataStorage.closeArray = closeArray;
  86443. vertexData.applyToMesh(ribbon, updatable);
  86444. return ribbon;
  86445. }
  86446. };
  86447. /**
  86448. * Creates a cylinder or a cone mesh
  86449. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  86450. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  86451. * * 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.
  86452. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  86453. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  86454. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  86455. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  86456. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  86457. * * 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).
  86458. * * 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
  86459. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  86460. * * 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
  86461. * * 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.
  86462. * * If `enclose` is false, a ring surface is one element.
  86463. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  86464. * * 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
  86465. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86466. * * 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
  86467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  86468. * @param name defines the name of the mesh
  86469. * @param options defines the options used to create the mesh
  86470. * @param scene defines the hosting scene
  86471. * @returns the cylinder mesh
  86472. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  86473. */
  86474. MeshBuilder.CreateCylinder = function (name, options, scene) {
  86475. var cylinder = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86476. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86477. cylinder._originalBuilderSideOrientation = options.sideOrientation;
  86478. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateCylinder(options);
  86479. vertexData.applyToMesh(cylinder, options.updatable);
  86480. return cylinder;
  86481. };
  86482. /**
  86483. * Creates a torus mesh
  86484. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  86485. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  86486. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  86487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86488. * * 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
  86489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  86490. * @param name defines the name of the mesh
  86491. * @param options defines the options used to create the mesh
  86492. * @param scene defines the hosting scene
  86493. * @returns the torus mesh
  86494. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  86495. */
  86496. MeshBuilder.CreateTorus = function (name, options, scene) {
  86497. var torus = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86498. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86499. torus._originalBuilderSideOrientation = options.sideOrientation;
  86500. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateTorus(options);
  86501. vertexData.applyToMesh(torus, options.updatable);
  86502. return torus;
  86503. };
  86504. /**
  86505. * Creates a torus knot mesh
  86506. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  86507. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  86508. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  86509. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  86510. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86511. * * 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
  86512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  86513. * @param name defines the name of the mesh
  86514. * @param options defines the options used to create the mesh
  86515. * @param scene defines the hosting scene
  86516. * @returns the torus knot mesh
  86517. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  86518. */
  86519. MeshBuilder.CreateTorusKnot = function (name, options, scene) {
  86520. var torusKnot = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86521. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86522. torusKnot._originalBuilderSideOrientation = options.sideOrientation;
  86523. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateTorusKnot(options);
  86524. vertexData.applyToMesh(torusKnot, options.updatable);
  86525. return torusKnot;
  86526. };
  86527. /**
  86528. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  86529. * * 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
  86530. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  86531. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  86532. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  86533. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  86534. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  86535. * * 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
  86536. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  86537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86538. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  86539. * @param name defines the name of the new line system
  86540. * @param options defines the options used to create the line system
  86541. * @param scene defines the hosting scene
  86542. * @returns a new line system mesh
  86543. */
  86544. MeshBuilder.CreateLineSystem = function (name, options, scene) {
  86545. var instance = options.instance;
  86546. var lines = options.lines;
  86547. var colors = options.colors;
  86548. if (instance) { // lines update
  86549. var positions = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  86550. var vertexColor;
  86551. var lineColors;
  86552. if (colors) {
  86553. vertexColor = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  86554. }
  86555. var i = 0;
  86556. var c = 0;
  86557. for (var l = 0; l < lines.length; l++) {
  86558. var points = lines[l];
  86559. for (var p = 0; p < points.length; p++) {
  86560. positions[i] = points[p].x;
  86561. positions[i + 1] = points[p].y;
  86562. positions[i + 2] = points[p].z;
  86563. if (colors && vertexColor) {
  86564. lineColors = colors[l];
  86565. vertexColor[c] = lineColors[p].r;
  86566. vertexColor[c + 1] = lineColors[p].g;
  86567. vertexColor[c + 2] = lineColors[p].b;
  86568. vertexColor[c + 3] = lineColors[p].a;
  86569. c += 4;
  86570. }
  86571. i += 3;
  86572. }
  86573. }
  86574. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, positions, false, false);
  86575. if (colors && vertexColor) {
  86576. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind, vertexColor, false, false);
  86577. }
  86578. return instance;
  86579. }
  86580. // line system creation
  86581. var useVertexColor = (colors) ? true : false;
  86582. var lineSystem = new _linesMesh__WEBPACK_IMPORTED_MODULE_5__["LinesMesh"](name, scene, null, undefined, undefined, useVertexColor, options.useVertexAlpha);
  86583. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateLineSystem(options);
  86584. vertexData.applyToMesh(lineSystem, options.updatable);
  86585. return lineSystem;
  86586. };
  86587. /**
  86588. * Creates a line mesh
  86589. * 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
  86590. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  86591. * * The parameter `points` is an array successive Vector3
  86592. * * 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
  86593. * * The optional parameter `colors` is an array of successive Color4, one per line point
  86594. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  86595. * * When updating an instance, remember that only point positions can change, not the number of points
  86596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86597. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  86598. * @param name defines the name of the new line system
  86599. * @param options defines the options used to create the line system
  86600. * @param scene defines the hosting scene
  86601. * @returns a new line mesh
  86602. */
  86603. MeshBuilder.CreateLines = function (name, options, scene) {
  86604. if (scene === void 0) { scene = null; }
  86605. var colors = (options.colors) ? [options.colors] : null;
  86606. var lines = MeshBuilder.CreateLineSystem(name, { lines: [options.points], updatable: options.updatable, instance: options.instance, colors: colors, useVertexAlpha: options.useVertexAlpha }, scene);
  86607. return lines;
  86608. };
  86609. /**
  86610. * Creates a dashed line mesh
  86611. * * 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
  86612. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  86613. * * The parameter `points` is an array successive Vector3
  86614. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  86615. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  86616. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  86617. * * 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
  86618. * * When updating an instance, remember that only point positions can change, not the number of points
  86619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86620. * @param name defines the name of the mesh
  86621. * @param options defines the options used to create the mesh
  86622. * @param scene defines the hosting scene
  86623. * @returns the dashed line mesh
  86624. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  86625. */
  86626. MeshBuilder.CreateDashedLines = function (name, options, scene) {
  86627. if (scene === void 0) { scene = null; }
  86628. var points = options.points;
  86629. var instance = options.instance;
  86630. var gapSize = options.gapSize || 1;
  86631. var dashSize = options.dashSize || 3;
  86632. if (instance) { // dashed lines update
  86633. var positionFunction = function (positions) {
  86634. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  86635. var nbSeg = positions.length / 6;
  86636. var lg = 0;
  86637. var nb = 0;
  86638. var shft = 0;
  86639. var dashshft = 0;
  86640. var curshft = 0;
  86641. var p = 0;
  86642. var i = 0;
  86643. var j = 0;
  86644. for (i = 0; i < points.length - 1; i++) {
  86645. points[i + 1].subtractToRef(points[i], curvect);
  86646. lg += curvect.length();
  86647. }
  86648. shft = lg / nbSeg;
  86649. var dashSize = instance._creationDataStorage.dashSize;
  86650. var gapSize = instance._creationDataStorage.gapSize;
  86651. dashshft = dashSize * shft / (dashSize + gapSize);
  86652. for (i = 0; i < points.length - 1; i++) {
  86653. points[i + 1].subtractToRef(points[i], curvect);
  86654. nb = Math.floor(curvect.length() / shft);
  86655. curvect.normalize();
  86656. j = 0;
  86657. while (j < nb && p < positions.length) {
  86658. curshft = shft * j;
  86659. positions[p] = points[i].x + curshft * curvect.x;
  86660. positions[p + 1] = points[i].y + curshft * curvect.y;
  86661. positions[p + 2] = points[i].z + curshft * curvect.z;
  86662. positions[p + 3] = points[i].x + (curshft + dashshft) * curvect.x;
  86663. positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;
  86664. positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;
  86665. p += 6;
  86666. j++;
  86667. }
  86668. }
  86669. while (p < positions.length) {
  86670. positions[p] = points[i].x;
  86671. positions[p + 1] = points[i].y;
  86672. positions[p + 2] = points[i].z;
  86673. p += 3;
  86674. }
  86675. };
  86676. instance.updateMeshPositions(positionFunction, false);
  86677. return instance;
  86678. }
  86679. // dashed lines creation
  86680. var dashedLines = new _linesMesh__WEBPACK_IMPORTED_MODULE_5__["LinesMesh"](name, scene);
  86681. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateDashedLines(options);
  86682. vertexData.applyToMesh(dashedLines, options.updatable);
  86683. dashedLines._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_3__["_CreationDataStorage"]();
  86684. dashedLines._creationDataStorage.dashSize = dashSize;
  86685. dashedLines._creationDataStorage.gapSize = gapSize;
  86686. return dashedLines;
  86687. };
  86688. /**
  86689. * 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.
  86690. * * 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.
  86691. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  86692. * * 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.
  86693. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  86694. * * 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
  86695. * * 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
  86696. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  86697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86698. * * 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
  86699. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  86700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  86701. * @param name defines the name of the mesh
  86702. * @param options defines the options used to create the mesh
  86703. * @param scene defines the hosting scene
  86704. * @returns the extruded shape mesh
  86705. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  86706. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  86707. */
  86708. MeshBuilder.ExtrudeShape = function (name, options, scene) {
  86709. if (scene === void 0) { scene = null; }
  86710. var path = options.path;
  86711. var shape = options.shape;
  86712. var scale = options.scale || 1;
  86713. var rotation = options.rotation || 0;
  86714. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP;
  86715. var updatable = options.updatable;
  86716. var sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86717. var instance = options.instance || null;
  86718. var invertUV = options.invertUV || false;
  86719. return MeshBuilder._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);
  86720. };
  86721. /**
  86722. * Creates an custom extruded shape mesh.
  86723. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  86724. * * 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.
  86725. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  86726. * * 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
  86727. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  86728. * * 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
  86729. * * It must returns a float value that will be the scale value applied to the shape on each path point
  86730. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  86731. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  86732. * * 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
  86733. * * 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
  86734. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  86735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86736. * * 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
  86737. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  86738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86739. * @param name defines the name of the mesh
  86740. * @param options defines the options used to create the mesh
  86741. * @param scene defines the hosting scene
  86742. * @returns the custom extruded shape mesh
  86743. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  86744. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  86745. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  86746. */
  86747. MeshBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  86748. var path = options.path;
  86749. var shape = options.shape;
  86750. var scaleFunction = options.scaleFunction || (function () { return 1; });
  86751. var rotationFunction = options.rotationFunction || (function () { return 0; });
  86752. var ribbonCloseArray = options.ribbonCloseArray || false;
  86753. var ribbonClosePath = options.ribbonClosePath || false;
  86754. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP;
  86755. var updatable = options.updatable;
  86756. var sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86757. var instance = options.instance;
  86758. var invertUV = options.invertUV || false;
  86759. return MeshBuilder._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);
  86760. };
  86761. /**
  86762. * Creates lathe mesh.
  86763. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  86764. * * 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
  86765. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  86766. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  86767. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  86768. * * 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
  86769. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  86770. * * 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
  86771. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86772. * * 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
  86773. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  86774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86775. * @param name defines the name of the mesh
  86776. * @param options defines the options used to create the mesh
  86777. * @param scene defines the hosting scene
  86778. * @returns the lathe mesh
  86779. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  86780. */
  86781. MeshBuilder.CreateLathe = function (name, options, scene) {
  86782. var arc = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
  86783. var closed = (options.closed === undefined) ? true : options.closed;
  86784. var shape = options.shape;
  86785. var radius = options.radius || 1;
  86786. var tessellation = options.tessellation || 64;
  86787. var clip = options.clip || 0;
  86788. var updatable = options.updatable;
  86789. var sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86790. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP;
  86791. var pi2 = Math.PI * 2;
  86792. var paths = new Array();
  86793. var invertUV = options.invertUV || false;
  86794. var i = 0;
  86795. var p = 0;
  86796. var step = pi2 / tessellation * arc;
  86797. var rotated;
  86798. var path = new Array();
  86799. for (i = 0; i <= tessellation - clip; i++) {
  86800. var path = [];
  86801. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_START || cap == _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_ALL) {
  86802. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, shape[0].y, 0));
  86803. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](Math.cos(i * step) * shape[0].x * radius, shape[0].y, Math.sin(i * step) * shape[0].x * radius));
  86804. }
  86805. for (p = 0; p < shape.length; p++) {
  86806. rotated = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](Math.cos(i * step) * shape[p].x * radius, shape[p].y, Math.sin(i * step) * shape[p].x * radius);
  86807. path.push(rotated);
  86808. }
  86809. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_END || cap == _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_ALL) {
  86810. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["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));
  86811. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, shape[shape.length - 1].y, 0));
  86812. }
  86813. paths.push(path);
  86814. }
  86815. // lathe ribbon
  86816. var lathe = MeshBuilder.CreateRibbon(name, { pathArray: paths, closeArray: closed, sideOrientation: sideOrientation, updatable: updatable, invertUV: invertUV, frontUVs: options.frontUVs, backUVs: options.backUVs }, scene);
  86817. return lathe;
  86818. };
  86819. /**
  86820. * Creates a plane mesh
  86821. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  86822. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  86823. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  86824. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86825. * * 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
  86826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86827. * @param name defines the name of the mesh
  86828. * @param options defines the options used to create the mesh
  86829. * @param scene defines the hosting scene
  86830. * @returns the plane mesh
  86831. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  86832. */
  86833. MeshBuilder.CreatePlane = function (name, options, scene) {
  86834. var plane = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86835. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86836. plane._originalBuilderSideOrientation = options.sideOrientation;
  86837. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreatePlane(options);
  86838. vertexData.applyToMesh(plane, options.updatable);
  86839. if (options.sourcePlane) {
  86840. plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);
  86841. plane.setDirection(options.sourcePlane.normal.scale(-1));
  86842. }
  86843. return plane;
  86844. };
  86845. /**
  86846. * Creates a ground mesh
  86847. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  86848. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  86849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86850. * @param name defines the name of the mesh
  86851. * @param options defines the options used to create the mesh
  86852. * @param scene defines the hosting scene
  86853. * @returns the ground mesh
  86854. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  86855. */
  86856. MeshBuilder.CreateGround = function (name, options, scene) {
  86857. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_7__["GroundMesh"](name, scene);
  86858. ground._setReady(false);
  86859. ground._subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  86860. ground._subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  86861. ground._width = options.width || 1;
  86862. ground._height = options.height || 1;
  86863. ground._maxX = ground._width / 2;
  86864. ground._maxZ = ground._height / 2;
  86865. ground._minX = -ground._maxX;
  86866. ground._minZ = -ground._maxZ;
  86867. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateGround(options);
  86868. vertexData.applyToMesh(ground, options.updatable);
  86869. ground._setReady(true);
  86870. return ground;
  86871. };
  86872. /**
  86873. * Creates a tiled ground mesh
  86874. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  86875. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  86876. * * 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
  86877. * * 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
  86878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  86879. * @param name defines the name of the mesh
  86880. * @param options defines the options used to create the mesh
  86881. * @param scene defines the hosting scene
  86882. * @returns the tiled ground mesh
  86883. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  86884. */
  86885. MeshBuilder.CreateTiledGround = function (name, options, scene) {
  86886. var tiledGround = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  86887. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateTiledGround(options);
  86888. vertexData.applyToMesh(tiledGround, options.updatable);
  86889. return tiledGround;
  86890. };
  86891. /**
  86892. * Creates a ground mesh from a height map
  86893. * * The parameter `url` sets the URL of the height map image resource.
  86894. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  86895. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  86896. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  86897. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  86898. * * 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.
  86899. * * 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).
  86900. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  86901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  86902. * @param name defines the name of the mesh
  86903. * @param url defines the url to the height map
  86904. * @param options defines the options used to create the mesh
  86905. * @param scene defines the hosting scene
  86906. * @returns the ground mesh
  86907. * @see https://doc.babylonjs.com/babylon101/height_map
  86908. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  86909. */
  86910. MeshBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  86911. var width = options.width || 10.0;
  86912. var height = options.height || 10.0;
  86913. var subdivisions = options.subdivisions || 1 | 0;
  86914. var minHeight = options.minHeight || 0.0;
  86915. var maxHeight = options.maxHeight || 1.0;
  86916. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.59, 0.11);
  86917. var alphaFilter = options.alphaFilter || 0.0;
  86918. var updatable = options.updatable;
  86919. var onReady = options.onReady;
  86920. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_7__["GroundMesh"](name, scene);
  86921. ground._subdivisionsX = subdivisions;
  86922. ground._subdivisionsY = subdivisions;
  86923. ground._width = width;
  86924. ground._height = height;
  86925. ground._maxX = ground._width / 2.0;
  86926. ground._maxZ = ground._height / 2.0;
  86927. ground._minX = -ground._maxX;
  86928. ground._minZ = -ground._maxZ;
  86929. ground._setReady(false);
  86930. var onload = function (img) {
  86931. // Getting height map data
  86932. var canvas = document.createElement("canvas");
  86933. var context = canvas.getContext("2d");
  86934. if (!context) {
  86935. throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");
  86936. }
  86937. if (scene.isDisposed) {
  86938. return;
  86939. }
  86940. var bufferWidth = img.width;
  86941. var bufferHeight = img.height;
  86942. canvas.width = bufferWidth;
  86943. canvas.height = bufferHeight;
  86944. context.drawImage(img, 0, 0);
  86945. // Create VertexData from map data
  86946. // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  86947. var buffer = context.getImageData(0, 0, bufferWidth, bufferHeight).data;
  86948. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreateGroundFromHeightMap({
  86949. width: width, height: height,
  86950. subdivisions: subdivisions,
  86951. minHeight: minHeight, maxHeight: maxHeight, colorFilter: filter,
  86952. buffer: buffer, bufferWidth: bufferWidth, bufferHeight: bufferHeight,
  86953. alphaFilter: alphaFilter
  86954. });
  86955. vertexData.applyToMesh(ground, updatable);
  86956. //execute ready callback, if set
  86957. if (onReady) {
  86958. onReady(ground);
  86959. }
  86960. ground._setReady(true);
  86961. };
  86962. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  86963. return ground;
  86964. };
  86965. /**
  86966. * Creates a polygon mesh
  86967. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  86968. * * 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
  86969. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86971. * * 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)
  86972. * * Remember you can only change the shape positions, not their number when updating a polygon
  86973. * @param name defines the name of the mesh
  86974. * @param options defines the options used to create the mesh
  86975. * @param scene defines the hosting scene
  86976. * @returns the polygon mesh
  86977. */
  86978. MeshBuilder.CreatePolygon = function (name, options, scene) {
  86979. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  86980. var shape = options.shape;
  86981. var holes = options.holes || [];
  86982. var depth = options.depth || 0;
  86983. var contours = [];
  86984. var hole = [];
  86985. for (var i = 0; i < shape.length; i++) {
  86986. contours[i] = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](shape[i].x, shape[i].z);
  86987. }
  86988. var epsilon = 0.00000001;
  86989. if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {
  86990. contours.pop();
  86991. }
  86992. var polygonTriangulation = new _polygonMesh__WEBPACK_IMPORTED_MODULE_8__["PolygonMeshBuilder"](name, contours, scene);
  86993. for (var hNb = 0; hNb < holes.length; hNb++) {
  86994. hole = [];
  86995. for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
  86996. hole.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](holes[hNb][hPoint].x, holes[hNb][hPoint].z));
  86997. }
  86998. polygonTriangulation.addHole(hole);
  86999. }
  87000. var polygon = polygonTriangulation.build(options.updatable, depth);
  87001. polygon._originalBuilderSideOrientation = options.sideOrientation;
  87002. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreatePolygon(polygon, options.sideOrientation, options.faceUV, options.faceColors, options.frontUVs, options.backUVs);
  87003. vertexData.applyToMesh(polygon, options.updatable);
  87004. return polygon;
  87005. };
  87006. /**
  87007. * Creates an extruded polygon mesh, with depth in the Y direction.
  87008. * * 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)
  87009. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  87010. * @param name defines the name of the mesh
  87011. * @param options defines the options used to create the mesh
  87012. * @param scene defines the hosting scene
  87013. * @returns the polygon mesh
  87014. */
  87015. MeshBuilder.ExtrudePolygon = function (name, options, scene) {
  87016. return MeshBuilder.CreatePolygon(name, options, scene);
  87017. };
  87018. /**
  87019. * Creates a tube mesh.
  87020. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  87021. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  87022. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  87023. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  87024. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  87025. * * 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)
  87026. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  87027. * * 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
  87028. * * 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
  87029. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  87030. * * 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
  87031. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  87032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87033. * @param name defines the name of the mesh
  87034. * @param options defines the options used to create the mesh
  87035. * @param scene defines the hosting scene
  87036. * @returns the tube mesh
  87037. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  87038. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  87039. */
  87040. MeshBuilder.CreateTube = function (name, options, scene) {
  87041. var path = options.path;
  87042. var instance = options.instance;
  87043. var radius = 1.0;
  87044. if (options.radius !== undefined) {
  87045. radius = options.radius;
  87046. }
  87047. else if (instance) {
  87048. radius = instance._creationDataStorage.radius;
  87049. }
  87050. var tessellation = options.tessellation || 64 | 0;
  87051. var radiusFunction = options.radiusFunction || null;
  87052. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP;
  87053. var invertUV = options.invertUV || false;
  87054. var updatable = options.updatable;
  87055. var sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  87056. options.arc = options.arc && (options.arc <= 0.0 || options.arc > 1.0) ? 1.0 : options.arc || 1.0;
  87057. // tube geometry
  87058. var tubePathArray = function (path, path3D, circlePaths, radius, tessellation, radiusFunction, cap, arc) {
  87059. var tangents = path3D.getTangents();
  87060. var normals = path3D.getNormals();
  87061. var distances = path3D.getDistances();
  87062. var pi2 = Math.PI * 2;
  87063. var step = pi2 / tessellation * arc;
  87064. var returnRadius = function () { return radius; };
  87065. var radiusFunctionFinal = radiusFunction || returnRadius;
  87066. var circlePath;
  87067. var rad;
  87068. var normal;
  87069. var rotated;
  87070. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0];
  87071. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_END) ? 0 : 2;
  87072. for (var i = 0; i < path.length; i++) {
  87073. rad = radiusFunctionFinal(i, distances[i]); // current radius
  87074. circlePath = Array(); // current circle array
  87075. normal = normals[i]; // current normal
  87076. for (var t = 0; t < tessellation; t++) {
  87077. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationAxisToRef(tangents[i], step * t, rotationMatrix);
  87078. rotated = circlePath[t] ? circlePath[t] : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  87079. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(normal, rotationMatrix, rotated);
  87080. rotated.scaleInPlace(rad).addInPlace(path[i]);
  87081. circlePath[t] = rotated;
  87082. }
  87083. circlePaths[index] = circlePath;
  87084. index++;
  87085. }
  87086. // cap
  87087. var capPath = function (nbPoints, pathIndex) {
  87088. var pointCap = Array();
  87089. for (var i = 0; i < nbPoints; i++) {
  87090. pointCap.push(path[pathIndex]);
  87091. }
  87092. return pointCap;
  87093. };
  87094. switch (cap) {
  87095. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP:
  87096. break;
  87097. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_START:
  87098. circlePaths[0] = capPath(tessellation, 0);
  87099. circlePaths[1] = circlePaths[2].slice(0);
  87100. break;
  87101. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_END:
  87102. circlePaths[index] = circlePaths[index - 1].slice(0);
  87103. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  87104. break;
  87105. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_ALL:
  87106. circlePaths[0] = capPath(tessellation, 0);
  87107. circlePaths[1] = circlePaths[2].slice(0);
  87108. circlePaths[index] = circlePaths[index - 1].slice(0);
  87109. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  87110. break;
  87111. default:
  87112. break;
  87113. }
  87114. return circlePaths;
  87115. };
  87116. var path3D;
  87117. var pathArray;
  87118. if (instance) { // tube update
  87119. var storage = instance._creationDataStorage;
  87120. var arc = options.arc || storage.arc;
  87121. path3D = storage.path3D.update(path);
  87122. pathArray = tubePathArray(path, path3D, storage.pathArray, radius, storage.tessellation, radiusFunction, storage.cap, arc);
  87123. instance = MeshBuilder.CreateRibbon("", { pathArray: pathArray, instance: instance });
  87124. // Update mode, no need to recreate the storage.
  87125. storage.path3D = path3D;
  87126. storage.pathArray = pathArray;
  87127. storage.arc = arc;
  87128. storage.radius = radius;
  87129. return instance;
  87130. }
  87131. // tube creation
  87132. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path3D"](path);
  87133. var newPathArray = new Array();
  87134. cap = (cap < 0 || cap > 3) ? 0 : cap;
  87135. pathArray = tubePathArray(path, path3D, newPathArray, radius, tessellation, radiusFunction, cap, options.arc);
  87136. var tube = MeshBuilder.CreateRibbon(name, { pathArray: pathArray, closePath: true, closeArray: false, updatable: updatable, sideOrientation: sideOrientation, invertUV: invertUV, frontUVs: options.frontUVs, backUVs: options.backUVs }, scene);
  87137. tube._creationDataStorage.pathArray = pathArray;
  87138. tube._creationDataStorage.path3D = path3D;
  87139. tube._creationDataStorage.tessellation = tessellation;
  87140. tube._creationDataStorage.cap = cap;
  87141. tube._creationDataStorage.arc = options.arc;
  87142. tube._creationDataStorage.radius = radius;
  87143. return tube;
  87144. };
  87145. /**
  87146. * Creates a polyhedron mesh
  87147. * * 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
  87148. * * The parameter `size` (positive float, default 1) sets the polygon size
  87149. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  87150. * * 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`
  87151. * * 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
  87152. * * 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)`)
  87153. * * 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
  87154. * * 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
  87155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  87156. * * 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
  87157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87158. * @param name defines the name of the mesh
  87159. * @param options defines the options used to create the mesh
  87160. * @param scene defines the hosting scene
  87161. * @returns the polyhedron mesh
  87162. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  87163. */
  87164. MeshBuilder.CreatePolyhedron = function (name, options, scene) {
  87165. var polyhedron = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, scene);
  87166. options.sideOrientation = MeshBuilder._UpdateSideOrientation(options.sideOrientation);
  87167. polyhedron._originalBuilderSideOrientation = options.sideOrientation;
  87168. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].CreatePolyhedron(options);
  87169. vertexData.applyToMesh(polyhedron, options.updatable);
  87170. return polyhedron;
  87171. };
  87172. /**
  87173. * Creates a decal mesh.
  87174. * 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
  87175. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  87176. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  87177. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  87178. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  87179. * @param name defines the name of the mesh
  87180. * @param sourceMesh defines the mesh where the decal must be applied
  87181. * @param options defines the options used to create the mesh
  87182. * @param scene defines the hosting scene
  87183. * @returns the decal mesh
  87184. * @see https://doc.babylonjs.com/how_to/decals
  87185. */
  87186. MeshBuilder.CreateDecal = function (name, sourceMesh, options) {
  87187. var indices = sourceMesh.getIndices();
  87188. var positions = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  87189. var normals = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  87190. var position = options.position || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  87191. var normal = options.normal || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  87192. var size = options.size || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].One();
  87193. var angle = options.angle || 0;
  87194. // Getting correct rotation
  87195. if (!normal) {
  87196. var target = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 1);
  87197. var camera = sourceMesh.getScene().activeCamera;
  87198. var cameraWorldTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(target, camera.getWorldMatrix());
  87199. normal = camera.globalPosition.subtract(cameraWorldTarget);
  87200. }
  87201. var yaw = -Math.atan2(normal.z, normal.x) - Math.PI / 2;
  87202. var len = Math.sqrt(normal.x * normal.x + normal.z * normal.z);
  87203. var pitch = Math.atan2(normal.y, len);
  87204. // Matrix
  87205. var decalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationYawPitchRoll(yaw, pitch, angle).multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Translation(position.x, position.y, position.z));
  87206. var inverseDecalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Invert(decalWorldMatrix);
  87207. var meshWorldMatrix = sourceMesh.getWorldMatrix();
  87208. var transformMatrix = meshWorldMatrix.multiply(inverseDecalWorldMatrix);
  87209. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"]();
  87210. vertexData.indices = [];
  87211. vertexData.positions = [];
  87212. vertexData.normals = [];
  87213. vertexData.uvs = [];
  87214. var currentVertexDataIndex = 0;
  87215. var extractDecalVector3 = function (indexId) {
  87216. var result = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["PositionNormalVertex"]();
  87217. if (!indices || !positions || !normals) {
  87218. return result;
  87219. }
  87220. var vertexId = indices[indexId];
  87221. result.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](positions[vertexId * 3], positions[vertexId * 3 + 1], positions[vertexId * 3 + 2]);
  87222. // Send vector to decal local world
  87223. result.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(result.position, transformMatrix);
  87224. // Get normal
  87225. result.normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](normals[vertexId * 3], normals[vertexId * 3 + 1], normals[vertexId * 3 + 2]);
  87226. result.normal = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(result.normal, transformMatrix);
  87227. return result;
  87228. }; // Inspired by https://github.com/mrdoob/three.js/blob/eee231960882f6f3b6113405f524956145148146/examples/js/geometries/DecalGeometry.js
  87229. var clip = function (vertices, axis) {
  87230. if (vertices.length === 0) {
  87231. return vertices;
  87232. }
  87233. var clipSize = 0.5 * Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(size, axis));
  87234. var clipVertices = function (v0, v1) {
  87235. var clipFactor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].GetClipFactor(v0.position, v1.position, axis, clipSize);
  87236. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["PositionNormalVertex"](_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Lerp(v0.position, v1.position, clipFactor), _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Lerp(v0.normal, v1.normal, clipFactor));
  87237. };
  87238. var result = new Array();
  87239. for (var index = 0; index < vertices.length; index += 3) {
  87240. var v1Out;
  87241. var v2Out;
  87242. var v3Out;
  87243. var total = 0;
  87244. var nV1 = null;
  87245. var nV2 = null;
  87246. var nV3 = null;
  87247. var nV4 = null;
  87248. var d1 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(vertices[index].position, axis) - clipSize;
  87249. var d2 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(vertices[index + 1].position, axis) - clipSize;
  87250. var d3 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(vertices[index + 2].position, axis) - clipSize;
  87251. v1Out = d1 > 0;
  87252. v2Out = d2 > 0;
  87253. v3Out = d3 > 0;
  87254. total = (v1Out ? 1 : 0) + (v2Out ? 1 : 0) + (v3Out ? 1 : 0);
  87255. switch (total) {
  87256. case 0:
  87257. result.push(vertices[index]);
  87258. result.push(vertices[index + 1]);
  87259. result.push(vertices[index + 2]);
  87260. break;
  87261. case 1:
  87262. if (v1Out) {
  87263. nV1 = vertices[index + 1];
  87264. nV2 = vertices[index + 2];
  87265. nV3 = clipVertices(vertices[index], nV1);
  87266. nV4 = clipVertices(vertices[index], nV2);
  87267. }
  87268. if (v2Out) {
  87269. nV1 = vertices[index];
  87270. nV2 = vertices[index + 2];
  87271. nV3 = clipVertices(vertices[index + 1], nV1);
  87272. nV4 = clipVertices(vertices[index + 1], nV2);
  87273. result.push(nV3);
  87274. result.push(nV2.clone());
  87275. result.push(nV1.clone());
  87276. result.push(nV2.clone());
  87277. result.push(nV3.clone());
  87278. result.push(nV4);
  87279. break;
  87280. }
  87281. if (v3Out) {
  87282. nV1 = vertices[index];
  87283. nV2 = vertices[index + 1];
  87284. nV3 = clipVertices(vertices[index + 2], nV1);
  87285. nV4 = clipVertices(vertices[index + 2], nV2);
  87286. }
  87287. if (nV1 && nV2 && nV3 && nV4) {
  87288. result.push(nV1.clone());
  87289. result.push(nV2.clone());
  87290. result.push(nV3);
  87291. result.push(nV4);
  87292. result.push(nV3.clone());
  87293. result.push(nV2.clone());
  87294. }
  87295. break;
  87296. case 2:
  87297. if (!v1Out) {
  87298. nV1 = vertices[index].clone();
  87299. nV2 = clipVertices(nV1, vertices[index + 1]);
  87300. nV3 = clipVertices(nV1, vertices[index + 2]);
  87301. result.push(nV1);
  87302. result.push(nV2);
  87303. result.push(nV3);
  87304. }
  87305. if (!v2Out) {
  87306. nV1 = vertices[index + 1].clone();
  87307. nV2 = clipVertices(nV1, vertices[index + 2]);
  87308. nV3 = clipVertices(nV1, vertices[index]);
  87309. result.push(nV1);
  87310. result.push(nV2);
  87311. result.push(nV3);
  87312. }
  87313. if (!v3Out) {
  87314. nV1 = vertices[index + 2].clone();
  87315. nV2 = clipVertices(nV1, vertices[index]);
  87316. nV3 = clipVertices(nV1, vertices[index + 1]);
  87317. result.push(nV1);
  87318. result.push(nV2);
  87319. result.push(nV3);
  87320. }
  87321. break;
  87322. case 3:
  87323. break;
  87324. }
  87325. }
  87326. return result;
  87327. };
  87328. for (var index = 0; index < indices.length; index += 3) {
  87329. var faceVertices = new Array();
  87330. faceVertices.push(extractDecalVector3(index));
  87331. faceVertices.push(extractDecalVector3(index + 1));
  87332. faceVertices.push(extractDecalVector3(index + 2));
  87333. // Clip
  87334. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 0, 0));
  87335. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](-1, 0, 0));
  87336. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0));
  87337. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, -1, 0));
  87338. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 1));
  87339. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, -1));
  87340. if (faceVertices.length === 0) {
  87341. continue;
  87342. }
  87343. // Add UVs and get back to world
  87344. for (var vIndex = 0; vIndex < faceVertices.length; vIndex++) {
  87345. var vertex = faceVertices[vIndex];
  87346. //TODO check for Int32Array | Uint32Array | Uint16Array
  87347. vertexData.indices.push(currentVertexDataIndex);
  87348. vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);
  87349. vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);
  87350. vertexData.uvs.push(0.5 + vertex.position.x / size.x);
  87351. vertexData.uvs.push(0.5 + vertex.position.y / size.y);
  87352. currentVertexDataIndex++;
  87353. }
  87354. }
  87355. // Return mesh
  87356. var decal = new _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](name, sourceMesh.getScene());
  87357. vertexData.applyToMesh(decal);
  87358. decal.position = position.clone();
  87359. decal.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](pitch, yaw, angle);
  87360. return decal;
  87361. };
  87362. // Privates
  87363. MeshBuilder._ExtrudeShapeGeneric = function (name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs) {
  87364. // extrusion geometry
  87365. var extrusionPathArray = function (shape, curve, path3D, shapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom) {
  87366. var tangents = path3D.getTangents();
  87367. var normals = path3D.getNormals();
  87368. var binormals = path3D.getBinormals();
  87369. var distances = path3D.getDistances();
  87370. var angle = 0;
  87371. var returnScale = function () { return scale !== null ? scale : 1; };
  87372. var returnRotation = function () { return rotation !== null ? rotation : 0; };
  87373. var rotate = custom && rotateFunction ? rotateFunction : returnRotation;
  87374. var scl = custom && scaleFunction ? scaleFunction : returnScale;
  87375. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_END) ? 0 : 2;
  87376. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0];
  87377. for (var i = 0; i < curve.length; i++) {
  87378. var shapePath = new Array();
  87379. var angleStep = rotate(i, distances[i]);
  87380. var scaleRatio = scl(i, distances[i]);
  87381. for (var p = 0; p < shape.length; p++) {
  87382. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationAxisToRef(tangents[i], angle, rotationMatrix);
  87383. var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
  87384. var rotated = shapePath[p] ? shapePath[p] : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  87385. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(planed, rotationMatrix, rotated);
  87386. rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);
  87387. shapePath[p] = rotated;
  87388. }
  87389. shapePaths[index] = shapePath;
  87390. angle += angleStep;
  87391. index++;
  87392. }
  87393. // cap
  87394. var capPath = function (shapePath) {
  87395. var pointCap = Array();
  87396. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  87397. var i;
  87398. for (i = 0; i < shapePath.length; i++) {
  87399. barycenter.addInPlace(shapePath[i]);
  87400. }
  87401. barycenter.scaleInPlace(1.0 / shapePath.length);
  87402. for (i = 0; i < shapePath.length; i++) {
  87403. pointCap.push(barycenter);
  87404. }
  87405. return pointCap;
  87406. };
  87407. switch (cap) {
  87408. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].NO_CAP:
  87409. break;
  87410. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_START:
  87411. shapePaths[0] = capPath(shapePaths[2]);
  87412. shapePaths[1] = shapePaths[2];
  87413. break;
  87414. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_END:
  87415. shapePaths[index] = shapePaths[index - 1];
  87416. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  87417. break;
  87418. case _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CAP_ALL:
  87419. shapePaths[0] = capPath(shapePaths[2]);
  87420. shapePaths[1] = shapePaths[2];
  87421. shapePaths[index] = shapePaths[index - 1];
  87422. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  87423. break;
  87424. default:
  87425. break;
  87426. }
  87427. return shapePaths;
  87428. };
  87429. var path3D;
  87430. var pathArray;
  87431. if (instance) { // instance update
  87432. var storage = instance._creationDataStorage;
  87433. path3D = storage.path3D.update(curve);
  87434. pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom);
  87435. instance = _mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateRibbon("", pathArray, false, false, 0, scene || undefined, false, 0, instance);
  87436. return instance;
  87437. }
  87438. // extruded shape creation
  87439. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path3D"](curve);
  87440. var newShapePaths = new Array();
  87441. cap = (cap < 0 || cap > 3) ? 0 : cap;
  87442. pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom);
  87443. var extrudedGeneric = MeshBuilder.CreateRibbon(name, { pathArray: pathArray, closeArray: rbCA, closePath: rbCP, updatable: updtbl, sideOrientation: side, invertUV: invertUV, frontUVs: frontUVs || undefined, backUVs: backUVs || undefined }, scene);
  87444. extrudedGeneric._creationDataStorage.pathArray = pathArray;
  87445. extrudedGeneric._creationDataStorage.path3D = path3D;
  87446. extrudedGeneric._creationDataStorage.cap = cap;
  87447. return extrudedGeneric;
  87448. };
  87449. return MeshBuilder;
  87450. }());
  87451. /***/ }),
  87452. /***/ "./Meshes/meshSimplification.ts":
  87453. /*!**************************************!*\
  87454. !*** ./Meshes/meshSimplification.ts ***!
  87455. \**************************************/
  87456. /*! exports provided: SimplificationSettings, SimplificationQueue, SimplificationType */
  87457. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  87458. "use strict";
  87459. __webpack_require__.r(__webpack_exports__);
  87460. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return SimplificationSettings; });
  87461. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return SimplificationQueue; });
  87462. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return SimplificationType; });
  87463. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  87464. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  87465. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  87466. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  87467. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  87468. /**
  87469. * Class used to specify simplification options
  87470. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  87471. */
  87472. var SimplificationSettings = /** @class */ (function () {
  87473. /**
  87474. * Creates a SimplificationSettings
  87475. * @param quality expected quality
  87476. * @param distance distance when this optimized version should be used
  87477. * @param optimizeMesh already optimized mesh
  87478. */
  87479. function SimplificationSettings(
  87480. /** expected quality */
  87481. quality,
  87482. /** distance when this optimized version should be used */
  87483. distance,
  87484. /** already optimized mesh */
  87485. optimizeMesh) {
  87486. this.quality = quality;
  87487. this.distance = distance;
  87488. this.optimizeMesh = optimizeMesh;
  87489. }
  87490. return SimplificationSettings;
  87491. }());
  87492. /**
  87493. * Queue used to order the simplification tasks
  87494. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  87495. */
  87496. var SimplificationQueue = /** @class */ (function () {
  87497. /**
  87498. * Creates a new queue
  87499. */
  87500. function SimplificationQueue() {
  87501. this.running = false;
  87502. this._simplificationArray = [];
  87503. }
  87504. /**
  87505. * Adds a new simplification task
  87506. * @param task defines a task to add
  87507. */
  87508. SimplificationQueue.prototype.addTask = function (task) {
  87509. this._simplificationArray.push(task);
  87510. };
  87511. /**
  87512. * Execute next task
  87513. */
  87514. SimplificationQueue.prototype.executeNext = function () {
  87515. var task = this._simplificationArray.pop();
  87516. if (task) {
  87517. this.running = true;
  87518. this.runSimplification(task);
  87519. }
  87520. else {
  87521. this.running = false;
  87522. }
  87523. };
  87524. /**
  87525. * Execute a simplification task
  87526. * @param task defines the task to run
  87527. */
  87528. SimplificationQueue.prototype.runSimplification = function (task) {
  87529. var _this = this;
  87530. if (task.parallelProcessing) {
  87531. //parallel simplifier
  87532. task.settings.forEach(function (setting) {
  87533. var simplifier = _this.getSimplifier(task);
  87534. simplifier.simplify(setting, function (newMesh) {
  87535. task.mesh.addLODLevel(setting.distance, newMesh);
  87536. newMesh.isVisible = true;
  87537. //check if it is the last
  87538. if (setting.quality === task.settings[task.settings.length - 1].quality && task.successCallback) {
  87539. //all done, run the success callback.
  87540. task.successCallback();
  87541. }
  87542. _this.executeNext();
  87543. });
  87544. });
  87545. }
  87546. else {
  87547. //single simplifier.
  87548. var simplifier = this.getSimplifier(task);
  87549. var runDecimation = function (setting, callback) {
  87550. simplifier.simplify(setting, function (newMesh) {
  87551. task.mesh.addLODLevel(setting.distance, newMesh);
  87552. newMesh.isVisible = true;
  87553. //run the next quality level
  87554. callback();
  87555. });
  87556. };
  87557. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(task.settings.length, function (loop) {
  87558. runDecimation(task.settings[loop.index], function () {
  87559. loop.executeNext();
  87560. });
  87561. }, function () {
  87562. //execution ended, run the success callback.
  87563. if (task.successCallback) {
  87564. task.successCallback();
  87565. }
  87566. _this.executeNext();
  87567. });
  87568. }
  87569. };
  87570. SimplificationQueue.prototype.getSimplifier = function (task) {
  87571. switch (task.simplificationType) {
  87572. case SimplificationType.QUADRATIC:
  87573. default:
  87574. return new QuadraticErrorSimplification(task.mesh);
  87575. }
  87576. };
  87577. return SimplificationQueue;
  87578. }());
  87579. /**
  87580. * The implemented types of simplification
  87581. * At the moment only Quadratic Error Decimation is implemented
  87582. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  87583. */
  87584. var SimplificationType;
  87585. (function (SimplificationType) {
  87586. /** Quadratic error decimation */
  87587. SimplificationType[SimplificationType["QUADRATIC"] = 0] = "QUADRATIC";
  87588. })(SimplificationType || (SimplificationType = {}));
  87589. var DecimationTriangle = /** @class */ (function () {
  87590. function DecimationTriangle(vertices) {
  87591. this.vertices = vertices;
  87592. this.error = new Array(4);
  87593. this.deleted = false;
  87594. this.isDirty = false;
  87595. this.deletePending = false;
  87596. this.borderFactor = 0;
  87597. }
  87598. return DecimationTriangle;
  87599. }());
  87600. var DecimationVertex = /** @class */ (function () {
  87601. function DecimationVertex(position, id) {
  87602. this.position = position;
  87603. this.id = id;
  87604. this.isBorder = true;
  87605. this.q = new QuadraticMatrix();
  87606. this.triangleCount = 0;
  87607. this.triangleStart = 0;
  87608. this.originalOffsets = [];
  87609. }
  87610. DecimationVertex.prototype.updatePosition = function (newPosition) {
  87611. this.position.copyFrom(newPosition);
  87612. };
  87613. return DecimationVertex;
  87614. }());
  87615. var QuadraticMatrix = /** @class */ (function () {
  87616. function QuadraticMatrix(data) {
  87617. this.data = new Array(10);
  87618. for (var i = 0; i < 10; ++i) {
  87619. if (data && data[i]) {
  87620. this.data[i] = data[i];
  87621. }
  87622. else {
  87623. this.data[i] = 0;
  87624. }
  87625. }
  87626. }
  87627. QuadraticMatrix.prototype.det = function (a11, a12, a13, a21, a22, a23, a31, a32, a33) {
  87628. var det = this.data[a11] * this.data[a22] * this.data[a33] + this.data[a13] * this.data[a21] * this.data[a32] +
  87629. this.data[a12] * this.data[a23] * this.data[a31] - this.data[a13] * this.data[a22] * this.data[a31] -
  87630. this.data[a11] * this.data[a23] * this.data[a32] - this.data[a12] * this.data[a21] * this.data[a33];
  87631. return det;
  87632. };
  87633. QuadraticMatrix.prototype.addInPlace = function (matrix) {
  87634. for (var i = 0; i < 10; ++i) {
  87635. this.data[i] += matrix.data[i];
  87636. }
  87637. };
  87638. QuadraticMatrix.prototype.addArrayInPlace = function (data) {
  87639. for (var i = 0; i < 10; ++i) {
  87640. this.data[i] += data[i];
  87641. }
  87642. };
  87643. QuadraticMatrix.prototype.add = function (matrix) {
  87644. var m = new QuadraticMatrix();
  87645. for (var i = 0; i < 10; ++i) {
  87646. m.data[i] = this.data[i] + matrix.data[i];
  87647. }
  87648. return m;
  87649. };
  87650. QuadraticMatrix.FromData = function (a, b, c, d) {
  87651. return new QuadraticMatrix(QuadraticMatrix.DataFromNumbers(a, b, c, d));
  87652. };
  87653. //returning an array to avoid garbage collection
  87654. QuadraticMatrix.DataFromNumbers = function (a, b, c, d) {
  87655. return [a * a, a * b, a * c, a * d, b * b, b * c, b * d, c * c, c * d, d * d];
  87656. };
  87657. return QuadraticMatrix;
  87658. }());
  87659. var Reference = /** @class */ (function () {
  87660. function Reference(vertexId, triangleId) {
  87661. this.vertexId = vertexId;
  87662. this.triangleId = triangleId;
  87663. }
  87664. return Reference;
  87665. }());
  87666. /**
  87667. * An implementation of the Quadratic Error simplification algorithm.
  87668. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  87669. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  87670. * @author RaananW
  87671. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  87672. */
  87673. var QuadraticErrorSimplification = /** @class */ (function () {
  87674. function QuadraticErrorSimplification(_mesh) {
  87675. this._mesh = _mesh;
  87676. this.syncIterations = 5000;
  87677. this.aggressiveness = 7;
  87678. this.decimationIterations = 100;
  87679. this.boundingBoxEpsilon = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"];
  87680. }
  87681. QuadraticErrorSimplification.prototype.simplify = function (settings, successCallback) {
  87682. var _this = this;
  87683. this.initDecimatedMesh();
  87684. //iterating through the submeshes array, one after the other.
  87685. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this._mesh.subMeshes.length, function (loop) {
  87686. _this.initWithMesh(loop.index, function () {
  87687. _this.runDecimation(settings, loop.index, function () {
  87688. loop.executeNext();
  87689. });
  87690. }, settings.optimizeMesh);
  87691. }, function () {
  87692. setTimeout(function () {
  87693. successCallback(_this._reconstructedMesh);
  87694. }, 0);
  87695. });
  87696. };
  87697. QuadraticErrorSimplification.prototype.runDecimation = function (settings, submeshIndex, successCallback) {
  87698. var _this = this;
  87699. var targetCount = ~~(this.triangles.length * settings.quality);
  87700. var deletedTriangles = 0;
  87701. var triangleCount = this.triangles.length;
  87702. var iterationFunction = function (iteration, callback) {
  87703. setTimeout(function () {
  87704. if (iteration % 5 === 0) {
  87705. _this.updateMesh(iteration === 0);
  87706. }
  87707. for (var i = 0; i < _this.triangles.length; ++i) {
  87708. _this.triangles[i].isDirty = false;
  87709. }
  87710. var threshold = 0.000000001 * Math.pow((iteration + 3), _this.aggressiveness);
  87711. var trianglesIterator = function (i) {
  87712. var tIdx = ~~(((_this.triangles.length / 2) + i) % _this.triangles.length);
  87713. var t = _this.triangles[tIdx];
  87714. if (!t) {
  87715. return;
  87716. }
  87717. if (t.error[3] > threshold || t.deleted || t.isDirty) {
  87718. return;
  87719. }
  87720. for (var j = 0; j < 3; ++j) {
  87721. if (t.error[j] < threshold) {
  87722. var deleted0 = [];
  87723. var deleted1 = [];
  87724. var v0 = t.vertices[j];
  87725. var v1 = t.vertices[(j + 1) % 3];
  87726. if (v0.isBorder || v1.isBorder) {
  87727. continue;
  87728. }
  87729. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87730. // var n = Vector3.Zero();
  87731. // var uv = Vector2.Zero();
  87732. // var color = new Color4(0, 0, 0, 1);
  87733. _this.calculateError(v0, v1, p);
  87734. var delTr = new Array();
  87735. if (_this.isFlipped(v0, v1, p, deleted0, delTr)) {
  87736. continue;
  87737. }
  87738. if (_this.isFlipped(v1, v0, p, deleted1, delTr)) {
  87739. continue;
  87740. }
  87741. if (deleted0.indexOf(true) < 0 || deleted1.indexOf(true) < 0) {
  87742. continue;
  87743. }
  87744. var uniqueArray = new Array();
  87745. delTr.forEach(function (deletedT) {
  87746. if (uniqueArray.indexOf(deletedT) === -1) {
  87747. deletedT.deletePending = true;
  87748. uniqueArray.push(deletedT);
  87749. }
  87750. });
  87751. if (uniqueArray.length % 2 !== 0) {
  87752. continue;
  87753. }
  87754. v0.q = v1.q.add(v0.q);
  87755. v0.updatePosition(p);
  87756. var tStart = _this.references.length;
  87757. deletedTriangles = _this.updateTriangles(v0, v0, deleted0, deletedTriangles);
  87758. deletedTriangles = _this.updateTriangles(v0, v1, deleted1, deletedTriangles);
  87759. var tCount = _this.references.length - tStart;
  87760. if (tCount <= v0.triangleCount) {
  87761. if (tCount) {
  87762. for (var c = 0; c < tCount; c++) {
  87763. _this.references[v0.triangleStart + c] = _this.references[tStart + c];
  87764. }
  87765. }
  87766. }
  87767. else {
  87768. v0.triangleStart = tStart;
  87769. }
  87770. v0.triangleCount = tCount;
  87771. break;
  87772. }
  87773. }
  87774. };
  87775. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, trianglesIterator, callback, function () { return (triangleCount - deletedTriangles <= targetCount); });
  87776. }, 0);
  87777. };
  87778. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this.decimationIterations, function (loop) {
  87779. if (triangleCount - deletedTriangles <= targetCount) {
  87780. loop.breakLoop();
  87781. }
  87782. else {
  87783. iterationFunction(loop.index, function () {
  87784. loop.executeNext();
  87785. });
  87786. }
  87787. }, function () {
  87788. setTimeout(function () {
  87789. //reconstruct this part of the mesh
  87790. _this.reconstructMesh(submeshIndex);
  87791. successCallback();
  87792. }, 0);
  87793. });
  87794. };
  87795. QuadraticErrorSimplification.prototype.initWithMesh = function (submeshIndex, callback, optimizeMesh) {
  87796. var _this = this;
  87797. this.vertices = [];
  87798. this.triangles = [];
  87799. var positionData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  87800. var indices = this._mesh.getIndices();
  87801. var submesh = this._mesh.subMeshes[submeshIndex];
  87802. var findInVertices = function (positionToSearch) {
  87803. if (optimizeMesh) {
  87804. for (var ii = 0; ii < _this.vertices.length; ++ii) {
  87805. if (_this.vertices[ii].position.equals(positionToSearch)) {
  87806. return _this.vertices[ii];
  87807. }
  87808. }
  87809. }
  87810. return null;
  87811. };
  87812. var vertexReferences = [];
  87813. var vertexInit = function (i) {
  87814. if (!positionData) {
  87815. return;
  87816. }
  87817. var offset = i + submesh.verticesStart;
  87818. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positionData, offset * 3);
  87819. var vertex = findInVertices(position) || new DecimationVertex(position, _this.vertices.length);
  87820. vertex.originalOffsets.push(offset);
  87821. if (vertex.id === _this.vertices.length) {
  87822. _this.vertices.push(vertex);
  87823. }
  87824. vertexReferences.push(vertex.id);
  87825. };
  87826. //var totalVertices = mesh.getTotalVertices();
  87827. var totalVertices = submesh.verticesCount;
  87828. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(totalVertices, (this.syncIterations / 4) >> 0, vertexInit, function () {
  87829. var indicesInit = function (i) {
  87830. if (!indices) {
  87831. return;
  87832. }
  87833. var offset = (submesh.indexStart / 3) + i;
  87834. var pos = (offset * 3);
  87835. var i0 = indices[pos + 0];
  87836. var i1 = indices[pos + 1];
  87837. var i2 = indices[pos + 2];
  87838. var v0 = _this.vertices[vertexReferences[i0 - submesh.verticesStart]];
  87839. var v1 = _this.vertices[vertexReferences[i1 - submesh.verticesStart]];
  87840. var v2 = _this.vertices[vertexReferences[i2 - submesh.verticesStart]];
  87841. var triangle = new DecimationTriangle([v0, v1, v2]);
  87842. triangle.originalOffset = pos;
  87843. _this.triangles.push(triangle);
  87844. };
  87845. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(submesh.indexCount / 3, _this.syncIterations, indicesInit, function () {
  87846. _this.init(callback);
  87847. });
  87848. });
  87849. };
  87850. QuadraticErrorSimplification.prototype.init = function (callback) {
  87851. var _this = this;
  87852. var triangleInit1 = function (i) {
  87853. var t = _this.triangles[i];
  87854. 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();
  87855. for (var j = 0; j < 3; j++) {
  87856. 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))));
  87857. }
  87858. };
  87859. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(this.triangles.length, this.syncIterations, triangleInit1, function () {
  87860. var triangleInit2 = function (i) {
  87861. var t = _this.triangles[i];
  87862. for (var j = 0; j < 3; ++j) {
  87863. t.error[j] = _this.calculateError(t.vertices[j], t.vertices[(j + 1) % 3]);
  87864. }
  87865. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  87866. };
  87867. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, triangleInit2, function () {
  87868. callback();
  87869. });
  87870. });
  87871. };
  87872. QuadraticErrorSimplification.prototype.reconstructMesh = function (submeshIndex) {
  87873. var newTriangles = [];
  87874. var i;
  87875. for (i = 0; i < this.vertices.length; ++i) {
  87876. this.vertices[i].triangleCount = 0;
  87877. }
  87878. var t;
  87879. var j;
  87880. for (i = 0; i < this.triangles.length; ++i) {
  87881. if (!this.triangles[i].deleted) {
  87882. t = this.triangles[i];
  87883. for (j = 0; j < 3; ++j) {
  87884. t.vertices[j].triangleCount = 1;
  87885. }
  87886. newTriangles.push(t);
  87887. }
  87888. }
  87889. var newPositionData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind) || []);
  87890. var newNormalData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind) || []);
  87891. var newUVsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind) || []);
  87892. var newColorsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind) || []);
  87893. var normalData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  87894. var uvs = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  87895. var colorsData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  87896. var vertexCount = 0;
  87897. for (i = 0; i < this.vertices.length; ++i) {
  87898. var vertex = this.vertices[i];
  87899. vertex.id = vertexCount;
  87900. if (vertex.triangleCount) {
  87901. vertex.originalOffsets.forEach(function (originalOffset) {
  87902. if (!normalData) {
  87903. return;
  87904. }
  87905. newPositionData.push(vertex.position.x);
  87906. newPositionData.push(vertex.position.y);
  87907. newPositionData.push(vertex.position.z);
  87908. newNormalData.push(normalData[originalOffset * 3]);
  87909. newNormalData.push(normalData[(originalOffset * 3) + 1]);
  87910. newNormalData.push(normalData[(originalOffset * 3) + 2]);
  87911. if (uvs && uvs.length) {
  87912. newUVsData.push(uvs[(originalOffset * 2)]);
  87913. newUVsData.push(uvs[(originalOffset * 2) + 1]);
  87914. }
  87915. else if (colorsData && colorsData.length) {
  87916. newColorsData.push(colorsData[(originalOffset * 4)]);
  87917. newColorsData.push(colorsData[(originalOffset * 4) + 1]);
  87918. newColorsData.push(colorsData[(originalOffset * 4) + 2]);
  87919. newColorsData.push(colorsData[(originalOffset * 4) + 3]);
  87920. }
  87921. ++vertexCount;
  87922. });
  87923. }
  87924. }
  87925. var startingIndex = this._reconstructedMesh.getTotalIndices();
  87926. var startingVertex = this._reconstructedMesh.getTotalVertices();
  87927. var submeshesArray = this._reconstructedMesh.subMeshes;
  87928. this._reconstructedMesh.subMeshes = [];
  87929. var newIndicesArray = this._reconstructedMesh.getIndices(); //[];
  87930. var originalIndices = this._mesh.getIndices();
  87931. for (i = 0; i < newTriangles.length; ++i) {
  87932. t = newTriangles[i]; //now get the new referencing point for each vertex
  87933. [0, 1, 2].forEach(function (idx) {
  87934. var id = originalIndices[t.originalOffset + idx];
  87935. var offset = t.vertices[idx].originalOffsets.indexOf(id);
  87936. if (offset < 0) {
  87937. offset = 0;
  87938. }
  87939. newIndicesArray.push(t.vertices[idx].id + offset + startingVertex);
  87940. });
  87941. }
  87942. //overwriting the old vertex buffers and indices.
  87943. this._reconstructedMesh.setIndices(newIndicesArray);
  87944. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, newPositionData);
  87945. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, newNormalData);
  87946. if (newUVsData.length > 0) {
  87947. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, newUVsData);
  87948. }
  87949. if (newColorsData.length > 0) {
  87950. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, newColorsData);
  87951. }
  87952. //create submesh
  87953. var originalSubmesh = this._mesh.subMeshes[submeshIndex];
  87954. if (submeshIndex > 0) {
  87955. this._reconstructedMesh.subMeshes = [];
  87956. submeshesArray.forEach(function (submesh) {
  87957. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(submesh.materialIndex, submesh.verticesStart, submesh.verticesCount, /* 0, newPositionData.length/3, */ submesh.indexStart, submesh.indexCount, submesh.getMesh());
  87958. });
  87959. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(originalSubmesh.materialIndex, startingVertex, vertexCount, /* 0, newPositionData.length / 3, */ startingIndex, newTriangles.length * 3, this._reconstructedMesh);
  87960. }
  87961. };
  87962. QuadraticErrorSimplification.prototype.initDecimatedMesh = function () {
  87963. this._reconstructedMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this._mesh.name + "Decimated", this._mesh.getScene());
  87964. this._reconstructedMesh.material = this._mesh.material;
  87965. this._reconstructedMesh.parent = this._mesh.parent;
  87966. this._reconstructedMesh.isVisible = false;
  87967. this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId;
  87968. };
  87969. QuadraticErrorSimplification.prototype.isFlipped = function (vertex1, vertex2, point, deletedArray, delTr) {
  87970. for (var i = 0; i < vertex1.triangleCount; ++i) {
  87971. var t = this.triangles[this.references[vertex1.triangleStart + i].triangleId];
  87972. if (t.deleted) {
  87973. continue;
  87974. }
  87975. var s = this.references[vertex1.triangleStart + i].vertexId;
  87976. var v1 = t.vertices[(s + 1) % 3];
  87977. var v2 = t.vertices[(s + 2) % 3];
  87978. if ((v1 === vertex2 || v2 === vertex2)) {
  87979. deletedArray[i] = true;
  87980. delTr.push(t);
  87981. continue;
  87982. }
  87983. var d1 = v1.position.subtract(point);
  87984. d1 = d1.normalize();
  87985. var d2 = v2.position.subtract(point);
  87986. d2 = d2.normalize();
  87987. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(d1, d2)) > 0.999) {
  87988. return true;
  87989. }
  87990. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(d1, d2).normalize();
  87991. deletedArray[i] = false;
  87992. if (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(normal, t.normal) < 0.2) {
  87993. return true;
  87994. }
  87995. }
  87996. return false;
  87997. };
  87998. QuadraticErrorSimplification.prototype.updateTriangles = function (origVertex, vertex, deletedArray, deletedTriangles) {
  87999. var newDeleted = deletedTriangles;
  88000. for (var i = 0; i < vertex.triangleCount; ++i) {
  88001. var ref = this.references[vertex.triangleStart + i];
  88002. var t = this.triangles[ref.triangleId];
  88003. if (t.deleted) {
  88004. continue;
  88005. }
  88006. if (deletedArray[i] && t.deletePending) {
  88007. t.deleted = true;
  88008. newDeleted++;
  88009. continue;
  88010. }
  88011. t.vertices[ref.vertexId] = origVertex;
  88012. t.isDirty = true;
  88013. t.error[0] = this.calculateError(t.vertices[0], t.vertices[1]) + (t.borderFactor / 2);
  88014. t.error[1] = this.calculateError(t.vertices[1], t.vertices[2]) + (t.borderFactor / 2);
  88015. t.error[2] = this.calculateError(t.vertices[2], t.vertices[0]) + (t.borderFactor / 2);
  88016. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  88017. this.references.push(ref);
  88018. }
  88019. return newDeleted;
  88020. };
  88021. QuadraticErrorSimplification.prototype.identifyBorder = function () {
  88022. for (var i = 0; i < this.vertices.length; ++i) {
  88023. var vCount = [];
  88024. var vId = [];
  88025. var v = this.vertices[i];
  88026. var j;
  88027. for (j = 0; j < v.triangleCount; ++j) {
  88028. var triangle = this.triangles[this.references[v.triangleStart + j].triangleId];
  88029. for (var ii = 0; ii < 3; ii++) {
  88030. var ofs = 0;
  88031. var vv = triangle.vertices[ii];
  88032. while (ofs < vCount.length) {
  88033. if (vId[ofs] === vv.id) {
  88034. break;
  88035. }
  88036. ++ofs;
  88037. }
  88038. if (ofs === vCount.length) {
  88039. vCount.push(1);
  88040. vId.push(vv.id);
  88041. }
  88042. else {
  88043. vCount[ofs]++;
  88044. }
  88045. }
  88046. }
  88047. for (j = 0; j < vCount.length; ++j) {
  88048. if (vCount[j] === 1) {
  88049. this.vertices[vId[j]].isBorder = true;
  88050. }
  88051. else {
  88052. this.vertices[vId[j]].isBorder = false;
  88053. }
  88054. }
  88055. }
  88056. };
  88057. QuadraticErrorSimplification.prototype.updateMesh = function (identifyBorders) {
  88058. if (identifyBorders === void 0) { identifyBorders = false; }
  88059. var i;
  88060. if (!identifyBorders) {
  88061. var newTrianglesVector = [];
  88062. for (i = 0; i < this.triangles.length; ++i) {
  88063. if (!this.triangles[i].deleted) {
  88064. newTrianglesVector.push(this.triangles[i]);
  88065. }
  88066. }
  88067. this.triangles = newTrianglesVector;
  88068. }
  88069. for (i = 0; i < this.vertices.length; ++i) {
  88070. this.vertices[i].triangleCount = 0;
  88071. this.vertices[i].triangleStart = 0;
  88072. }
  88073. var t;
  88074. var j;
  88075. var v;
  88076. for (i = 0; i < this.triangles.length; ++i) {
  88077. t = this.triangles[i];
  88078. for (j = 0; j < 3; ++j) {
  88079. v = t.vertices[j];
  88080. v.triangleCount++;
  88081. }
  88082. }
  88083. var tStart = 0;
  88084. for (i = 0; i < this.vertices.length; ++i) {
  88085. this.vertices[i].triangleStart = tStart;
  88086. tStart += this.vertices[i].triangleCount;
  88087. this.vertices[i].triangleCount = 0;
  88088. }
  88089. var newReferences = new Array(this.triangles.length * 3);
  88090. for (i = 0; i < this.triangles.length; ++i) {
  88091. t = this.triangles[i];
  88092. for (j = 0; j < 3; ++j) {
  88093. v = t.vertices[j];
  88094. newReferences[v.triangleStart + v.triangleCount] = new Reference(j, i);
  88095. v.triangleCount++;
  88096. }
  88097. }
  88098. this.references = newReferences;
  88099. if (identifyBorders) {
  88100. this.identifyBorder();
  88101. }
  88102. };
  88103. QuadraticErrorSimplification.prototype.vertexError = function (q, point) {
  88104. var x = point.x;
  88105. var y = point.y;
  88106. var z = point.z;
  88107. 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
  88108. + 2 * q.data[5] * y * z + 2 * q.data[6] * y + q.data[7] * z * z + 2 * q.data[8] * z + q.data[9];
  88109. };
  88110. QuadraticErrorSimplification.prototype.calculateError = function (vertex1, vertex2, pointResult) {
  88111. var q = vertex1.q.add(vertex2.q);
  88112. var border = vertex1.isBorder && vertex2.isBorder;
  88113. var error = 0;
  88114. var qDet = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
  88115. if (qDet !== 0 && !border) {
  88116. if (!pointResult) {
  88117. pointResult = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  88118. }
  88119. pointResult.x = -1 / qDet * (q.det(1, 2, 3, 4, 5, 6, 5, 7, 8));
  88120. pointResult.y = 1 / qDet * (q.det(0, 2, 3, 1, 5, 6, 2, 7, 8));
  88121. pointResult.z = -1 / qDet * (q.det(0, 1, 3, 1, 4, 6, 2, 5, 8));
  88122. error = this.vertexError(q, pointResult);
  88123. }
  88124. else {
  88125. var p3 = (vertex1.position.add(vertex2.position)).divide(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](2, 2, 2));
  88126. //var norm3 = (vertex1.normal.add(vertex2.normal)).divide(new Vector3(2, 2, 2)).normalize();
  88127. var error1 = this.vertexError(q, vertex1.position);
  88128. var error2 = this.vertexError(q, vertex2.position);
  88129. var error3 = this.vertexError(q, p3);
  88130. error = Math.min(error1, error2, error3);
  88131. if (error === error1) {
  88132. if (pointResult) {
  88133. pointResult.copyFrom(vertex1.position);
  88134. }
  88135. }
  88136. else if (error === error2) {
  88137. if (pointResult) {
  88138. pointResult.copyFrom(vertex2.position);
  88139. }
  88140. }
  88141. else {
  88142. if (pointResult) {
  88143. pointResult.copyFrom(p3);
  88144. }
  88145. }
  88146. }
  88147. return error;
  88148. };
  88149. return QuadraticErrorSimplification;
  88150. }());
  88151. /***/ }),
  88152. /***/ "./Meshes/meshSimplificationSceneComponent.ts":
  88153. /*!****************************************************!*\
  88154. !*** ./Meshes/meshSimplificationSceneComponent.ts ***!
  88155. \****************************************************/
  88156. /*! exports provided: SimplicationQueueSceneComponent */
  88157. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88158. "use strict";
  88159. __webpack_require__.r(__webpack_exports__);
  88160. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return SimplicationQueueSceneComponent; });
  88161. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  88162. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  88163. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  88164. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  88165. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "simplificationQueue", {
  88166. get: function () {
  88167. if (!this._simplificationQueue) {
  88168. this._simplificationQueue = new _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationQueue"]();
  88169. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE);
  88170. if (!component) {
  88171. component = new SimplicationQueueSceneComponent(this);
  88172. this._addComponent(component);
  88173. }
  88174. }
  88175. return this._simplificationQueue;
  88176. },
  88177. set: function (value) {
  88178. this._simplificationQueue = value;
  88179. },
  88180. enumerable: true,
  88181. configurable: true
  88182. });
  88183. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].prototype.simplify = function (settings, parallelProcessing, simplificationType, successCallback) {
  88184. if (parallelProcessing === void 0) { parallelProcessing = true; }
  88185. if (simplificationType === void 0) { simplificationType = _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationType"].QUADRATIC; }
  88186. this.getScene().simplificationQueue.addTask({
  88187. settings: settings,
  88188. parallelProcessing: parallelProcessing,
  88189. mesh: this,
  88190. simplificationType: simplificationType,
  88191. successCallback: successCallback
  88192. });
  88193. return this;
  88194. };
  88195. /**
  88196. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  88197. * created in a scene
  88198. */
  88199. var SimplicationQueueSceneComponent = /** @class */ (function () {
  88200. /**
  88201. * Creates a new instance of the component for the given scene
  88202. * @param scene Defines the scene to register the component in
  88203. */
  88204. function SimplicationQueueSceneComponent(scene) {
  88205. /**
  88206. * The component name helpfull to identify the component in the list of scene components.
  88207. */
  88208. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE;
  88209. this.scene = scene;
  88210. }
  88211. /**
  88212. * Registers the component in a given scene
  88213. */
  88214. SimplicationQueueSceneComponent.prototype.register = function () {
  88215. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate);
  88216. };
  88217. /**
  88218. * Rebuilds the elements related to this component in case of
  88219. * context lost for instance.
  88220. */
  88221. SimplicationQueueSceneComponent.prototype.rebuild = function () {
  88222. // Nothing to do for this component
  88223. };
  88224. /**
  88225. * Disposes the component and the associated ressources
  88226. */
  88227. SimplicationQueueSceneComponent.prototype.dispose = function () {
  88228. // Nothing to do for this component
  88229. };
  88230. SimplicationQueueSceneComponent.prototype._beforeCameraUpdate = function () {
  88231. if (this.scene._simplificationQueue && !this.scene._simplificationQueue.running) {
  88232. this.scene._simplificationQueue.executeNext();
  88233. }
  88234. };
  88235. return SimplicationQueueSceneComponent;
  88236. }());
  88237. /***/ }),
  88238. /***/ "./Meshes/polygonMesh.ts":
  88239. /*!*******************************!*\
  88240. !*** ./Meshes/polygonMesh.ts ***!
  88241. \*******************************/
  88242. /*! exports provided: Polygon, PolygonMeshBuilder */
  88243. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88244. "use strict";
  88245. __webpack_require__.r(__webpack_exports__);
  88246. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return Polygon; });
  88247. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return PolygonMeshBuilder; });
  88248. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  88249. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  88250. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  88251. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  88252. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  88253. /**
  88254. * Vector2 wth index property
  88255. */
  88256. var IndexedVector2 = /** @class */ (function (_super) {
  88257. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IndexedVector2, _super);
  88258. function IndexedVector2(original,
  88259. /** Index of the vector2 */
  88260. index) {
  88261. var _this = _super.call(this, original.x, original.y) || this;
  88262. _this.index = index;
  88263. return _this;
  88264. }
  88265. return IndexedVector2;
  88266. }(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"]));
  88267. /**
  88268. * Defines points to create a polygon
  88269. */
  88270. var PolygonPoints = /** @class */ (function () {
  88271. function PolygonPoints() {
  88272. this.elements = new Array();
  88273. }
  88274. PolygonPoints.prototype.add = function (originalPoints) {
  88275. var _this = this;
  88276. var result = new Array();
  88277. originalPoints.forEach(function (point) {
  88278. if (result.length === 0 || !point.equalsWithEpsilon(result[0])) {
  88279. var newPoint = new IndexedVector2(point, _this.elements.length);
  88280. result.push(newPoint);
  88281. _this.elements.push(newPoint);
  88282. }
  88283. });
  88284. return result;
  88285. };
  88286. PolygonPoints.prototype.computeBounds = function () {
  88287. var lmin = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  88288. var lmax = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  88289. this.elements.forEach(function (point) {
  88290. // x
  88291. if (point.x < lmin.x) {
  88292. lmin.x = point.x;
  88293. }
  88294. else if (point.x > lmax.x) {
  88295. lmax.x = point.x;
  88296. }
  88297. // y
  88298. if (point.y < lmin.y) {
  88299. lmin.y = point.y;
  88300. }
  88301. else if (point.y > lmax.y) {
  88302. lmax.y = point.y;
  88303. }
  88304. });
  88305. return {
  88306. min: lmin,
  88307. max: lmax,
  88308. width: lmax.x - lmin.x,
  88309. height: lmax.y - lmin.y
  88310. };
  88311. };
  88312. return PolygonPoints;
  88313. }());
  88314. /**
  88315. * Polygon
  88316. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  88317. */
  88318. var Polygon = /** @class */ (function () {
  88319. function Polygon() {
  88320. }
  88321. /**
  88322. * Creates a rectangle
  88323. * @param xmin bottom X coord
  88324. * @param ymin bottom Y coord
  88325. * @param xmax top X coord
  88326. * @param ymax top Y coord
  88327. * @returns points that make the resulting rectation
  88328. */
  88329. Polygon.Rectangle = function (xmin, ymin, xmax, ymax) {
  88330. return [
  88331. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymin),
  88332. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymin),
  88333. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymax),
  88334. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymax)
  88335. ];
  88336. };
  88337. /**
  88338. * Creates a circle
  88339. * @param radius radius of circle
  88340. * @param cx scale in x
  88341. * @param cy scale in y
  88342. * @param numberOfSides number of sides that make up the circle
  88343. * @returns points that make the resulting circle
  88344. */
  88345. Polygon.Circle = function (radius, cx, cy, numberOfSides) {
  88346. if (cx === void 0) { cx = 0; }
  88347. if (cy === void 0) { cy = 0; }
  88348. if (numberOfSides === void 0) { numberOfSides = 32; }
  88349. var result = new Array();
  88350. var angle = 0;
  88351. var increment = (Math.PI * 2) / numberOfSides;
  88352. for (var i = 0; i < numberOfSides; i++) {
  88353. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius));
  88354. angle -= increment;
  88355. }
  88356. return result;
  88357. };
  88358. /**
  88359. * Creates a polygon from input string
  88360. * @param input Input polygon data
  88361. * @returns the parsed points
  88362. */
  88363. Polygon.Parse = function (input) {
  88364. var floats = input.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function (val) { return (!isNaN(val)); });
  88365. var i, result = [];
  88366. for (i = 0; i < (floats.length & 0x7FFFFFFE); i += 2) {
  88367. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](floats[i], floats[i + 1]));
  88368. }
  88369. return result;
  88370. };
  88371. /**
  88372. * Starts building a polygon from x and y coordinates
  88373. * @param x x coordinate
  88374. * @param y y coordinate
  88375. * @returns the started path2
  88376. */
  88377. Polygon.StartingAt = function (x, y) {
  88378. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"].StartingAt(x, y);
  88379. };
  88380. return Polygon;
  88381. }());
  88382. /**
  88383. * Builds a polygon
  88384. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  88385. */
  88386. var PolygonMeshBuilder = /** @class */ (function () {
  88387. /**
  88388. * Creates a PolygonMeshBuilder
  88389. * @param name name of the builder
  88390. * @param contours Path of the polygon
  88391. * @param scene scene to add to
  88392. */
  88393. function PolygonMeshBuilder(name, contours, scene, earcutInjection) {
  88394. if (earcutInjection === void 0) { earcutInjection = earcut; }
  88395. this._points = new PolygonPoints();
  88396. this._outlinepoints = new PolygonPoints();
  88397. this._holes = new Array();
  88398. this._epoints = new Array();
  88399. this._eholes = new Array();
  88400. this.bjsEarcut = earcutInjection;
  88401. this._name = name;
  88402. this._scene = scene;
  88403. var points;
  88404. if (contours instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"]) {
  88405. points = contours.getPoints();
  88406. }
  88407. else {
  88408. points = contours;
  88409. }
  88410. this._addToepoint(points);
  88411. this._points.add(points);
  88412. this._outlinepoints.add(points);
  88413. if (typeof this.bjsEarcut === 'undefined') {
  88414. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Earcut was not found, the polygon will not be built.");
  88415. }
  88416. }
  88417. PolygonMeshBuilder.prototype._addToepoint = function (points) {
  88418. for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
  88419. var p = points_1[_i];
  88420. this._epoints.push(p.x, p.y);
  88421. }
  88422. };
  88423. /**
  88424. * Adds a whole within the polygon
  88425. * @param hole Array of points defining the hole
  88426. * @returns this
  88427. */
  88428. PolygonMeshBuilder.prototype.addHole = function (hole) {
  88429. this._points.add(hole);
  88430. var holepoints = new PolygonPoints();
  88431. holepoints.add(hole);
  88432. this._holes.push(holepoints);
  88433. this._eholes.push(this._epoints.length / 2);
  88434. this._addToepoint(hole);
  88435. return this;
  88436. };
  88437. /**
  88438. * Creates the polygon
  88439. * @param updatable If the mesh should be updatable
  88440. * @param depth The depth of the mesh created
  88441. * @returns the created mesh
  88442. */
  88443. PolygonMeshBuilder.prototype.build = function (updatable, depth) {
  88444. var _this = this;
  88445. if (updatable === void 0) { updatable = false; }
  88446. if (depth === void 0) { depth = 0; }
  88447. var result = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this._name, this._scene);
  88448. var normals = new Array();
  88449. var positions = new Array();
  88450. var uvs = new Array();
  88451. var bounds = this._points.computeBounds();
  88452. this._points.elements.forEach(function (p) {
  88453. normals.push(0, 1.0, 0);
  88454. positions.push(p.x, 0, p.y);
  88455. uvs.push((p.x - bounds.min.x) / bounds.width, (p.y - bounds.min.y) / bounds.height);
  88456. });
  88457. var indices = new Array();
  88458. var res = this.bjsEarcut(this._epoints, this._eholes, 2);
  88459. for (var i = 0; i < res.length; i++) {
  88460. indices.push(res[i]);
  88461. }
  88462. if (depth > 0) {
  88463. var positionscount = (positions.length / 3); //get the current pointcount
  88464. this._points.elements.forEach(function (p) {
  88465. normals.push(0, -1.0, 0);
  88466. positions.push(p.x, -depth, p.y);
  88467. uvs.push(1 - (p.x - bounds.min.x) / bounds.width, 1 - (p.y - bounds.min.y) / bounds.height);
  88468. });
  88469. var totalCount = indices.length;
  88470. for (var i = 0; i < totalCount; i += 3) {
  88471. var i0 = indices[i + 0];
  88472. var i1 = indices[i + 1];
  88473. var i2 = indices[i + 2];
  88474. indices.push(i2 + positionscount);
  88475. indices.push(i1 + positionscount);
  88476. indices.push(i0 + positionscount);
  88477. }
  88478. //Add the sides
  88479. this.addSide(positions, normals, uvs, indices, bounds, this._outlinepoints, depth, false);
  88480. this._holes.forEach(function (hole) {
  88481. _this.addSide(positions, normals, uvs, indices, bounds, hole, depth, true);
  88482. });
  88483. }
  88484. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positions, updatable);
  88485. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normals, updatable);
  88486. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, uvs, updatable);
  88487. result.setIndices(indices);
  88488. return result;
  88489. };
  88490. /**
  88491. * Adds a side to the polygon
  88492. * @param positions points that make the polygon
  88493. * @param normals normals of the polygon
  88494. * @param uvs uvs of the polygon
  88495. * @param indices indices of the polygon
  88496. * @param bounds bounds of the polygon
  88497. * @param points points of the polygon
  88498. * @param depth depth of the polygon
  88499. * @param flip flip of the polygon
  88500. */
  88501. PolygonMeshBuilder.prototype.addSide = function (positions, normals, uvs, indices, bounds, points, depth, flip) {
  88502. var StartIndex = positions.length / 3;
  88503. var ulength = 0;
  88504. for (var i = 0; i < points.elements.length; i++) {
  88505. var p = points.elements[i];
  88506. var p1;
  88507. if ((i + 1) > points.elements.length - 1) {
  88508. p1 = points.elements[0];
  88509. }
  88510. else {
  88511. p1 = points.elements[i + 1];
  88512. }
  88513. positions.push(p.x, 0, p.y);
  88514. positions.push(p.x, -depth, p.y);
  88515. positions.push(p1.x, 0, p1.y);
  88516. positions.push(p1.x, -depth, p1.y);
  88517. var v1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p.x, 0, p.y);
  88518. var v2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p1.x, 0, p1.y);
  88519. var v3 = v2.subtract(v1);
  88520. var v4 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0);
  88521. var vn = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(v3, v4);
  88522. vn = vn.normalize();
  88523. uvs.push(ulength / bounds.width, 0);
  88524. uvs.push(ulength / bounds.width, 1);
  88525. ulength += v3.length();
  88526. uvs.push((ulength / bounds.width), 0);
  88527. uvs.push((ulength / bounds.width), 1);
  88528. if (!flip) {
  88529. normals.push(-vn.x, -vn.y, -vn.z);
  88530. normals.push(-vn.x, -vn.y, -vn.z);
  88531. normals.push(-vn.x, -vn.y, -vn.z);
  88532. normals.push(-vn.x, -vn.y, -vn.z);
  88533. indices.push(StartIndex);
  88534. indices.push(StartIndex + 1);
  88535. indices.push(StartIndex + 2);
  88536. indices.push(StartIndex + 1);
  88537. indices.push(StartIndex + 3);
  88538. indices.push(StartIndex + 2);
  88539. }
  88540. else {
  88541. normals.push(vn.x, vn.y, vn.z);
  88542. normals.push(vn.x, vn.y, vn.z);
  88543. normals.push(vn.x, vn.y, vn.z);
  88544. normals.push(vn.x, vn.y, vn.z);
  88545. indices.push(StartIndex);
  88546. indices.push(StartIndex + 2);
  88547. indices.push(StartIndex + 1);
  88548. indices.push(StartIndex + 1);
  88549. indices.push(StartIndex + 2);
  88550. indices.push(StartIndex + 3);
  88551. }
  88552. StartIndex += 4;
  88553. }
  88554. };
  88555. return PolygonMeshBuilder;
  88556. }());
  88557. /***/ }),
  88558. /***/ "./Meshes/subMesh.ts":
  88559. /*!***************************!*\
  88560. !*** ./Meshes/subMesh.ts ***!
  88561. \***************************/
  88562. /*! exports provided: BaseSubMesh, SubMesh */
  88563. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88564. "use strict";
  88565. __webpack_require__.r(__webpack_exports__);
  88566. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return BaseSubMesh; });
  88567. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return SubMesh; });
  88568. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  88569. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  88570. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  88571. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  88572. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  88573. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  88574. /**
  88575. * Base class for submeshes
  88576. */
  88577. var BaseSubMesh = /** @class */ (function () {
  88578. function BaseSubMesh() {
  88579. }
  88580. Object.defineProperty(BaseSubMesh.prototype, "effect", {
  88581. /**
  88582. * Gets associated effect
  88583. */
  88584. get: function () {
  88585. return this._materialEffect;
  88586. },
  88587. enumerable: true,
  88588. configurable: true
  88589. });
  88590. /**
  88591. * Sets associated effect (effect used to render this submesh)
  88592. * @param effect defines the effect to associate with
  88593. * @param defines defines the set of defines used to compile this effect
  88594. */
  88595. BaseSubMesh.prototype.setEffect = function (effect, defines) {
  88596. if (defines === void 0) { defines = null; }
  88597. if (this._materialEffect === effect) {
  88598. if (!effect) {
  88599. this._materialDefines = null;
  88600. }
  88601. return;
  88602. }
  88603. this._materialDefines = defines;
  88604. this._materialEffect = effect;
  88605. };
  88606. return BaseSubMesh;
  88607. }());
  88608. /**
  88609. * Defines a subdivision inside a mesh
  88610. */
  88611. var SubMesh = /** @class */ (function (_super) {
  88612. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SubMesh, _super);
  88613. /**
  88614. * Creates a new submesh
  88615. * @param materialIndex defines the material index to use
  88616. * @param verticesStart defines vertex index start
  88617. * @param verticesCount defines vertices count
  88618. * @param indexStart defines index start
  88619. * @param indexCount defines indices count
  88620. * @param mesh defines the parent mesh
  88621. * @param renderingMesh defines an optional rendering mesh
  88622. * @param createBoundingBox defines if bounding box should be created for this submesh
  88623. */
  88624. function SubMesh(
  88625. /** the material index to use */
  88626. materialIndex,
  88627. /** vertex index start */
  88628. verticesStart,
  88629. /** vertices count */
  88630. verticesCount,
  88631. /** index start */
  88632. indexStart,
  88633. /** indices count */
  88634. indexCount, mesh, renderingMesh, createBoundingBox) {
  88635. if (createBoundingBox === void 0) { createBoundingBox = true; }
  88636. var _this = _super.call(this) || this;
  88637. _this.materialIndex = materialIndex;
  88638. _this.verticesStart = verticesStart;
  88639. _this.verticesCount = verticesCount;
  88640. _this.indexStart = indexStart;
  88641. _this.indexCount = indexCount;
  88642. /** @hidden */
  88643. _this._renderId = 0;
  88644. _this._mesh = mesh;
  88645. _this._renderingMesh = renderingMesh || mesh;
  88646. mesh.subMeshes.push(_this);
  88647. _this._trianglePlanes = [];
  88648. _this._id = mesh.subMeshes.length - 1;
  88649. if (createBoundingBox) {
  88650. _this.refreshBoundingInfo();
  88651. mesh.computeWorldMatrix(true);
  88652. }
  88653. return _this;
  88654. }
  88655. /**
  88656. * Add a new submesh to a mesh
  88657. * @param materialIndex defines the material index to use
  88658. * @param verticesStart defines vertex index start
  88659. * @param verticesCount defines vertices count
  88660. * @param indexStart defines index start
  88661. * @param indexCount defines indices count
  88662. * @param mesh defines the parent mesh
  88663. * @param renderingMesh defines an optional rendering mesh
  88664. * @param createBoundingBox defines if bounding box should be created for this submesh
  88665. * @returns the new submesh
  88666. */
  88667. SubMesh.AddToMesh = function (materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox) {
  88668. if (createBoundingBox === void 0) { createBoundingBox = true; }
  88669. return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);
  88670. };
  88671. Object.defineProperty(SubMesh.prototype, "IsGlobal", {
  88672. /**
  88673. * Returns true if this submesh covers the entire parent mesh
  88674. * @ignorenaming
  88675. */
  88676. get: function () {
  88677. return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
  88678. },
  88679. enumerable: true,
  88680. configurable: true
  88681. });
  88682. /**
  88683. * Returns the submesh BoudingInfo object
  88684. * @returns current bounding info (or mesh's one if the submesh is global)
  88685. */
  88686. SubMesh.prototype.getBoundingInfo = function () {
  88687. if (this.IsGlobal) {
  88688. return this._mesh.getBoundingInfo();
  88689. }
  88690. return this._boundingInfo;
  88691. };
  88692. /**
  88693. * Sets the submesh BoundingInfo
  88694. * @param boundingInfo defines the new bounding info to use
  88695. * @returns the SubMesh
  88696. */
  88697. SubMesh.prototype.setBoundingInfo = function (boundingInfo) {
  88698. this._boundingInfo = boundingInfo;
  88699. return this;
  88700. };
  88701. /**
  88702. * Returns the mesh of the current submesh
  88703. * @return the parent mesh
  88704. */
  88705. SubMesh.prototype.getMesh = function () {
  88706. return this._mesh;
  88707. };
  88708. /**
  88709. * Returns the rendering mesh of the submesh
  88710. * @returns the rendering mesh (could be different from parent mesh)
  88711. */
  88712. SubMesh.prototype.getRenderingMesh = function () {
  88713. return this._renderingMesh;
  88714. };
  88715. /**
  88716. * Returns the submesh material
  88717. * @returns null or the current material
  88718. */
  88719. SubMesh.prototype.getMaterial = function () {
  88720. var rootMaterial = this._renderingMesh.material;
  88721. if (rootMaterial === null || rootMaterial === undefined) {
  88722. return this._mesh.getScene().defaultMaterial;
  88723. }
  88724. else if (rootMaterial.getSubMaterial) {
  88725. var multiMaterial = rootMaterial;
  88726. var effectiveMaterial = multiMaterial.getSubMaterial(this.materialIndex);
  88727. if (this._currentMaterial !== effectiveMaterial) {
  88728. this._currentMaterial = effectiveMaterial;
  88729. this._materialDefines = null;
  88730. }
  88731. return effectiveMaterial;
  88732. }
  88733. return rootMaterial;
  88734. };
  88735. // Methods
  88736. /**
  88737. * Sets a new updated BoundingInfo object to the submesh
  88738. * @returns the SubMesh
  88739. */
  88740. SubMesh.prototype.refreshBoundingInfo = function () {
  88741. this._lastColliderWorldVertices = null;
  88742. if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {
  88743. return this;
  88744. }
  88745. var data = this._renderingMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  88746. if (!data) {
  88747. this._boundingInfo = this._mesh.getBoundingInfo();
  88748. return this;
  88749. }
  88750. var indices = this._renderingMesh.getIndices();
  88751. var extend;
  88752. //is this the only submesh?
  88753. if (this.indexStart === 0 && this.indexCount === indices.length) {
  88754. var boundingInfo = this._renderingMesh.getBoundingInfo();
  88755. //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.
  88756. extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };
  88757. }
  88758. else {
  88759. extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
  88760. }
  88761. if (this._boundingInfo) {
  88762. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  88763. }
  88764. else {
  88765. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](extend.minimum, extend.maximum);
  88766. }
  88767. return this;
  88768. };
  88769. /** @hidden */
  88770. SubMesh.prototype._checkCollision = function (collider) {
  88771. var boundingInfo = this.getBoundingInfo();
  88772. return boundingInfo._checkCollision(collider);
  88773. };
  88774. /**
  88775. * Updates the submesh BoundingInfo
  88776. * @param world defines the world matrix to use to update the bounding info
  88777. * @returns the submesh
  88778. */
  88779. SubMesh.prototype.updateBoundingInfo = function (world) {
  88780. var boundingInfo = this.getBoundingInfo();
  88781. if (!boundingInfo) {
  88782. this.refreshBoundingInfo();
  88783. boundingInfo = this.getBoundingInfo();
  88784. }
  88785. boundingInfo.update(world);
  88786. return this;
  88787. };
  88788. /**
  88789. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  88790. * @param frustumPlanes defines the frustum planes
  88791. * @returns true if the submesh is intersecting with the frustum
  88792. */
  88793. SubMesh.prototype.isInFrustum = function (frustumPlanes) {
  88794. var boundingInfo = this.getBoundingInfo();
  88795. if (!boundingInfo) {
  88796. return false;
  88797. }
  88798. return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);
  88799. };
  88800. /**
  88801. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  88802. * @param frustumPlanes defines the frustum planes
  88803. * @returns true if the submesh is inside the frustum
  88804. */
  88805. SubMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  88806. var boundingInfo = this.getBoundingInfo();
  88807. if (!boundingInfo) {
  88808. return false;
  88809. }
  88810. return boundingInfo.isCompletelyInFrustum(frustumPlanes);
  88811. };
  88812. /**
  88813. * Renders the submesh
  88814. * @param enableAlphaMode defines if alpha needs to be used
  88815. * @returns the submesh
  88816. */
  88817. SubMesh.prototype.render = function (enableAlphaMode) {
  88818. this._renderingMesh.render(this, enableAlphaMode);
  88819. return this;
  88820. };
  88821. /**
  88822. * @hidden
  88823. */
  88824. SubMesh.prototype._getLinesIndexBuffer = function (indices, engine) {
  88825. if (!this._linesIndexBuffer) {
  88826. var linesIndices = [];
  88827. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  88828. linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);
  88829. }
  88830. this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);
  88831. this._linesIndexCount = linesIndices.length;
  88832. }
  88833. return this._linesIndexBuffer;
  88834. };
  88835. /**
  88836. * Checks if the submesh intersects with a ray
  88837. * @param ray defines the ray to test
  88838. * @returns true is the passed ray intersects the submesh bounding box
  88839. */
  88840. SubMesh.prototype.canIntersects = function (ray) {
  88841. var boundingInfo = this.getBoundingInfo();
  88842. if (!boundingInfo) {
  88843. return false;
  88844. }
  88845. return ray.intersectsBox(boundingInfo.boundingBox);
  88846. };
  88847. /**
  88848. * Intersects current submesh with a ray
  88849. * @param ray defines the ray to test
  88850. * @param positions defines mesh's positions array
  88851. * @param indices defines mesh's indices array
  88852. * @param fastCheck defines if only bounding info should be used
  88853. * @returns intersection info or null if no intersection
  88854. */
  88855. SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck) {
  88856. var material = this.getMaterial();
  88857. if (!material) {
  88858. return null;
  88859. }
  88860. switch (material.fillMode) {
  88861. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_PointListDrawMode:
  88862. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineListDrawMode:
  88863. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineLoopDrawMode:
  88864. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineStripDrawMode:
  88865. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleFanDrawMode:
  88866. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleStripDrawMode:
  88867. return null;
  88868. }
  88869. // LineMesh first as it's also a Mesh...
  88870. if (this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh") {
  88871. return this._intersectLines(ray, positions, indices, this._mesh.intersectionThreshold, fastCheck);
  88872. }
  88873. return this._intersectTriangles(ray, positions, indices, fastCheck);
  88874. };
  88875. /** @hidden */
  88876. SubMesh.prototype._intersectLines = function (ray, positions, indices, intersectionThreshold, fastCheck) {
  88877. var intersectInfo = null;
  88878. // Line test
  88879. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {
  88880. var p0 = positions[indices[index]];
  88881. var p1 = positions[indices[index + 1]];
  88882. var length = ray.intersectionSegment(p0, p1, intersectionThreshold);
  88883. if (length < 0) {
  88884. continue;
  88885. }
  88886. if (fastCheck || !intersectInfo || length < intersectInfo.distance) {
  88887. intersectInfo = new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](null, null, length);
  88888. intersectInfo.faceId = index / 2;
  88889. if (fastCheck) {
  88890. break;
  88891. }
  88892. }
  88893. }
  88894. return intersectInfo;
  88895. };
  88896. /** @hidden */
  88897. SubMesh.prototype._intersectTriangles = function (ray, positions, indices, fastCheck) {
  88898. var intersectInfo = null;
  88899. // Triangles test
  88900. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  88901. var p0 = positions[indices[index]];
  88902. var p1 = positions[indices[index + 1]];
  88903. var p2 = positions[indices[index + 2]];
  88904. var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
  88905. if (currentIntersectInfo) {
  88906. if (currentIntersectInfo.distance < 0) {
  88907. continue;
  88908. }
  88909. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  88910. intersectInfo = currentIntersectInfo;
  88911. intersectInfo.faceId = index / 3;
  88912. if (fastCheck) {
  88913. break;
  88914. }
  88915. }
  88916. }
  88917. }
  88918. return intersectInfo;
  88919. };
  88920. /** @hidden */
  88921. SubMesh.prototype._rebuild = function () {
  88922. if (this._linesIndexBuffer) {
  88923. this._linesIndexBuffer = null;
  88924. }
  88925. };
  88926. // Clone
  88927. /**
  88928. * Creates a new submesh from the passed mesh
  88929. * @param newMesh defines the new hosting mesh
  88930. * @param newRenderingMesh defines an optional rendering mesh
  88931. * @returns the new submesh
  88932. */
  88933. SubMesh.prototype.clone = function (newMesh, newRenderingMesh) {
  88934. var result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);
  88935. if (!this.IsGlobal) {
  88936. var boundingInfo = this.getBoundingInfo();
  88937. if (!boundingInfo) {
  88938. return result;
  88939. }
  88940. result._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](boundingInfo.minimum, boundingInfo.maximum);
  88941. }
  88942. return result;
  88943. };
  88944. // Dispose
  88945. /**
  88946. * Release associated resources
  88947. */
  88948. SubMesh.prototype.dispose = function () {
  88949. if (this._linesIndexBuffer) {
  88950. this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);
  88951. this._linesIndexBuffer = null;
  88952. }
  88953. // Remove from mesh
  88954. var index = this._mesh.subMeshes.indexOf(this);
  88955. this._mesh.subMeshes.splice(index, 1);
  88956. };
  88957. /**
  88958. * Gets the class name
  88959. * @returns the string "SubMesh".
  88960. */
  88961. SubMesh.prototype.getClassName = function () {
  88962. return "SubMesh";
  88963. };
  88964. // Statics
  88965. /**
  88966. * Creates a new submesh from indices data
  88967. * @param materialIndex the index of the main mesh material
  88968. * @param startIndex the index where to start the copy in the mesh indices array
  88969. * @param indexCount the number of indices to copy then from the startIndex
  88970. * @param mesh the main mesh to create the submesh from
  88971. * @param renderingMesh the optional rendering mesh
  88972. * @returns a new submesh
  88973. */
  88974. SubMesh.CreateFromIndices = function (materialIndex, startIndex, indexCount, mesh, renderingMesh) {
  88975. var minVertexIndex = Number.MAX_VALUE;
  88976. var maxVertexIndex = -Number.MAX_VALUE;
  88977. var whatWillRender = (renderingMesh || mesh);
  88978. var indices = whatWillRender.getIndices();
  88979. for (var index = startIndex; index < startIndex + indexCount; index++) {
  88980. var vertexIndex = indices[index];
  88981. if (vertexIndex < minVertexIndex) {
  88982. minVertexIndex = vertexIndex;
  88983. }
  88984. if (vertexIndex > maxVertexIndex) {
  88985. maxVertexIndex = vertexIndex;
  88986. }
  88987. }
  88988. return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
  88989. };
  88990. return SubMesh;
  88991. }(BaseSubMesh));
  88992. /***/ }),
  88993. /***/ "./Meshes/transformNode.ts":
  88994. /*!*********************************!*\
  88995. !*** ./Meshes/transformNode.ts ***!
  88996. \*********************************/
  88997. /*! exports provided: TransformNode */
  88998. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88999. "use strict";
  89000. __webpack_require__.r(__webpack_exports__);
  89001. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return TransformNode; });
  89002. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  89003. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  89004. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  89005. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  89006. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  89007. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  89008. /**
  89009. * 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.
  89010. * @see https://doc.babylonjs.com/how_to/transformnode
  89011. */
  89012. var TransformNode = /** @class */ (function (_super) {
  89013. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TransformNode, _super);
  89014. function TransformNode(name, scene, isPure) {
  89015. if (scene === void 0) { scene = null; }
  89016. if (isPure === void 0) { isPure = true; }
  89017. var _this = _super.call(this, name, scene) || this;
  89018. _this._forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, 1);
  89019. _this._forwardInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, -1);
  89020. _this._up = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0);
  89021. _this._right = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](1, 0, 0);
  89022. _this._rightInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](-1, 0, 0);
  89023. // Properties
  89024. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89025. _this._rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89026. _this._scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  89027. _this._isDirty = false;
  89028. /**
  89029. * Set the billboard mode. Default is 0.
  89030. *
  89031. * | Value | Type | Description |
  89032. * | --- | --- | --- |
  89033. * | 0 | BILLBOARDMODE_NONE | |
  89034. * | 1 | BILLBOARDMODE_X | |
  89035. * | 2 | BILLBOARDMODE_Y | |
  89036. * | 4 | BILLBOARDMODE_Z | |
  89037. * | 7 | BILLBOARDMODE_ALL | |
  89038. *
  89039. */
  89040. _this.billboardMode = TransformNode.BILLBOARDMODE_NONE;
  89041. /**
  89042. * 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
  89043. */
  89044. _this.scalingDeterminant = 1;
  89045. /**
  89046. * Sets the distance of the object to max, often used by skybox
  89047. */
  89048. _this.infiniteDistance = false;
  89049. /**
  89050. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  89051. * By default the system will update normals to compensate
  89052. */
  89053. _this.ignoreNonUniformScaling = false;
  89054. /** @hidden */
  89055. _this._localMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  89056. _this._absolutePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89057. _this._pivotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  89058. _this._postMultiplyPivotMatrix = false;
  89059. _this._isWorldMatrixFrozen = false;
  89060. /** @hidden */
  89061. _this._indexInSceneTransformNodesArray = -1;
  89062. /**
  89063. * An event triggered after the world matrix is updated
  89064. */
  89065. _this.onAfterWorldMatrixUpdateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  89066. _this._nonUniformScaling = false;
  89067. if (isPure) {
  89068. _this.getScene().addTransformNode(_this);
  89069. }
  89070. return _this;
  89071. }
  89072. /**
  89073. * Gets a string identifying the name of the class
  89074. * @returns "TransformNode" string
  89075. */
  89076. TransformNode.prototype.getClassName = function () {
  89077. return "TransformNode";
  89078. };
  89079. Object.defineProperty(TransformNode.prototype, "position", {
  89080. /**
  89081. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  89082. */
  89083. get: function () {
  89084. return this._position;
  89085. },
  89086. set: function (newPosition) {
  89087. this._position = newPosition;
  89088. this._isDirty = true;
  89089. },
  89090. enumerable: true,
  89091. configurable: true
  89092. });
  89093. Object.defineProperty(TransformNode.prototype, "rotation", {
  89094. /**
  89095. * 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)).
  89096. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  89097. */
  89098. get: function () {
  89099. return this._rotation;
  89100. },
  89101. set: function (newRotation) {
  89102. this._rotation = newRotation;
  89103. this._isDirty = true;
  89104. },
  89105. enumerable: true,
  89106. configurable: true
  89107. });
  89108. Object.defineProperty(TransformNode.prototype, "scaling", {
  89109. /**
  89110. * 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)).
  89111. */
  89112. get: function () {
  89113. return this._scaling;
  89114. },
  89115. set: function (newScaling) {
  89116. this._scaling = newScaling;
  89117. this._isDirty = true;
  89118. },
  89119. enumerable: true,
  89120. configurable: true
  89121. });
  89122. Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
  89123. /**
  89124. * 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).
  89125. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  89126. */
  89127. get: function () {
  89128. return this._rotationQuaternion;
  89129. },
  89130. set: function (quaternion) {
  89131. this._rotationQuaternion = quaternion;
  89132. //reset the rotation vector.
  89133. if (quaternion) {
  89134. this.rotation.setAll(0.0);
  89135. }
  89136. },
  89137. enumerable: true,
  89138. configurable: true
  89139. });
  89140. Object.defineProperty(TransformNode.prototype, "forward", {
  89141. /**
  89142. * The forward direction of that transform in world space.
  89143. */
  89144. get: function () {
  89145. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormal(this.getScene().useRightHandedSystem ? this._forwardInverted : this._forward, this.getWorldMatrix()));
  89146. },
  89147. enumerable: true,
  89148. configurable: true
  89149. });
  89150. Object.defineProperty(TransformNode.prototype, "up", {
  89151. /**
  89152. * The up direction of that transform in world space.
  89153. */
  89154. get: function () {
  89155. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormal(this._up, this.getWorldMatrix()));
  89156. },
  89157. enumerable: true,
  89158. configurable: true
  89159. });
  89160. Object.defineProperty(TransformNode.prototype, "right", {
  89161. /**
  89162. * The right direction of that transform in world space.
  89163. */
  89164. get: function () {
  89165. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormal(this.getScene().useRightHandedSystem ? this._rightInverted : this._right, this.getWorldMatrix()));
  89166. },
  89167. enumerable: true,
  89168. configurable: true
  89169. });
  89170. /**
  89171. * Copies the parameter passed Matrix into the mesh Pose matrix.
  89172. * @param matrix the matrix to copy the pose from
  89173. * @returns this TransformNode.
  89174. */
  89175. TransformNode.prototype.updatePoseMatrix = function (matrix) {
  89176. this._poseMatrix.copyFrom(matrix);
  89177. return this;
  89178. };
  89179. /**
  89180. * Returns the mesh Pose matrix.
  89181. * @returns the pose matrix
  89182. */
  89183. TransformNode.prototype.getPoseMatrix = function () {
  89184. return this._poseMatrix;
  89185. };
  89186. /** @hidden */
  89187. TransformNode.prototype._isSynchronized = function () {
  89188. if (this._isDirty) {
  89189. return false;
  89190. }
  89191. if (this.billboardMode !== this._cache.billboardMode || this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  89192. return false;
  89193. }
  89194. if (this._cache.pivotMatrixUpdated) {
  89195. return false;
  89196. }
  89197. if (this.infiniteDistance) {
  89198. return false;
  89199. }
  89200. if (!this._cache.position.equals(this._position)) {
  89201. return false;
  89202. }
  89203. if (this._rotationQuaternion) {
  89204. if (!this._cache.rotationQuaternion.equals(this._rotationQuaternion)) {
  89205. return false;
  89206. }
  89207. }
  89208. if (!this._cache.rotation.equals(this._rotation)) {
  89209. return false;
  89210. }
  89211. if (!this._cache.scaling.equals(this._scaling)) {
  89212. return false;
  89213. }
  89214. return true;
  89215. };
  89216. /** @hidden */
  89217. TransformNode.prototype._initCache = function () {
  89218. _super.prototype._initCache.call(this);
  89219. this._cache.localMatrixUpdated = false;
  89220. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89221. this._cache.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89222. this._cache.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89223. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"](0, 0, 0, 0);
  89224. this._cache.billboardMode = -1;
  89225. this._cache.infiniteDistance = false;
  89226. };
  89227. /**
  89228. * Flag the transform node as dirty (Forcing it to update everything)
  89229. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  89230. * @returns this transform node
  89231. */
  89232. TransformNode.prototype.markAsDirty = function (property) {
  89233. if (property === "rotation") {
  89234. this.rotationQuaternion = null;
  89235. }
  89236. this._currentRenderId = Number.MAX_VALUE;
  89237. this._isDirty = true;
  89238. return this;
  89239. };
  89240. Object.defineProperty(TransformNode.prototype, "absolutePosition", {
  89241. /**
  89242. * Returns the current mesh absolute position.
  89243. * Returns a Vector3.
  89244. */
  89245. get: function () {
  89246. return this._absolutePosition;
  89247. },
  89248. enumerable: true,
  89249. configurable: true
  89250. });
  89251. /**
  89252. * Sets a new matrix to apply before all other transformation
  89253. * @param matrix defines the transform matrix
  89254. * @returns the current TransformNode
  89255. */
  89256. TransformNode.prototype.setPreTransformMatrix = function (matrix) {
  89257. return this.setPivotMatrix(matrix, false);
  89258. };
  89259. /**
  89260. * Sets a new pivot matrix to the current node
  89261. * @param matrix defines the new pivot matrix to use
  89262. * @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
  89263. * @returns the current TransformNode
  89264. */
  89265. TransformNode.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
  89266. if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = true; }
  89267. this._pivotMatrix.copyFrom(matrix);
  89268. this._cache.pivotMatrixUpdated = true;
  89269. this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
  89270. if (this._postMultiplyPivotMatrix) {
  89271. if (!this._pivotMatrixInverse) {
  89272. this._pivotMatrixInverse = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Invert(this._pivotMatrix);
  89273. }
  89274. else {
  89275. this._pivotMatrix.invertToRef(this._pivotMatrixInverse);
  89276. }
  89277. }
  89278. return this;
  89279. };
  89280. /**
  89281. * Returns the mesh pivot matrix.
  89282. * Default : Identity.
  89283. * @returns the matrix
  89284. */
  89285. TransformNode.prototype.getPivotMatrix = function () {
  89286. return this._pivotMatrix;
  89287. };
  89288. /**
  89289. * Prevents the World matrix to be computed any longer.
  89290. * @returns the TransformNode.
  89291. */
  89292. TransformNode.prototype.freezeWorldMatrix = function () {
  89293. this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
  89294. this.computeWorldMatrix(true);
  89295. this._isWorldMatrixFrozen = true;
  89296. return this;
  89297. };
  89298. /**
  89299. * Allows back the World matrix computation.
  89300. * @returns the TransformNode.
  89301. */
  89302. TransformNode.prototype.unfreezeWorldMatrix = function () {
  89303. this._isWorldMatrixFrozen = false;
  89304. this.computeWorldMatrix(true);
  89305. return this;
  89306. };
  89307. Object.defineProperty(TransformNode.prototype, "isWorldMatrixFrozen", {
  89308. /**
  89309. * True if the World matrix has been frozen.
  89310. */
  89311. get: function () {
  89312. return this._isWorldMatrixFrozen;
  89313. },
  89314. enumerable: true,
  89315. configurable: true
  89316. });
  89317. /**
  89318. * Retuns the mesh absolute position in the World.
  89319. * @returns a Vector3.
  89320. */
  89321. TransformNode.prototype.getAbsolutePosition = function () {
  89322. this.computeWorldMatrix();
  89323. return this._absolutePosition;
  89324. };
  89325. /**
  89326. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  89327. * @param absolutePosition the absolute position to set
  89328. * @returns the TransformNode.
  89329. */
  89330. TransformNode.prototype.setAbsolutePosition = function (absolutePosition) {
  89331. if (!absolutePosition) {
  89332. return this;
  89333. }
  89334. var absolutePositionX;
  89335. var absolutePositionY;
  89336. var absolutePositionZ;
  89337. if (absolutePosition.x === undefined) {
  89338. if (arguments.length < 3) {
  89339. return this;
  89340. }
  89341. absolutePositionX = arguments[0];
  89342. absolutePositionY = arguments[1];
  89343. absolutePositionZ = arguments[2];
  89344. }
  89345. else {
  89346. absolutePositionX = absolutePosition.x;
  89347. absolutePositionY = absolutePosition.y;
  89348. absolutePositionZ = absolutePosition.z;
  89349. }
  89350. if (this.parent) {
  89351. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  89352. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  89353. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesFromFloatsToRef(absolutePositionX, absolutePositionY, absolutePositionZ, invertParentWorldMatrix, this.position);
  89354. }
  89355. else {
  89356. this.position.x = absolutePositionX;
  89357. this.position.y = absolutePositionY;
  89358. this.position.z = absolutePositionZ;
  89359. }
  89360. return this;
  89361. };
  89362. /**
  89363. * Sets the mesh position in its local space.
  89364. * @param vector3 the position to set in localspace
  89365. * @returns the TransformNode.
  89366. */
  89367. TransformNode.prototype.setPositionWithLocalVector = function (vector3) {
  89368. this.computeWorldMatrix();
  89369. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormal(vector3, this._localMatrix);
  89370. return this;
  89371. };
  89372. /**
  89373. * Returns the mesh position in the local space from the current World matrix values.
  89374. * @returns a new Vector3.
  89375. */
  89376. TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
  89377. this.computeWorldMatrix();
  89378. var invLocalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  89379. this._localMatrix.invertToRef(invLocalWorldMatrix);
  89380. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormal(this.position, invLocalWorldMatrix);
  89381. };
  89382. /**
  89383. * Translates the mesh along the passed Vector3 in its local space.
  89384. * @param vector3 the distance to translate in localspace
  89385. * @returns the TransformNode.
  89386. */
  89387. TransformNode.prototype.locallyTranslate = function (vector3) {
  89388. this.computeWorldMatrix(true);
  89389. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(vector3, this._localMatrix);
  89390. return this;
  89391. };
  89392. /**
  89393. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  89394. * @param targetPoint the position (must be in same space as current mesh) to look at
  89395. * @param yawCor optional yaw (y-axis) correction in radians
  89396. * @param pitchCor optional pitch (x-axis) correction in radians
  89397. * @param rollCor optional roll (z-axis) correction in radians
  89398. * @param space the choosen space of the target
  89399. * @returns the TransformNode.
  89400. */
  89401. TransformNode.prototype.lookAt = function (targetPoint, yawCor, pitchCor, rollCor, space) {
  89402. if (yawCor === void 0) { yawCor = 0; }
  89403. if (pitchCor === void 0) { pitchCor = 0; }
  89404. if (rollCor === void 0) { rollCor = 0; }
  89405. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  89406. var dv = TransformNode._lookAtVectorCache;
  89407. var pos = space === _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL ? this.position : this.getAbsolutePosition();
  89408. targetPoint.subtractToRef(pos, dv);
  89409. this.setDirection(dv, yawCor, pitchCor, rollCor);
  89410. // Correct for parent's rotation offset
  89411. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].WORLD && this.parent) {
  89412. if (this.rotationQuaternion) {
  89413. // Get local rotation matrix of the looking object
  89414. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  89415. this.rotationQuaternion.toRotationMatrix(rotationMatrix);
  89416. // Offset rotation by parent's inverted rotation matrix to correct in world space
  89417. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1];
  89418. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  89419. parentRotationMatrix.invert();
  89420. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  89421. this.rotationQuaternion.fromRotationMatrix(rotationMatrix);
  89422. }
  89423. else {
  89424. // Get local rotation matrix of the looking object
  89425. var quaternionRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  89426. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromEulerVectorToRef(this.rotation, quaternionRotation);
  89427. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  89428. quaternionRotation.toRotationMatrix(rotationMatrix);
  89429. // Offset rotation by parent's inverted rotation matrix to correct in world space
  89430. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1];
  89431. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  89432. parentRotationMatrix.invert();
  89433. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  89434. quaternionRotation.fromRotationMatrix(rotationMatrix);
  89435. quaternionRotation.toEulerAnglesToRef(this.rotation);
  89436. }
  89437. }
  89438. return this;
  89439. };
  89440. /**
  89441. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  89442. * This Vector3 is expressed in the World space.
  89443. * @param localAxis axis to rotate
  89444. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  89445. */
  89446. TransformNode.prototype.getDirection = function (localAxis) {
  89447. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89448. this.getDirectionToRef(localAxis, result);
  89449. return result;
  89450. };
  89451. /**
  89452. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  89453. * localAxis is expressed in the mesh local space.
  89454. * result is computed in the Wordl space from the mesh World matrix.
  89455. * @param localAxis axis to rotate
  89456. * @param result the resulting transformnode
  89457. * @returns this TransformNode.
  89458. */
  89459. TransformNode.prototype.getDirectionToRef = function (localAxis, result) {
  89460. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  89461. return this;
  89462. };
  89463. /**
  89464. * Sets this transform node rotation to the given local axis.
  89465. * @param localAxis the axis in local space
  89466. * @param yawCor optional yaw (y-axis) correction in radians
  89467. * @param pitchCor optional pitch (x-axis) correction in radians
  89468. * @param rollCor optional roll (z-axis) correction in radians
  89469. * @returns this TransformNode
  89470. */
  89471. TransformNode.prototype.setDirection = function (localAxis, yawCor, pitchCor, rollCor) {
  89472. if (yawCor === void 0) { yawCor = 0; }
  89473. if (pitchCor === void 0) { pitchCor = 0; }
  89474. if (rollCor === void 0) { rollCor = 0; }
  89475. var yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;
  89476. var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
  89477. var pitch = -Math.atan2(localAxis.y, len);
  89478. if (this.rotationQuaternion) {
  89479. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
  89480. }
  89481. else {
  89482. this.rotation.x = pitch + pitchCor;
  89483. this.rotation.y = yaw + yawCor;
  89484. this.rotation.z = rollCor;
  89485. }
  89486. return this;
  89487. };
  89488. /**
  89489. * Sets a new pivot point to the current node
  89490. * @param point defines the new pivot point to use
  89491. * @param space defines if the point is in world or local space (local by default)
  89492. * @returns the current TransformNode
  89493. */
  89494. TransformNode.prototype.setPivotPoint = function (point, space) {
  89495. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL; }
  89496. if (this.getScene().getRenderId() == 0) {
  89497. this.computeWorldMatrix(true);
  89498. }
  89499. var wm = this.getWorldMatrix();
  89500. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].WORLD) {
  89501. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  89502. wm.invertToRef(tmat);
  89503. point = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(point, tmat);
  89504. }
  89505. return this.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(-point.x, -point.y, -point.z), true);
  89506. };
  89507. /**
  89508. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  89509. * @returns the pivot point
  89510. */
  89511. TransformNode.prototype.getPivotPoint = function () {
  89512. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89513. this.getPivotPointToRef(point);
  89514. return point;
  89515. };
  89516. /**
  89517. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  89518. * @param result the vector3 to store the result
  89519. * @returns this TransformNode.
  89520. */
  89521. TransformNode.prototype.getPivotPointToRef = function (result) {
  89522. result.x = -this._pivotMatrix.m[12];
  89523. result.y = -this._pivotMatrix.m[13];
  89524. result.z = -this._pivotMatrix.m[14];
  89525. return this;
  89526. };
  89527. /**
  89528. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  89529. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  89530. */
  89531. TransformNode.prototype.getAbsolutePivotPoint = function () {
  89532. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  89533. this.getAbsolutePivotPointToRef(point);
  89534. return point;
  89535. };
  89536. /**
  89537. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  89538. * @param result vector3 to store the result
  89539. * @returns this TransformNode.
  89540. */
  89541. TransformNode.prototype.getAbsolutePivotPointToRef = function (result) {
  89542. result.x = this._pivotMatrix.m[12];
  89543. result.y = this._pivotMatrix.m[13];
  89544. result.z = this._pivotMatrix.m[14];
  89545. this.getPivotPointToRef(result);
  89546. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(result, this.getWorldMatrix(), result);
  89547. return this;
  89548. };
  89549. /**
  89550. * Defines the passed node as the parent of the current node.
  89551. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  89552. * @param node the node ot set as the parent
  89553. * @returns this TransformNode.
  89554. */
  89555. TransformNode.prototype.setParent = function (node) {
  89556. if (!node && !this.parent) {
  89557. return this;
  89558. }
  89559. var quatRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  89560. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  89561. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  89562. if (!node) {
  89563. if (this.parent && this.parent.computeWorldMatrix) {
  89564. this.parent.computeWorldMatrix(true);
  89565. }
  89566. this.computeWorldMatrix(true);
  89567. this.getWorldMatrix().decompose(scale, quatRotation, position);
  89568. }
  89569. else {
  89570. var diffMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  89571. var invParentMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1];
  89572. this.computeWorldMatrix(true);
  89573. node.computeWorldMatrix(true);
  89574. node.getWorldMatrix().invertToRef(invParentMatrix);
  89575. this.getWorldMatrix().multiplyToRef(invParentMatrix, diffMatrix);
  89576. diffMatrix.decompose(scale, quatRotation, position);
  89577. }
  89578. if (this.rotationQuaternion) {
  89579. this.rotationQuaternion.copyFrom(quatRotation);
  89580. }
  89581. else {
  89582. quatRotation.toEulerAnglesToRef(this.rotation);
  89583. }
  89584. this.scaling.copyFrom(scale);
  89585. this.position.copyFrom(position);
  89586. this.parent = node;
  89587. return this;
  89588. };
  89589. Object.defineProperty(TransformNode.prototype, "nonUniformScaling", {
  89590. /**
  89591. * True if the scaling property of this object is non uniform eg. (1,2,1)
  89592. */
  89593. get: function () {
  89594. return this._nonUniformScaling;
  89595. },
  89596. enumerable: true,
  89597. configurable: true
  89598. });
  89599. /** @hidden */
  89600. TransformNode.prototype._updateNonUniformScalingState = function (value) {
  89601. if (this._nonUniformScaling === value) {
  89602. return false;
  89603. }
  89604. this._nonUniformScaling = value;
  89605. return true;
  89606. };
  89607. /**
  89608. * Attach the current TransformNode to another TransformNode associated with a bone
  89609. * @param bone Bone affecting the TransformNode
  89610. * @param affectedTransformNode TransformNode associated with the bone
  89611. * @returns this object
  89612. */
  89613. TransformNode.prototype.attachToBone = function (bone, affectedTransformNode) {
  89614. this._transformToBoneReferal = affectedTransformNode;
  89615. this.parent = bone;
  89616. if (bone.getWorldMatrix().determinant() < 0) {
  89617. this.scalingDeterminant *= -1;
  89618. }
  89619. return this;
  89620. };
  89621. /**
  89622. * Detach the transform node if its associated with a bone
  89623. * @returns this object
  89624. */
  89625. TransformNode.prototype.detachFromBone = function () {
  89626. if (!this.parent) {
  89627. return this;
  89628. }
  89629. if (this.parent.getWorldMatrix().determinant() < 0) {
  89630. this.scalingDeterminant *= -1;
  89631. }
  89632. this._transformToBoneReferal = null;
  89633. this.parent = null;
  89634. return this;
  89635. };
  89636. /**
  89637. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  89638. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  89639. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  89640. * The passed axis is also normalized.
  89641. * @param axis the axis to rotate around
  89642. * @param amount the amount to rotate in radians
  89643. * @param space Space to rotate in (Default: local)
  89644. * @returns the TransformNode.
  89645. */
  89646. TransformNode.prototype.rotate = function (axis, amount, space) {
  89647. axis.normalize();
  89648. if (!this.rotationQuaternion) {
  89649. this.rotationQuaternion = this.rotation.toQuaternion();
  89650. this.rotation.setAll(0);
  89651. }
  89652. var rotationQuaternion;
  89653. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL) {
  89654. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  89655. this.rotationQuaternion.multiplyToRef(rotationQuaternion, this.rotationQuaternion);
  89656. }
  89657. else {
  89658. if (this.parent) {
  89659. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0];
  89660. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  89661. axis = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormal(axis, invertParentWorldMatrix);
  89662. }
  89663. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  89664. rotationQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  89665. }
  89666. return this;
  89667. };
  89668. /**
  89669. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  89670. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  89671. * The passed axis is also normalized. .
  89672. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  89673. * @param point the point to rotate around
  89674. * @param axis the axis to rotate around
  89675. * @param amount the amount to rotate in radians
  89676. * @returns the TransformNode
  89677. */
  89678. TransformNode.prototype.rotateAround = function (point, axis, amount) {
  89679. axis.normalize();
  89680. if (!this.rotationQuaternion) {
  89681. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  89682. this.rotation.setAll(0);
  89683. }
  89684. var tmpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  89685. var finalScale = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  89686. var finalTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[2];
  89687. var finalRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  89688. var translationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]; // T
  89689. var translationMatrixInv = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1]; // T'
  89690. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[2]; // R
  89691. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[3]; // T' x R x T
  89692. point.subtractToRef(this.position, tmpVector);
  89693. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(tmpVector.x, tmpVector.y, tmpVector.z, translationMatrix); // T
  89694. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(-tmpVector.x, -tmpVector.y, -tmpVector.z, translationMatrixInv); // T'
  89695. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationAxisToRef(axis, amount, rotationMatrix); // R
  89696. translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R
  89697. finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x T
  89698. finalMatrix.decompose(finalScale, finalRotation, finalTranslation);
  89699. this.position.addInPlace(finalTranslation);
  89700. finalRotation.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  89701. return this;
  89702. };
  89703. /**
  89704. * Translates the mesh along the axis vector for the passed distance in the given space.
  89705. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  89706. * @param axis the axis to translate in
  89707. * @param distance the distance to translate
  89708. * @param space Space to rotate in (Default: local)
  89709. * @returns the TransformNode.
  89710. */
  89711. TransformNode.prototype.translate = function (axis, distance, space) {
  89712. var displacementVector = axis.scale(distance);
  89713. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Space"].LOCAL) {
  89714. var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
  89715. this.setPositionWithLocalVector(tempV3);
  89716. }
  89717. else {
  89718. this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
  89719. }
  89720. return this;
  89721. };
  89722. /**
  89723. * Adds a rotation step to the mesh current rotation.
  89724. * x, y, z are Euler angles expressed in radians.
  89725. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  89726. * This means this rotation is made in the mesh local space only.
  89727. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  89728. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  89729. * ```javascript
  89730. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  89731. * ```
  89732. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  89733. * 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.
  89734. * @param x Rotation to add
  89735. * @param y Rotation to add
  89736. * @param z Rotation to add
  89737. * @returns the TransformNode.
  89738. */
  89739. TransformNode.prototype.addRotation = function (x, y, z) {
  89740. var rotationQuaternion;
  89741. if (this.rotationQuaternion) {
  89742. rotationQuaternion = this.rotationQuaternion;
  89743. }
  89744. else {
  89745. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[1];
  89746. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, rotationQuaternion);
  89747. }
  89748. var accumulation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  89749. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRollToRef(y, x, z, accumulation);
  89750. rotationQuaternion.multiplyInPlace(accumulation);
  89751. if (!this.rotationQuaternion) {
  89752. rotationQuaternion.toEulerAnglesToRef(this.rotation);
  89753. }
  89754. return this;
  89755. };
  89756. /**
  89757. * Computes the world matrix of the node
  89758. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89759. * @returns the world matrix
  89760. */
  89761. TransformNode.prototype.computeWorldMatrix = function (force) {
  89762. if (this._isWorldMatrixFrozen) {
  89763. return this._worldMatrix;
  89764. }
  89765. if (!force && this.isSynchronized()) {
  89766. this._currentRenderId = this.getScene().getRenderId();
  89767. return this._worldMatrix;
  89768. }
  89769. this._updateCache();
  89770. this._cache.position.copyFrom(this.position);
  89771. this._cache.scaling.copyFrom(this.scaling);
  89772. this._cache.pivotMatrixUpdated = false;
  89773. this._cache.billboardMode = this.billboardMode;
  89774. this._cache.infiniteDistance = this.infiniteDistance;
  89775. this._currentRenderId = this.getScene().getRenderId();
  89776. this._childRenderId = this.getScene().getRenderId();
  89777. this._isDirty = false;
  89778. // Scaling
  89779. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ScalingToRef(this.scaling.x * this.scalingDeterminant, this.scaling.y * this.scalingDeterminant, this.scaling.z * this.scalingDeterminant, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1]);
  89780. // Rotation
  89781. //rotate, if quaternion is set and rotation was used
  89782. if (this.rotationQuaternion) {
  89783. var len = this.rotation.length();
  89784. if (len) {
  89785. this.rotationQuaternion.multiplyInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z));
  89786. this.rotation.copyFromFloats(0, 0, 0);
  89787. }
  89788. }
  89789. if (this.rotationQuaternion) {
  89790. this.rotationQuaternion.toRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]);
  89791. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  89792. }
  89793. else {
  89794. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]);
  89795. this._cache.rotation.copyFrom(this.rotation);
  89796. }
  89797. // Translation
  89798. var camera = this.getScene().activeCamera;
  89799. if (this.infiniteDistance && !this.parent && camera) {
  89800. var cameraWorldMatrix = camera.getWorldMatrix();
  89801. var cameraGlobalPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](cameraWorldMatrix.m[12], cameraWorldMatrix.m[13], cameraWorldMatrix.m[14]);
  89802. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.position.x + cameraGlobalPosition.x, this.position.y + cameraGlobalPosition.y, this.position.z + cameraGlobalPosition.z, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[2]);
  89803. }
  89804. else {
  89805. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[2]);
  89806. }
  89807. // Composing transformations
  89808. this._pivotMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1], _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[4]);
  89809. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[4].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0], _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5]);
  89810. // Billboarding (testing PG:http://www.babylonjs-playground.com/#UJEIL#13)
  89811. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE && camera) {
  89812. if ((this.billboardMode & TransformNode.BILLBOARDMODE_ALL) !== TransformNode.BILLBOARDMODE_ALL) {
  89813. // Need to decompose each rotation here
  89814. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[3];
  89815. if (this.parent && this.parent.getWorldMatrix) {
  89816. if (this._transformToBoneReferal) {
  89817. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6]);
  89818. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this.position, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6], currentPosition);
  89819. }
  89820. else {
  89821. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), currentPosition);
  89822. }
  89823. }
  89824. else {
  89825. currentPosition.copyFrom(this.position);
  89826. }
  89827. currentPosition.subtractInPlace(camera.globalPosition);
  89828. var finalEuler = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[4].copyFromFloats(0, 0, 0);
  89829. if ((this.billboardMode & TransformNode.BILLBOARDMODE_X) === TransformNode.BILLBOARDMODE_X) {
  89830. finalEuler.x = Math.atan2(-currentPosition.y, currentPosition.z);
  89831. }
  89832. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Y) === TransformNode.BILLBOARDMODE_Y) {
  89833. finalEuler.y = Math.atan2(currentPosition.x, currentPosition.z);
  89834. }
  89835. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Z) === TransformNode.BILLBOARDMODE_Z) {
  89836. finalEuler.z = Math.atan2(currentPosition.y, currentPosition.x);
  89837. }
  89838. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(finalEuler.y, finalEuler.x, finalEuler.z, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]);
  89839. }
  89840. else {
  89841. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1].copyFrom(camera.getViewMatrix());
  89842. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1].setTranslationFromFloats(0, 0, 0);
  89843. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1].invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]);
  89844. }
  89845. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1].copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5]);
  89846. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[1].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0], _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5]);
  89847. }
  89848. // Post multiply inverse of pivotMatrix
  89849. if (this._postMultiplyPivotMatrix) {
  89850. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5].multiplyToRef(this._pivotMatrixInverse, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5]);
  89851. }
  89852. // Local world
  89853. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[2], this._localMatrix);
  89854. // Parent
  89855. if (this.parent && this.parent.getWorldMatrix) {
  89856. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  89857. if (this._transformToBoneReferal) {
  89858. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6]);
  89859. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5].copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6]);
  89860. }
  89861. else {
  89862. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5].copyFrom(this.parent.getWorldMatrix());
  89863. }
  89864. this._localMatrix.getTranslationToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[5]);
  89865. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[5], _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[5], _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[5]);
  89866. this._worldMatrix.copyFrom(this._localMatrix);
  89867. this._worldMatrix.setTranslation(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[5]);
  89868. }
  89869. else {
  89870. if (this._transformToBoneReferal) {
  89871. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6]);
  89872. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix);
  89873. }
  89874. else {
  89875. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  89876. }
  89877. }
  89878. this._markSyncedWithParent();
  89879. }
  89880. else {
  89881. this._worldMatrix.copyFrom(this._localMatrix);
  89882. }
  89883. // Normal matrix
  89884. if (!this.ignoreNonUniformScaling) {
  89885. if (this.scaling.isNonUniform) {
  89886. this._updateNonUniformScalingState(true);
  89887. }
  89888. else if (this.parent && this.parent._nonUniformScaling) {
  89889. this._updateNonUniformScalingState(this.parent._nonUniformScaling);
  89890. }
  89891. else {
  89892. this._updateNonUniformScalingState(false);
  89893. }
  89894. }
  89895. else {
  89896. this._updateNonUniformScalingState(false);
  89897. }
  89898. this._afterComputeWorldMatrix();
  89899. // Absolute position
  89900. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
  89901. // Callbacks
  89902. this.onAfterWorldMatrixUpdateObservable.notifyObservers(this);
  89903. if (!this._poseMatrix) {
  89904. this._poseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Invert(this._worldMatrix);
  89905. }
  89906. // Cache the determinant
  89907. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  89908. return this._worldMatrix;
  89909. };
  89910. TransformNode.prototype._afterComputeWorldMatrix = function () {
  89911. };
  89912. /**
  89913. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  89914. * @param func callback function to add
  89915. *
  89916. * @returns the TransformNode.
  89917. */
  89918. TransformNode.prototype.registerAfterWorldMatrixUpdate = function (func) {
  89919. this.onAfterWorldMatrixUpdateObservable.add(func);
  89920. return this;
  89921. };
  89922. /**
  89923. * Removes a registered callback function.
  89924. * @param func callback function to remove
  89925. * @returns the TransformNode.
  89926. */
  89927. TransformNode.prototype.unregisterAfterWorldMatrixUpdate = function (func) {
  89928. this.onAfterWorldMatrixUpdateObservable.removeCallback(func);
  89929. return this;
  89930. };
  89931. /**
  89932. * Gets the position of the current mesh in camera space
  89933. * @param camera defines the camera to use
  89934. * @returns a position
  89935. */
  89936. TransformNode.prototype.getPositionInCameraSpace = function (camera) {
  89937. if (camera === void 0) { camera = null; }
  89938. if (!camera) {
  89939. camera = this.getScene().activeCamera;
  89940. }
  89941. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(this.absolutePosition, camera.getViewMatrix());
  89942. };
  89943. /**
  89944. * Returns the distance from the mesh to the active camera
  89945. * @param camera defines the camera to use
  89946. * @returns the distance
  89947. */
  89948. TransformNode.prototype.getDistanceToCamera = function (camera) {
  89949. if (camera === void 0) { camera = null; }
  89950. if (!camera) {
  89951. camera = this.getScene().activeCamera;
  89952. }
  89953. return this.absolutePosition.subtract(camera.position).length();
  89954. };
  89955. /**
  89956. * Clone the current transform node
  89957. * @param name Name of the new clone
  89958. * @param newParent New parent for the clone
  89959. * @param doNotCloneChildren Do not clone children hierarchy
  89960. * @returns the new transform node
  89961. */
  89962. TransformNode.prototype.clone = function (name, newParent, doNotCloneChildren) {
  89963. var _this = this;
  89964. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new TransformNode(name, _this.getScene()); }, this);
  89965. result.name = name;
  89966. result.id = name;
  89967. if (newParent) {
  89968. result.parent = newParent;
  89969. }
  89970. if (!doNotCloneChildren) {
  89971. // Children
  89972. var directDescendants = this.getDescendants(true);
  89973. for (var index = 0; index < directDescendants.length; index++) {
  89974. var child = directDescendants[index];
  89975. if (child.clone) {
  89976. child.clone(name + "." + child.name, result);
  89977. }
  89978. }
  89979. }
  89980. return result;
  89981. };
  89982. /**
  89983. * Serializes the objects information.
  89984. * @param currentSerializationObject defines the object to serialize in
  89985. * @returns the serialized object
  89986. */
  89987. TransformNode.prototype.serialize = function (currentSerializationObject) {
  89988. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, currentSerializationObject);
  89989. serializationObject.type = this.getClassName();
  89990. // Parent
  89991. if (this.parent) {
  89992. serializationObject.parentId = this.parent.id;
  89993. }
  89994. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].HasTags(this)) {
  89995. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  89996. }
  89997. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  89998. serializationObject.isEnabled = this.isEnabled();
  89999. // Parent
  90000. if (this.parent) {
  90001. serializationObject.parentId = this.parent.id;
  90002. }
  90003. return serializationObject;
  90004. };
  90005. // Statics
  90006. /**
  90007. * Returns a new TransformNode object parsed from the source provided.
  90008. * @param parsedTransformNode is the source.
  90009. * @param scene the scne the object belongs to
  90010. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  90011. * @returns a new TransformNode object parsed from the source provided.
  90012. */
  90013. TransformNode.Parse = function (parsedTransformNode, scene, rootUrl) {
  90014. var transformNode = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new TransformNode(parsedTransformNode.name, scene); }, parsedTransformNode, scene, rootUrl);
  90015. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  90016. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(transformNode, parsedTransformNode.tags);
  90017. }
  90018. if (parsedTransformNode.localMatrix) {
  90019. transformNode.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArray(parsedTransformNode.localMatrix));
  90020. }
  90021. else if (parsedTransformNode.pivotMatrix) {
  90022. transformNode.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArray(parsedTransformNode.pivotMatrix));
  90023. }
  90024. transformNode.setEnabled(parsedTransformNode.isEnabled);
  90025. // Parent
  90026. if (parsedTransformNode.parentId) {
  90027. transformNode._waitingParentId = parsedTransformNode.parentId;
  90028. }
  90029. return transformNode;
  90030. };
  90031. /**
  90032. * Get all child-transformNodes of this node
  90033. * @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
  90034. * @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
  90035. * @returns an array of TransformNode
  90036. */
  90037. TransformNode.prototype.getChildTransformNodes = function (directDescendantsOnly, predicate) {
  90038. var results = [];
  90039. this._getDescendants(results, directDescendantsOnly, function (node) {
  90040. return ((!predicate || predicate(node)) && (node instanceof TransformNode));
  90041. });
  90042. return results;
  90043. };
  90044. /**
  90045. * Releases resources associated with this transform node.
  90046. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90047. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90048. */
  90049. TransformNode.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  90050. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  90051. // Animations
  90052. this.getScene().stopAnimation(this);
  90053. // Remove from scene
  90054. this.getScene().removeTransformNode(this);
  90055. this.onAfterWorldMatrixUpdateObservable.clear();
  90056. if (doNotRecurse) {
  90057. var transformNodes = this.getChildTransformNodes(true);
  90058. for (var _i = 0, transformNodes_1 = transformNodes; _i < transformNodes_1.length; _i++) {
  90059. var transformNode = transformNodes_1[_i];
  90060. transformNode.parent = null;
  90061. transformNode.computeWorldMatrix(true);
  90062. }
  90063. }
  90064. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  90065. };
  90066. // Statics
  90067. /**
  90068. * Object will not rotate to face the camera
  90069. */
  90070. TransformNode.BILLBOARDMODE_NONE = 0;
  90071. /**
  90072. * Object will rotate to face the camera but only on the x axis
  90073. */
  90074. TransformNode.BILLBOARDMODE_X = 1;
  90075. /**
  90076. * Object will rotate to face the camera but only on the y axis
  90077. */
  90078. TransformNode.BILLBOARDMODE_Y = 2;
  90079. /**
  90080. * Object will rotate to face the camera but only on the z axis
  90081. */
  90082. TransformNode.BILLBOARDMODE_Z = 4;
  90083. /**
  90084. * Object will rotate to face the camera
  90085. */
  90086. TransformNode.BILLBOARDMODE_ALL = 7;
  90087. TransformNode._lookAtVectorCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, 0);
  90088. TransformNode._rotationAxisCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  90089. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90090. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  90091. ], TransformNode.prototype, "_position", void 0);
  90092. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90093. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("rotation")
  90094. ], TransformNode.prototype, "_rotation", void 0);
  90095. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90096. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsQuaternion"])("rotationQuaternion")
  90097. ], TransformNode.prototype, "_rotationQuaternion", void 0);
  90098. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90099. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("scaling")
  90100. ], TransformNode.prototype, "_scaling", void 0);
  90101. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90102. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  90103. ], TransformNode.prototype, "billboardMode", void 0);
  90104. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90105. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  90106. ], TransformNode.prototype, "scalingDeterminant", void 0);
  90107. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90108. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  90109. ], TransformNode.prototype, "infiniteDistance", void 0);
  90110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  90111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  90112. ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
  90113. return TransformNode;
  90114. }(_node__WEBPACK_IMPORTED_MODULE_5__["Node"]));
  90115. /***/ }),
  90116. /***/ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts":
  90117. /*!***************************************************************!*\
  90118. !*** ./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts ***!
  90119. \***************************************************************/
  90120. /*! exports provided: CubeMapToSphericalPolynomialTools */
  90121. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90122. "use strict";
  90123. __webpack_require__.r(__webpack_exports__);
  90124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return CubeMapToSphericalPolynomialTools; });
  90125. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  90126. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  90127. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  90128. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  90129. var FileFaceOrientation = /** @class */ (function () {
  90130. function FileFaceOrientation(name, worldAxisForNormal, worldAxisForFileX, worldAxisForFileY) {
  90131. this.name = name;
  90132. this.worldAxisForNormal = worldAxisForNormal;
  90133. this.worldAxisForFileX = worldAxisForFileX;
  90134. this.worldAxisForFileY = worldAxisForFileY;
  90135. }
  90136. return FileFaceOrientation;
  90137. }());
  90138. /**
  90139. * Helper class dealing with the extraction of spherical polynomial dataArray
  90140. * from a cube map.
  90141. */
  90142. var CubeMapToSphericalPolynomialTools = /** @class */ (function () {
  90143. function CubeMapToSphericalPolynomialTools() {
  90144. }
  90145. /**
  90146. * Converts a texture to the according Spherical Polynomial data.
  90147. * This extracts the first 3 orders only as they are the only one used in the lighting.
  90148. *
  90149. * @param texture The texture to extract the information from.
  90150. * @return The Spherical Polynomial data.
  90151. */
  90152. CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial = function (texture) {
  90153. if (!texture.isCube) {
  90154. // Only supports cube Textures currently.
  90155. return null;
  90156. }
  90157. var size = texture.getSize().width;
  90158. var right = texture.readPixels(0);
  90159. var left = texture.readPixels(1);
  90160. var up;
  90161. var down;
  90162. if (texture.isRenderTarget) {
  90163. up = texture.readPixels(3);
  90164. down = texture.readPixels(2);
  90165. }
  90166. else {
  90167. up = texture.readPixels(2);
  90168. down = texture.readPixels(3);
  90169. }
  90170. var front = texture.readPixels(4);
  90171. var back = texture.readPixels(5);
  90172. var gammaSpace = texture.gammaSpace;
  90173. // Always read as RGBA.
  90174. var format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA;
  90175. var type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  90176. if (texture.textureType && texture.textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  90177. type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_FLOAT;
  90178. }
  90179. var cubeInfo = {
  90180. size: size,
  90181. right: right,
  90182. left: left,
  90183. up: up,
  90184. down: down,
  90185. front: front,
  90186. back: back,
  90187. format: format,
  90188. type: type,
  90189. gammaSpace: gammaSpace,
  90190. };
  90191. return this.ConvertCubeMapToSphericalPolynomial(cubeInfo);
  90192. };
  90193. /**
  90194. * Converts a cubemap to the according Spherical Polynomial data.
  90195. * This extracts the first 3 orders only as they are the only one used in the lighting.
  90196. *
  90197. * @param cubeInfo The Cube map to extract the information from.
  90198. * @return The Spherical Polynomial data.
  90199. */
  90200. CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial = function (cubeInfo) {
  90201. var sphericalHarmonics = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]();
  90202. var totalSolidAngle = 0.0;
  90203. // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.
  90204. var du = 2.0 / cubeInfo.size;
  90205. var dv = du;
  90206. // The (u,v) of the first texel is half a texel from the corner (-1,-1).
  90207. var minUV = du * 0.5 - 1.0;
  90208. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  90209. var fileFace = this.FileFaces[faceIndex];
  90210. var dataArray = cubeInfo[fileFace.name];
  90211. var v = minUV;
  90212. // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).
  90213. // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.
  90214. // Because SP is still linear, so summation is fine in that basis.
  90215. var stride = cubeInfo.format === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA ? 4 : 3;
  90216. for (var y = 0; y < cubeInfo.size; y++) {
  90217. var u = minUV;
  90218. for (var x = 0; x < cubeInfo.size; x++) {
  90219. // World direction (not normalised)
  90220. var worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);
  90221. worldDirection.normalize();
  90222. var deltaSolidAngle = Math.pow(1.0 + u * u + v * v, -3.0 / 2.0);
  90223. var r = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 0];
  90224. var g = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 1];
  90225. var b = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 2];
  90226. // Handle Integer types.
  90227. if (cubeInfo.type === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  90228. r /= 255;
  90229. g /= 255;
  90230. b /= 255;
  90231. }
  90232. // Handle Gamma space textures.
  90233. if (cubeInfo.gammaSpace) {
  90234. r = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(r), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  90235. g = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(g), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  90236. b = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(b), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  90237. }
  90238. var color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](r, g, b);
  90239. sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);
  90240. totalSolidAngle += deltaSolidAngle;
  90241. u += du;
  90242. }
  90243. v += dv;
  90244. }
  90245. }
  90246. // Solid angle for entire sphere is 4*pi
  90247. var sphereSolidAngle = 4.0 * Math.PI;
  90248. // Adjust the solid angle to allow for how many faces we processed.
  90249. var facesProcessed = 6.0;
  90250. var expectedSolidAngle = sphereSolidAngle * facesProcessed / 6.0;
  90251. // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.
  90252. // This is needed because the numerical integration over the cube uses a
  90253. // small angle approximation of solid angle for each texel (see deltaSolidAngle),
  90254. // and also to compensate for accumulative error due to float precision in the summation.
  90255. var correctionFactor = expectedSolidAngle / totalSolidAngle;
  90256. sphericalHarmonics.scale(correctionFactor);
  90257. sphericalHarmonics.convertIncidentRadianceToIrradiance();
  90258. sphericalHarmonics.convertIrradianceToLambertianRadiance();
  90259. return _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"].FromHarmonics(sphericalHarmonics);
  90260. };
  90261. CubeMapToSphericalPolynomialTools.FileFaces = [
  90262. 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)),
  90263. 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)),
  90264. 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)),
  90265. 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)),
  90266. 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)),
  90267. 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
  90268. ];
  90269. return CubeMapToSphericalPolynomialTools;
  90270. }());
  90271. /***/ }),
  90272. /***/ "./Misc/HighDynamicRange/hdr.ts":
  90273. /*!**************************************!*\
  90274. !*** ./Misc/HighDynamicRange/hdr.ts ***!
  90275. \**************************************/
  90276. /*! exports provided: HDRTools */
  90277. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90278. "use strict";
  90279. __webpack_require__.r(__webpack_exports__);
  90280. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return HDRTools; });
  90281. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  90282. /**
  90283. * This groups tools to convert HDR texture to native colors array.
  90284. */
  90285. var HDRTools = /** @class */ (function () {
  90286. function HDRTools() {
  90287. }
  90288. HDRTools.Ldexp = function (mantissa, exponent) {
  90289. if (exponent > 1023) {
  90290. return mantissa * Math.pow(2, 1023) * Math.pow(2, exponent - 1023);
  90291. }
  90292. if (exponent < -1074) {
  90293. return mantissa * Math.pow(2, -1074) * Math.pow(2, exponent + 1074);
  90294. }
  90295. return mantissa * Math.pow(2, exponent);
  90296. };
  90297. HDRTools.Rgbe2float = function (float32array, red, green, blue, exponent, index) {
  90298. if (exponent > 0) { /*nonzero pixel*/
  90299. exponent = this.Ldexp(1.0, exponent - (128 + 8));
  90300. float32array[index + 0] = red * exponent;
  90301. float32array[index + 1] = green * exponent;
  90302. float32array[index + 2] = blue * exponent;
  90303. }
  90304. else {
  90305. float32array[index + 0] = 0;
  90306. float32array[index + 1] = 0;
  90307. float32array[index + 2] = 0;
  90308. }
  90309. };
  90310. HDRTools.readStringLine = function (uint8array, startIndex) {
  90311. var line = "";
  90312. var character = "";
  90313. for (var i = startIndex; i < uint8array.length - startIndex; i++) {
  90314. character = String.fromCharCode(uint8array[i]);
  90315. if (character == "\n") {
  90316. break;
  90317. }
  90318. line += character;
  90319. }
  90320. return line;
  90321. };
  90322. /**
  90323. * Reads header information from an RGBE texture stored in a native array.
  90324. * More information on this format are available here:
  90325. * https://en.wikipedia.org/wiki/RGBE_image_format
  90326. *
  90327. * @param uint8array The binary file stored in native array.
  90328. * @return The header information.
  90329. */
  90330. HDRTools.RGBE_ReadHeader = function (uint8array) {
  90331. var height = 0;
  90332. var width = 0;
  90333. var line = this.readStringLine(uint8array, 0);
  90334. if (line[0] != '#' || line[1] != '?') {
  90335. throw "Bad HDR Format.";
  90336. }
  90337. var endOfHeader = false;
  90338. var findFormat = false;
  90339. var lineIndex = 0;
  90340. do {
  90341. lineIndex += (line.length + 1);
  90342. line = this.readStringLine(uint8array, lineIndex);
  90343. if (line == "FORMAT=32-bit_rle_rgbe") {
  90344. findFormat = true;
  90345. }
  90346. else if (line.length == 0) {
  90347. endOfHeader = true;
  90348. }
  90349. } while (!endOfHeader);
  90350. if (!findFormat) {
  90351. throw "HDR Bad header format, unsupported FORMAT";
  90352. }
  90353. lineIndex += (line.length + 1);
  90354. line = this.readStringLine(uint8array, lineIndex);
  90355. var sizeRegexp = /^\-Y (.*) \+X (.*)$/g;
  90356. var match = sizeRegexp.exec(line);
  90357. // TODO. Support +Y and -X if needed.
  90358. if (!match || match.length < 3) {
  90359. throw "HDR Bad header format, no size";
  90360. }
  90361. width = parseInt(match[2]);
  90362. height = parseInt(match[1]);
  90363. if (width < 8 || width > 0x7fff) {
  90364. throw "HDR Bad header format, unsupported size";
  90365. }
  90366. lineIndex += (line.length + 1);
  90367. return {
  90368. height: height,
  90369. width: width,
  90370. dataPosition: lineIndex
  90371. };
  90372. };
  90373. /**
  90374. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  90375. * This RGBE texture needs to store the information as a panorama.
  90376. *
  90377. * More information on this format are available here:
  90378. * https://en.wikipedia.org/wiki/RGBE_image_format
  90379. *
  90380. * @param buffer The binary file stored in an array buffer.
  90381. * @param size The expected size of the extracted cubemap.
  90382. * @return The Cube Map information.
  90383. */
  90384. HDRTools.GetCubeMapTextureData = function (buffer, size) {
  90385. var uint8array = new Uint8Array(buffer);
  90386. var hdrInfo = this.RGBE_ReadHeader(uint8array);
  90387. var data = this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  90388. var cubeMapData = _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(data, hdrInfo.width, hdrInfo.height, size);
  90389. return cubeMapData;
  90390. };
  90391. /**
  90392. * Returns the pixels data extracted from an RGBE texture.
  90393. * This pixels will be stored left to right up to down in the R G B order in one array.
  90394. *
  90395. * More information on this format are available here:
  90396. * https://en.wikipedia.org/wiki/RGBE_image_format
  90397. *
  90398. * @param uint8array The binary file stored in an array buffer.
  90399. * @param hdrInfo The header information of the file.
  90400. * @return The pixels data in RGB right to left up to down order.
  90401. */
  90402. HDRTools.RGBE_ReadPixels = function (uint8array, hdrInfo) {
  90403. // Keep for multi format supports.
  90404. return this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  90405. };
  90406. HDRTools.RGBE_ReadPixels_RLE = function (uint8array, hdrInfo) {
  90407. var num_scanlines = hdrInfo.height;
  90408. var scanline_width = hdrInfo.width;
  90409. var a, b, c, d, count;
  90410. var dataIndex = hdrInfo.dataPosition;
  90411. var index = 0, endIndex = 0, i = 0;
  90412. var scanLineArrayBuffer = new ArrayBuffer(scanline_width * 4); // four channel R G B E
  90413. var scanLineArray = new Uint8Array(scanLineArrayBuffer);
  90414. // 3 channels of 4 bytes per pixel in float.
  90415. var resultBuffer = new ArrayBuffer(hdrInfo.width * hdrInfo.height * 4 * 3);
  90416. var resultArray = new Float32Array(resultBuffer);
  90417. // read in each successive scanline
  90418. while (num_scanlines > 0) {
  90419. a = uint8array[dataIndex++];
  90420. b = uint8array[dataIndex++];
  90421. c = uint8array[dataIndex++];
  90422. d = uint8array[dataIndex++];
  90423. if (a != 2 || b != 2 || (c & 0x80)) {
  90424. // this file is not run length encoded
  90425. throw "HDR Bad header format, not RLE";
  90426. }
  90427. if (((c << 8) | d) != scanline_width) {
  90428. throw "HDR Bad header format, wrong scan line width";
  90429. }
  90430. index = 0;
  90431. // read each of the four channels for the scanline into the buffer
  90432. for (i = 0; i < 4; i++) {
  90433. endIndex = (i + 1) * scanline_width;
  90434. while (index < endIndex) {
  90435. a = uint8array[dataIndex++];
  90436. b = uint8array[dataIndex++];
  90437. if (a > 128) {
  90438. // a run of the same value
  90439. count = a - 128;
  90440. if ((count == 0) || (count > endIndex - index)) {
  90441. throw "HDR Bad Format, bad scanline data (run)";
  90442. }
  90443. while (count-- > 0) {
  90444. scanLineArray[index++] = b;
  90445. }
  90446. }
  90447. else {
  90448. // a non-run
  90449. count = a;
  90450. if ((count == 0) || (count > endIndex - index)) {
  90451. throw "HDR Bad Format, bad scanline data (non-run)";
  90452. }
  90453. scanLineArray[index++] = b;
  90454. if (--count > 0) {
  90455. for (var j = 0; j < count; j++) {
  90456. scanLineArray[index++] = uint8array[dataIndex++];
  90457. }
  90458. }
  90459. }
  90460. }
  90461. }
  90462. // now convert data from buffer into floats
  90463. for (i = 0; i < scanline_width; i++) {
  90464. a = scanLineArray[i];
  90465. b = scanLineArray[i + scanline_width];
  90466. c = scanLineArray[i + 2 * scanline_width];
  90467. d = scanLineArray[i + 3 * scanline_width];
  90468. this.Rgbe2float(resultArray, a, b, c, d, (hdrInfo.height - num_scanlines) * scanline_width * 3 + i * 3);
  90469. }
  90470. num_scanlines--;
  90471. }
  90472. return resultArray;
  90473. };
  90474. return HDRTools;
  90475. }());
  90476. /***/ }),
  90477. /***/ "./Misc/HighDynamicRange/index.ts":
  90478. /*!****************************************!*\
  90479. !*** ./Misc/HighDynamicRange/index.ts ***!
  90480. \****************************************/
  90481. /*! exports provided: CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  90482. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90483. "use strict";
  90484. __webpack_require__.r(__webpack_exports__);
  90485. /* harmony import */ var _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  90486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  90487. /* harmony import */ var _hdr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hdr */ "./Misc/HighDynamicRange/hdr.ts");
  90488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _hdr__WEBPACK_IMPORTED_MODULE_1__["HDRTools"]; });
  90489. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  90490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__["PanoramaToCubeMapTools"]; });
  90491. /***/ }),
  90492. /***/ "./Misc/HighDynamicRange/panoramaToCubemap.ts":
  90493. /*!****************************************************!*\
  90494. !*** ./Misc/HighDynamicRange/panoramaToCubemap.ts ***!
  90495. \****************************************************/
  90496. /*! exports provided: PanoramaToCubeMapTools */
  90497. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90498. "use strict";
  90499. __webpack_require__.r(__webpack_exports__);
  90500. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return PanoramaToCubeMapTools; });
  90501. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  90502. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  90503. /**
  90504. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  90505. */
  90506. var PanoramaToCubeMapTools = /** @class */ (function () {
  90507. function PanoramaToCubeMapTools() {
  90508. }
  90509. /**
  90510. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  90511. *
  90512. * @param float32Array The source data.
  90513. * @param inputWidth The width of the input panorama.
  90514. * @param inputHeight The height of the input panorama.
  90515. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  90516. * @return The cubemap data
  90517. */
  90518. PanoramaToCubeMapTools.ConvertPanoramaToCubemap = function (float32Array, inputWidth, inputHeight, size) {
  90519. if (!float32Array) {
  90520. throw "ConvertPanoramaToCubemap: input cannot be null";
  90521. }
  90522. if (float32Array.length != inputWidth * inputHeight * 3) {
  90523. throw "ConvertPanoramaToCubemap: input size is wrong";
  90524. }
  90525. var textureFront = this.CreateCubemapTexture(size, this.FACE_FRONT, float32Array, inputWidth, inputHeight);
  90526. var textureBack = this.CreateCubemapTexture(size, this.FACE_BACK, float32Array, inputWidth, inputHeight);
  90527. var textureLeft = this.CreateCubemapTexture(size, this.FACE_LEFT, float32Array, inputWidth, inputHeight);
  90528. var textureRight = this.CreateCubemapTexture(size, this.FACE_RIGHT, float32Array, inputWidth, inputHeight);
  90529. var textureUp = this.CreateCubemapTexture(size, this.FACE_UP, float32Array, inputWidth, inputHeight);
  90530. var textureDown = this.CreateCubemapTexture(size, this.FACE_DOWN, float32Array, inputWidth, inputHeight);
  90531. return {
  90532. front: textureFront,
  90533. back: textureBack,
  90534. left: textureLeft,
  90535. right: textureRight,
  90536. up: textureUp,
  90537. down: textureDown,
  90538. size: size,
  90539. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT,
  90540. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGB,
  90541. gammaSpace: false,
  90542. };
  90543. };
  90544. PanoramaToCubeMapTools.CreateCubemapTexture = function (texSize, faceData, float32Array, inputWidth, inputHeight) {
  90545. var buffer = new ArrayBuffer(texSize * texSize * 4 * 3);
  90546. var textureArray = new Float32Array(buffer);
  90547. var rotDX1 = faceData[1].subtract(faceData[0]).scale(1 / texSize);
  90548. var rotDX2 = faceData[3].subtract(faceData[2]).scale(1 / texSize);
  90549. var dy = 1 / texSize;
  90550. var fy = 0;
  90551. for (var y = 0; y < texSize; y++) {
  90552. var xv1 = faceData[0];
  90553. var xv2 = faceData[2];
  90554. for (var x = 0; x < texSize; x++) {
  90555. var v = xv2.subtract(xv1).scale(fy).add(xv1);
  90556. v.normalize();
  90557. var color = this.CalcProjectionSpherical(v, float32Array, inputWidth, inputHeight);
  90558. // 3 channels per pixels
  90559. textureArray[y * texSize * 3 + (x * 3) + 0] = color.r;
  90560. textureArray[y * texSize * 3 + (x * 3) + 1] = color.g;
  90561. textureArray[y * texSize * 3 + (x * 3) + 2] = color.b;
  90562. xv1 = xv1.add(rotDX1);
  90563. xv2 = xv2.add(rotDX2);
  90564. }
  90565. fy += dy;
  90566. }
  90567. return textureArray;
  90568. };
  90569. PanoramaToCubeMapTools.CalcProjectionSpherical = function (vDir, float32Array, inputWidth, inputHeight) {
  90570. var theta = Math.atan2(vDir.z, vDir.x);
  90571. var phi = Math.acos(vDir.y);
  90572. while (theta < -Math.PI) {
  90573. theta += 2 * Math.PI;
  90574. }
  90575. while (theta > Math.PI) {
  90576. theta -= 2 * Math.PI;
  90577. }
  90578. var dx = theta / Math.PI;
  90579. var dy = phi / Math.PI;
  90580. // recenter.
  90581. dx = dx * 0.5 + 0.5;
  90582. var px = Math.round(dx * inputWidth);
  90583. if (px < 0) {
  90584. px = 0;
  90585. }
  90586. else if (px >= inputWidth) {
  90587. px = inputWidth - 1;
  90588. }
  90589. var py = Math.round(dy * inputHeight);
  90590. if (py < 0) {
  90591. py = 0;
  90592. }
  90593. else if (py >= inputHeight) {
  90594. py = inputHeight - 1;
  90595. }
  90596. var inputY = (inputHeight - py - 1);
  90597. var r = float32Array[inputY * inputWidth * 3 + (px * 3) + 0];
  90598. var g = float32Array[inputY * inputWidth * 3 + (px * 3) + 1];
  90599. var b = float32Array[inputY * inputWidth * 3 + (px * 3) + 2];
  90600. return {
  90601. r: r,
  90602. g: g,
  90603. b: b
  90604. };
  90605. };
  90606. PanoramaToCubeMapTools.FACE_FRONT = [
  90607. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  90608. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  90609. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  90610. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0)
  90611. ];
  90612. PanoramaToCubeMapTools.FACE_BACK = [
  90613. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  90614. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  90615. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0),
  90616. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0)
  90617. ];
  90618. PanoramaToCubeMapTools.FACE_RIGHT = [
  90619. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  90620. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  90621. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  90622. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  90623. ];
  90624. PanoramaToCubeMapTools.FACE_LEFT = [
  90625. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  90626. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  90627. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  90628. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0)
  90629. ];
  90630. PanoramaToCubeMapTools.FACE_DOWN = [
  90631. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  90632. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  90633. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  90634. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  90635. ];
  90636. PanoramaToCubeMapTools.FACE_UP = [
  90637. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  90638. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  90639. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  90640. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0)
  90641. ];
  90642. return PanoramaToCubeMapTools;
  90643. }());
  90644. /***/ }),
  90645. /***/ "./Misc/andOrNotEvaluator.ts":
  90646. /*!***********************************!*\
  90647. !*** ./Misc/andOrNotEvaluator.ts ***!
  90648. \***********************************/
  90649. /*! exports provided: AndOrNotEvaluator */
  90650. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90651. "use strict";
  90652. __webpack_require__.r(__webpack_exports__);
  90653. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return AndOrNotEvaluator; });
  90654. /**
  90655. * Class used to evalaute queries containing `and` and `or` operators
  90656. */
  90657. var AndOrNotEvaluator = /** @class */ (function () {
  90658. function AndOrNotEvaluator() {
  90659. }
  90660. /**
  90661. * Evaluate a query
  90662. * @param query defines the query to evaluate
  90663. * @param evaluateCallback defines the callback used to filter result
  90664. * @returns true if the query matches
  90665. */
  90666. AndOrNotEvaluator.Eval = function (query, evaluateCallback) {
  90667. if (!query.match(/\([^\(\)]*\)/g)) {
  90668. query = AndOrNotEvaluator._HandleParenthesisContent(query, evaluateCallback);
  90669. }
  90670. else {
  90671. query = query.replace(/\([^\(\)]*\)/g, function (r) {
  90672. // remove parenthesis
  90673. r = r.slice(1, r.length - 1);
  90674. return AndOrNotEvaluator._HandleParenthesisContent(r, evaluateCallback);
  90675. });
  90676. }
  90677. if (query === "true") {
  90678. return true;
  90679. }
  90680. if (query === "false") {
  90681. return false;
  90682. }
  90683. return AndOrNotEvaluator.Eval(query, evaluateCallback);
  90684. };
  90685. AndOrNotEvaluator._HandleParenthesisContent = function (parenthesisContent, evaluateCallback) {
  90686. evaluateCallback = evaluateCallback || (function (r) {
  90687. return r === "true" ? true : false;
  90688. });
  90689. var result;
  90690. var or = parenthesisContent.split("||");
  90691. for (var i in or) {
  90692. if (or.hasOwnProperty(i)) {
  90693. var ori = AndOrNotEvaluator._SimplifyNegation(or[i].trim());
  90694. var and = ori.split("&&");
  90695. if (and.length > 1) {
  90696. for (var j = 0; j < and.length; ++j) {
  90697. var andj = AndOrNotEvaluator._SimplifyNegation(and[j].trim());
  90698. if (andj !== "true" && andj !== "false") {
  90699. if (andj[0] === "!") {
  90700. result = !evaluateCallback(andj.substring(1));
  90701. }
  90702. else {
  90703. result = evaluateCallback(andj);
  90704. }
  90705. }
  90706. else {
  90707. result = andj === "true" ? true : false;
  90708. }
  90709. if (!result) { // no need to continue since 'false && ... && ...' will always return false
  90710. ori = "false";
  90711. break;
  90712. }
  90713. }
  90714. }
  90715. if (result || ori === "true") { // no need to continue since 'true || ... || ...' will always return true
  90716. result = true;
  90717. break;
  90718. }
  90719. // result equals false (or undefined)
  90720. if (ori !== "true" && ori !== "false") {
  90721. if (ori[0] === "!") {
  90722. result = !evaluateCallback(ori.substring(1));
  90723. }
  90724. else {
  90725. result = evaluateCallback(ori);
  90726. }
  90727. }
  90728. else {
  90729. result = ori === "true" ? true : false;
  90730. }
  90731. }
  90732. }
  90733. // the whole parenthesis scope is replaced by 'true' or 'false'
  90734. return result ? "true" : "false";
  90735. };
  90736. AndOrNotEvaluator._SimplifyNegation = function (booleanString) {
  90737. booleanString = booleanString.replace(/^[\s!]+/, function (r) {
  90738. // remove whitespaces
  90739. r = r.replace(/[\s]/g, function () { return ""; });
  90740. return r.length % 2 ? "!" : "";
  90741. });
  90742. booleanString = booleanString.trim();
  90743. if (booleanString === "!true") {
  90744. booleanString = "false";
  90745. }
  90746. else if (booleanString === "!false") {
  90747. booleanString = "true";
  90748. }
  90749. return booleanString;
  90750. };
  90751. return AndOrNotEvaluator;
  90752. }());
  90753. /***/ }),
  90754. /***/ "./Misc/arrayTools.ts":
  90755. /*!****************************!*\
  90756. !*** ./Misc/arrayTools.ts ***!
  90757. \****************************/
  90758. /*! exports provided: ArrayTools */
  90759. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90760. "use strict";
  90761. __webpack_require__.r(__webpack_exports__);
  90762. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayTools", function() { return ArrayTools; });
  90763. /**
  90764. * Class containing a set of static utilities functions for arrays.
  90765. */
  90766. var ArrayTools = /** @class */ (function () {
  90767. function ArrayTools() {
  90768. }
  90769. /**
  90770. * Returns an array of the given size filled with element built from the given constructor and the paramters
  90771. * @param size the number of element to construct and put in the array
  90772. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  90773. * @returns a new array filled with new objects
  90774. */
  90775. ArrayTools.BuildArray = function (size, itemBuilder) {
  90776. var a = [];
  90777. for (var i = 0; i < size; ++i) {
  90778. a.push(itemBuilder());
  90779. }
  90780. return a;
  90781. };
  90782. return ArrayTools;
  90783. }());
  90784. /***/ }),
  90785. /***/ "./Misc/assetsManager.ts":
  90786. /*!*******************************!*\
  90787. !*** ./Misc/assetsManager.ts ***!
  90788. \*******************************/
  90789. /*! exports provided: AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager */
  90790. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90791. "use strict";
  90792. __webpack_require__.r(__webpack_exports__);
  90793. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return AssetTaskState; });
  90794. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return AbstractAssetTask; });
  90795. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return AssetsProgressEvent; });
  90796. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return MeshAssetTask; });
  90797. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return TextFileAssetTask; });
  90798. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return BinaryFileAssetTask; });
  90799. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return ImageAssetTask; });
  90800. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return TextureAssetTask; });
  90801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return CubeTextureAssetTask; });
  90802. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return HDRCubeTextureAssetTask; });
  90803. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return AssetsManager; });
  90804. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  90805. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  90806. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  90807. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  90808. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  90809. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  90810. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  90811. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  90812. /**
  90813. * Defines the list of states available for a task inside a AssetsManager
  90814. */
  90815. var AssetTaskState;
  90816. (function (AssetTaskState) {
  90817. /**
  90818. * Initialization
  90819. */
  90820. AssetTaskState[AssetTaskState["INIT"] = 0] = "INIT";
  90821. /**
  90822. * Running
  90823. */
  90824. AssetTaskState[AssetTaskState["RUNNING"] = 1] = "RUNNING";
  90825. /**
  90826. * Done
  90827. */
  90828. AssetTaskState[AssetTaskState["DONE"] = 2] = "DONE";
  90829. /**
  90830. * Error
  90831. */
  90832. AssetTaskState[AssetTaskState["ERROR"] = 3] = "ERROR";
  90833. })(AssetTaskState || (AssetTaskState = {}));
  90834. /**
  90835. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  90836. */
  90837. var AbstractAssetTask = /** @class */ (function () {
  90838. /**
  90839. * Creates a new AssetsManager
  90840. * @param name defines the name of the task
  90841. */
  90842. function AbstractAssetTask(
  90843. /**
  90844. * Task name
  90845. */ name) {
  90846. this.name = name;
  90847. this._isCompleted = false;
  90848. this._taskState = AssetTaskState.INIT;
  90849. }
  90850. Object.defineProperty(AbstractAssetTask.prototype, "isCompleted", {
  90851. /**
  90852. * Get if the task is completed
  90853. */
  90854. get: function () {
  90855. return this._isCompleted;
  90856. },
  90857. enumerable: true,
  90858. configurable: true
  90859. });
  90860. Object.defineProperty(AbstractAssetTask.prototype, "taskState", {
  90861. /**
  90862. * Gets the current state of the task
  90863. */
  90864. get: function () {
  90865. return this._taskState;
  90866. },
  90867. enumerable: true,
  90868. configurable: true
  90869. });
  90870. Object.defineProperty(AbstractAssetTask.prototype, "errorObject", {
  90871. /**
  90872. * Gets the current error object (if task is in error)
  90873. */
  90874. get: function () {
  90875. return this._errorObject;
  90876. },
  90877. enumerable: true,
  90878. configurable: true
  90879. });
  90880. /**
  90881. * Internal only
  90882. * @hidden
  90883. */
  90884. AbstractAssetTask.prototype._setErrorObject = function (message, exception) {
  90885. if (this._errorObject) {
  90886. return;
  90887. }
  90888. this._errorObject = {
  90889. message: message,
  90890. exception: exception
  90891. };
  90892. };
  90893. /**
  90894. * Execute the current task
  90895. * @param scene defines the scene where you want your assets to be loaded
  90896. * @param onSuccess is a callback called when the task is successfully executed
  90897. * @param onError is a callback called if an error occurs
  90898. */
  90899. AbstractAssetTask.prototype.run = function (scene, onSuccess, onError) {
  90900. var _this = this;
  90901. this._taskState = AssetTaskState.RUNNING;
  90902. this.runTask(scene, function () {
  90903. _this.onDoneCallback(onSuccess, onError);
  90904. }, function (msg, exception) {
  90905. _this.onErrorCallback(onError, msg, exception);
  90906. });
  90907. };
  90908. /**
  90909. * Execute the current task
  90910. * @param scene defines the scene where you want your assets to be loaded
  90911. * @param onSuccess is a callback called when the task is successfully executed
  90912. * @param onError is a callback called if an error occurs
  90913. */
  90914. AbstractAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  90915. throw new Error("runTask is not implemented");
  90916. };
  90917. /**
  90918. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  90919. * This can be used with failed tasks that have the reason for failure fixed.
  90920. */
  90921. AbstractAssetTask.prototype.reset = function () {
  90922. this._taskState = AssetTaskState.INIT;
  90923. };
  90924. AbstractAssetTask.prototype.onErrorCallback = function (onError, message, exception) {
  90925. this._taskState = AssetTaskState.ERROR;
  90926. this._errorObject = {
  90927. message: message,
  90928. exception: exception
  90929. };
  90930. if (this.onError) {
  90931. this.onError(this, message, exception);
  90932. }
  90933. onError();
  90934. };
  90935. AbstractAssetTask.prototype.onDoneCallback = function (onSuccess, onError) {
  90936. try {
  90937. this._taskState = AssetTaskState.DONE;
  90938. this._isCompleted = true;
  90939. if (this.onSuccess) {
  90940. this.onSuccess(this);
  90941. }
  90942. onSuccess();
  90943. }
  90944. catch (e) {
  90945. this.onErrorCallback(onError, "Task is done, error executing success callback(s)", e);
  90946. }
  90947. };
  90948. return AbstractAssetTask;
  90949. }());
  90950. /**
  90951. * Class used to share progress information about assets loading
  90952. */
  90953. var AssetsProgressEvent = /** @class */ (function () {
  90954. /**
  90955. * Creates a AssetsProgressEvent
  90956. * @param remainingCount defines the number of remaining tasks to process
  90957. * @param totalCount defines the total number of tasks
  90958. * @param task defines the task that was just processed
  90959. */
  90960. function AssetsProgressEvent(remainingCount, totalCount, task) {
  90961. this.remainingCount = remainingCount;
  90962. this.totalCount = totalCount;
  90963. this.task = task;
  90964. }
  90965. return AssetsProgressEvent;
  90966. }());
  90967. /**
  90968. * Define a task used by AssetsManager to load meshes
  90969. */
  90970. var MeshAssetTask = /** @class */ (function (_super) {
  90971. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshAssetTask, _super);
  90972. /**
  90973. * Creates a new MeshAssetTask
  90974. * @param name defines the name of the task
  90975. * @param meshesNames defines the list of mesh's names you want to load
  90976. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  90977. * @param sceneFilename defines the filename of the scene to load from
  90978. */
  90979. function MeshAssetTask(
  90980. /**
  90981. * Defines the name of the task
  90982. */
  90983. name,
  90984. /**
  90985. * Defines the list of mesh's names you want to load
  90986. */
  90987. meshesNames,
  90988. /**
  90989. * Defines the root url to use as a base to load your meshes and associated resources
  90990. */
  90991. rootUrl,
  90992. /**
  90993. * Defines the filename of the scene to load from
  90994. */
  90995. sceneFilename) {
  90996. var _this = _super.call(this, name) || this;
  90997. _this.name = name;
  90998. _this.meshesNames = meshesNames;
  90999. _this.rootUrl = rootUrl;
  91000. _this.sceneFilename = sceneFilename;
  91001. return _this;
  91002. }
  91003. /**
  91004. * Execute the current task
  91005. * @param scene defines the scene where you want your assets to be loaded
  91006. * @param onSuccess is a callback called when the task is successfully executed
  91007. * @param onError is a callback called if an error occurs
  91008. */
  91009. MeshAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91010. var _this = this;
  91011. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  91012. _this.loadedMeshes = meshes;
  91013. _this.loadedParticleSystems = particleSystems;
  91014. _this.loadedSkeletons = skeletons;
  91015. _this.loadedAnimationGroups = animationGroups;
  91016. onSuccess();
  91017. }, null, function (scene, message, exception) {
  91018. onError(message, exception);
  91019. });
  91020. };
  91021. return MeshAssetTask;
  91022. }(AbstractAssetTask));
  91023. /**
  91024. * Define a task used by AssetsManager to load text content
  91025. */
  91026. var TextFileAssetTask = /** @class */ (function (_super) {
  91027. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextFileAssetTask, _super);
  91028. /**
  91029. * Creates a new TextFileAssetTask object
  91030. * @param name defines the name of the task
  91031. * @param url defines the location of the file to load
  91032. */
  91033. function TextFileAssetTask(
  91034. /**
  91035. * Defines the name of the task
  91036. */
  91037. name,
  91038. /**
  91039. * Defines the location of the file to load
  91040. */
  91041. url) {
  91042. var _this = _super.call(this, name) || this;
  91043. _this.name = name;
  91044. _this.url = url;
  91045. return _this;
  91046. }
  91047. /**
  91048. * Execute the current task
  91049. * @param scene defines the scene where you want your assets to be loaded
  91050. * @param onSuccess is a callback called when the task is successfully executed
  91051. * @param onError is a callback called if an error occurs
  91052. */
  91053. TextFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91054. var _this = this;
  91055. scene._loadFile(this.url, function (data) {
  91056. _this.text = data;
  91057. onSuccess();
  91058. }, undefined, false, false, function (request, exception) {
  91059. if (request) {
  91060. onError(request.status + " " + request.statusText, exception);
  91061. }
  91062. });
  91063. };
  91064. return TextFileAssetTask;
  91065. }(AbstractAssetTask));
  91066. /**
  91067. * Define a task used by AssetsManager to load binary data
  91068. */
  91069. var BinaryFileAssetTask = /** @class */ (function (_super) {
  91070. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BinaryFileAssetTask, _super);
  91071. /**
  91072. * Creates a new BinaryFileAssetTask object
  91073. * @param name defines the name of the new task
  91074. * @param url defines the location of the file to load
  91075. */
  91076. function BinaryFileAssetTask(
  91077. /**
  91078. * Defines the name of the task
  91079. */
  91080. name,
  91081. /**
  91082. * Defines the location of the file to load
  91083. */
  91084. url) {
  91085. var _this = _super.call(this, name) || this;
  91086. _this.name = name;
  91087. _this.url = url;
  91088. return _this;
  91089. }
  91090. /**
  91091. * Execute the current task
  91092. * @param scene defines the scene where you want your assets to be loaded
  91093. * @param onSuccess is a callback called when the task is successfully executed
  91094. * @param onError is a callback called if an error occurs
  91095. */
  91096. BinaryFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91097. var _this = this;
  91098. scene._loadFile(this.url, function (data) {
  91099. _this.data = data;
  91100. onSuccess();
  91101. }, undefined, true, true, function (request, exception) {
  91102. if (request) {
  91103. onError(request.status + " " + request.statusText, exception);
  91104. }
  91105. });
  91106. };
  91107. return BinaryFileAssetTask;
  91108. }(AbstractAssetTask));
  91109. /**
  91110. * Define a task used by AssetsManager to load images
  91111. */
  91112. var ImageAssetTask = /** @class */ (function (_super) {
  91113. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageAssetTask, _super);
  91114. /**
  91115. * Creates a new ImageAssetTask
  91116. * @param name defines the name of the task
  91117. * @param url defines the location of the image to load
  91118. */
  91119. function ImageAssetTask(
  91120. /**
  91121. * Defines the name of the task
  91122. */
  91123. name,
  91124. /**
  91125. * Defines the location of the image to load
  91126. */
  91127. url) {
  91128. var _this = _super.call(this, name) || this;
  91129. _this.name = name;
  91130. _this.url = url;
  91131. return _this;
  91132. }
  91133. /**
  91134. * Execute the current task
  91135. * @param scene defines the scene where you want your assets to be loaded
  91136. * @param onSuccess is a callback called when the task is successfully executed
  91137. * @param onError is a callback called if an error occurs
  91138. */
  91139. ImageAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91140. var _this = this;
  91141. var img = new Image();
  91142. _tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(this.url, img);
  91143. img.onload = function () {
  91144. _this.image = img;
  91145. onSuccess();
  91146. };
  91147. img.onerror = function (err) {
  91148. onError("Error loading image", err);
  91149. };
  91150. img.src = this.url;
  91151. };
  91152. return ImageAssetTask;
  91153. }(AbstractAssetTask));
  91154. /**
  91155. * Define a task used by AssetsManager to load 2D textures
  91156. */
  91157. var TextureAssetTask = /** @class */ (function (_super) {
  91158. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureAssetTask, _super);
  91159. /**
  91160. * Creates a new TextureAssetTask object
  91161. * @param name defines the name of the task
  91162. * @param url defines the location of the file to load
  91163. * @param noMipmap defines if mipmap should not be generated (default is false)
  91164. * @param invertY defines if texture must be inverted on Y axis (default is false)
  91165. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  91166. */
  91167. function TextureAssetTask(
  91168. /**
  91169. * Defines the name of the task
  91170. */
  91171. name,
  91172. /**
  91173. * Defines the location of the file to load
  91174. */
  91175. url,
  91176. /**
  91177. * Defines if mipmap should not be generated (default is false)
  91178. */
  91179. noMipmap,
  91180. /**
  91181. * Defines if texture must be inverted on Y axis (default is false)
  91182. */
  91183. invertY,
  91184. /**
  91185. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  91186. */
  91187. samplingMode) {
  91188. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  91189. var _this = _super.call(this, name) || this;
  91190. _this.name = name;
  91191. _this.url = url;
  91192. _this.noMipmap = noMipmap;
  91193. _this.invertY = invertY;
  91194. _this.samplingMode = samplingMode;
  91195. return _this;
  91196. }
  91197. /**
  91198. * Execute the current task
  91199. * @param scene defines the scene where you want your assets to be loaded
  91200. * @param onSuccess is a callback called when the task is successfully executed
  91201. * @param onError is a callback called if an error occurs
  91202. */
  91203. TextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91204. var onload = function () {
  91205. onSuccess();
  91206. };
  91207. var onerror = function (message, exception) {
  91208. onError(message, exception);
  91209. };
  91210. this.texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this.url, scene, this.noMipmap, this.invertY, this.samplingMode, onload, onerror);
  91211. };
  91212. return TextureAssetTask;
  91213. }(AbstractAssetTask));
  91214. /**
  91215. * Define a task used by AssetsManager to load cube textures
  91216. */
  91217. var CubeTextureAssetTask = /** @class */ (function (_super) {
  91218. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTextureAssetTask, _super);
  91219. /**
  91220. * Creates a new CubeTextureAssetTask
  91221. * @param name defines the name of the task
  91222. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  91223. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  91224. * @param noMipmap defines if mipmaps should not be generated (default is false)
  91225. * @param files defines the explicit list of files (undefined by default)
  91226. */
  91227. function CubeTextureAssetTask(
  91228. /**
  91229. * Defines the name of the task
  91230. */
  91231. name,
  91232. /**
  91233. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  91234. */
  91235. url,
  91236. /**
  91237. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  91238. */
  91239. extensions,
  91240. /**
  91241. * Defines if mipmaps should not be generated (default is false)
  91242. */
  91243. noMipmap,
  91244. /**
  91245. * Defines the explicit list of files (undefined by default)
  91246. */
  91247. files) {
  91248. var _this = _super.call(this, name) || this;
  91249. _this.name = name;
  91250. _this.url = url;
  91251. _this.extensions = extensions;
  91252. _this.noMipmap = noMipmap;
  91253. _this.files = files;
  91254. return _this;
  91255. }
  91256. /**
  91257. * Execute the current task
  91258. * @param scene defines the scene where you want your assets to be loaded
  91259. * @param onSuccess is a callback called when the task is successfully executed
  91260. * @param onError is a callback called if an error occurs
  91261. */
  91262. CubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  91263. var onload = function () {
  91264. onSuccess();
  91265. };
  91266. var onerror = function (message, exception) {
  91267. onError(message, exception);
  91268. };
  91269. this.texture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__["CubeTexture"](this.url, scene, this.extensions, this.noMipmap, this.files, onload, onerror);
  91270. };
  91271. return CubeTextureAssetTask;
  91272. }(AbstractAssetTask));
  91273. /**
  91274. * Define a task used by AssetsManager to load HDR cube textures
  91275. */
  91276. var HDRCubeTextureAssetTask = /** @class */ (function (_super) {
  91277. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTextureAssetTask, _super);
  91278. /**
  91279. * Creates a new HDRCubeTextureAssetTask object
  91280. * @param name defines the name of the task
  91281. * @param url defines the location of the file to load
  91282. * @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.
  91283. * @param noMipmap defines if mipmaps should not be generated (default is false)
  91284. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  91285. * @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)
  91286. * @param reserved Internal use only
  91287. */
  91288. function HDRCubeTextureAssetTask(
  91289. /**
  91290. * Defines the name of the task
  91291. */
  91292. name,
  91293. /**
  91294. * Defines the location of the file to load
  91295. */
  91296. url,
  91297. /**
  91298. * Defines the desired size (the more it increases the longer the generation will be)
  91299. */
  91300. size,
  91301. /**
  91302. * Defines if mipmaps should not be generated (default is false)
  91303. */
  91304. noMipmap,
  91305. /**
  91306. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  91307. */
  91308. generateHarmonics,
  91309. /**
  91310. * 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)
  91311. */
  91312. gammaSpace,
  91313. /**
  91314. * Internal Use Only
  91315. */
  91316. reserved) {
  91317. if (noMipmap === void 0) { noMipmap = false; }
  91318. if (generateHarmonics === void 0) { generateHarmonics = true; }
  91319. if (gammaSpace === void 0) { gammaSpace = false; }
  91320. if (reserved === void 0) { reserved = false; }
  91321. var _this = _super.call(this, name) || this;
  91322. _this.name = name;
  91323. _this.url = url;
  91324. _this.size = size;
  91325. _this.noMipmap = noMipmap;
  91326. _this.generateHarmonics = generateHarmonics;
  91327. _this.gammaSpace = gammaSpace;
  91328. _this.reserved = reserved;
  91329. return _this;
  91330. }
  91331. /**
  91332. * Execute the current task
  91333. * @param scene defines the scene where you want your assets to be loaded
  91334. * @param onSuccess is a callback called when the task is successfully executed
  91335. * @param onError is a callback called if an error occurs
  91336. */
  91337. HDRCubeTextureAssetTask.prototype.run = function (scene, onSuccess, onError) {
  91338. var onload = function () {
  91339. onSuccess();
  91340. };
  91341. var onerror = function (message, exception) {
  91342. onError(message, exception);
  91343. };
  91344. 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);
  91345. };
  91346. return HDRCubeTextureAssetTask;
  91347. }(AbstractAssetTask));
  91348. /**
  91349. * This class can be used to easily import assets into a scene
  91350. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  91351. */
  91352. var AssetsManager = /** @class */ (function () {
  91353. /**
  91354. * Creates a new AssetsManager
  91355. * @param scene defines the scene to work on
  91356. */
  91357. function AssetsManager(scene) {
  91358. this._isLoading = false;
  91359. this._tasks = new Array();
  91360. this._waitingTasksCount = 0;
  91361. this._totalTasksCount = 0;
  91362. /**
  91363. * Observable called when all tasks are processed
  91364. */
  91365. this.onTaskSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  91366. /**
  91367. * Observable called when a task had an error
  91368. */
  91369. this.onTaskErrorObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  91370. /**
  91371. * Observable called when a task is successful
  91372. */
  91373. this.onTasksDoneObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  91374. /**
  91375. * Observable called when a task is done (whatever the result is)
  91376. */
  91377. this.onProgressObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  91378. /**
  91379. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  91380. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91381. */
  91382. this.useDefaultLoadingScreen = true;
  91383. this._scene = scene;
  91384. }
  91385. /**
  91386. * Add a MeshAssetTask to the list of active tasks
  91387. * @param taskName defines the name of the new task
  91388. * @param meshesNames defines the name of meshes to load
  91389. * @param rootUrl defines the root url to use to locate files
  91390. * @param sceneFilename defines the filename of the scene file
  91391. * @returns a new MeshAssetTask object
  91392. */
  91393. AssetsManager.prototype.addMeshTask = function (taskName, meshesNames, rootUrl, sceneFilename) {
  91394. var task = new MeshAssetTask(taskName, meshesNames, rootUrl, sceneFilename);
  91395. this._tasks.push(task);
  91396. return task;
  91397. };
  91398. /**
  91399. * Add a TextFileAssetTask to the list of active tasks
  91400. * @param taskName defines the name of the new task
  91401. * @param url defines the url of the file to load
  91402. * @returns a new TextFileAssetTask object
  91403. */
  91404. AssetsManager.prototype.addTextFileTask = function (taskName, url) {
  91405. var task = new TextFileAssetTask(taskName, url);
  91406. this._tasks.push(task);
  91407. return task;
  91408. };
  91409. /**
  91410. * Add a BinaryFileAssetTask to the list of active tasks
  91411. * @param taskName defines the name of the new task
  91412. * @param url defines the url of the file to load
  91413. * @returns a new BinaryFileAssetTask object
  91414. */
  91415. AssetsManager.prototype.addBinaryFileTask = function (taskName, url) {
  91416. var task = new BinaryFileAssetTask(taskName, url);
  91417. this._tasks.push(task);
  91418. return task;
  91419. };
  91420. /**
  91421. * Add a ImageAssetTask to the list of active tasks
  91422. * @param taskName defines the name of the new task
  91423. * @param url defines the url of the file to load
  91424. * @returns a new ImageAssetTask object
  91425. */
  91426. AssetsManager.prototype.addImageTask = function (taskName, url) {
  91427. var task = new ImageAssetTask(taskName, url);
  91428. this._tasks.push(task);
  91429. return task;
  91430. };
  91431. /**
  91432. * Add a TextureAssetTask to the list of active tasks
  91433. * @param taskName defines the name of the new task
  91434. * @param url defines the url of the file to load
  91435. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  91436. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  91437. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  91438. * @returns a new TextureAssetTask object
  91439. */
  91440. AssetsManager.prototype.addTextureTask = function (taskName, url, noMipmap, invertY, samplingMode) {
  91441. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  91442. var task = new TextureAssetTask(taskName, url, noMipmap, invertY, samplingMode);
  91443. this._tasks.push(task);
  91444. return task;
  91445. };
  91446. /**
  91447. * Add a CubeTextureAssetTask to the list of active tasks
  91448. * @param taskName defines the name of the new task
  91449. * @param url defines the url of the file to load
  91450. * @param extensions defines the extension to use to load the cube map (can be null)
  91451. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  91452. * @param files defines the list of files to load (can be null)
  91453. * @returns a new CubeTextureAssetTask object
  91454. */
  91455. AssetsManager.prototype.addCubeTextureTask = function (taskName, url, extensions, noMipmap, files) {
  91456. var task = new CubeTextureAssetTask(taskName, url, extensions, noMipmap, files);
  91457. this._tasks.push(task);
  91458. return task;
  91459. };
  91460. /**
  91461. *
  91462. * Add a HDRCubeTextureAssetTask to the list of active tasks
  91463. * @param taskName defines the name of the new task
  91464. * @param url defines the url of the file to load
  91465. * @param size defines the size you want for the cubemap (can be null)
  91466. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  91467. * @param generateHarmonics defines if you want to automatically generate (true by default)
  91468. * @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)
  91469. * @param reserved Internal use only
  91470. * @returns a new HDRCubeTextureAssetTask object
  91471. */
  91472. AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
  91473. if (noMipmap === void 0) { noMipmap = false; }
  91474. if (generateHarmonics === void 0) { generateHarmonics = true; }
  91475. if (gammaSpace === void 0) { gammaSpace = false; }
  91476. if (reserved === void 0) { reserved = false; }
  91477. var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
  91478. this._tasks.push(task);
  91479. return task;
  91480. };
  91481. /**
  91482. * Remove a task from the assets manager.
  91483. * @param task the task to remove
  91484. */
  91485. AssetsManager.prototype.removeTask = function (task) {
  91486. var index = this._tasks.indexOf(task);
  91487. if (index > -1) {
  91488. this._tasks.splice(index, 1);
  91489. }
  91490. };
  91491. AssetsManager.prototype._decreaseWaitingTasksCount = function (task) {
  91492. this._waitingTasksCount--;
  91493. try {
  91494. if (this.onProgress) {
  91495. this.onProgress(this._waitingTasksCount, this._totalTasksCount, task);
  91496. }
  91497. this.onProgressObservable.notifyObservers(new AssetsProgressEvent(this._waitingTasksCount, this._totalTasksCount, task));
  91498. }
  91499. catch (e) {
  91500. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running progress callbacks.");
  91501. console.log(e);
  91502. }
  91503. if (this._waitingTasksCount === 0) {
  91504. try {
  91505. if (this.onFinish) {
  91506. this.onFinish(this._tasks);
  91507. }
  91508. // Let's remove successfull tasks
  91509. var currentTasks = this._tasks.slice();
  91510. for (var _i = 0, currentTasks_1 = currentTasks; _i < currentTasks_1.length; _i++) {
  91511. var task = currentTasks_1[_i];
  91512. if (task.taskState === AssetTaskState.DONE) {
  91513. var index = this._tasks.indexOf(task);
  91514. if (index > -1) {
  91515. this._tasks.splice(index, 1);
  91516. }
  91517. }
  91518. }
  91519. this.onTasksDoneObservable.notifyObservers(this._tasks);
  91520. }
  91521. catch (e) {
  91522. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running tasks-done callbacks.");
  91523. console.log(e);
  91524. }
  91525. this._isLoading = false;
  91526. this._scene.getEngine().hideLoadingUI();
  91527. }
  91528. };
  91529. AssetsManager.prototype._runTask = function (task) {
  91530. var _this = this;
  91531. var done = function () {
  91532. try {
  91533. if (_this.onTaskSuccess) {
  91534. _this.onTaskSuccess(task);
  91535. }
  91536. _this.onTaskSuccessObservable.notifyObservers(task);
  91537. _this._decreaseWaitingTasksCount(task);
  91538. }
  91539. catch (e) {
  91540. error("Error executing task success callbacks", e);
  91541. }
  91542. };
  91543. var error = function (message, exception) {
  91544. task._setErrorObject(message, exception);
  91545. if (_this.onTaskError) {
  91546. _this.onTaskError(task);
  91547. }
  91548. _this.onTaskErrorObservable.notifyObservers(task);
  91549. _this._decreaseWaitingTasksCount(task);
  91550. };
  91551. task.run(this._scene, done, error);
  91552. };
  91553. /**
  91554. * Reset the AssetsManager and remove all tasks
  91555. * @return the current instance of the AssetsManager
  91556. */
  91557. AssetsManager.prototype.reset = function () {
  91558. this._isLoading = false;
  91559. this._tasks = new Array();
  91560. return this;
  91561. };
  91562. /**
  91563. * Start the loading process
  91564. * @return the current instance of the AssetsManager
  91565. */
  91566. AssetsManager.prototype.load = function () {
  91567. if (this._isLoading) {
  91568. return this;
  91569. }
  91570. this._isLoading = true;
  91571. this._waitingTasksCount = this._tasks.length;
  91572. this._totalTasksCount = this._tasks.length;
  91573. if (this._waitingTasksCount === 0) {
  91574. this._isLoading = false;
  91575. if (this.onFinish) {
  91576. this.onFinish(this._tasks);
  91577. }
  91578. this.onTasksDoneObservable.notifyObservers(this._tasks);
  91579. return this;
  91580. }
  91581. if (this.useDefaultLoadingScreen) {
  91582. this._scene.getEngine().displayLoadingUI();
  91583. }
  91584. for (var index = 0; index < this._tasks.length; index++) {
  91585. var task = this._tasks[index];
  91586. if (task.taskState === AssetTaskState.INIT) {
  91587. this._runTask(task);
  91588. }
  91589. }
  91590. return this;
  91591. };
  91592. return AssetsManager;
  91593. }());
  91594. /***/ }),
  91595. /***/ "./Misc/dds.ts":
  91596. /*!*********************!*\
  91597. !*** ./Misc/dds.ts ***!
  91598. \*********************/
  91599. /*! exports provided: DDSTools */
  91600. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91601. "use strict";
  91602. __webpack_require__.r(__webpack_exports__);
  91603. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return DDSTools; });
  91604. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  91605. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  91606. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  91607. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  91608. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  91609. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  91610. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  91611. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  91612. // Based on demo done by Brandon Jones - http://media.tojicode.com/webgl-samples/dds.html
  91613. // All values and structures referenced from:
  91614. // http://msdn.microsoft.com/en-us/library/bb943991.aspx/
  91615. var DDS_MAGIC = 0x20534444;
  91616. var
  91617. //DDSD_CAPS = 0x1,
  91618. //DDSD_HEIGHT = 0x2,
  91619. //DDSD_WIDTH = 0x4,
  91620. //DDSD_PITCH = 0x8,
  91621. //DDSD_PIXELFORMAT = 0x1000,
  91622. DDSD_MIPMAPCOUNT = 0x20000;
  91623. //DDSD_LINEARSIZE = 0x80000,
  91624. //DDSD_DEPTH = 0x800000;
  91625. // var DDSCAPS_COMPLEX = 0x8,
  91626. // DDSCAPS_MIPMAP = 0x400000,
  91627. // DDSCAPS_TEXTURE = 0x1000;
  91628. var DDSCAPS2_CUBEMAP = 0x200;
  91629. // DDSCAPS2_CUBEMAP_POSITIVEX = 0x400,
  91630. // DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800,
  91631. // DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000,
  91632. // DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000,
  91633. // DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000,
  91634. // DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000,
  91635. // DDSCAPS2_VOLUME = 0x200000;
  91636. var
  91637. //DDPF_ALPHAPIXELS = 0x1,
  91638. //DDPF_ALPHA = 0x2,
  91639. DDPF_FOURCC = 0x4, DDPF_RGB = 0x40,
  91640. //DDPF_YUV = 0x200,
  91641. DDPF_LUMINANCE = 0x20000;
  91642. function FourCCToInt32(value) {
  91643. return value.charCodeAt(0) +
  91644. (value.charCodeAt(1) << 8) +
  91645. (value.charCodeAt(2) << 16) +
  91646. (value.charCodeAt(3) << 24);
  91647. }
  91648. function Int32ToFourCC(value) {
  91649. return String.fromCharCode(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff);
  91650. }
  91651. var FOURCC_DXT1 = FourCCToInt32("DXT1");
  91652. var FOURCC_DXT3 = FourCCToInt32("DXT3");
  91653. var FOURCC_DXT5 = FourCCToInt32("DXT5");
  91654. var FOURCC_DX10 = FourCCToInt32("DX10");
  91655. var FOURCC_D3DFMT_R16G16B16A16F = 113;
  91656. var FOURCC_D3DFMT_R32G32B32A32F = 116;
  91657. var DXGI_FORMAT_R16G16B16A16_FLOAT = 10;
  91658. var DXGI_FORMAT_B8G8R8X8_UNORM = 88;
  91659. var headerLengthInt = 31; // The header length in 32 bit ints
  91660. // Offsets into the header array
  91661. var off_magic = 0;
  91662. var off_size = 1;
  91663. var off_flags = 2;
  91664. var off_height = 3;
  91665. var off_width = 4;
  91666. var off_mipmapCount = 7;
  91667. var off_pfFlags = 20;
  91668. var off_pfFourCC = 21;
  91669. var off_RGBbpp = 22;
  91670. var off_RMask = 23;
  91671. var off_GMask = 24;
  91672. var off_BMask = 25;
  91673. var off_AMask = 26;
  91674. // var off_caps1 = 27;
  91675. var off_caps2 = 28;
  91676. // var off_caps3 = 29;
  91677. // var off_caps4 = 30;
  91678. var off_dxgiFormat = 32;
  91679. /**
  91680. * Class used to provide DDS decompression tools
  91681. */
  91682. var DDSTools = /** @class */ (function () {
  91683. function DDSTools() {
  91684. }
  91685. /**
  91686. * Gets DDS information from an array buffer
  91687. * @param arrayBuffer defines the array buffer to read data from
  91688. * @returns the DDS information
  91689. */
  91690. DDSTools.GetDDSInfo = function (arrayBuffer) {
  91691. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  91692. var extendedHeader = new Int32Array(arrayBuffer, 0, headerLengthInt + 4);
  91693. var mipmapCount = 1;
  91694. if (header[off_flags] & DDSD_MIPMAPCOUNT) {
  91695. mipmapCount = Math.max(1, header[off_mipmapCount]);
  91696. }
  91697. var fourCC = header[off_pfFourCC];
  91698. var dxgiFormat = (fourCC === FOURCC_DX10) ? extendedHeader[off_dxgiFormat] : 0;
  91699. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  91700. switch (fourCC) {
  91701. case FOURCC_D3DFMT_R16G16B16A16F:
  91702. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  91703. break;
  91704. case FOURCC_D3DFMT_R32G32B32A32F:
  91705. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  91706. break;
  91707. case FOURCC_DX10:
  91708. if (dxgiFormat === DXGI_FORMAT_R16G16B16A16_FLOAT) {
  91709. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  91710. break;
  91711. }
  91712. }
  91713. return {
  91714. width: header[off_width],
  91715. height: header[off_height],
  91716. mipmapCount: mipmapCount,
  91717. isFourCC: (header[off_pfFlags] & DDPF_FOURCC) === DDPF_FOURCC,
  91718. isRGB: (header[off_pfFlags] & DDPF_RGB) === DDPF_RGB,
  91719. isLuminance: (header[off_pfFlags] & DDPF_LUMINANCE) === DDPF_LUMINANCE,
  91720. isCube: (header[off_caps2] & DDSCAPS2_CUBEMAP) === DDSCAPS2_CUBEMAP,
  91721. isCompressed: (fourCC === FOURCC_DXT1 || fourCC === FOURCC_DXT3 || fourCC === FOURCC_DXT5),
  91722. dxgiFormat: dxgiFormat,
  91723. textureType: textureType
  91724. };
  91725. };
  91726. DDSTools._ToHalfFloat = function (value) {
  91727. if (!DDSTools._FloatView) {
  91728. DDSTools._FloatView = new Float32Array(1);
  91729. DDSTools._Int32View = new Int32Array(DDSTools._FloatView.buffer);
  91730. }
  91731. DDSTools._FloatView[0] = value;
  91732. var x = DDSTools._Int32View[0];
  91733. var bits = (x >> 16) & 0x8000; /* Get the sign */
  91734. var m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */
  91735. var e = (x >> 23) & 0xff; /* Using int is faster here */
  91736. /* If zero, or denormal, or exponent underflows too much for a denormal
  91737. * half, return signed zero. */
  91738. if (e < 103) {
  91739. return bits;
  91740. }
  91741. /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */
  91742. if (e > 142) {
  91743. bits |= 0x7c00;
  91744. /* If exponent was 0xff and one mantissa bit was set, it means NaN,
  91745. * not Inf, so make sure we set one mantissa bit too. */
  91746. bits |= ((e == 255) ? 0 : 1) && (x & 0x007fffff);
  91747. return bits;
  91748. }
  91749. /* If exponent underflows but not too much, return a denormal */
  91750. if (e < 113) {
  91751. m |= 0x0800;
  91752. /* Extra rounding may overflow and set mantissa to 0 and exponent
  91753. * to 1, which is OK. */
  91754. bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);
  91755. return bits;
  91756. }
  91757. bits |= ((e - 112) << 10) | (m >> 1);
  91758. bits += m & 1;
  91759. return bits;
  91760. };
  91761. DDSTools._FromHalfFloat = function (value) {
  91762. var s = (value & 0x8000) >> 15;
  91763. var e = (value & 0x7C00) >> 10;
  91764. var f = value & 0x03FF;
  91765. if (e === 0) {
  91766. return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));
  91767. }
  91768. else if (e == 0x1F) {
  91769. return f ? NaN : ((s ? -1 : 1) * Infinity);
  91770. }
  91771. return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + (f / Math.pow(2, 10)));
  91772. };
  91773. DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  91774. var destArray = new Float32Array(dataLength);
  91775. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  91776. var index = 0;
  91777. for (var y = 0; y < height; y++) {
  91778. for (var x = 0; x < width; x++) {
  91779. var srcPos = (x + y * width) * 4;
  91780. destArray[index] = DDSTools._FromHalfFloat(srcData[srcPos]);
  91781. destArray[index + 1] = DDSTools._FromHalfFloat(srcData[srcPos + 1]);
  91782. destArray[index + 2] = DDSTools._FromHalfFloat(srcData[srcPos + 2]);
  91783. if (DDSTools.StoreLODInAlphaChannel) {
  91784. destArray[index + 3] = lod;
  91785. }
  91786. else {
  91787. destArray[index + 3] = DDSTools._FromHalfFloat(srcData[srcPos + 3]);
  91788. }
  91789. index += 4;
  91790. }
  91791. }
  91792. return destArray;
  91793. };
  91794. DDSTools._GetHalfFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  91795. if (DDSTools.StoreLODInAlphaChannel) {
  91796. var destArray = new Uint16Array(dataLength);
  91797. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  91798. var index = 0;
  91799. for (var y = 0; y < height; y++) {
  91800. for (var x = 0; x < width; x++) {
  91801. var srcPos = (x + y * width) * 4;
  91802. destArray[index] = srcData[srcPos];
  91803. destArray[index + 1] = srcData[srcPos + 1];
  91804. destArray[index + 2] = srcData[srcPos + 2];
  91805. destArray[index + 3] = DDSTools._ToHalfFloat(lod);
  91806. index += 4;
  91807. }
  91808. }
  91809. return destArray;
  91810. }
  91811. return new Uint16Array(arrayBuffer, dataOffset, dataLength);
  91812. };
  91813. DDSTools._GetFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  91814. if (DDSTools.StoreLODInAlphaChannel) {
  91815. var destArray = new Float32Array(dataLength);
  91816. var srcData = new Float32Array(arrayBuffer, dataOffset);
  91817. var index = 0;
  91818. for (var y = 0; y < height; y++) {
  91819. for (var x = 0; x < width; x++) {
  91820. var srcPos = (x + y * width) * 4;
  91821. destArray[index] = srcData[srcPos];
  91822. destArray[index + 1] = srcData[srcPos + 1];
  91823. destArray[index + 2] = srcData[srcPos + 2];
  91824. destArray[index + 3] = lod;
  91825. index += 4;
  91826. }
  91827. }
  91828. return destArray;
  91829. }
  91830. return new Float32Array(arrayBuffer, dataOffset, dataLength);
  91831. };
  91832. DDSTools._GetFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  91833. var destArray = new Uint8Array(dataLength);
  91834. var srcData = new Float32Array(arrayBuffer, dataOffset);
  91835. var index = 0;
  91836. for (var y = 0; y < height; y++) {
  91837. for (var x = 0; x < width; x++) {
  91838. var srcPos = (x + y * width) * 4;
  91839. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos]) * 255;
  91840. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 1]) * 255;
  91841. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 2]) * 255;
  91842. if (DDSTools.StoreLODInAlphaChannel) {
  91843. destArray[index + 3] = lod;
  91844. }
  91845. else {
  91846. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 3]) * 255;
  91847. }
  91848. index += 4;
  91849. }
  91850. }
  91851. return destArray;
  91852. };
  91853. DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  91854. var destArray = new Uint8Array(dataLength);
  91855. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  91856. var index = 0;
  91857. for (var y = 0; y < height; y++) {
  91858. for (var x = 0; x < width; x++) {
  91859. var srcPos = (x + y * width) * 4;
  91860. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos])) * 255;
  91861. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 1])) * 255;
  91862. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 2])) * 255;
  91863. if (DDSTools.StoreLODInAlphaChannel) {
  91864. destArray[index + 3] = lod;
  91865. }
  91866. else {
  91867. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 3])) * 255;
  91868. }
  91869. index += 4;
  91870. }
  91871. }
  91872. return destArray;
  91873. };
  91874. DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
  91875. var byteArray = new Uint8Array(dataLength);
  91876. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  91877. var index = 0;
  91878. for (var y = 0; y < height; y++) {
  91879. for (var x = 0; x < width; x++) {
  91880. var srcPos = (x + y * width) * 4;
  91881. byteArray[index] = srcData[srcPos + rOffset];
  91882. byteArray[index + 1] = srcData[srcPos + gOffset];
  91883. byteArray[index + 2] = srcData[srcPos + bOffset];
  91884. byteArray[index + 3] = srcData[srcPos + aOffset];
  91885. index += 4;
  91886. }
  91887. }
  91888. return byteArray;
  91889. };
  91890. DDSTools._ExtractLongWordOrder = function (value) {
  91891. if (value === 0 || value === 255 || value === -16777216) {
  91892. return 0;
  91893. }
  91894. return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
  91895. };
  91896. DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
  91897. var byteArray = new Uint8Array(dataLength);
  91898. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  91899. var index = 0;
  91900. for (var y = 0; y < height; y++) {
  91901. for (var x = 0; x < width; x++) {
  91902. var srcPos = (x + y * width) * 3;
  91903. byteArray[index] = srcData[srcPos + rOffset];
  91904. byteArray[index + 1] = srcData[srcPos + gOffset];
  91905. byteArray[index + 2] = srcData[srcPos + bOffset];
  91906. index += 3;
  91907. }
  91908. }
  91909. return byteArray;
  91910. };
  91911. DDSTools._GetLuminanceArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
  91912. var byteArray = new Uint8Array(dataLength);
  91913. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  91914. var index = 0;
  91915. for (var y = 0; y < height; y++) {
  91916. for (var x = 0; x < width; x++) {
  91917. var srcPos = (x + y * width);
  91918. byteArray[index] = srcData[srcPos];
  91919. index++;
  91920. }
  91921. }
  91922. return byteArray;
  91923. };
  91924. /**
  91925. * Uploads DDS Levels to a Babylon Texture
  91926. * @hidden
  91927. */
  91928. DDSTools.UploadDDSLevels = function (engine, texture, arrayBuffer, info, loadMipmaps, faces, lodIndex, currentFace) {
  91929. if (lodIndex === void 0) { lodIndex = -1; }
  91930. var sphericalPolynomialFaces = null;
  91931. if (info.sphericalPolynomial) {
  91932. sphericalPolynomialFaces = new Array();
  91933. }
  91934. var ext = engine.getCaps().s3tc;
  91935. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  91936. var fourCC, width, height, dataLength = 0, dataOffset;
  91937. var byteArray, mipmapCount, mip;
  91938. var internalCompressedFormat = 0;
  91939. var blockBytes = 1;
  91940. if (header[off_magic] !== DDS_MAGIC) {
  91941. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Invalid magic number in DDS header");
  91942. return;
  91943. }
  91944. if (!info.isFourCC && !info.isRGB && !info.isLuminance) {
  91945. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
  91946. return;
  91947. }
  91948. if (info.isCompressed && !ext) {
  91949. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Compressed textures are not supported on this platform.");
  91950. return;
  91951. }
  91952. var bpp = header[off_RGBbpp];
  91953. dataOffset = header[off_size] + 4;
  91954. var computeFormats = false;
  91955. if (info.isFourCC) {
  91956. fourCC = header[off_pfFourCC];
  91957. switch (fourCC) {
  91958. case FOURCC_DXT1:
  91959. blockBytes = 8;
  91960. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT1_EXT;
  91961. break;
  91962. case FOURCC_DXT3:
  91963. blockBytes = 16;
  91964. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT3_EXT;
  91965. break;
  91966. case FOURCC_DXT5:
  91967. blockBytes = 16;
  91968. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT5_EXT;
  91969. break;
  91970. case FOURCC_D3DFMT_R16G16B16A16F:
  91971. computeFormats = true;
  91972. break;
  91973. case FOURCC_D3DFMT_R32G32B32A32F:
  91974. computeFormats = true;
  91975. break;
  91976. case FOURCC_DX10:
  91977. // There is an additionnal header so dataOffset need to be changed
  91978. dataOffset += 5 * 4; // 5 uints
  91979. var supported = false;
  91980. switch (info.dxgiFormat) {
  91981. case DXGI_FORMAT_R16G16B16A16_FLOAT:
  91982. computeFormats = true;
  91983. supported = true;
  91984. break;
  91985. case DXGI_FORMAT_B8G8R8X8_UNORM:
  91986. info.isRGB = true;
  91987. info.isFourCC = false;
  91988. bpp = 32;
  91989. supported = true;
  91990. break;
  91991. }
  91992. if (supported) {
  91993. break;
  91994. }
  91995. default:
  91996. console.error("Unsupported FourCC code:", Int32ToFourCC(fourCC));
  91997. return;
  91998. }
  91999. }
  92000. var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
  92001. var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
  92002. var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
  92003. var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
  92004. if (computeFormats) {
  92005. internalCompressedFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
  92006. }
  92007. mipmapCount = 1;
  92008. if (header[off_flags] & DDSD_MIPMAPCOUNT && loadMipmaps !== false) {
  92009. mipmapCount = Math.max(1, header[off_mipmapCount]);
  92010. }
  92011. for (var face = 0; face < faces; face++) {
  92012. width = header[off_width];
  92013. height = header[off_height];
  92014. for (mip = 0; mip < mipmapCount; ++mip) {
  92015. if (lodIndex === -1 || lodIndex === mip) {
  92016. // In case of fixed LOD, if the lod has just been uploaded, early exit.
  92017. var i = (lodIndex === -1) ? mip : 0;
  92018. if (!info.isCompressed && info.isFourCC) {
  92019. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  92020. dataLength = width * height * 4;
  92021. var floatArray = null;
  92022. if (engine._badOS || engine._badDesktopOS || (!engine.getCaps().textureHalfFloat && !engine.getCaps().textureFloat)) { // Required because iOS has many issues with float and half float generation
  92023. if (bpp === 128) {
  92024. floatArray = DDSTools._GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  92025. if (sphericalPolynomialFaces && i == 0) {
  92026. sphericalPolynomialFaces.push(DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  92027. }
  92028. }
  92029. else if (bpp === 64) {
  92030. floatArray = DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  92031. if (sphericalPolynomialFaces && i == 0) {
  92032. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  92033. }
  92034. }
  92035. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  92036. }
  92037. else {
  92038. if (bpp === 128) {
  92039. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  92040. floatArray = DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  92041. if (sphericalPolynomialFaces && i == 0) {
  92042. sphericalPolynomialFaces.push(floatArray);
  92043. }
  92044. }
  92045. else if (bpp === 64 && !engine.getCaps().textureHalfFloat) {
  92046. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  92047. floatArray = DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  92048. if (sphericalPolynomialFaces && i == 0) {
  92049. sphericalPolynomialFaces.push(floatArray);
  92050. }
  92051. }
  92052. else { // 64
  92053. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  92054. floatArray = DDSTools._GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  92055. if (sphericalPolynomialFaces && i == 0) {
  92056. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  92057. }
  92058. }
  92059. }
  92060. if (floatArray) {
  92061. engine._uploadDataToTextureDirectly(texture, floatArray, face, i);
  92062. }
  92063. }
  92064. else if (info.isRGB) {
  92065. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  92066. if (bpp === 24) {
  92067. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB;
  92068. dataLength = width * height * 3;
  92069. byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  92070. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  92071. }
  92072. else { // 32
  92073. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  92074. dataLength = width * height * 4;
  92075. byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  92076. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  92077. }
  92078. }
  92079. else if (info.isLuminance) {
  92080. var unpackAlignment = engine._getUnpackAlignement();
  92081. var unpaddedRowSize = width;
  92082. var paddedRowSize = Math.floor((width + unpackAlignment - 1) / unpackAlignment) * unpackAlignment;
  92083. dataLength = paddedRowSize * (height - 1) + unpaddedRowSize;
  92084. byteArray = DDSTools._GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  92085. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE;
  92086. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  92087. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  92088. }
  92089. else {
  92090. dataLength = Math.max(4, width) / 4 * Math.max(4, height) / 4 * blockBytes;
  92091. byteArray = new Uint8Array(arrayBuffer, dataOffset, dataLength);
  92092. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  92093. engine._uploadCompressedDataToTextureDirectly(texture, internalCompressedFormat, width, height, byteArray, face, i);
  92094. }
  92095. }
  92096. dataOffset += bpp ? (width * height * (bpp / 8)) : dataLength;
  92097. width *= 0.5;
  92098. height *= 0.5;
  92099. width = Math.max(1.0, width);
  92100. height = Math.max(1.0, height);
  92101. }
  92102. if (currentFace !== undefined) {
  92103. // Loading a single face
  92104. break;
  92105. }
  92106. }
  92107. if (sphericalPolynomialFaces && sphericalPolynomialFaces.length > 0) {
  92108. info.sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial({
  92109. size: header[off_width],
  92110. right: sphericalPolynomialFaces[0],
  92111. left: sphericalPolynomialFaces[1],
  92112. up: sphericalPolynomialFaces[2],
  92113. down: sphericalPolynomialFaces[3],
  92114. front: sphericalPolynomialFaces[4],
  92115. back: sphericalPolynomialFaces[5],
  92116. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA,
  92117. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT,
  92118. gammaSpace: false,
  92119. });
  92120. }
  92121. else {
  92122. info.sphericalPolynomial = undefined;
  92123. }
  92124. };
  92125. /**
  92126. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  92127. */
  92128. DDSTools.StoreLODInAlphaChannel = false;
  92129. return DDSTools;
  92130. }());
  92131. /**
  92132. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  92133. * @param rootUrl defines the url where the file to load is located
  92134. * @param scene defines the current scene
  92135. * @param lodScale defines scale to apply to the mip map selection
  92136. * @param lodOffset defines offset to apply to the mip map selection
  92137. * @param onLoad defines an optional callback raised when the texture is loaded
  92138. * @param onError defines an optional callback raised if there is an issue to load the texture
  92139. * @param format defines the format of the data
  92140. * @param forcedExtension defines the extension to use to pick the right loader
  92141. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  92142. * @returns the cube texture as an InternalTexture
  92143. */
  92144. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createPrefilteredCubeTexture = function (rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, createPolynomials) {
  92145. var _this = this;
  92146. if (onLoad === void 0) { onLoad = null; }
  92147. if (onError === void 0) { onError = null; }
  92148. if (forcedExtension === void 0) { forcedExtension = null; }
  92149. if (createPolynomials === void 0) { createPolynomials = true; }
  92150. var callback = function (loadData) {
  92151. if (!loadData) {
  92152. if (onLoad) {
  92153. onLoad(null);
  92154. }
  92155. return;
  92156. }
  92157. var texture = loadData.texture;
  92158. if (!createPolynomials) {
  92159. texture._sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__["SphericalPolynomial"]();
  92160. }
  92161. else if (loadData.info.sphericalPolynomial) {
  92162. texture._sphericalPolynomial = loadData.info.sphericalPolynomial;
  92163. }
  92164. texture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBEPREFILTERED;
  92165. if (_this.getCaps().textureLOD) {
  92166. // Do not add extra process if texture lod is supported.
  92167. if (onLoad) {
  92168. onLoad(texture);
  92169. }
  92170. return;
  92171. }
  92172. var mipSlices = 3;
  92173. var gl = _this._gl;
  92174. var width = loadData.width;
  92175. if (!width) {
  92176. return;
  92177. }
  92178. var textures = [];
  92179. for (var i = 0; i < mipSlices; i++) {
  92180. //compute LOD from even spacing in smoothness (matching shader calculation)
  92181. var smoothness = i / (mipSlices - 1);
  92182. var roughness = 1 - smoothness;
  92183. var minLODIndex = lodOffset; // roughness = 0
  92184. var maxLODIndex = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) * lodScale + lodOffset; // roughness = 1
  92185. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  92186. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  92187. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  92188. glTextureFromLod.type = texture.type;
  92189. glTextureFromLod.format = texture.format;
  92190. glTextureFromLod.width = Math.pow(2, Math.max(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) - mipmapIndex, 0));
  92191. glTextureFromLod.height = glTextureFromLod.width;
  92192. glTextureFromLod.isCube = true;
  92193. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, glTextureFromLod, true);
  92194. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  92195. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  92196. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  92197. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  92198. if (loadData.isDDS) {
  92199. var info = loadData.info;
  92200. var data = loadData.data;
  92201. _this._unpackFlipY(info.isCompressed);
  92202. DDSTools.UploadDDSLevels(_this, glTextureFromLod, data, info, true, 6, mipmapIndex);
  92203. }
  92204. else {
  92205. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("DDS is the only prefiltered cube map supported so far.");
  92206. }
  92207. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  92208. // Wrap in a base texture for easy binding.
  92209. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__["BaseTexture"](scene);
  92210. lodTexture.isCube = true;
  92211. lodTexture._texture = glTextureFromLod;
  92212. glTextureFromLod.isReady = true;
  92213. textures.push(lodTexture);
  92214. }
  92215. texture._lodTextureHigh = textures[2];
  92216. texture._lodTextureMid = textures[1];
  92217. texture._lodTextureLow = textures[0];
  92218. if (onLoad) {
  92219. onLoad(texture);
  92220. }
  92221. };
  92222. return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset);
  92223. };
  92224. /***/ }),
  92225. /***/ "./Misc/decorators.ts":
  92226. /*!****************************!*\
  92227. !*** ./Misc/decorators.ts ***!
  92228. \****************************/
  92229. /*! exports provided: expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper */
  92230. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92231. "use strict";
  92232. __webpack_require__.r(__webpack_exports__);
  92233. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return expandToProperty; });
  92234. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return serialize; });
  92235. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return serializeAsTexture; });
  92236. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return serializeAsColor3; });
  92237. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return serializeAsFresnelParameters; });
  92238. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return serializeAsVector2; });
  92239. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return serializeAsVector3; });
  92240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return serializeAsMeshReference; });
  92241. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return serializeAsColorCurves; });
  92242. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return serializeAsColor4; });
  92243. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return serializeAsImageProcessingConfiguration; });
  92244. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return serializeAsQuaternion; });
  92245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return serializeAsCameraReference; });
  92246. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return SerializationHelper; });
  92247. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  92248. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  92249. var __decoratorInitialStore = {};
  92250. var __mergedStore = {};
  92251. var _copySource = function (creationFunction, source, instanciate) {
  92252. var destination = creationFunction();
  92253. // Tags
  92254. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  92255. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  92256. }
  92257. var classStore = getMergedStore(destination);
  92258. // Properties
  92259. for (var property in classStore) {
  92260. var propertyDescriptor = classStore[property];
  92261. var sourceProperty = source[property];
  92262. var propertyType = propertyDescriptor.type;
  92263. if (sourceProperty !== undefined && sourceProperty !== null) {
  92264. switch (propertyType) {
  92265. case 0: // Value
  92266. case 6: // Mesh reference
  92267. case 11: // Camera reference
  92268. destination[property] = sourceProperty;
  92269. break;
  92270. case 1: // Texture
  92271. destination[property] = (instanciate || sourceProperty.isRenderTarget) ? sourceProperty : sourceProperty.clone();
  92272. break;
  92273. case 2: // Color3
  92274. case 3: // FresnelParameters
  92275. case 4: // Vector2
  92276. case 5: // Vector3
  92277. case 7: // Color Curves
  92278. case 10: // Quaternion
  92279. destination[property] = instanciate ? sourceProperty : sourceProperty.clone();
  92280. break;
  92281. }
  92282. }
  92283. }
  92284. return destination;
  92285. };
  92286. function getDirectStore(target) {
  92287. var classKey = target.getClassName();
  92288. if (!__decoratorInitialStore[classKey]) {
  92289. __decoratorInitialStore[classKey] = {};
  92290. }
  92291. return __decoratorInitialStore[classKey];
  92292. }
  92293. /**
  92294. * Return the list of properties flagged as serializable
  92295. * @param target: host object
  92296. */
  92297. function getMergedStore(target) {
  92298. var classKey = target.getClassName();
  92299. if (__mergedStore[classKey]) {
  92300. return __mergedStore[classKey];
  92301. }
  92302. __mergedStore[classKey] = {};
  92303. var store = __mergedStore[classKey];
  92304. var currentTarget = target;
  92305. var currentKey = classKey;
  92306. while (currentKey) {
  92307. var initialStore = __decoratorInitialStore[currentKey];
  92308. for (var property in initialStore) {
  92309. store[property] = initialStore[property];
  92310. }
  92311. var parent_1 = void 0;
  92312. var done = false;
  92313. do {
  92314. parent_1 = Object.getPrototypeOf(currentTarget);
  92315. if (!parent_1.getClassName) {
  92316. done = true;
  92317. break;
  92318. }
  92319. if (parent_1.getClassName() !== currentKey) {
  92320. break;
  92321. }
  92322. currentTarget = parent_1;
  92323. } while (parent_1);
  92324. if (done) {
  92325. break;
  92326. }
  92327. currentKey = parent_1.getClassName();
  92328. currentTarget = parent_1;
  92329. }
  92330. return store;
  92331. }
  92332. function generateSerializableMember(type, sourceName) {
  92333. return function (target, propertyKey) {
  92334. var classStore = getDirectStore(target);
  92335. if (!classStore[propertyKey]) {
  92336. classStore[propertyKey] = { type: type, sourceName: sourceName };
  92337. }
  92338. };
  92339. }
  92340. function generateExpandMember(setCallback, targetKey) {
  92341. if (targetKey === void 0) { targetKey = null; }
  92342. return function (target, propertyKey) {
  92343. var key = targetKey || ("_" + propertyKey);
  92344. Object.defineProperty(target, propertyKey, {
  92345. get: function () {
  92346. return this[key];
  92347. },
  92348. set: function (value) {
  92349. if (this[key] === value) {
  92350. return;
  92351. }
  92352. this[key] = value;
  92353. target[setCallback].apply(this);
  92354. },
  92355. enumerable: true,
  92356. configurable: true
  92357. });
  92358. };
  92359. }
  92360. function expandToProperty(callback, targetKey) {
  92361. if (targetKey === void 0) { targetKey = null; }
  92362. return generateExpandMember(callback, targetKey);
  92363. }
  92364. function serialize(sourceName) {
  92365. return generateSerializableMember(0, sourceName); // value member
  92366. }
  92367. function serializeAsTexture(sourceName) {
  92368. return generateSerializableMember(1, sourceName); // texture member
  92369. }
  92370. function serializeAsColor3(sourceName) {
  92371. return generateSerializableMember(2, sourceName); // color3 member
  92372. }
  92373. function serializeAsFresnelParameters(sourceName) {
  92374. return generateSerializableMember(3, sourceName); // fresnel parameters member
  92375. }
  92376. function serializeAsVector2(sourceName) {
  92377. return generateSerializableMember(4, sourceName); // vector2 member
  92378. }
  92379. function serializeAsVector3(sourceName) {
  92380. return generateSerializableMember(5, sourceName); // vector3 member
  92381. }
  92382. function serializeAsMeshReference(sourceName) {
  92383. return generateSerializableMember(6, sourceName); // mesh reference member
  92384. }
  92385. function serializeAsColorCurves(sourceName) {
  92386. return generateSerializableMember(7, sourceName); // color curves
  92387. }
  92388. function serializeAsColor4(sourceName) {
  92389. return generateSerializableMember(8, sourceName); // color 4
  92390. }
  92391. function serializeAsImageProcessingConfiguration(sourceName) {
  92392. return generateSerializableMember(9, sourceName); // image processing
  92393. }
  92394. function serializeAsQuaternion(sourceName) {
  92395. return generateSerializableMember(10, sourceName); // quaternion member
  92396. }
  92397. /**
  92398. * Decorator used to define property that can be serialized as reference to a camera
  92399. * @param sourceName defines the name of the property to decorate
  92400. */
  92401. function serializeAsCameraReference(sourceName) {
  92402. return generateSerializableMember(11, sourceName); // camera reference member
  92403. }
  92404. /**
  92405. * Class used to help serialization objects
  92406. */
  92407. var SerializationHelper = /** @class */ (function () {
  92408. function SerializationHelper() {
  92409. }
  92410. /**
  92411. * Appends the serialized animations from the source animations
  92412. * @param source Source containing the animations
  92413. * @param destination Target to store the animations
  92414. */
  92415. SerializationHelper.AppendSerializedAnimations = function (source, destination) {
  92416. if (source.animations) {
  92417. destination.animations = [];
  92418. for (var animationIndex = 0; animationIndex < source.animations.length; animationIndex++) {
  92419. var animation = source.animations[animationIndex];
  92420. destination.animations.push(animation.serialize());
  92421. }
  92422. }
  92423. };
  92424. /**
  92425. * Static function used to serialized a specific entity
  92426. * @param entity defines the entity to serialize
  92427. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  92428. * @returns a JSON compatible object representing the serialization of the entity
  92429. */
  92430. SerializationHelper.Serialize = function (entity, serializationObject) {
  92431. if (!serializationObject) {
  92432. serializationObject = {};
  92433. }
  92434. // Tags
  92435. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  92436. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].GetTags(entity);
  92437. }
  92438. var serializedProperties = getMergedStore(entity);
  92439. // Properties
  92440. for (var property in serializedProperties) {
  92441. var propertyDescriptor = serializedProperties[property];
  92442. var targetPropertyName = propertyDescriptor.sourceName || property;
  92443. var propertyType = propertyDescriptor.type;
  92444. var sourceProperty = entity[property];
  92445. if (sourceProperty !== undefined && sourceProperty !== null) {
  92446. switch (propertyType) {
  92447. case 0: // Value
  92448. serializationObject[targetPropertyName] = sourceProperty;
  92449. break;
  92450. case 1: // Texture
  92451. serializationObject[targetPropertyName] = sourceProperty.serialize();
  92452. break;
  92453. case 2: // Color3
  92454. serializationObject[targetPropertyName] = sourceProperty.asArray();
  92455. break;
  92456. case 3: // FresnelParameters
  92457. serializationObject[targetPropertyName] = sourceProperty.serialize();
  92458. break;
  92459. case 4: // Vector2
  92460. serializationObject[targetPropertyName] = sourceProperty.asArray();
  92461. break;
  92462. case 5: // Vector3
  92463. serializationObject[targetPropertyName] = sourceProperty.asArray();
  92464. break;
  92465. case 6: // Mesh reference
  92466. serializationObject[targetPropertyName] = sourceProperty.id;
  92467. break;
  92468. case 7: // Color Curves
  92469. serializationObject[targetPropertyName] = sourceProperty.serialize();
  92470. break;
  92471. case 8: // Color 4
  92472. serializationObject[targetPropertyName] = sourceProperty.asArray();
  92473. break;
  92474. case 9: // Image Processing
  92475. serializationObject[targetPropertyName] = sourceProperty.serialize();
  92476. break;
  92477. case 10: // Quaternion
  92478. serializationObject[targetPropertyName] = sourceProperty.asArray();
  92479. break;
  92480. case 11: // Camera reference
  92481. serializationObject[targetPropertyName] = sourceProperty.id;
  92482. break;
  92483. }
  92484. }
  92485. }
  92486. return serializationObject;
  92487. };
  92488. /**
  92489. * Creates a new entity from a serialization data object
  92490. * @param creationFunction defines a function used to instanciated the new entity
  92491. * @param source defines the source serialization data
  92492. * @param scene defines the hosting scene
  92493. * @param rootUrl defines the root url for resources
  92494. * @returns a new entity
  92495. */
  92496. SerializationHelper.Parse = function (creationFunction, source, scene, rootUrl) {
  92497. if (rootUrl === void 0) { rootUrl = null; }
  92498. var destination = creationFunction();
  92499. if (!rootUrl) {
  92500. rootUrl = "";
  92501. }
  92502. // Tags
  92503. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  92504. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  92505. }
  92506. var classStore = getMergedStore(destination);
  92507. // Properties
  92508. for (var property in classStore) {
  92509. var propertyDescriptor = classStore[property];
  92510. var sourceProperty = source[propertyDescriptor.sourceName || property];
  92511. var propertyType = propertyDescriptor.type;
  92512. if (sourceProperty !== undefined && sourceProperty !== null) {
  92513. var dest = destination;
  92514. switch (propertyType) {
  92515. case 0: // Value
  92516. dest[property] = sourceProperty;
  92517. break;
  92518. case 1: // Texture
  92519. if (scene) {
  92520. dest[property] = SerializationHelper._TextureParser(sourceProperty, scene, rootUrl);
  92521. }
  92522. break;
  92523. case 2: // Color3
  92524. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(sourceProperty);
  92525. break;
  92526. case 3: // FresnelParameters
  92527. dest[property] = SerializationHelper._FresnelParametersParser(sourceProperty);
  92528. break;
  92529. case 4: // Vector2
  92530. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"].FromArray(sourceProperty);
  92531. break;
  92532. case 5: // Vector3
  92533. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(sourceProperty);
  92534. break;
  92535. case 6: // Mesh reference
  92536. if (scene) {
  92537. dest[property] = scene.getLastMeshByID(sourceProperty);
  92538. }
  92539. break;
  92540. case 7: // Color Curves
  92541. dest[property] = SerializationHelper._ColorCurvesParser(sourceProperty);
  92542. break;
  92543. case 8: // Color 4
  92544. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(sourceProperty);
  92545. break;
  92546. case 9: // Image Processing
  92547. dest[property] = SerializationHelper._ImageProcessingConfigurationParser(sourceProperty);
  92548. break;
  92549. case 10: // Quaternion
  92550. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray(sourceProperty);
  92551. break;
  92552. case 11: // Camera reference
  92553. if (scene) {
  92554. dest[property] = scene.getCameraByID(sourceProperty);
  92555. }
  92556. break;
  92557. }
  92558. }
  92559. }
  92560. return destination;
  92561. };
  92562. /**
  92563. * Clones an object
  92564. * @param creationFunction defines the function used to instanciate the new object
  92565. * @param source defines the source object
  92566. * @returns the cloned object
  92567. */
  92568. SerializationHelper.Clone = function (creationFunction, source) {
  92569. return _copySource(creationFunction, source, false);
  92570. };
  92571. /**
  92572. * Instanciates a new object based on a source one (some data will be shared between both object)
  92573. * @param creationFunction defines the function used to instanciate the new object
  92574. * @param source defines the source object
  92575. * @returns the new object
  92576. */
  92577. SerializationHelper.Instanciate = function (creationFunction, source) {
  92578. return _copySource(creationFunction, source, true);
  92579. };
  92580. /** hidden */
  92581. SerializationHelper._ImageProcessingConfigurationParser = function (sourceProperty) {
  92582. throw "ImageProcessingConfiguration needs to be imported before being deserialized.";
  92583. };
  92584. /** hidden */
  92585. SerializationHelper._FresnelParametersParser = function (sourceProperty) {
  92586. throw "FresnelParameters needs to be imported before being deserialized.";
  92587. };
  92588. /** hidden */
  92589. SerializationHelper._ColorCurvesParser = function (sourceProperty) {
  92590. throw "ColorCurves needs to be imported before being deserialized.";
  92591. };
  92592. /** hidden */
  92593. SerializationHelper._TextureParser = function (sourceProperty, scene, rootUrl) {
  92594. throw "Texture needs to be imported before being deserialized.";
  92595. };
  92596. return SerializationHelper;
  92597. }());
  92598. /***/ }),
  92599. /***/ "./Misc/deepCopier.ts":
  92600. /*!****************************!*\
  92601. !*** ./Misc/deepCopier.ts ***!
  92602. \****************************/
  92603. /*! exports provided: DeepCopier */
  92604. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92605. "use strict";
  92606. __webpack_require__.r(__webpack_exports__);
  92607. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return DeepCopier; });
  92608. var cloneValue = function (source, destinationObject) {
  92609. if (!source) {
  92610. return null;
  92611. }
  92612. if (source.getClassName && source.getClassName() === "Mesh") {
  92613. return null;
  92614. }
  92615. if (source.getClassName && source.getClassName() === "SubMesh") {
  92616. return source.clone(destinationObject);
  92617. }
  92618. else if (source.clone) {
  92619. return source.clone();
  92620. }
  92621. return null;
  92622. };
  92623. /**
  92624. * Class containing a set of static utilities functions for deep copy.
  92625. */
  92626. var DeepCopier = /** @class */ (function () {
  92627. function DeepCopier() {
  92628. }
  92629. /**
  92630. * Tries to copy an object by duplicating every property
  92631. * @param source defines the source object
  92632. * @param destination defines the target object
  92633. * @param doNotCopyList defines a list of properties to avoid
  92634. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  92635. */
  92636. DeepCopier.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  92637. for (var prop in source) {
  92638. if (prop[0] === "_" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {
  92639. continue;
  92640. }
  92641. if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {
  92642. continue;
  92643. }
  92644. var sourceValue = source[prop];
  92645. var typeOfSourceValue = typeof sourceValue;
  92646. if (typeOfSourceValue === "function") {
  92647. continue;
  92648. }
  92649. try {
  92650. if (typeOfSourceValue === "object") {
  92651. if (sourceValue instanceof Array) {
  92652. destination[prop] = [];
  92653. if (sourceValue.length > 0) {
  92654. if (typeof sourceValue[0] == "object") {
  92655. for (var index = 0; index < sourceValue.length; index++) {
  92656. var clonedValue = cloneValue(sourceValue[index], destination);
  92657. if (destination[prop].indexOf(clonedValue) === -1) { // Test if auto inject was not done
  92658. destination[prop].push(clonedValue);
  92659. }
  92660. }
  92661. }
  92662. else {
  92663. destination[prop] = sourceValue.slice(0);
  92664. }
  92665. }
  92666. }
  92667. else {
  92668. destination[prop] = cloneValue(sourceValue, destination);
  92669. }
  92670. }
  92671. else {
  92672. destination[prop] = sourceValue;
  92673. }
  92674. }
  92675. catch (e) {
  92676. // Just ignore error (it could be because of a read-only property)
  92677. }
  92678. }
  92679. };
  92680. return DeepCopier;
  92681. }());
  92682. /***/ }),
  92683. /***/ "./Misc/deferred.ts":
  92684. /*!**************************!*\
  92685. !*** ./Misc/deferred.ts ***!
  92686. \**************************/
  92687. /*! exports provided: Deferred */
  92688. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92689. "use strict";
  92690. __webpack_require__.r(__webpack_exports__);
  92691. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return Deferred; });
  92692. /**
  92693. * Wrapper class for promise with external resolve and reject.
  92694. */
  92695. var Deferred = /** @class */ (function () {
  92696. /**
  92697. * Constructor for this deferred object.
  92698. */
  92699. function Deferred() {
  92700. var _this = this;
  92701. this.promise = new Promise(function (resolve, reject) {
  92702. _this._resolve = resolve;
  92703. _this._reject = reject;
  92704. });
  92705. }
  92706. Object.defineProperty(Deferred.prototype, "resolve", {
  92707. /**
  92708. * The resolve method of the promise associated with this deferred object.
  92709. */
  92710. get: function () {
  92711. return this._resolve;
  92712. },
  92713. enumerable: true,
  92714. configurable: true
  92715. });
  92716. Object.defineProperty(Deferred.prototype, "reject", {
  92717. /**
  92718. * The reject method of the promise associated with this deferred object.
  92719. */
  92720. get: function () {
  92721. return this._reject;
  92722. },
  92723. enumerable: true,
  92724. configurable: true
  92725. });
  92726. return Deferred;
  92727. }());
  92728. /***/ }),
  92729. /***/ "./Misc/domManagement.ts":
  92730. /*!*******************************!*\
  92731. !*** ./Misc/domManagement.ts ***!
  92732. \*******************************/
  92733. /*! exports provided: DomManagement */
  92734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92735. "use strict";
  92736. __webpack_require__.r(__webpack_exports__);
  92737. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomManagement", function() { return DomManagement; });
  92738. /**
  92739. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  92740. * Babylon.js
  92741. */
  92742. var DomManagement = /** @class */ (function () {
  92743. function DomManagement() {
  92744. }
  92745. /**
  92746. * Checks if the window object exists
  92747. * @returns true if the window object exists
  92748. */
  92749. DomManagement.IsWindowObjectExist = function () {
  92750. return (typeof window) !== "undefined";
  92751. };
  92752. /**
  92753. * Extracts text content from a DOM element hierarchy
  92754. * @param element defines the root element
  92755. * @returns a string
  92756. */
  92757. DomManagement.GetDOMTextContent = function (element) {
  92758. var result = "";
  92759. var child = element.firstChild;
  92760. while (child) {
  92761. if (child.nodeType === 3) {
  92762. result += child.textContent;
  92763. }
  92764. child = (child.nextSibling);
  92765. }
  92766. return result;
  92767. };
  92768. return DomManagement;
  92769. }());
  92770. /***/ }),
  92771. /***/ "./Misc/environmentTextureTools.ts":
  92772. /*!*****************************************!*\
  92773. !*** ./Misc/environmentTextureTools.ts ***!
  92774. \*****************************************/
  92775. /*! exports provided: EnvironmentTextureTools */
  92776. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92777. "use strict";
  92778. __webpack_require__.r(__webpack_exports__);
  92779. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return EnvironmentTextureTools; });
  92780. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  92781. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  92782. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  92783. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  92784. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  92785. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  92786. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  92787. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  92788. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  92789. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  92790. /* harmony import */ var _Shaders_rgbdEncode_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/rgbdEncode.fragment */ "./Shaders/rgbdEncode.fragment.ts");
  92791. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  92792. /**
  92793. * Sets of helpers addressing the serialization and deserialization of environment texture
  92794. * stored in a BabylonJS env file.
  92795. * Those files are usually stored as .env files.
  92796. */
  92797. var EnvironmentTextureTools = /** @class */ (function () {
  92798. function EnvironmentTextureTools() {
  92799. }
  92800. /**
  92801. * Gets the environment info from an env file.
  92802. * @param data The array buffer containing the .env bytes.
  92803. * @returns the environment file info (the json header) if successfully parsed.
  92804. */
  92805. EnvironmentTextureTools.GetEnvInfo = function (data) {
  92806. var dataView = new DataView(data);
  92807. var pos = 0;
  92808. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  92809. if (dataView.getUint8(pos++) !== EnvironmentTextureTools._MagicBytes[i]) {
  92810. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error('Not a babylon environment map');
  92811. return null;
  92812. }
  92813. }
  92814. // Read json manifest - collect characters up to null terminator
  92815. var manifestString = '';
  92816. var charCode = 0x00;
  92817. while ((charCode = dataView.getUint8(pos++))) {
  92818. manifestString += String.fromCharCode(charCode);
  92819. }
  92820. var manifest = JSON.parse(manifestString);
  92821. if (manifest.specular) {
  92822. // Extend the header with the position of the payload.
  92823. manifest.specular.specularDataPosition = pos;
  92824. // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.
  92825. manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;
  92826. }
  92827. return manifest;
  92828. };
  92829. /**
  92830. * Creates an environment texture from a loaded cube texture.
  92831. * @param texture defines the cube texture to convert in env file
  92832. * @return a promise containing the environment data if succesfull.
  92833. */
  92834. EnvironmentTextureTools.CreateEnvTextureAsync = function (texture) {
  92835. var _this = this;
  92836. var internalTexture = texture.getInternalTexture();
  92837. if (!internalTexture) {
  92838. return Promise.reject("The cube texture is invalid.");
  92839. }
  92840. if (!texture._prefiltered) {
  92841. return Promise.reject("The cube texture is invalid (not prefiltered).");
  92842. }
  92843. var engine = internalTexture.getEngine();
  92844. if (engine && engine.premultipliedAlpha) {
  92845. return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");
  92846. }
  92847. if (texture.textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  92848. return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");
  92849. }
  92850. var canvas = engine.getRenderingCanvas();
  92851. if (!canvas) {
  92852. return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");
  92853. }
  92854. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  92855. if (!engine.getCaps().textureFloatRender) {
  92856. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  92857. if (!engine.getCaps().textureHalfFloatRender) {
  92858. return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");
  92859. }
  92860. }
  92861. var cubeWidth = internalTexture.width;
  92862. var hostingScene = new _scene__WEBPACK_IMPORTED_MODULE_7__["Scene"](engine);
  92863. var specularTextures = {};
  92864. var promises = [];
  92865. // Read and collect all mipmaps data from the cube.
  92866. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(internalTexture.width);
  92867. mipmapsCount = Math.round(mipmapsCount);
  92868. var _loop_1 = function (i) {
  92869. var faceWidth = Math.pow(2, mipmapsCount - i);
  92870. var _loop_2 = function (face) {
  92871. var data = texture.readPixels(face, i);
  92872. // Creates a temp texture with the face data.
  92873. 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);
  92874. // And rgbdEncode them.
  92875. var promise = new Promise(function (resolve, reject) {
  92876. 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);
  92877. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  92878. rgbdPostProcess.onApply = function (effect) {
  92879. effect._bindTexture("textureSampler", tempTexture);
  92880. };
  92881. // As the process needs to happen on the main canvas, keep track of the current size
  92882. var currentW = engine.getRenderWidth();
  92883. var currentH = engine.getRenderHeight();
  92884. // Set the desired size for the texture
  92885. engine.setSize(faceWidth, faceWidth);
  92886. hostingScene.postProcessManager.directRender([rgbdPostProcess], null);
  92887. // Reading datas from WebGL
  92888. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToBlob(canvas, function (blob) {
  92889. var fileReader = new FileReader();
  92890. fileReader.onload = function (event) {
  92891. var arrayBuffer = event.target.result;
  92892. specularTextures[i * 6 + face] = arrayBuffer;
  92893. resolve();
  92894. };
  92895. fileReader.readAsArrayBuffer(blob);
  92896. });
  92897. // Reapply the previous canvas size
  92898. engine.setSize(currentW, currentH);
  92899. });
  92900. });
  92901. promises.push(promise);
  92902. };
  92903. // All faces of the cube.
  92904. for (var face = 0; face < 6; face++) {
  92905. _loop_2(face);
  92906. }
  92907. };
  92908. for (var i = 0; i <= mipmapsCount; i++) {
  92909. _loop_1(i);
  92910. }
  92911. // Once all the textures haves been collected as RGBD stored in PNGs
  92912. return Promise.all(promises).then(function () {
  92913. // We can delete the hosting scene keeping track of all the creation objects
  92914. hostingScene.dispose();
  92915. // Creates the json header for the env texture
  92916. var info = {
  92917. version: 1,
  92918. width: cubeWidth,
  92919. irradiance: _this._CreateEnvTextureIrradiance(texture),
  92920. specular: {
  92921. mipmaps: [],
  92922. lodGenerationScale: texture.lodGenerationScale
  92923. }
  92924. };
  92925. // Sets the specular image data information
  92926. var position = 0;
  92927. for (var i = 0; i <= mipmapsCount; i++) {
  92928. for (var face = 0; face < 6; face++) {
  92929. var byteLength = specularTextures[i * 6 + face].byteLength;
  92930. info.specular.mipmaps.push({
  92931. length: byteLength,
  92932. position: position
  92933. });
  92934. position += byteLength;
  92935. }
  92936. }
  92937. // Encode the JSON as an array buffer
  92938. var infoString = JSON.stringify(info);
  92939. var infoBuffer = new ArrayBuffer(infoString.length + 1);
  92940. var infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.
  92941. for (var i = 0, strLen = infoString.length; i < strLen; i++) {
  92942. infoView[i] = infoString.charCodeAt(i);
  92943. }
  92944. // Ends up with a null terminator for easier parsing
  92945. infoView[infoString.length] = 0x00;
  92946. // Computes the final required size and creates the storage
  92947. var totalSize = EnvironmentTextureTools._MagicBytes.length + position + infoBuffer.byteLength;
  92948. var finalBuffer = new ArrayBuffer(totalSize);
  92949. var finalBufferView = new Uint8Array(finalBuffer);
  92950. var dataView = new DataView(finalBuffer);
  92951. // Copy the magic bytes identifying the file in
  92952. var pos = 0;
  92953. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  92954. dataView.setUint8(pos++, EnvironmentTextureTools._MagicBytes[i]);
  92955. }
  92956. // Add the json info
  92957. finalBufferView.set(new Uint8Array(infoBuffer), pos);
  92958. pos += infoBuffer.byteLength;
  92959. // Finally inserts the texture data
  92960. for (var i = 0; i <= mipmapsCount; i++) {
  92961. for (var face = 0; face < 6; face++) {
  92962. var dataBuffer = specularTextures[i * 6 + face];
  92963. finalBufferView.set(new Uint8Array(dataBuffer), pos);
  92964. pos += dataBuffer.byteLength;
  92965. }
  92966. }
  92967. // Voila
  92968. return finalBuffer;
  92969. });
  92970. };
  92971. /**
  92972. * Creates a JSON representation of the spherical data.
  92973. * @param texture defines the texture containing the polynomials
  92974. * @return the JSON representation of the spherical info
  92975. */
  92976. EnvironmentTextureTools._CreateEnvTextureIrradiance = function (texture) {
  92977. var polynmials = texture.sphericalPolynomial;
  92978. if (polynmials == null) {
  92979. return null;
  92980. }
  92981. return {
  92982. x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],
  92983. y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],
  92984. z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],
  92985. xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],
  92986. yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],
  92987. zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],
  92988. yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],
  92989. zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],
  92990. xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z]
  92991. };
  92992. };
  92993. /**
  92994. * Uploads the texture info contained in the env file to the GPU.
  92995. * @param texture defines the internal texture to upload to
  92996. * @param arrayBuffer defines the buffer cotaining the data to load
  92997. * @param info defines the texture info retrieved through the GetEnvInfo method
  92998. * @returns a promise
  92999. */
  93000. EnvironmentTextureTools.UploadEnvLevelsAsync = function (texture, arrayBuffer, info) {
  93001. if (info.version !== 1) {
  93002. throw new Error("Unsupported babylon environment map version \"" + info.version + "\"");
  93003. }
  93004. var specularInfo = info.specular;
  93005. if (!specularInfo) {
  93006. // Nothing else parsed so far
  93007. return Promise.resolve();
  93008. }
  93009. // Double checks the enclosed info
  93010. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(info.width);
  93011. mipmapsCount = Math.round(mipmapsCount) + 1;
  93012. if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {
  93013. throw new Error("Unsupported specular mipmaps number \"" + specularInfo.mipmaps.length + "\"");
  93014. }
  93015. texture._lodGenerationScale = specularInfo.lodGenerationScale;
  93016. var imageData = new Array(mipmapsCount);
  93017. for (var i = 0; i < mipmapsCount; i++) {
  93018. imageData[i] = new Array(6);
  93019. for (var face = 0; face < 6; face++) {
  93020. var imageInfo = specularInfo.mipmaps[i * 6 + face];
  93021. imageData[i][face] = new Uint8Array(arrayBuffer, specularInfo.specularDataPosition + imageInfo.position, imageInfo.length);
  93022. }
  93023. }
  93024. return EnvironmentTextureTools.UploadLevelsAsync(texture, imageData);
  93025. };
  93026. /**
  93027. * Uploads the levels of image data to the GPU.
  93028. * @param texture defines the internal texture to upload to
  93029. * @param imageData defines the array buffer views of image data [mipmap][face]
  93030. * @returns a promise
  93031. */
  93032. EnvironmentTextureTools.UploadLevelsAsync = function (texture, imageData) {
  93033. if (!_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsExponentOfTwo(texture.width)) {
  93034. throw new Error("Texture size must be a power of two");
  93035. }
  93036. var mipmapsCount = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(texture.width)) + 1;
  93037. // Gets everything ready.
  93038. var engine = texture.getEngine();
  93039. var expandTexture = false;
  93040. var generateNonLODTextures = false;
  93041. var rgbdPostProcess = null;
  93042. var cubeRtt = null;
  93043. var lodTextures = null;
  93044. var caps = engine.getCaps();
  93045. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA;
  93046. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93047. texture.generateMipMaps = true;
  93048. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, texture);
  93049. // Add extra process if texture lod is not supported
  93050. if (!caps.textureLOD) {
  93051. expandTexture = false;
  93052. generateNonLODTextures = true;
  93053. lodTextures = {};
  93054. }
  93055. // in webgl 1 there are no ways to either render or copy lod level information for float textures.
  93056. else if (engine.webGLVersion < 2) {
  93057. expandTexture = false;
  93058. }
  93059. // If half float available we can uncompress the texture
  93060. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  93061. expandTexture = true;
  93062. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  93063. }
  93064. // If full float available we can uncompress the texture
  93065. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  93066. expandTexture = true;
  93067. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  93068. }
  93069. // Expand the texture if possible
  93070. if (expandTexture) {
  93071. // Simply run through the decode PP
  93072. 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);
  93073. texture._isRGBD = false;
  93074. texture.invertY = false;
  93075. cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {
  93076. generateDepthBuffer: false,
  93077. generateMipMaps: true,
  93078. generateStencilBuffer: false,
  93079. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE,
  93080. type: texture.type,
  93081. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA
  93082. });
  93083. }
  93084. else {
  93085. texture._isRGBD = true;
  93086. texture.invertY = true;
  93087. // In case of missing support, applies the same patch than DDS files.
  93088. if (generateNonLODTextures) {
  93089. var mipSlices = 3;
  93090. var scale = texture._lodGenerationScale;
  93091. var offset = texture._lodGenerationOffset;
  93092. for (var i = 0; i < mipSlices; i++) {
  93093. //compute LOD from even spacing in smoothness (matching shader calculation)
  93094. var smoothness = i / (mipSlices - 1);
  93095. var roughness = 1 - smoothness;
  93096. var minLODIndex = offset; // roughness = 0
  93097. var maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)
  93098. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  93099. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  93100. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](engine, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  93101. glTextureFromLod.isCube = true;
  93102. glTextureFromLod.invertY = true;
  93103. glTextureFromLod.generateMipMaps = false;
  93104. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR, glTextureFromLod);
  93105. // Wrap in a base texture for easy binding.
  93106. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"](null);
  93107. lodTexture.isCube = true;
  93108. lodTexture._texture = glTextureFromLod;
  93109. lodTextures[mipmapIndex] = lodTexture;
  93110. switch (i) {
  93111. case 0:
  93112. texture._lodTextureLow = lodTexture;
  93113. break;
  93114. case 1:
  93115. texture._lodTextureMid = lodTexture;
  93116. break;
  93117. case 2:
  93118. texture._lodTextureHigh = lodTexture;
  93119. break;
  93120. }
  93121. }
  93122. }
  93123. }
  93124. var promises = [];
  93125. var _loop_3 = function (i) {
  93126. var _loop_4 = function (face) {
  93127. // Constructs an image element from image data
  93128. var bytes = imageData[i][face];
  93129. var blob = new Blob([bytes], { type: 'image/png' });
  93130. var url = URL.createObjectURL(blob);
  93131. var image = new Image();
  93132. image.src = url;
  93133. // Enqueue promise to upload to the texture.
  93134. var promise = new Promise(function (resolve, reject) {
  93135. image.onload = function () {
  93136. if (expandTexture) {
  93137. var tempTexture_1 = engine.createTexture(null, true, true, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, null, function (message) {
  93138. reject(message);
  93139. }, image);
  93140. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  93141. // Uncompress the data to a RTT
  93142. rgbdPostProcess.onApply = function (effect) {
  93143. effect._bindTexture("textureSampler", tempTexture_1);
  93144. effect.setFloat2("scale", 1, 1);
  93145. };
  93146. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);
  93147. // Cleanup
  93148. engine.restoreDefaultFramebuffer();
  93149. tempTexture_1.dispose();
  93150. window.URL.revokeObjectURL(url);
  93151. resolve();
  93152. });
  93153. }
  93154. else {
  93155. engine._uploadImageToTexture(texture, image, face, i);
  93156. // Upload the face to the non lod texture support
  93157. if (generateNonLODTextures) {
  93158. var lodTexture = lodTextures[i];
  93159. if (lodTexture) {
  93160. engine._uploadImageToTexture(lodTexture._texture, image, face, 0);
  93161. }
  93162. }
  93163. resolve();
  93164. }
  93165. };
  93166. image.onerror = function (error) {
  93167. reject(error);
  93168. };
  93169. });
  93170. promises.push(promise);
  93171. };
  93172. // All faces
  93173. for (var face = 0; face < 6; face++) {
  93174. _loop_4(face);
  93175. }
  93176. };
  93177. // All mipmaps up to provided number of images
  93178. for (var i = 0; i < imageData.length; i++) {
  93179. _loop_3(i);
  93180. }
  93181. // Fill remaining mipmaps with black textures.
  93182. if (imageData.length < mipmapsCount) {
  93183. var data = void 0;
  93184. var size = Math.pow(2, mipmapsCount - 1 - imageData.length);
  93185. var dataLength = size * size * 4;
  93186. switch (texture.type) {
  93187. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT: {
  93188. data = new Uint8Array(dataLength);
  93189. break;
  93190. }
  93191. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT: {
  93192. data = new Uint16Array(dataLength);
  93193. break;
  93194. }
  93195. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT: {
  93196. data = new Float32Array(dataLength);
  93197. break;
  93198. }
  93199. }
  93200. for (var i = imageData.length; i < mipmapsCount; i++) {
  93201. for (var face = 0; face < 6; face++) {
  93202. engine._uploadArrayBufferViewToTexture(texture, data, face, i);
  93203. }
  93204. }
  93205. }
  93206. // Once all done, finishes the cleanup and return
  93207. return Promise.all(promises).then(function () {
  93208. // Release temp RTT.
  93209. if (cubeRtt) {
  93210. engine._releaseFramebufferObjects(cubeRtt);
  93211. cubeRtt._swapAndDie(texture);
  93212. }
  93213. // Release temp Post Process.
  93214. if (rgbdPostProcess) {
  93215. rgbdPostProcess.dispose();
  93216. }
  93217. // Flag internal texture as ready in case they are in use.
  93218. if (generateNonLODTextures) {
  93219. if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {
  93220. texture._lodTextureHigh._texture.isReady = true;
  93221. }
  93222. if (texture._lodTextureMid && texture._lodTextureMid._texture) {
  93223. texture._lodTextureMid._texture.isReady = true;
  93224. }
  93225. if (texture._lodTextureLow && texture._lodTextureLow._texture) {
  93226. texture._lodTextureLow._texture.isReady = true;
  93227. }
  93228. }
  93229. });
  93230. };
  93231. /**
  93232. * Uploads spherical polynomials information to the texture.
  93233. * @param texture defines the texture we are trying to upload the information to
  93234. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  93235. */
  93236. EnvironmentTextureTools.UploadEnvSpherical = function (texture, info) {
  93237. if (info.version !== 1) {
  93238. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn('Unsupported babylon environment map version "' + info.version + '"');
  93239. }
  93240. var irradianceInfo = info.irradiance;
  93241. if (!irradianceInfo) {
  93242. return;
  93243. }
  93244. var sp = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__["SphericalPolynomial"]();
  93245. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.x, 0, sp.x);
  93246. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.y, 0, sp.y);
  93247. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.z, 0, sp.z);
  93248. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xx, 0, sp.xx);
  93249. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yy, 0, sp.yy);
  93250. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zz, 0, sp.zz);
  93251. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yz, 0, sp.yz);
  93252. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zx, 0, sp.zx);
  93253. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xy, 0, sp.xy);
  93254. texture._sphericalPolynomial = sp;
  93255. };
  93256. /** @hidden */
  93257. EnvironmentTextureTools._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  93258. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  93259. internalTexture._bufferViewArrayArray = data;
  93260. internalTexture._lodGenerationScale = lodScale;
  93261. internalTexture._lodGenerationOffset = lodOffset;
  93262. internalTexture._sphericalPolynomial = sphericalPolynomial;
  93263. return EnvironmentTextureTools.UploadLevelsAsync(internalTexture, data).then(function () {
  93264. internalTexture.isReady = true;
  93265. });
  93266. };
  93267. /**
  93268. * Magic number identifying the env file.
  93269. */
  93270. EnvironmentTextureTools._MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];
  93271. return EnvironmentTextureTools;
  93272. }());
  93273. // References the dependencies.
  93274. _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"]._UpdateRGBDAsync = EnvironmentTextureTools._UpdateRGBDAsync;
  93275. /***/ }),
  93276. /***/ "./Misc/filesInput.ts":
  93277. /*!****************************!*\
  93278. !*** ./Misc/filesInput.ts ***!
  93279. \****************************/
  93280. /*! exports provided: FilesInput */
  93281. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93282. "use strict";
  93283. __webpack_require__.r(__webpack_exports__);
  93284. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return FilesInput; });
  93285. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  93286. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  93287. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  93288. /**
  93289. * Class used to help managing file picking and drag'n'drop
  93290. */
  93291. var FilesInput = /** @class */ (function () {
  93292. /**
  93293. * Creates a new FilesInput
  93294. * @param engine defines the rendering engine
  93295. * @param scene defines the hosting scene
  93296. * @param sceneLoadedCallback callback called when scene is loaded
  93297. * @param progressCallback callback called to track progress
  93298. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  93299. * @param textureLoadingCallback callback called when a texture is loading
  93300. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  93301. * @param onReloadCallback callback called when a reload is requested
  93302. * @param errorCallback callback call if an error occurs
  93303. */
  93304. function FilesInput(engine, scene, sceneLoadedCallback, progressCallback, additionalRenderLoopLogicCallback, textureLoadingCallback, startingProcessingFilesCallback, onReloadCallback, errorCallback) {
  93305. /**
  93306. * Callback called when a file is processed
  93307. */
  93308. this.onProcessFileCallback = function () { return true; };
  93309. this._engine = engine;
  93310. this._currentScene = scene;
  93311. this._sceneLoadedCallback = sceneLoadedCallback;
  93312. this._progressCallback = progressCallback;
  93313. this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;
  93314. this._textureLoadingCallback = textureLoadingCallback;
  93315. this._startingProcessingFilesCallback = startingProcessingFilesCallback;
  93316. this._onReloadCallback = onReloadCallback;
  93317. this._errorCallback = errorCallback;
  93318. }
  93319. Object.defineProperty(FilesInput, "FilesToLoad", {
  93320. /**
  93321. * List of files ready to be loaded
  93322. */
  93323. get: function () {
  93324. return _filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad;
  93325. },
  93326. enumerable: true,
  93327. configurable: true
  93328. });
  93329. /**
  93330. * Calls this function to listen to drag'n'drop events on a specific DOM element
  93331. * @param elementToMonitor defines the DOM element to track
  93332. */
  93333. FilesInput.prototype.monitorElementForDragNDrop = function (elementToMonitor) {
  93334. var _this = this;
  93335. if (elementToMonitor) {
  93336. this._elementToMonitor = elementToMonitor;
  93337. this._dragEnterHandler = function (e) { _this.drag(e); };
  93338. this._dragOverHandler = function (e) { _this.drag(e); };
  93339. this._dropHandler = function (e) { _this.drop(e); };
  93340. this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, false);
  93341. this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, false);
  93342. this._elementToMonitor.addEventListener("drop", this._dropHandler, false);
  93343. }
  93344. };
  93345. /**
  93346. * Release all associated resources
  93347. */
  93348. FilesInput.prototype.dispose = function () {
  93349. if (!this._elementToMonitor) {
  93350. return;
  93351. }
  93352. this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler);
  93353. this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler);
  93354. this._elementToMonitor.removeEventListener("drop", this._dropHandler);
  93355. };
  93356. FilesInput.prototype.renderFunction = function () {
  93357. if (this._additionalRenderLoopLogicCallback) {
  93358. this._additionalRenderLoopLogicCallback();
  93359. }
  93360. if (this._currentScene) {
  93361. if (this._textureLoadingCallback) {
  93362. var remaining = this._currentScene.getWaitingItemsCount();
  93363. if (remaining > 0) {
  93364. this._textureLoadingCallback(remaining);
  93365. }
  93366. }
  93367. this._currentScene.render();
  93368. }
  93369. };
  93370. FilesInput.prototype.drag = function (e) {
  93371. e.stopPropagation();
  93372. e.preventDefault();
  93373. };
  93374. FilesInput.prototype.drop = function (eventDrop) {
  93375. eventDrop.stopPropagation();
  93376. eventDrop.preventDefault();
  93377. this.loadFiles(eventDrop);
  93378. };
  93379. FilesInput.prototype._traverseFolder = function (folder, files, remaining, callback) {
  93380. var _this = this;
  93381. var reader = folder.createReader();
  93382. var relativePath = folder.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
  93383. reader.readEntries(function (entries) {
  93384. remaining.count += entries.length;
  93385. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  93386. var entry = entries_1[_i];
  93387. if (entry.isFile) {
  93388. entry.file(function (file) {
  93389. file.correctName = relativePath + file.name;
  93390. files.push(file);
  93391. if (--remaining.count === 0) {
  93392. callback();
  93393. }
  93394. });
  93395. }
  93396. else if (entry.isDirectory) {
  93397. _this._traverseFolder(entry, files, remaining, callback);
  93398. }
  93399. }
  93400. if (--remaining.count) {
  93401. callback();
  93402. }
  93403. });
  93404. };
  93405. FilesInput.prototype._processFiles = function (files) {
  93406. for (var i = 0; i < files.length; i++) {
  93407. var name = files[i].correctName.toLowerCase();
  93408. var extension = name.split('.').pop();
  93409. if (!this.onProcessFileCallback(files[i], name, extension)) {
  93410. continue;
  93411. }
  93412. if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
  93413. && name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
  93414. this._sceneFileToLoad = files[i];
  93415. }
  93416. FilesInput.FilesToLoad[name] = files[i];
  93417. }
  93418. };
  93419. /**
  93420. * Load files from a drop event
  93421. * @param event defines the drop event to use as source
  93422. */
  93423. FilesInput.prototype.loadFiles = function (event) {
  93424. var _this = this;
  93425. // Handling data transfer via drag'n'drop
  93426. if (event && event.dataTransfer && event.dataTransfer.files) {
  93427. this._filesToLoad = event.dataTransfer.files;
  93428. }
  93429. // Handling files from input files
  93430. if (event && event.target && event.target.files) {
  93431. this._filesToLoad = event.target.files;
  93432. }
  93433. if (!this._filesToLoad || this._filesToLoad.length === 0) {
  93434. return;
  93435. }
  93436. if (this._startingProcessingFilesCallback) {
  93437. this._startingProcessingFilesCallback(this._filesToLoad);
  93438. }
  93439. if (this._filesToLoad && this._filesToLoad.length > 0) {
  93440. var files_1 = new Array();
  93441. var folders = [];
  93442. var items = event.dataTransfer ? event.dataTransfer.items : null;
  93443. for (var i = 0; i < this._filesToLoad.length; i++) {
  93444. var fileToLoad = this._filesToLoad[i];
  93445. var name_1 = fileToLoad.name.toLowerCase();
  93446. var entry = void 0;
  93447. fileToLoad.correctName = name_1;
  93448. if (items) {
  93449. var item = items[i];
  93450. if (item.getAsEntry) {
  93451. entry = item.getAsEntry();
  93452. }
  93453. else if (item.webkitGetAsEntry) {
  93454. entry = item.webkitGetAsEntry();
  93455. }
  93456. }
  93457. if (!entry) {
  93458. files_1.push(fileToLoad);
  93459. }
  93460. else {
  93461. if (entry.isDirectory) {
  93462. folders.push(entry);
  93463. }
  93464. else {
  93465. files_1.push(fileToLoad);
  93466. }
  93467. }
  93468. }
  93469. if (folders.length === 0) {
  93470. this._processFiles(files_1);
  93471. this._processReload();
  93472. }
  93473. else {
  93474. var remaining = { count: folders.length };
  93475. for (var _i = 0, folders_1 = folders; _i < folders_1.length; _i++) {
  93476. var folder = folders_1[_i];
  93477. this._traverseFolder(folder, files_1, remaining, function () {
  93478. _this._processFiles(files_1);
  93479. if (remaining.count === 0) {
  93480. _this._processReload();
  93481. }
  93482. });
  93483. }
  93484. }
  93485. }
  93486. };
  93487. FilesInput.prototype._processReload = function () {
  93488. if (this._onReloadCallback) {
  93489. this._onReloadCallback(this._sceneFileToLoad);
  93490. }
  93491. else {
  93492. this.reload();
  93493. }
  93494. };
  93495. /**
  93496. * Reload the current scene from the loaded files
  93497. */
  93498. FilesInput.prototype.reload = function () {
  93499. var _this = this;
  93500. // If a scene file has been provided
  93501. if (this._sceneFileToLoad) {
  93502. if (this._currentScene) {
  93503. if (_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].errorsCount > 0) {
  93504. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].ClearLogCache();
  93505. }
  93506. this._engine.stopRenderLoop();
  93507. }
  93508. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].LoadAsync("file:", this._sceneFileToLoad, this._engine, function (progress) {
  93509. if (_this._progressCallback) {
  93510. _this._progressCallback(progress);
  93511. }
  93512. }).then(function (scene) {
  93513. if (_this._currentScene) {
  93514. _this._currentScene.dispose();
  93515. }
  93516. _this._currentScene = scene;
  93517. if (_this._sceneLoadedCallback) {
  93518. _this._sceneLoadedCallback(_this._sceneFileToLoad, _this._currentScene);
  93519. }
  93520. // Wait for textures and shaders to be ready
  93521. _this._currentScene.executeWhenReady(function () {
  93522. _this._engine.runRenderLoop(function () {
  93523. _this.renderFunction();
  93524. });
  93525. });
  93526. }).catch(function (error) {
  93527. if (_this._errorCallback) {
  93528. _this._errorCallback(_this._sceneFileToLoad, _this._currentScene, error.message);
  93529. }
  93530. });
  93531. }
  93532. else {
  93533. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Please provide a valid .babylon file.");
  93534. }
  93535. };
  93536. return FilesInput;
  93537. }());
  93538. /***/ }),
  93539. /***/ "./Misc/filesInputStore.ts":
  93540. /*!*********************************!*\
  93541. !*** ./Misc/filesInputStore.ts ***!
  93542. \*********************************/
  93543. /*! exports provided: FilesInputStore */
  93544. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93545. "use strict";
  93546. __webpack_require__.r(__webpack_exports__);
  93547. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return FilesInputStore; });
  93548. /**
  93549. * Class used to help managing file picking and drag'n'drop
  93550. * File Storage
  93551. */
  93552. var FilesInputStore = /** @class */ (function () {
  93553. function FilesInputStore() {
  93554. }
  93555. /**
  93556. * List of files ready to be loaded
  93557. */
  93558. FilesInputStore.FilesToLoad = {};
  93559. return FilesInputStore;
  93560. }());
  93561. /***/ }),
  93562. /***/ "./Misc/index.ts":
  93563. /*!***********************!*\
  93564. !*** ./Misc/index.ts ***!
  93565. \***********************/
  93566. /*! 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 */
  93567. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93568. "use strict";
  93569. __webpack_require__.r(__webpack_exports__);
  93570. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  93571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  93572. /* harmony import */ var _assetsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetsManager */ "./Misc/assetsManager.ts");
  93573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetTaskState"]; });
  93574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AbstractAssetTask"]; });
  93575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsProgressEvent"]; });
  93576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["MeshAssetTask"]; });
  93577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextFileAssetTask"]; });
  93578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["BinaryFileAssetTask"]; });
  93579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["ImageAssetTask"]; });
  93580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextureAssetTask"]; });
  93581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["CubeTextureAssetTask"]; });
  93582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["HDRCubeTextureAssetTask"]; });
  93583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsManager"]; });
  93584. /* harmony import */ var _dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dds */ "./Misc/dds.ts");
  93585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"]; });
  93586. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  93587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["expandToProperty"]; });
  93588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"]; });
  93589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsTexture"]; });
  93590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor3"]; });
  93591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsFresnelParameters"]; });
  93592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector2"]; });
  93593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector3"]; });
  93594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMeshReference"]; });
  93595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColorCurves"]; });
  93596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor4"]; });
  93597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsImageProcessingConfiguration"]; });
  93598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsQuaternion"]; });
  93599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsCameraReference"]; });
  93600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]; });
  93601. /* harmony import */ var _deferred__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./deferred */ "./Misc/deferred.ts");
  93602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _deferred__WEBPACK_IMPORTED_MODULE_4__["Deferred"]; });
  93603. /* harmony import */ var _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  93604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__["EnvironmentTextureTools"]; });
  93605. /* harmony import */ var _filesInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./filesInput */ "./Misc/filesInput.ts");
  93606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _filesInput__WEBPACK_IMPORTED_MODULE_6__["FilesInput"]; });
  93607. /* harmony import */ var _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./HighDynamicRange/index */ "./Misc/HighDynamicRange/index.ts");
  93608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"]; });
  93609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["HDRTools"]; });
  93610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["PanoramaToCubeMapTools"]; });
  93611. /* harmony import */ var _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  93612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_8__["KhronosTextureContainer"]; });
  93613. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  93614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["EventState"]; });
  93615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["Observer"]; });
  93616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["MultiObserver"]; });
  93617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["Observable"]; });
  93618. /* harmony import */ var _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./performanceMonitor */ "./Misc/performanceMonitor.ts");
  93619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__["PerformanceMonitor"]; });
  93620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__["RollingAverage"]; });
  93621. /* harmony import */ var _promise__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./promise */ "./Misc/promise.ts");
  93622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _promise__WEBPACK_IMPORTED_MODULE_11__["PromisePolyfill"]; });
  93623. /* harmony import */ var _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./sceneOptimizer */ "./Misc/sceneOptimizer.ts");
  93624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimization"]; });
  93625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["TextureOptimization"]; });
  93626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["HardwareScalingOptimization"]; });
  93627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["ShadowsOptimization"]; });
  93628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["PostProcessesOptimization"]; });
  93629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["LensFlaresOptimization"]; });
  93630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["CustomOptimization"]; });
  93631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["ParticlesOptimization"]; });
  93632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["RenderTargetsOptimization"]; });
  93633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["MergeMeshesOptimization"]; });
  93634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimizerOptions"]; });
  93635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimizer"]; });
  93636. /* harmony import */ var _sceneSerializer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./sceneSerializer */ "./Misc/sceneSerializer.ts");
  93637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _sceneSerializer__WEBPACK_IMPORTED_MODULE_13__["SceneSerializer"]; });
  93638. /* harmony import */ var _smartArray__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./smartArray */ "./Misc/smartArray.ts");
  93639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_14__["SmartArray"]; });
  93640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_14__["SmartArrayNoDuplicate"]; });
  93641. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  93642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _stringDictionary__WEBPACK_IMPORTED_MODULE_15__["StringDictionary"]; });
  93643. /* harmony import */ var _tags__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./tags */ "./Misc/tags.ts");
  93644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _tags__WEBPACK_IMPORTED_MODULE_16__["Tags"]; });
  93645. /* harmony import */ var _textureTools__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./textureTools */ "./Misc/textureTools.ts");
  93646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _textureTools__WEBPACK_IMPORTED_MODULE_17__["TextureTools"]; });
  93647. /* harmony import */ var _tga__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./tga */ "./Misc/tga.ts");
  93648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _tga__WEBPACK_IMPORTED_MODULE_18__["TGATools"]; });
  93649. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  93650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["ColorGradient"]; });
  93651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["Color3Gradient"]; });
  93652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["FactorGradient"]; });
  93653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["LoadFileError"]; });
  93654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["RetryStrategy"]; });
  93655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["Tools"]; });
  93656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["PerfCounter"]; });
  93657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["className"]; });
  93658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["AsyncLoop"]; });
  93659. /* harmony import */ var _videoRecorder__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./videoRecorder */ "./Misc/videoRecorder.ts");
  93660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _videoRecorder__WEBPACK_IMPORTED_MODULE_20__["VideoRecorder"]; });
  93661. /* harmony import */ var _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./virtualJoystick */ "./Misc/virtualJoystick.ts");
  93662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__["JoystickAxis"]; });
  93663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__["VirtualJoystick"]; });
  93664. /* harmony import */ var _workerPool__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./workerPool */ "./Misc/workerPool.ts");
  93665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _workerPool__WEBPACK_IMPORTED_MODULE_22__["WorkerPool"]; });
  93666. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  93667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _logger__WEBPACK_IMPORTED_MODULE_23__["Logger"]; });
  93668. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  93669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _typeStore__WEBPACK_IMPORTED_MODULE_24__["_TypeStore"]; });
  93670. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  93671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _filesInputStore__WEBPACK_IMPORTED_MODULE_25__["FilesInputStore"]; });
  93672. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  93673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _deepCopier__WEBPACK_IMPORTED_MODULE_26__["DeepCopier"]; });
  93674. /* harmony import */ var _pivotTools__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./pivotTools */ "./Misc/pivotTools.ts");
  93675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _pivotTools__WEBPACK_IMPORTED_MODULE_27__["PivotTools"]; });
  93676. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  93677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _precisionDate__WEBPACK_IMPORTED_MODULE_28__["PrecisionDate"]; });
  93678. /* harmony import */ var _screenshotTools__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./screenshotTools */ "./Misc/screenshotTools.ts");
  93679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _screenshotTools__WEBPACK_IMPORTED_MODULE_29__["ScreenshotTools"]; });
  93680. /* empty/unused harmony star reexport */
  93681. /***/ }),
  93682. /***/ "./Misc/khronosTextureContainer.ts":
  93683. /*!*****************************************!*\
  93684. !*** ./Misc/khronosTextureContainer.ts ***!
  93685. \*****************************************/
  93686. /*! exports provided: KhronosTextureContainer */
  93687. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93688. "use strict";
  93689. __webpack_require__.r(__webpack_exports__);
  93690. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return KhronosTextureContainer; });
  93691. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  93692. /**
  93693. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  93694. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  93695. */
  93696. var KhronosTextureContainer = /** @class */ (function () {
  93697. /**
  93698. * Creates a new KhronosTextureContainer
  93699. * @param arrayBuffer contents of the KTX container file
  93700. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  93701. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  93702. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  93703. */
  93704. function KhronosTextureContainer(
  93705. /** contents of the KTX container file */
  93706. arrayBuffer, facesExpected, threeDExpected, textureArrayExpected) {
  93707. this.arrayBuffer = arrayBuffer;
  93708. /**
  93709. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  93710. */
  93711. this.isInvalid = false;
  93712. // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is:
  93713. // '�', 'K', 'T', 'X', ' ', '1', '1', '�', '\r', '\n', '\x1A', '\n'
  93714. // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
  93715. var identifier = new Uint8Array(this.arrayBuffer, 0, 12);
  93716. if (identifier[0] !== 0xAB || identifier[1] !== 0x4B || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 ||
  93717. identifier[6] !== 0x31 || identifier[7] !== 0xBB || identifier[8] !== 0x0D || identifier[9] !== 0x0A || identifier[10] !== 0x1A || identifier[11] !== 0x0A) {
  93718. this.isInvalid = true;
  93719. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture missing KTX identifier");
  93720. return;
  93721. }
  93722. // load the reset of the header in native 32 bit uint
  93723. var dataSize = Uint32Array.BYTES_PER_ELEMENT;
  93724. var headerDataView = new DataView(this.arrayBuffer, 12, 13 * dataSize);
  93725. var endianness = headerDataView.getUint32(0, true);
  93726. var littleEndian = endianness === 0x04030201;
  93727. this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures
  93728. this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures
  93729. this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures
  93730. this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)
  93731. this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)
  93732. this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)
  93733. this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)
  93734. this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)
  93735. this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays
  93736. this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6
  93737. this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures
  93738. this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data
  93739. // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.
  93740. if (this.glType !== 0) {
  93741. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only compressed formats currently supported");
  93742. return;
  93743. }
  93744. else {
  93745. // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
  93746. this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
  93747. }
  93748. if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
  93749. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only 2D textures currently supported");
  93750. return;
  93751. }
  93752. if (this.numberOfArrayElements !== 0) {
  93753. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture arrays not currently supported");
  93754. return;
  93755. }
  93756. if (this.numberOfFaces !== facesExpected) {
  93757. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces);
  93758. return;
  93759. }
  93760. // we now have a completely validated file, so could use existence of loadType as success
  93761. // would need to make this more elaborate & adjust checks above to support more than one load type
  93762. this.loadType = KhronosTextureContainer.COMPRESSED_2D;
  93763. }
  93764. /**
  93765. * Uploads KTX content to a Babylon Texture.
  93766. * It is assumed that the texture has already been created & is currently bound
  93767. * @hidden
  93768. */
  93769. KhronosTextureContainer.prototype.uploadLevels = function (texture, loadMipmaps) {
  93770. switch (this.loadType) {
  93771. case KhronosTextureContainer.COMPRESSED_2D:
  93772. this._upload2DCompressedLevels(texture, loadMipmaps);
  93773. break;
  93774. case KhronosTextureContainer.TEX_2D:
  93775. case KhronosTextureContainer.COMPRESSED_3D:
  93776. case KhronosTextureContainer.TEX_3D:
  93777. }
  93778. };
  93779. KhronosTextureContainer.prototype._upload2DCompressedLevels = function (texture, loadMipmaps) {
  93780. // initialize width & height for level 1
  93781. var dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;
  93782. var width = this.pixelWidth;
  93783. var height = this.pixelHeight;
  93784. var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;
  93785. for (var level = 0; level < mipmapCount; level++) {
  93786. var imageSize = new Int32Array(this.arrayBuffer, dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
  93787. dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.
  93788. for (var face = 0; face < this.numberOfFaces; face++) {
  93789. var byteArray = new Uint8Array(this.arrayBuffer, dataOffset, imageSize);
  93790. var engine = texture.getEngine();
  93791. engine._uploadCompressedDataToTextureDirectly(texture, this.glInternalFormat, width, height, byteArray, face, level);
  93792. dataOffset += imageSize; // add size of the image for the next face/mipmap
  93793. dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image
  93794. }
  93795. width = Math.max(1.0, width * 0.5);
  93796. height = Math.max(1.0, height * 0.5);
  93797. }
  93798. };
  93799. KhronosTextureContainer.HEADER_LEN = 12 + (13 * 4); // identifier + header elements (not including key value meta-data pairs)
  93800. // load types
  93801. KhronosTextureContainer.COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
  93802. KhronosTextureContainer.COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()
  93803. KhronosTextureContainer.TEX_2D = 2; // uses a gl.texImage2D()
  93804. KhronosTextureContainer.TEX_3D = 3; // uses a gl.texImage3D()
  93805. return KhronosTextureContainer;
  93806. }());
  93807. /***/ }),
  93808. /***/ "./Misc/logger.ts":
  93809. /*!************************!*\
  93810. !*** ./Misc/logger.ts ***!
  93811. \************************/
  93812. /*! exports provided: Logger */
  93813. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93814. "use strict";
  93815. __webpack_require__.r(__webpack_exports__);
  93816. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return Logger; });
  93817. /**
  93818. * Logger used througouht the application to allow configuration of
  93819. * the log level required for the messages.
  93820. */
  93821. var Logger = /** @class */ (function () {
  93822. function Logger() {
  93823. }
  93824. Logger._AddLogEntry = function (entry) {
  93825. Logger._LogCache = entry + Logger._LogCache;
  93826. if (Logger.OnNewCacheEntry) {
  93827. Logger.OnNewCacheEntry(entry);
  93828. }
  93829. };
  93830. Logger._FormatMessage = function (message) {
  93831. var padStr = function (i) { return (i < 10) ? "0" + i : "" + i; };
  93832. var date = new Date();
  93833. return "[" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
  93834. };
  93835. Logger._LogDisabled = function (message) {
  93836. // nothing to do
  93837. };
  93838. Logger._LogEnabled = function (message) {
  93839. var formattedMessage = Logger._FormatMessage(message);
  93840. console.log("BJS - " + formattedMessage);
  93841. var entry = "<div style='color:white'>" + formattedMessage + "</div><br>";
  93842. Logger._AddLogEntry(entry);
  93843. };
  93844. Logger._WarnDisabled = function (message) {
  93845. // nothing to do
  93846. };
  93847. Logger._WarnEnabled = function (message) {
  93848. var formattedMessage = Logger._FormatMessage(message);
  93849. console.warn("BJS - " + formattedMessage);
  93850. var entry = "<div style='color:orange'>" + formattedMessage + "</div><br>";
  93851. Logger._AddLogEntry(entry);
  93852. };
  93853. Logger._ErrorDisabled = function (message) {
  93854. // nothing to do
  93855. };
  93856. Logger._ErrorEnabled = function (message) {
  93857. Logger.errorsCount++;
  93858. var formattedMessage = Logger._FormatMessage(message);
  93859. console.error("BJS - " + formattedMessage);
  93860. var entry = "<div style='color:red'>" + formattedMessage + "</div><br>";
  93861. Logger._AddLogEntry(entry);
  93862. };
  93863. Object.defineProperty(Logger, "LogCache", {
  93864. /**
  93865. * Gets current log cache (list of logs)
  93866. */
  93867. get: function () {
  93868. return Logger._LogCache;
  93869. },
  93870. enumerable: true,
  93871. configurable: true
  93872. });
  93873. /**
  93874. * Clears the log cache
  93875. */
  93876. Logger.ClearLogCache = function () {
  93877. Logger._LogCache = "";
  93878. Logger.errorsCount = 0;
  93879. };
  93880. Object.defineProperty(Logger, "LogLevels", {
  93881. /**
  93882. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  93883. */
  93884. set: function (level) {
  93885. if ((level & Logger.MessageLogLevel) === Logger.MessageLogLevel) {
  93886. Logger.Log = Logger._LogEnabled;
  93887. }
  93888. else {
  93889. Logger.Log = Logger._LogDisabled;
  93890. }
  93891. if ((level & Logger.WarningLogLevel) === Logger.WarningLogLevel) {
  93892. Logger.Warn = Logger._WarnEnabled;
  93893. }
  93894. else {
  93895. Logger.Warn = Logger._WarnDisabled;
  93896. }
  93897. if ((level & Logger.ErrorLogLevel) === Logger.ErrorLogLevel) {
  93898. Logger.Error = Logger._ErrorEnabled;
  93899. }
  93900. else {
  93901. Logger.Error = Logger._ErrorDisabled;
  93902. }
  93903. },
  93904. enumerable: true,
  93905. configurable: true
  93906. });
  93907. /**
  93908. * No log
  93909. */
  93910. Logger.NoneLogLevel = 0;
  93911. /**
  93912. * Only message logs
  93913. */
  93914. Logger.MessageLogLevel = 1;
  93915. /**
  93916. * Only warning logs
  93917. */
  93918. Logger.WarningLogLevel = 2;
  93919. /**
  93920. * Only error logs
  93921. */
  93922. Logger.ErrorLogLevel = 4;
  93923. /**
  93924. * All logs
  93925. */
  93926. Logger.AllLogLevel = 7;
  93927. Logger._LogCache = "";
  93928. /**
  93929. * Gets a value indicating the number of loading errors
  93930. * @ignorenaming
  93931. */
  93932. Logger.errorsCount = 0;
  93933. /**
  93934. * Log a message to the console
  93935. */
  93936. Logger.Log = Logger._LogEnabled;
  93937. /**
  93938. * Write a warning message to the console
  93939. */
  93940. Logger.Warn = Logger._WarnEnabled;
  93941. /**
  93942. * Write an error message to the console
  93943. */
  93944. Logger.Error = Logger._ErrorEnabled;
  93945. return Logger;
  93946. }());
  93947. /***/ }),
  93948. /***/ "./Misc/observable.ts":
  93949. /*!****************************!*\
  93950. !*** ./Misc/observable.ts ***!
  93951. \****************************/
  93952. /*! exports provided: EventState, Observer, MultiObserver, Observable */
  93953. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93954. "use strict";
  93955. __webpack_require__.r(__webpack_exports__);
  93956. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return EventState; });
  93957. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return Observer; });
  93958. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return MultiObserver; });
  93959. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return Observable; });
  93960. /**
  93961. * A class serves as a medium between the observable and its observers
  93962. */
  93963. var EventState = /** @class */ (function () {
  93964. /**
  93965. * Create a new EventState
  93966. * @param mask defines the mask associated with this state
  93967. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  93968. * @param target defines the original target of the state
  93969. * @param currentTarget defines the current target of the state
  93970. */
  93971. function EventState(mask, skipNextObservers, target, currentTarget) {
  93972. if (skipNextObservers === void 0) { skipNextObservers = false; }
  93973. this.initalize(mask, skipNextObservers, target, currentTarget);
  93974. }
  93975. /**
  93976. * Initialize the current event state
  93977. * @param mask defines the mask associated with this state
  93978. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  93979. * @param target defines the original target of the state
  93980. * @param currentTarget defines the current target of the state
  93981. * @returns the current event state
  93982. */
  93983. EventState.prototype.initalize = function (mask, skipNextObservers, target, currentTarget) {
  93984. if (skipNextObservers === void 0) { skipNextObservers = false; }
  93985. this.mask = mask;
  93986. this.skipNextObservers = skipNextObservers;
  93987. this.target = target;
  93988. this.currentTarget = currentTarget;
  93989. return this;
  93990. };
  93991. return EventState;
  93992. }());
  93993. /**
  93994. * Represent an Observer registered to a given Observable object.
  93995. */
  93996. var Observer = /** @class */ (function () {
  93997. /**
  93998. * Creates a new observer
  93999. * @param callback defines the callback to call when the observer is notified
  94000. * @param mask defines the mask of the observer (used to filter notifications)
  94001. * @param scope defines the current scope used to restore the JS context
  94002. */
  94003. function Observer(
  94004. /**
  94005. * Defines the callback to call when the observer is notified
  94006. */
  94007. callback,
  94008. /**
  94009. * Defines the mask of the observer (used to filter notifications)
  94010. */
  94011. mask,
  94012. /**
  94013. * Defines the current scope used to restore the JS context
  94014. */
  94015. scope) {
  94016. if (scope === void 0) { scope = null; }
  94017. this.callback = callback;
  94018. this.mask = mask;
  94019. this.scope = scope;
  94020. /** @hidden */
  94021. this._willBeUnregistered = false;
  94022. /**
  94023. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  94024. */
  94025. this.unregisterOnNextCall = false;
  94026. }
  94027. return Observer;
  94028. }());
  94029. /**
  94030. * Represent a list of observers registered to multiple Observables object.
  94031. */
  94032. var MultiObserver = /** @class */ (function () {
  94033. function MultiObserver() {
  94034. }
  94035. /**
  94036. * Release associated resources
  94037. */
  94038. MultiObserver.prototype.dispose = function () {
  94039. if (this._observers && this._observables) {
  94040. for (var index = 0; index < this._observers.length; index++) {
  94041. this._observables[index].remove(this._observers[index]);
  94042. }
  94043. }
  94044. this._observers = null;
  94045. this._observables = null;
  94046. };
  94047. /**
  94048. * Raise a callback when one of the observable will notify
  94049. * @param observables defines a list of observables to watch
  94050. * @param callback defines the callback to call on notification
  94051. * @param mask defines the mask used to filter notifications
  94052. * @param scope defines the current scope used to restore the JS context
  94053. * @returns the new MultiObserver
  94054. */
  94055. MultiObserver.Watch = function (observables, callback, mask, scope) {
  94056. if (mask === void 0) { mask = -1; }
  94057. if (scope === void 0) { scope = null; }
  94058. var result = new MultiObserver();
  94059. result._observers = new Array();
  94060. result._observables = observables;
  94061. for (var _i = 0, observables_1 = observables; _i < observables_1.length; _i++) {
  94062. var observable = observables_1[_i];
  94063. var observer = observable.add(callback, mask, false, scope);
  94064. if (observer) {
  94065. result._observers.push(observer);
  94066. }
  94067. }
  94068. return result;
  94069. };
  94070. return MultiObserver;
  94071. }());
  94072. /**
  94073. * The Observable class is a simple implementation of the Observable pattern.
  94074. *
  94075. * 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.
  94076. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  94077. * 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).
  94078. * 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.
  94079. */
  94080. var Observable = /** @class */ (function () {
  94081. /**
  94082. * Creates a new observable
  94083. * @param onObserverAdded defines a callback to call when a new observer is added
  94084. */
  94085. function Observable(onObserverAdded) {
  94086. this._observers = new Array();
  94087. this._eventState = new EventState(0);
  94088. if (onObserverAdded) {
  94089. this._onObserverAdded = onObserverAdded;
  94090. }
  94091. }
  94092. /**
  94093. * Create a new Observer with the specified callback
  94094. * @param callback the callback that will be executed for that Observer
  94095. * @param mask the mask used to filter observers
  94096. * @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.
  94097. * @param scope optional scope for the callback to be called from
  94098. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  94099. * @returns the new observer created for the callback
  94100. */
  94101. Observable.prototype.add = function (callback, mask, insertFirst, scope, unregisterOnFirstCall) {
  94102. if (mask === void 0) { mask = -1; }
  94103. if (insertFirst === void 0) { insertFirst = false; }
  94104. if (scope === void 0) { scope = null; }
  94105. if (unregisterOnFirstCall === void 0) { unregisterOnFirstCall = false; }
  94106. if (!callback) {
  94107. return null;
  94108. }
  94109. var observer = new Observer(callback, mask, scope);
  94110. observer.unregisterOnNextCall = unregisterOnFirstCall;
  94111. if (insertFirst) {
  94112. this._observers.unshift(observer);
  94113. }
  94114. else {
  94115. this._observers.push(observer);
  94116. }
  94117. if (this._onObserverAdded) {
  94118. this._onObserverAdded(observer);
  94119. }
  94120. return observer;
  94121. };
  94122. /**
  94123. * Create a new Observer with the specified callback and unregisters after the next notification
  94124. * @param callback the callback that will be executed for that Observer
  94125. * @returns the new observer created for the callback
  94126. */
  94127. Observable.prototype.addOnce = function (callback) {
  94128. return this.add(callback, undefined, undefined, undefined, true);
  94129. };
  94130. /**
  94131. * Remove an Observer from the Observable object
  94132. * @param observer the instance of the Observer to remove
  94133. * @returns false if it doesn't belong to this Observable
  94134. */
  94135. Observable.prototype.remove = function (observer) {
  94136. if (!observer) {
  94137. return false;
  94138. }
  94139. var index = this._observers.indexOf(observer);
  94140. if (index !== -1) {
  94141. this._deferUnregister(observer);
  94142. return true;
  94143. }
  94144. return false;
  94145. };
  94146. /**
  94147. * Remove a callback from the Observable object
  94148. * @param callback the callback to remove
  94149. * @param scope optional scope. If used only the callbacks with this scope will be removed
  94150. * @returns false if it doesn't belong to this Observable
  94151. */
  94152. Observable.prototype.removeCallback = function (callback, scope) {
  94153. for (var index = 0; index < this._observers.length; index++) {
  94154. if (this._observers[index].callback === callback && (!scope || scope === this._observers[index].scope)) {
  94155. this._deferUnregister(this._observers[index]);
  94156. return true;
  94157. }
  94158. }
  94159. return false;
  94160. };
  94161. Observable.prototype._deferUnregister = function (observer) {
  94162. var _this = this;
  94163. observer.unregisterOnNextCall = false;
  94164. observer._willBeUnregistered = true;
  94165. setTimeout(function () {
  94166. _this._remove(observer);
  94167. }, 0);
  94168. };
  94169. // This should only be called when not iterating over _observers to avoid callback skipping.
  94170. // Removes an observer from the _observer Array.
  94171. Observable.prototype._remove = function (observer) {
  94172. if (!observer) {
  94173. return false;
  94174. }
  94175. var index = this._observers.indexOf(observer);
  94176. if (index !== -1) {
  94177. this._observers.splice(index, 1);
  94178. return true;
  94179. }
  94180. return false;
  94181. };
  94182. /**
  94183. * Notify all Observers by calling their respective callback with the given data
  94184. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  94185. * @param eventData defines the data to send to all observers
  94186. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  94187. * @param target defines the original target of the state
  94188. * @param currentTarget defines the current target of the state
  94189. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  94190. */
  94191. Observable.prototype.notifyObservers = function (eventData, mask, target, currentTarget) {
  94192. if (mask === void 0) { mask = -1; }
  94193. if (!this._observers.length) {
  94194. return true;
  94195. }
  94196. var state = this._eventState;
  94197. state.mask = mask;
  94198. state.target = target;
  94199. state.currentTarget = currentTarget;
  94200. state.skipNextObservers = false;
  94201. state.lastReturnValue = eventData;
  94202. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  94203. var obs = _a[_i];
  94204. if (obs._willBeUnregistered) {
  94205. continue;
  94206. }
  94207. if (obs.mask & mask) {
  94208. if (obs.scope) {
  94209. state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);
  94210. }
  94211. else {
  94212. state.lastReturnValue = obs.callback(eventData, state);
  94213. }
  94214. if (obs.unregisterOnNextCall) {
  94215. this._deferUnregister(obs);
  94216. }
  94217. }
  94218. if (state.skipNextObservers) {
  94219. return false;
  94220. }
  94221. }
  94222. return true;
  94223. };
  94224. /**
  94225. * Calling this will execute each callback, expecting it to be a promise or return a value.
  94226. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  94227. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  94228. * and it is crucial that all callbacks will be executed.
  94229. * The order of the callbacks is kept, callbacks are not executed parallel.
  94230. *
  94231. * @param eventData The data to be sent to each callback
  94232. * @param mask is used to filter observers defaults to -1
  94233. * @param target defines the callback target (see EventState)
  94234. * @param currentTarget defines he current object in the bubbling phase
  94235. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  94236. */
  94237. Observable.prototype.notifyObserversWithPromise = function (eventData, mask, target, currentTarget) {
  94238. var _this = this;
  94239. if (mask === void 0) { mask = -1; }
  94240. // create an empty promise
  94241. var p = Promise.resolve(eventData);
  94242. // no observers? return this promise.
  94243. if (!this._observers.length) {
  94244. return p;
  94245. }
  94246. var state = this._eventState;
  94247. state.mask = mask;
  94248. state.target = target;
  94249. state.currentTarget = currentTarget;
  94250. state.skipNextObservers = false;
  94251. // execute one callback after another (not using Promise.all, the order is important)
  94252. this._observers.forEach(function (obs) {
  94253. if (state.skipNextObservers) {
  94254. return;
  94255. }
  94256. if (obs._willBeUnregistered) {
  94257. return;
  94258. }
  94259. if (obs.mask & mask) {
  94260. if (obs.scope) {
  94261. p = p.then(function (lastReturnedValue) {
  94262. state.lastReturnValue = lastReturnedValue;
  94263. return obs.callback.apply(obs.scope, [eventData, state]);
  94264. });
  94265. }
  94266. else {
  94267. p = p.then(function (lastReturnedValue) {
  94268. state.lastReturnValue = lastReturnedValue;
  94269. return obs.callback(eventData, state);
  94270. });
  94271. }
  94272. if (obs.unregisterOnNextCall) {
  94273. _this._deferUnregister(obs);
  94274. }
  94275. }
  94276. });
  94277. // return the eventData
  94278. return p.then(function () { return eventData; });
  94279. };
  94280. /**
  94281. * Notify a specific observer
  94282. * @param observer defines the observer to notify
  94283. * @param eventData defines the data to be sent to each callback
  94284. * @param mask is used to filter observers defaults to -1
  94285. */
  94286. Observable.prototype.notifyObserver = function (observer, eventData, mask) {
  94287. if (mask === void 0) { mask = -1; }
  94288. var state = this._eventState;
  94289. state.mask = mask;
  94290. state.skipNextObservers = false;
  94291. observer.callback(eventData, state);
  94292. };
  94293. /**
  94294. * Gets a boolean indicating if the observable has at least one observer
  94295. * @returns true is the Observable has at least one Observer registered
  94296. */
  94297. Observable.prototype.hasObservers = function () {
  94298. return this._observers.length > 0;
  94299. };
  94300. /**
  94301. * Clear the list of observers
  94302. */
  94303. Observable.prototype.clear = function () {
  94304. this._observers = new Array();
  94305. this._onObserverAdded = null;
  94306. };
  94307. /**
  94308. * Clone the current observable
  94309. * @returns a new observable
  94310. */
  94311. Observable.prototype.clone = function () {
  94312. var result = new Observable();
  94313. result._observers = this._observers.slice(0);
  94314. return result;
  94315. };
  94316. /**
  94317. * Does this observable handles observer registered with a given mask
  94318. * @param mask defines the mask to be tested
  94319. * @return whether or not one observer registered with the given mask is handeled
  94320. **/
  94321. Observable.prototype.hasSpecificMask = function (mask) {
  94322. if (mask === void 0) { mask = -1; }
  94323. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  94324. var obs = _a[_i];
  94325. if (obs.mask & mask || obs.mask === mask) {
  94326. return true;
  94327. }
  94328. }
  94329. return false;
  94330. };
  94331. return Observable;
  94332. }());
  94333. /***/ }),
  94334. /***/ "./Misc/performanceMonitor.ts":
  94335. /*!************************************!*\
  94336. !*** ./Misc/performanceMonitor.ts ***!
  94337. \************************************/
  94338. /*! exports provided: PerformanceMonitor, RollingAverage */
  94339. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94340. "use strict";
  94341. __webpack_require__.r(__webpack_exports__);
  94342. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return PerformanceMonitor; });
  94343. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return RollingAverage; });
  94344. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  94345. /**
  94346. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  94347. */
  94348. var PerformanceMonitor = /** @class */ (function () {
  94349. /**
  94350. * constructor
  94351. * @param frameSampleSize The number of samples required to saturate the sliding window
  94352. */
  94353. function PerformanceMonitor(frameSampleSize) {
  94354. if (frameSampleSize === void 0) { frameSampleSize = 30; }
  94355. this._enabled = true;
  94356. this._rollingFrameTime = new RollingAverage(frameSampleSize);
  94357. }
  94358. /**
  94359. * Samples current frame
  94360. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  94361. */
  94362. PerformanceMonitor.prototype.sampleFrame = function (timeMs) {
  94363. if (timeMs === void 0) { timeMs = _precisionDate__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"].Now; }
  94364. if (!this._enabled) {
  94365. return;
  94366. }
  94367. if (this._lastFrameTimeMs != null) {
  94368. var dt = timeMs - this._lastFrameTimeMs;
  94369. this._rollingFrameTime.add(dt);
  94370. }
  94371. this._lastFrameTimeMs = timeMs;
  94372. };
  94373. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTime", {
  94374. /**
  94375. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  94376. */
  94377. get: function () {
  94378. return this._rollingFrameTime.average;
  94379. },
  94380. enumerable: true,
  94381. configurable: true
  94382. });
  94383. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTimeVariance", {
  94384. /**
  94385. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  94386. */
  94387. get: function () {
  94388. return this._rollingFrameTime.variance;
  94389. },
  94390. enumerable: true,
  94391. configurable: true
  94392. });
  94393. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFrameTime", {
  94394. /**
  94395. * Returns the frame time of the most recent frame
  94396. */
  94397. get: function () {
  94398. return this._rollingFrameTime.history(0);
  94399. },
  94400. enumerable: true,
  94401. configurable: true
  94402. });
  94403. Object.defineProperty(PerformanceMonitor.prototype, "averageFPS", {
  94404. /**
  94405. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  94406. */
  94407. get: function () {
  94408. return 1000.0 / this._rollingFrameTime.average;
  94409. },
  94410. enumerable: true,
  94411. configurable: true
  94412. });
  94413. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFPS", {
  94414. /**
  94415. * Returns the average framerate in frames per second using the most recent frame time
  94416. */
  94417. get: function () {
  94418. var history = this._rollingFrameTime.history(0);
  94419. if (history === 0) {
  94420. return 0;
  94421. }
  94422. return 1000.0 / history;
  94423. },
  94424. enumerable: true,
  94425. configurable: true
  94426. });
  94427. Object.defineProperty(PerformanceMonitor.prototype, "isSaturated", {
  94428. /**
  94429. * Returns true if enough samples have been taken to completely fill the sliding window
  94430. */
  94431. get: function () {
  94432. return this._rollingFrameTime.isSaturated();
  94433. },
  94434. enumerable: true,
  94435. configurable: true
  94436. });
  94437. /**
  94438. * Enables contributions to the sliding window sample set
  94439. */
  94440. PerformanceMonitor.prototype.enable = function () {
  94441. this._enabled = true;
  94442. };
  94443. /**
  94444. * Disables contributions to the sliding window sample set
  94445. * Samples will not be interpolated over the disabled period
  94446. */
  94447. PerformanceMonitor.prototype.disable = function () {
  94448. this._enabled = false;
  94449. //clear last sample to avoid interpolating over the disabled period when next enabled
  94450. this._lastFrameTimeMs = null;
  94451. };
  94452. Object.defineProperty(PerformanceMonitor.prototype, "isEnabled", {
  94453. /**
  94454. * Returns true if sampling is enabled
  94455. */
  94456. get: function () {
  94457. return this._enabled;
  94458. },
  94459. enumerable: true,
  94460. configurable: true
  94461. });
  94462. /**
  94463. * Resets performance monitor
  94464. */
  94465. PerformanceMonitor.prototype.reset = function () {
  94466. //clear last sample to avoid interpolating over the disabled period when next enabled
  94467. this._lastFrameTimeMs = null;
  94468. //wipe record
  94469. this._rollingFrameTime.reset();
  94470. };
  94471. return PerformanceMonitor;
  94472. }());
  94473. /**
  94474. * RollingAverage
  94475. *
  94476. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  94477. */
  94478. var RollingAverage = /** @class */ (function () {
  94479. /**
  94480. * constructor
  94481. * @param length The number of samples required to saturate the sliding window
  94482. */
  94483. function RollingAverage(length) {
  94484. this._samples = new Array(length);
  94485. this.reset();
  94486. }
  94487. /**
  94488. * Adds a sample to the sample set
  94489. * @param v The sample value
  94490. */
  94491. RollingAverage.prototype.add = function (v) {
  94492. //http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
  94493. var delta;
  94494. //we need to check if we've already wrapped round
  94495. if (this.isSaturated()) {
  94496. //remove bottom of stack from mean
  94497. var bottomValue = this._samples[this._pos];
  94498. delta = bottomValue - this.average;
  94499. this.average -= delta / (this._sampleCount - 1);
  94500. this._m2 -= delta * (bottomValue - this.average);
  94501. }
  94502. else {
  94503. this._sampleCount++;
  94504. }
  94505. //add new value to mean
  94506. delta = v - this.average;
  94507. this.average += delta / (this._sampleCount);
  94508. this._m2 += delta * (v - this.average);
  94509. //set the new variance
  94510. this.variance = this._m2 / (this._sampleCount - 1);
  94511. this._samples[this._pos] = v;
  94512. this._pos++;
  94513. this._pos %= this._samples.length; //positive wrap around
  94514. };
  94515. /**
  94516. * Returns previously added values or null if outside of history or outside the sliding window domain
  94517. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  94518. * @return Value previously recorded with add() or null if outside of range
  94519. */
  94520. RollingAverage.prototype.history = function (i) {
  94521. if ((i >= this._sampleCount) || (i >= this._samples.length)) {
  94522. return 0;
  94523. }
  94524. var i0 = this._wrapPosition(this._pos - 1.0);
  94525. return this._samples[this._wrapPosition(i0 - i)];
  94526. };
  94527. /**
  94528. * Returns true if enough samples have been taken to completely fill the sliding window
  94529. * @return true if sample-set saturated
  94530. */
  94531. RollingAverage.prototype.isSaturated = function () {
  94532. return this._sampleCount >= this._samples.length;
  94533. };
  94534. /**
  94535. * Resets the rolling average (equivalent to 0 samples taken so far)
  94536. */
  94537. RollingAverage.prototype.reset = function () {
  94538. this.average = 0;
  94539. this.variance = 0;
  94540. this._sampleCount = 0;
  94541. this._pos = 0;
  94542. this._m2 = 0;
  94543. };
  94544. /**
  94545. * Wraps a value around the sample range boundaries
  94546. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  94547. * @return Wrapped position in sample range
  94548. */
  94549. RollingAverage.prototype._wrapPosition = function (i) {
  94550. var max = this._samples.length;
  94551. return ((i % max) + max) % max;
  94552. };
  94553. return RollingAverage;
  94554. }());
  94555. /***/ }),
  94556. /***/ "./Misc/pivotTools.ts":
  94557. /*!****************************!*\
  94558. !*** ./Misc/pivotTools.ts ***!
  94559. \****************************/
  94560. /*! exports provided: PivotTools */
  94561. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94562. "use strict";
  94563. __webpack_require__.r(__webpack_exports__);
  94564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return PivotTools; });
  94565. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  94566. /**
  94567. * Class containing a set of static utilities functions for managing Pivots
  94568. * @hidden
  94569. */
  94570. var PivotTools = /** @class */ (function () {
  94571. function PivotTools() {
  94572. }
  94573. /** @hidden */
  94574. PivotTools._RemoveAndStorePivotPoint = function (mesh) {
  94575. if (mesh && PivotTools._PivotCached === 0) {
  94576. // Save old pivot and set pivot to 0,0,0
  94577. mesh.getPivotPointToRef(PivotTools._OldPivotPoint);
  94578. if (!PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0)) {
  94579. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityReadOnly);
  94580. PivotTools._OldPivotPoint.subtractToRef(mesh.getPivotPoint(), PivotTools._PivotTranslation);
  94581. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  94582. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  94583. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  94584. mesh.position.addInPlace(PivotTools._PivotTmpVector);
  94585. }
  94586. }
  94587. PivotTools._PivotCached++;
  94588. };
  94589. /** @hidden */
  94590. PivotTools._RestorePivotPoint = function (mesh) {
  94591. if (mesh && !PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0) && PivotTools._PivotCached === 1) {
  94592. mesh.setPivotPoint(PivotTools._OldPivotPoint);
  94593. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  94594. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  94595. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  94596. mesh.position.subtractInPlace(PivotTools._PivotTmpVector);
  94597. }
  94598. this._PivotCached--;
  94599. };
  94600. // Stores the state of the pivot cache (_oldPivotPoint, _pivotTranslation)
  94601. // store/remove pivot point should only be applied during their outermost calls
  94602. PivotTools._PivotCached = 0;
  94603. PivotTools._OldPivotPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  94604. PivotTools._PivotTranslation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  94605. PivotTools._PivotTmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  94606. return PivotTools;
  94607. }());
  94608. /***/ }),
  94609. /***/ "./Misc/precisionDate.ts":
  94610. /*!*******************************!*\
  94611. !*** ./Misc/precisionDate.ts ***!
  94612. \*******************************/
  94613. /*! exports provided: PrecisionDate */
  94614. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94615. "use strict";
  94616. __webpack_require__.r(__webpack_exports__);
  94617. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return PrecisionDate; });
  94618. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  94619. /**
  94620. * Class containing a set of static utilities functions for precision date
  94621. */
  94622. var PrecisionDate = /** @class */ (function () {
  94623. function PrecisionDate() {
  94624. }
  94625. Object.defineProperty(PrecisionDate, "Now", {
  94626. /**
  94627. * Gets either window.performance.now() if supported or Date.now() else
  94628. */
  94629. get: function () {
  94630. if (_domManagement__WEBPACK_IMPORTED_MODULE_0__["DomManagement"].IsWindowObjectExist() && window.performance && window.performance.now) {
  94631. return window.performance.now();
  94632. }
  94633. return Date.now();
  94634. },
  94635. enumerable: true,
  94636. configurable: true
  94637. });
  94638. return PrecisionDate;
  94639. }());
  94640. /***/ }),
  94641. /***/ "./Misc/promise.ts":
  94642. /*!*************************!*\
  94643. !*** ./Misc/promise.ts ***!
  94644. \*************************/
  94645. /*! exports provided: PromisePolyfill */
  94646. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94647. "use strict";
  94648. __webpack_require__.r(__webpack_exports__);
  94649. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return PromisePolyfill; });
  94650. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  94651. var PromiseStates;
  94652. (function (PromiseStates) {
  94653. PromiseStates[PromiseStates["Pending"] = 0] = "Pending";
  94654. PromiseStates[PromiseStates["Fulfilled"] = 1] = "Fulfilled";
  94655. PromiseStates[PromiseStates["Rejected"] = 2] = "Rejected";
  94656. })(PromiseStates || (PromiseStates = {}));
  94657. var FulFillmentAgregator = /** @class */ (function () {
  94658. function FulFillmentAgregator() {
  94659. this.count = 0;
  94660. this.target = 0;
  94661. this.results = [];
  94662. }
  94663. return FulFillmentAgregator;
  94664. }());
  94665. var InternalPromise = /** @class */ (function () {
  94666. function InternalPromise(resolver) {
  94667. var _this = this;
  94668. this._state = PromiseStates.Pending;
  94669. this._children = new Array();
  94670. this._rejectWasConsumed = false;
  94671. if (!resolver) {
  94672. return;
  94673. }
  94674. try {
  94675. resolver(function (value) {
  94676. _this._resolve(value);
  94677. }, function (reason) {
  94678. _this._reject(reason);
  94679. });
  94680. }
  94681. catch (e) {
  94682. this._reject(e);
  94683. }
  94684. }
  94685. Object.defineProperty(InternalPromise.prototype, "_result", {
  94686. get: function () {
  94687. return this._resultValue;
  94688. },
  94689. set: function (value) {
  94690. this._resultValue = value;
  94691. if (this._parent && this._parent._result === undefined) {
  94692. this._parent._result = value;
  94693. }
  94694. },
  94695. enumerable: true,
  94696. configurable: true
  94697. });
  94698. InternalPromise.prototype.catch = function (onRejected) {
  94699. return this.then(undefined, onRejected);
  94700. };
  94701. InternalPromise.prototype.then = function (onFulfilled, onRejected) {
  94702. var _this = this;
  94703. var newPromise = new InternalPromise();
  94704. newPromise._onFulfilled = onFulfilled;
  94705. newPromise._onRejected = onRejected;
  94706. // Composition
  94707. this._children.push(newPromise);
  94708. newPromise._parent = this;
  94709. if (this._state !== PromiseStates.Pending) {
  94710. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  94711. if (_this._state === PromiseStates.Fulfilled || _this._rejectWasConsumed) {
  94712. var returnedValue = newPromise._resolve(_this._result);
  94713. if (returnedValue !== undefined && returnedValue !== null) {
  94714. if (returnedValue._state !== undefined) {
  94715. var returnedPromise = returnedValue;
  94716. newPromise._children.push(returnedPromise);
  94717. returnedPromise._parent = newPromise;
  94718. newPromise = returnedPromise;
  94719. }
  94720. else {
  94721. newPromise._result = returnedValue;
  94722. }
  94723. }
  94724. }
  94725. else {
  94726. newPromise._reject(_this._reason);
  94727. }
  94728. });
  94729. }
  94730. return newPromise;
  94731. };
  94732. InternalPromise.prototype._moveChildren = function (children) {
  94733. var _this = this;
  94734. var _a;
  94735. (_a = this._children).push.apply(_a, children.splice(0, children.length));
  94736. this._children.forEach(function (child) {
  94737. child._parent = _this;
  94738. });
  94739. if (this._state === PromiseStates.Fulfilled) {
  94740. for (var _i = 0, _b = this._children; _i < _b.length; _i++) {
  94741. var child = _b[_i];
  94742. child._resolve(this._result);
  94743. }
  94744. }
  94745. else if (this._state === PromiseStates.Rejected) {
  94746. for (var _c = 0, _d = this._children; _c < _d.length; _c++) {
  94747. var child = _d[_c];
  94748. child._reject(this._reason);
  94749. }
  94750. }
  94751. };
  94752. InternalPromise.prototype._resolve = function (value) {
  94753. try {
  94754. this._state = PromiseStates.Fulfilled;
  94755. var returnedValue = null;
  94756. if (this._onFulfilled) {
  94757. returnedValue = this._onFulfilled(value);
  94758. }
  94759. if (returnedValue !== undefined && returnedValue !== null) {
  94760. if (returnedValue._state !== undefined) {
  94761. // Transmit children
  94762. var returnedPromise = returnedValue;
  94763. returnedPromise._parent = this;
  94764. returnedPromise._moveChildren(this._children);
  94765. value = returnedPromise._result;
  94766. }
  94767. else {
  94768. value = returnedValue;
  94769. }
  94770. }
  94771. this._result = value;
  94772. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  94773. var child = _a[_i];
  94774. child._resolve(value);
  94775. }
  94776. this._children.length = 0;
  94777. delete this._onFulfilled;
  94778. delete this._onRejected;
  94779. }
  94780. catch (e) {
  94781. this._reject(e, true);
  94782. }
  94783. };
  94784. InternalPromise.prototype._reject = function (reason, onLocalThrow) {
  94785. if (onLocalThrow === void 0) { onLocalThrow = false; }
  94786. this._state = PromiseStates.Rejected;
  94787. this._reason = reason;
  94788. if (this._onRejected && !onLocalThrow) {
  94789. try {
  94790. this._onRejected(reason);
  94791. this._rejectWasConsumed = true;
  94792. }
  94793. catch (e) {
  94794. reason = e;
  94795. }
  94796. }
  94797. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  94798. var child = _a[_i];
  94799. if (this._rejectWasConsumed) {
  94800. child._resolve(null);
  94801. }
  94802. else {
  94803. child._reject(reason);
  94804. }
  94805. }
  94806. this._children.length = 0;
  94807. delete this._onFulfilled;
  94808. delete this._onRejected;
  94809. };
  94810. InternalPromise.resolve = function (value) {
  94811. var newPromise = new InternalPromise();
  94812. newPromise._resolve(value);
  94813. return newPromise;
  94814. };
  94815. InternalPromise._RegisterForFulfillment = function (promise, agregator, index) {
  94816. promise.then(function (value) {
  94817. agregator.results[index] = value;
  94818. agregator.count++;
  94819. if (agregator.count === agregator.target) {
  94820. agregator.rootPromise._resolve(agregator.results);
  94821. }
  94822. return null;
  94823. }, function (reason) {
  94824. if (agregator.rootPromise._state !== PromiseStates.Rejected) {
  94825. agregator.rootPromise._reject(reason);
  94826. }
  94827. });
  94828. };
  94829. InternalPromise.all = function (promises) {
  94830. var newPromise = new InternalPromise();
  94831. var agregator = new FulFillmentAgregator();
  94832. agregator.target = promises.length;
  94833. agregator.rootPromise = newPromise;
  94834. if (promises.length) {
  94835. for (var index = 0; index < promises.length; index++) {
  94836. InternalPromise._RegisterForFulfillment(promises[index], agregator, index);
  94837. }
  94838. }
  94839. else {
  94840. newPromise._resolve([]);
  94841. }
  94842. return newPromise;
  94843. };
  94844. InternalPromise.race = function (promises) {
  94845. var newPromise = new InternalPromise();
  94846. if (promises.length) {
  94847. for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) {
  94848. var promise = promises_1[_i];
  94849. promise.then(function (value) {
  94850. if (newPromise) {
  94851. newPromise._resolve(value);
  94852. newPromise = null;
  94853. }
  94854. return null;
  94855. }, function (reason) {
  94856. if (newPromise) {
  94857. newPromise._reject(reason);
  94858. newPromise = null;
  94859. }
  94860. });
  94861. }
  94862. }
  94863. return newPromise;
  94864. };
  94865. return InternalPromise;
  94866. }());
  94867. /**
  94868. * Helper class that provides a small promise polyfill
  94869. */
  94870. var PromisePolyfill = /** @class */ (function () {
  94871. function PromisePolyfill() {
  94872. }
  94873. /**
  94874. * Static function used to check if the polyfill is required
  94875. * If this is the case then the function will inject the polyfill to window.Promise
  94876. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  94877. */
  94878. PromisePolyfill.Apply = function (force) {
  94879. if (force === void 0) { force = false; }
  94880. if (force || typeof Promise === 'undefined') {
  94881. var root = window;
  94882. root.Promise = InternalPromise;
  94883. }
  94884. };
  94885. return PromisePolyfill;
  94886. }());
  94887. /***/ }),
  94888. /***/ "./Misc/sceneOptimizer.ts":
  94889. /*!********************************!*\
  94890. !*** ./Misc/sceneOptimizer.ts ***!
  94891. \********************************/
  94892. /*! exports provided: SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer */
  94893. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94894. "use strict";
  94895. __webpack_require__.r(__webpack_exports__);
  94896. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return SceneOptimization; });
  94897. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return TextureOptimization; });
  94898. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return HardwareScalingOptimization; });
  94899. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return ShadowsOptimization; });
  94900. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return PostProcessesOptimization; });
  94901. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return LensFlaresOptimization; });
  94902. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return CustomOptimization; });
  94903. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return ParticlesOptimization; });
  94904. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return RenderTargetsOptimization; });
  94905. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return MergeMeshesOptimization; });
  94906. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return SceneOptimizerOptions; });
  94907. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return SceneOptimizer; });
  94908. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  94909. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  94910. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  94911. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  94912. /**
  94913. * Defines the root class used to create scene optimization to use with SceneOptimizer
  94914. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  94915. */
  94916. var SceneOptimization = /** @class */ (function () {
  94917. /**
  94918. * Creates the SceneOptimization object
  94919. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  94920. * @param desc defines the description associated with the optimization
  94921. */
  94922. function SceneOptimization(
  94923. /**
  94924. * Defines the priority of this optimization (0 by default which means first in the list)
  94925. */
  94926. priority) {
  94927. if (priority === void 0) { priority = 0; }
  94928. this.priority = priority;
  94929. }
  94930. /**
  94931. * Gets a string describing the action executed by the current optimization
  94932. * @returns description string
  94933. */
  94934. SceneOptimization.prototype.getDescription = function () {
  94935. return "";
  94936. };
  94937. /**
  94938. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  94939. * @param scene defines the current scene where to apply this optimization
  94940. * @param optimizer defines the current optimizer
  94941. * @returns true if everything that can be done was applied
  94942. */
  94943. SceneOptimization.prototype.apply = function (scene, optimizer) {
  94944. return true;
  94945. };
  94946. return SceneOptimization;
  94947. }());
  94948. /**
  94949. * Defines an optimization used to reduce the size of render target textures
  94950. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  94951. */
  94952. var TextureOptimization = /** @class */ (function (_super) {
  94953. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureOptimization, _super);
  94954. /**
  94955. * Creates the TextureOptimization object
  94956. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  94957. * @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
  94958. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  94959. */
  94960. function TextureOptimization(
  94961. /**
  94962. * Defines the priority of this optimization (0 by default which means first in the list)
  94963. */
  94964. priority,
  94965. /**
  94966. * 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
  94967. */
  94968. maximumSize,
  94969. /**
  94970. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  94971. */
  94972. step) {
  94973. if (priority === void 0) { priority = 0; }
  94974. if (maximumSize === void 0) { maximumSize = 1024; }
  94975. if (step === void 0) { step = 0.5; }
  94976. var _this = _super.call(this, priority) || this;
  94977. _this.priority = priority;
  94978. _this.maximumSize = maximumSize;
  94979. _this.step = step;
  94980. return _this;
  94981. }
  94982. /**
  94983. * Gets a string describing the action executed by the current optimization
  94984. * @returns description string
  94985. */
  94986. TextureOptimization.prototype.getDescription = function () {
  94987. return "Reducing render target texture size to " + this.maximumSize;
  94988. };
  94989. /**
  94990. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  94991. * @param scene defines the current scene where to apply this optimization
  94992. * @param optimizer defines the current optimizer
  94993. * @returns true if everything that can be done was applied
  94994. */
  94995. TextureOptimization.prototype.apply = function (scene, optimizer) {
  94996. var allDone = true;
  94997. for (var index = 0; index < scene.textures.length; index++) {
  94998. var texture = scene.textures[index];
  94999. if (!texture.canRescale || texture.getContext) {
  95000. continue;
  95001. }
  95002. var currentSize = texture.getSize();
  95003. var maxDimension = Math.max(currentSize.width, currentSize.height);
  95004. if (maxDimension > this.maximumSize) {
  95005. texture.scale(this.step);
  95006. allDone = false;
  95007. }
  95008. }
  95009. return allDone;
  95010. };
  95011. return TextureOptimization;
  95012. }(SceneOptimization));
  95013. /**
  95014. * Defines an optimization used to increase or decrease the rendering resolution
  95015. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95016. */
  95017. var HardwareScalingOptimization = /** @class */ (function (_super) {
  95018. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HardwareScalingOptimization, _super);
  95019. /**
  95020. * Creates the HardwareScalingOptimization object
  95021. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  95022. * @param maximumScale defines the maximum scale to use (2 by default)
  95023. * @param step defines the step to use between two passes (0.5 by default)
  95024. */
  95025. function HardwareScalingOptimization(
  95026. /**
  95027. * Defines the priority of this optimization (0 by default which means first in the list)
  95028. */
  95029. priority,
  95030. /**
  95031. * Defines the maximum scale to use (2 by default)
  95032. */
  95033. maximumScale,
  95034. /**
  95035. * Defines the step to use between two passes (0.5 by default)
  95036. */
  95037. step) {
  95038. if (priority === void 0) { priority = 0; }
  95039. if (maximumScale === void 0) { maximumScale = 2; }
  95040. if (step === void 0) { step = 0.25; }
  95041. var _this = _super.call(this, priority) || this;
  95042. _this.priority = priority;
  95043. _this.maximumScale = maximumScale;
  95044. _this.step = step;
  95045. _this._currentScale = -1;
  95046. _this._directionOffset = 1;
  95047. return _this;
  95048. }
  95049. /**
  95050. * Gets a string describing the action executed by the current optimization
  95051. * @return description string
  95052. */
  95053. HardwareScalingOptimization.prototype.getDescription = function () {
  95054. return "Setting hardware scaling level to " + this._currentScale;
  95055. };
  95056. /**
  95057. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95058. * @param scene defines the current scene where to apply this optimization
  95059. * @param optimizer defines the current optimizer
  95060. * @returns true if everything that can be done was applied
  95061. */
  95062. HardwareScalingOptimization.prototype.apply = function (scene, optimizer) {
  95063. if (this._currentScale === -1) {
  95064. this._currentScale = scene.getEngine().getHardwareScalingLevel();
  95065. if (this._currentScale > this.maximumScale) {
  95066. this._directionOffset = -1;
  95067. }
  95068. }
  95069. this._currentScale += this._directionOffset * this.step;
  95070. scene.getEngine().setHardwareScalingLevel(this._currentScale);
  95071. return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;
  95072. };
  95073. return HardwareScalingOptimization;
  95074. }(SceneOptimization));
  95075. /**
  95076. * Defines an optimization used to remove shadows
  95077. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95078. */
  95079. var ShadowsOptimization = /** @class */ (function (_super) {
  95080. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowsOptimization, _super);
  95081. function ShadowsOptimization() {
  95082. return _super !== null && _super.apply(this, arguments) || this;
  95083. }
  95084. /**
  95085. * Gets a string describing the action executed by the current optimization
  95086. * @return description string
  95087. */
  95088. ShadowsOptimization.prototype.getDescription = function () {
  95089. return "Turning shadows on/off";
  95090. };
  95091. /**
  95092. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95093. * @param scene defines the current scene where to apply this optimization
  95094. * @param optimizer defines the current optimizer
  95095. * @returns true if everything that can be done was applied
  95096. */
  95097. ShadowsOptimization.prototype.apply = function (scene, optimizer) {
  95098. scene.shadowsEnabled = optimizer.isInImprovementMode;
  95099. return true;
  95100. };
  95101. return ShadowsOptimization;
  95102. }(SceneOptimization));
  95103. /**
  95104. * Defines an optimization used to turn post-processes off
  95105. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95106. */
  95107. var PostProcessesOptimization = /** @class */ (function (_super) {
  95108. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PostProcessesOptimization, _super);
  95109. function PostProcessesOptimization() {
  95110. return _super !== null && _super.apply(this, arguments) || this;
  95111. }
  95112. /**
  95113. * Gets a string describing the action executed by the current optimization
  95114. * @return description string
  95115. */
  95116. PostProcessesOptimization.prototype.getDescription = function () {
  95117. return "Turning post-processes on/off";
  95118. };
  95119. /**
  95120. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95121. * @param scene defines the current scene where to apply this optimization
  95122. * @param optimizer defines the current optimizer
  95123. * @returns true if everything that can be done was applied
  95124. */
  95125. PostProcessesOptimization.prototype.apply = function (scene, optimizer) {
  95126. scene.postProcessesEnabled = optimizer.isInImprovementMode;
  95127. return true;
  95128. };
  95129. return PostProcessesOptimization;
  95130. }(SceneOptimization));
  95131. /**
  95132. * Defines an optimization used to turn lens flares off
  95133. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95134. */
  95135. var LensFlaresOptimization = /** @class */ (function (_super) {
  95136. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensFlaresOptimization, _super);
  95137. function LensFlaresOptimization() {
  95138. return _super !== null && _super.apply(this, arguments) || this;
  95139. }
  95140. /**
  95141. * Gets a string describing the action executed by the current optimization
  95142. * @return description string
  95143. */
  95144. LensFlaresOptimization.prototype.getDescription = function () {
  95145. return "Turning lens flares on/off";
  95146. };
  95147. /**
  95148. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95149. * @param scene defines the current scene where to apply this optimization
  95150. * @param optimizer defines the current optimizer
  95151. * @returns true if everything that can be done was applied
  95152. */
  95153. LensFlaresOptimization.prototype.apply = function (scene, optimizer) {
  95154. scene.lensFlaresEnabled = optimizer.isInImprovementMode;
  95155. return true;
  95156. };
  95157. return LensFlaresOptimization;
  95158. }(SceneOptimization));
  95159. /**
  95160. * Defines an optimization based on user defined callback.
  95161. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95162. */
  95163. var CustomOptimization = /** @class */ (function (_super) {
  95164. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomOptimization, _super);
  95165. function CustomOptimization() {
  95166. return _super !== null && _super.apply(this, arguments) || this;
  95167. }
  95168. /**
  95169. * Gets a string describing the action executed by the current optimization
  95170. * @returns description string
  95171. */
  95172. CustomOptimization.prototype.getDescription = function () {
  95173. if (this.onGetDescription) {
  95174. return this.onGetDescription();
  95175. }
  95176. return "Running user defined callback";
  95177. };
  95178. /**
  95179. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95180. * @param scene defines the current scene where to apply this optimization
  95181. * @param optimizer defines the current optimizer
  95182. * @returns true if everything that can be done was applied
  95183. */
  95184. CustomOptimization.prototype.apply = function (scene, optimizer) {
  95185. if (this.onApply) {
  95186. return this.onApply(scene, optimizer);
  95187. }
  95188. return true;
  95189. };
  95190. return CustomOptimization;
  95191. }(SceneOptimization));
  95192. /**
  95193. * Defines an optimization used to turn particles off
  95194. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95195. */
  95196. var ParticlesOptimization = /** @class */ (function (_super) {
  95197. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticlesOptimization, _super);
  95198. function ParticlesOptimization() {
  95199. return _super !== null && _super.apply(this, arguments) || this;
  95200. }
  95201. /**
  95202. * Gets a string describing the action executed by the current optimization
  95203. * @return description string
  95204. */
  95205. ParticlesOptimization.prototype.getDescription = function () {
  95206. return "Turning particles on/off";
  95207. };
  95208. /**
  95209. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95210. * @param scene defines the current scene where to apply this optimization
  95211. * @param optimizer defines the current optimizer
  95212. * @returns true if everything that can be done was applied
  95213. */
  95214. ParticlesOptimization.prototype.apply = function (scene, optimizer) {
  95215. scene.particlesEnabled = optimizer.isInImprovementMode;
  95216. return true;
  95217. };
  95218. return ParticlesOptimization;
  95219. }(SceneOptimization));
  95220. /**
  95221. * Defines an optimization used to turn render targets off
  95222. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95223. */
  95224. var RenderTargetsOptimization = /** @class */ (function (_super) {
  95225. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetsOptimization, _super);
  95226. function RenderTargetsOptimization() {
  95227. return _super !== null && _super.apply(this, arguments) || this;
  95228. }
  95229. /**
  95230. * Gets a string describing the action executed by the current optimization
  95231. * @return description string
  95232. */
  95233. RenderTargetsOptimization.prototype.getDescription = function () {
  95234. return "Turning render targets off";
  95235. };
  95236. /**
  95237. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95238. * @param scene defines the current scene where to apply this optimization
  95239. * @param optimizer defines the current optimizer
  95240. * @returns true if everything that can be done was applied
  95241. */
  95242. RenderTargetsOptimization.prototype.apply = function (scene, optimizer) {
  95243. scene.renderTargetsEnabled = optimizer.isInImprovementMode;
  95244. return true;
  95245. };
  95246. return RenderTargetsOptimization;
  95247. }(SceneOptimization));
  95248. /**
  95249. * Defines an optimization used to merge meshes with compatible materials
  95250. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95251. */
  95252. var MergeMeshesOptimization = /** @class */ (function (_super) {
  95253. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MergeMeshesOptimization, _super);
  95254. function MergeMeshesOptimization() {
  95255. var _this = _super !== null && _super.apply(this, arguments) || this;
  95256. _this._canBeMerged = function (abstractMesh) {
  95257. if (!(abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"])) {
  95258. return false;
  95259. }
  95260. var mesh = abstractMesh;
  95261. if (mesh.isDisposed()) {
  95262. return false;
  95263. }
  95264. if (!mesh.isVisible || !mesh.isEnabled()) {
  95265. return false;
  95266. }
  95267. if (mesh.instances.length > 0) {
  95268. return false;
  95269. }
  95270. if (mesh.skeleton || mesh.hasLODLevels) {
  95271. return false;
  95272. }
  95273. return true;
  95274. };
  95275. return _this;
  95276. }
  95277. Object.defineProperty(MergeMeshesOptimization, "UpdateSelectionTree", {
  95278. /**
  95279. * Gets or sets a boolean which defines if optimization octree has to be updated
  95280. */
  95281. get: function () {
  95282. return MergeMeshesOptimization._UpdateSelectionTree;
  95283. },
  95284. /**
  95285. * Gets or sets a boolean which defines if optimization octree has to be updated
  95286. */
  95287. set: function (value) {
  95288. MergeMeshesOptimization._UpdateSelectionTree = value;
  95289. },
  95290. enumerable: true,
  95291. configurable: true
  95292. });
  95293. /**
  95294. * Gets a string describing the action executed by the current optimization
  95295. * @return description string
  95296. */
  95297. MergeMeshesOptimization.prototype.getDescription = function () {
  95298. return "Merging similar meshes together";
  95299. };
  95300. /**
  95301. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  95302. * @param scene defines the current scene where to apply this optimization
  95303. * @param optimizer defines the current optimizer
  95304. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  95305. * @returns true if everything that can be done was applied
  95306. */
  95307. MergeMeshesOptimization.prototype.apply = function (scene, optimizer, updateSelectionTree) {
  95308. var globalPool = scene.meshes.slice(0);
  95309. var globalLength = globalPool.length;
  95310. for (var index = 0; index < globalLength; index++) {
  95311. var currentPool = new Array();
  95312. var current = globalPool[index];
  95313. // Checks
  95314. if (!this._canBeMerged(current)) {
  95315. continue;
  95316. }
  95317. currentPool.push(current);
  95318. // Find compatible meshes
  95319. for (var subIndex = index + 1; subIndex < globalLength; subIndex++) {
  95320. var otherMesh = globalPool[subIndex];
  95321. if (!this._canBeMerged(otherMesh)) {
  95322. continue;
  95323. }
  95324. if (otherMesh.material !== current.material) {
  95325. continue;
  95326. }
  95327. if (otherMesh.checkCollisions !== current.checkCollisions) {
  95328. continue;
  95329. }
  95330. currentPool.push(otherMesh);
  95331. globalLength--;
  95332. globalPool.splice(subIndex, 1);
  95333. subIndex--;
  95334. }
  95335. if (currentPool.length < 2) {
  95336. continue;
  95337. }
  95338. // Merge meshes
  95339. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].MergeMeshes(currentPool, undefined, true);
  95340. }
  95341. // Call the octree system optimization if it is defined.
  95342. var sceneAsAny = scene;
  95343. if (sceneAsAny.createOrUpdateSelectionOctree) {
  95344. if (updateSelectionTree != undefined) {
  95345. if (updateSelectionTree) {
  95346. sceneAsAny.createOrUpdateSelectionOctree();
  95347. }
  95348. }
  95349. else if (MergeMeshesOptimization.UpdateSelectionTree) {
  95350. sceneAsAny.createOrUpdateSelectionOctree();
  95351. }
  95352. }
  95353. return true;
  95354. };
  95355. MergeMeshesOptimization._UpdateSelectionTree = false;
  95356. return MergeMeshesOptimization;
  95357. }(SceneOptimization));
  95358. /**
  95359. * Defines a list of options used by SceneOptimizer
  95360. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95361. */
  95362. var SceneOptimizerOptions = /** @class */ (function () {
  95363. /**
  95364. * Creates a new list of options used by SceneOptimizer
  95365. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  95366. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  95367. */
  95368. function SceneOptimizerOptions(
  95369. /**
  95370. * Defines the target frame rate to reach (60 by default)
  95371. */
  95372. targetFrameRate,
  95373. /**
  95374. * Defines the interval between two checkes (2000ms by default)
  95375. */
  95376. trackerDuration) {
  95377. if (targetFrameRate === void 0) { targetFrameRate = 60; }
  95378. if (trackerDuration === void 0) { trackerDuration = 2000; }
  95379. this.targetFrameRate = targetFrameRate;
  95380. this.trackerDuration = trackerDuration;
  95381. /**
  95382. * Gets the list of optimizations to apply
  95383. */
  95384. this.optimizations = new Array();
  95385. }
  95386. /**
  95387. * Add a new optimization
  95388. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  95389. * @returns the current SceneOptimizerOptions
  95390. */
  95391. SceneOptimizerOptions.prototype.addOptimization = function (optimization) {
  95392. this.optimizations.push(optimization);
  95393. return this;
  95394. };
  95395. /**
  95396. * Add a new custom optimization
  95397. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  95398. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  95399. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  95400. * @returns the current SceneOptimizerOptions
  95401. */
  95402. SceneOptimizerOptions.prototype.addCustomOptimization = function (onApply, onGetDescription, priority) {
  95403. if (priority === void 0) { priority = 0; }
  95404. var optimization = new CustomOptimization(priority);
  95405. optimization.onApply = onApply;
  95406. optimization.onGetDescription = onGetDescription;
  95407. this.optimizations.push(optimization);
  95408. return this;
  95409. };
  95410. /**
  95411. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  95412. * @param targetFrameRate defines the target frame rate (60 by default)
  95413. * @returns a SceneOptimizerOptions object
  95414. */
  95415. SceneOptimizerOptions.LowDegradationAllowed = function (targetFrameRate) {
  95416. var result = new SceneOptimizerOptions(targetFrameRate);
  95417. var priority = 0;
  95418. result.addOptimization(new MergeMeshesOptimization(priority));
  95419. result.addOptimization(new ShadowsOptimization(priority));
  95420. result.addOptimization(new LensFlaresOptimization(priority));
  95421. // Next priority
  95422. priority++;
  95423. result.addOptimization(new PostProcessesOptimization(priority));
  95424. result.addOptimization(new ParticlesOptimization(priority));
  95425. // Next priority
  95426. priority++;
  95427. result.addOptimization(new TextureOptimization(priority, 1024));
  95428. return result;
  95429. };
  95430. /**
  95431. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  95432. * @param targetFrameRate defines the target frame rate (60 by default)
  95433. * @returns a SceneOptimizerOptions object
  95434. */
  95435. SceneOptimizerOptions.ModerateDegradationAllowed = function (targetFrameRate) {
  95436. var result = new SceneOptimizerOptions(targetFrameRate);
  95437. var priority = 0;
  95438. result.addOptimization(new MergeMeshesOptimization(priority));
  95439. result.addOptimization(new ShadowsOptimization(priority));
  95440. result.addOptimization(new LensFlaresOptimization(priority));
  95441. // Next priority
  95442. priority++;
  95443. result.addOptimization(new PostProcessesOptimization(priority));
  95444. result.addOptimization(new ParticlesOptimization(priority));
  95445. // Next priority
  95446. priority++;
  95447. result.addOptimization(new TextureOptimization(priority, 512));
  95448. // Next priority
  95449. priority++;
  95450. result.addOptimization(new RenderTargetsOptimization(priority));
  95451. // Next priority
  95452. priority++;
  95453. result.addOptimization(new HardwareScalingOptimization(priority, 2));
  95454. return result;
  95455. };
  95456. /**
  95457. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  95458. * @param targetFrameRate defines the target frame rate (60 by default)
  95459. * @returns a SceneOptimizerOptions object
  95460. */
  95461. SceneOptimizerOptions.HighDegradationAllowed = function (targetFrameRate) {
  95462. var result = new SceneOptimizerOptions(targetFrameRate);
  95463. var priority = 0;
  95464. result.addOptimization(new MergeMeshesOptimization(priority));
  95465. result.addOptimization(new ShadowsOptimization(priority));
  95466. result.addOptimization(new LensFlaresOptimization(priority));
  95467. // Next priority
  95468. priority++;
  95469. result.addOptimization(new PostProcessesOptimization(priority));
  95470. result.addOptimization(new ParticlesOptimization(priority));
  95471. // Next priority
  95472. priority++;
  95473. result.addOptimization(new TextureOptimization(priority, 256));
  95474. // Next priority
  95475. priority++;
  95476. result.addOptimization(new RenderTargetsOptimization(priority));
  95477. // Next priority
  95478. priority++;
  95479. result.addOptimization(new HardwareScalingOptimization(priority, 4));
  95480. return result;
  95481. };
  95482. return SceneOptimizerOptions;
  95483. }());
  95484. /**
  95485. * Class used to run optimizations in order to reach a target frame rate
  95486. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  95487. */
  95488. var SceneOptimizer = /** @class */ (function () {
  95489. /**
  95490. * Creates a new SceneOptimizer
  95491. * @param scene defines the scene to work on
  95492. * @param options defines the options to use with the SceneOptimizer
  95493. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  95494. * @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)
  95495. */
  95496. function SceneOptimizer(scene, options, autoGeneratePriorities, improvementMode) {
  95497. if (autoGeneratePriorities === void 0) { autoGeneratePriorities = true; }
  95498. if (improvementMode === void 0) { improvementMode = false; }
  95499. var _this = this;
  95500. this._isRunning = false;
  95501. this._currentPriorityLevel = 0;
  95502. this._targetFrameRate = 60;
  95503. this._trackerDuration = 2000;
  95504. this._currentFrameRate = 0;
  95505. this._improvementMode = false;
  95506. /**
  95507. * Defines an observable called when the optimizer reaches the target frame rate
  95508. */
  95509. this.onSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  95510. /**
  95511. * Defines an observable called when the optimizer enables an optimization
  95512. */
  95513. this.onNewOptimizationAppliedObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  95514. /**
  95515. * Defines an observable called when the optimizer is not able to reach the target frame rate
  95516. */
  95517. this.onFailureObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  95518. if (!options) {
  95519. this._options = new SceneOptimizerOptions();
  95520. }
  95521. else {
  95522. this._options = options;
  95523. }
  95524. if (this._options.targetFrameRate) {
  95525. this._targetFrameRate = this._options.targetFrameRate;
  95526. }
  95527. if (this._options.trackerDuration) {
  95528. this._trackerDuration = this._options.trackerDuration;
  95529. }
  95530. if (autoGeneratePriorities) {
  95531. var priority = 0;
  95532. for (var _i = 0, _a = this._options.optimizations; _i < _a.length; _i++) {
  95533. var optim = _a[_i];
  95534. optim.priority = priority++;
  95535. }
  95536. }
  95537. this._improvementMode = improvementMode;
  95538. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene;
  95539. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  95540. _this._sceneDisposeObserver = null;
  95541. _this.dispose();
  95542. });
  95543. }
  95544. Object.defineProperty(SceneOptimizer.prototype, "isInImprovementMode", {
  95545. /**
  95546. * Gets a boolean indicating if the optimizer is in improvement mode
  95547. */
  95548. get: function () {
  95549. return this._improvementMode;
  95550. },
  95551. enumerable: true,
  95552. configurable: true
  95553. });
  95554. Object.defineProperty(SceneOptimizer.prototype, "currentPriorityLevel", {
  95555. /**
  95556. * Gets the current priority level (0 at start)
  95557. */
  95558. get: function () {
  95559. return this._currentPriorityLevel;
  95560. },
  95561. enumerable: true,
  95562. configurable: true
  95563. });
  95564. Object.defineProperty(SceneOptimizer.prototype, "currentFrameRate", {
  95565. /**
  95566. * Gets the current frame rate checked by the SceneOptimizer
  95567. */
  95568. get: function () {
  95569. return this._currentFrameRate;
  95570. },
  95571. enumerable: true,
  95572. configurable: true
  95573. });
  95574. Object.defineProperty(SceneOptimizer.prototype, "targetFrameRate", {
  95575. /**
  95576. * Gets or sets the current target frame rate (60 by default)
  95577. */
  95578. get: function () {
  95579. return this._targetFrameRate;
  95580. },
  95581. /**
  95582. * Gets or sets the current target frame rate (60 by default)
  95583. */
  95584. set: function (value) {
  95585. this._targetFrameRate = value;
  95586. },
  95587. enumerable: true,
  95588. configurable: true
  95589. });
  95590. Object.defineProperty(SceneOptimizer.prototype, "trackerDuration", {
  95591. /**
  95592. * Gets or sets the current interval between two checks (every 2000ms by default)
  95593. */
  95594. get: function () {
  95595. return this._trackerDuration;
  95596. },
  95597. /**
  95598. * Gets or sets the current interval between two checks (every 2000ms by default)
  95599. */
  95600. set: function (value) {
  95601. this._trackerDuration = value;
  95602. },
  95603. enumerable: true,
  95604. configurable: true
  95605. });
  95606. Object.defineProperty(SceneOptimizer.prototype, "optimizations", {
  95607. /**
  95608. * Gets the list of active optimizations
  95609. */
  95610. get: function () {
  95611. return this._options.optimizations;
  95612. },
  95613. enumerable: true,
  95614. configurable: true
  95615. });
  95616. /**
  95617. * Stops the current optimizer
  95618. */
  95619. SceneOptimizer.prototype.stop = function () {
  95620. this._isRunning = false;
  95621. };
  95622. /**
  95623. * Reset the optimizer to initial step (current priority level = 0)
  95624. */
  95625. SceneOptimizer.prototype.reset = function () {
  95626. this._currentPriorityLevel = 0;
  95627. };
  95628. /**
  95629. * Start the optimizer. By default it will try to reach a specific framerate
  95630. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  95631. */
  95632. SceneOptimizer.prototype.start = function () {
  95633. var _this = this;
  95634. if (this._isRunning) {
  95635. return;
  95636. }
  95637. this._isRunning = true;
  95638. // Let's wait for the scene to be ready before running our check
  95639. this._scene.executeWhenReady(function () {
  95640. setTimeout(function () {
  95641. _this._checkCurrentState();
  95642. }, _this._trackerDuration);
  95643. });
  95644. };
  95645. SceneOptimizer.prototype._checkCurrentState = function () {
  95646. var _this = this;
  95647. if (!this._isRunning) {
  95648. return;
  95649. }
  95650. var scene = this._scene;
  95651. var options = this._options;
  95652. this._currentFrameRate = Math.round(scene.getEngine().getFps());
  95653. if (this._improvementMode && this._currentFrameRate <= this._targetFrameRate ||
  95654. !this._improvementMode && this._currentFrameRate >= this._targetFrameRate) {
  95655. this._isRunning = false;
  95656. this.onSuccessObservable.notifyObservers(this);
  95657. return;
  95658. }
  95659. // Apply current level of optimizations
  95660. var allDone = true;
  95661. var noOptimizationApplied = true;
  95662. for (var index = 0; index < options.optimizations.length; index++) {
  95663. var optimization = options.optimizations[index];
  95664. if (optimization.priority === this._currentPriorityLevel) {
  95665. noOptimizationApplied = false;
  95666. allDone = allDone && optimization.apply(scene, this);
  95667. this.onNewOptimizationAppliedObservable.notifyObservers(optimization);
  95668. }
  95669. }
  95670. // If no optimization was applied, this is a failure :(
  95671. if (noOptimizationApplied) {
  95672. this._isRunning = false;
  95673. this.onFailureObservable.notifyObservers(this);
  95674. return;
  95675. }
  95676. // If all optimizations were done, move to next level
  95677. if (allDone) {
  95678. this._currentPriorityLevel++;
  95679. }
  95680. // Let's the system running for a specific amount of time before checking FPS
  95681. scene.executeWhenReady(function () {
  95682. setTimeout(function () {
  95683. _this._checkCurrentState();
  95684. }, _this._trackerDuration);
  95685. });
  95686. };
  95687. /**
  95688. * Release all resources
  95689. */
  95690. SceneOptimizer.prototype.dispose = function () {
  95691. this.stop();
  95692. this.onSuccessObservable.clear();
  95693. this.onFailureObservable.clear();
  95694. this.onNewOptimizationAppliedObservable.clear();
  95695. if (this._sceneDisposeObserver) {
  95696. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  95697. }
  95698. };
  95699. /**
  95700. * Helper function to create a SceneOptimizer with one single line of code
  95701. * @param scene defines the scene to work on
  95702. * @param options defines the options to use with the SceneOptimizer
  95703. * @param onSuccess defines a callback to call on success
  95704. * @param onFailure defines a callback to call on failure
  95705. * @returns the new SceneOptimizer object
  95706. */
  95707. SceneOptimizer.OptimizeAsync = function (scene, options, onSuccess, onFailure) {
  95708. var optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);
  95709. if (onSuccess) {
  95710. optimizer.onSuccessObservable.add(function () {
  95711. onSuccess();
  95712. });
  95713. }
  95714. if (onFailure) {
  95715. optimizer.onFailureObservable.add(function () {
  95716. onFailure();
  95717. });
  95718. }
  95719. optimizer.start();
  95720. return optimizer;
  95721. };
  95722. return SceneOptimizer;
  95723. }());
  95724. /***/ }),
  95725. /***/ "./Misc/sceneSerializer.ts":
  95726. /*!*********************************!*\
  95727. !*** ./Misc/sceneSerializer.ts ***!
  95728. \*********************************/
  95729. /*! exports provided: SceneSerializer */
  95730. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95731. "use strict";
  95732. __webpack_require__.r(__webpack_exports__);
  95733. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return SceneSerializer; });
  95734. /* harmony import */ var _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/geometry */ "./Meshes/geometry.ts");
  95735. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  95736. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  95737. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  95738. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  95739. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  95740. var serializedGeometries = [];
  95741. var serializeGeometry = function (geometry, serializationGeometries) {
  95742. if (serializedGeometries[geometry.id]) {
  95743. return;
  95744. }
  95745. if (geometry.doNotSerialize) {
  95746. return;
  95747. }
  95748. if (geometry instanceof _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__["BoxGeometry"]) {
  95749. serializationGeometries.boxes.push(geometry.serialize());
  95750. }
  95751. else if (geometry instanceof _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__["SphereGeometry"]) {
  95752. serializationGeometries.spheres.push(geometry.serialize());
  95753. }
  95754. else if (geometry instanceof _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__["CylinderGeometry"]) {
  95755. serializationGeometries.cylinders.push(geometry.serialize());
  95756. }
  95757. else if (geometry instanceof _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__["TorusGeometry"]) {
  95758. serializationGeometries.toruses.push(geometry.serialize());
  95759. }
  95760. else if (geometry instanceof _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__["GroundGeometry"]) {
  95761. serializationGeometries.grounds.push(geometry.serialize());
  95762. }
  95763. else if (geometry instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Plane"]) {
  95764. serializationGeometries.planes.push(geometry.serialize());
  95765. }
  95766. else if (geometry instanceof _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__["TorusKnotGeometry"]) {
  95767. serializationGeometries.torusKnots.push(geometry.serialize());
  95768. }
  95769. else if (geometry instanceof _Meshes_geometry__WEBPACK_IMPORTED_MODULE_0__["_PrimitiveGeometry"]) {
  95770. throw new Error("Unknown primitive type");
  95771. }
  95772. else {
  95773. serializationGeometries.vertexData.push(geometry.serializeVerticeData());
  95774. }
  95775. serializedGeometries[geometry.id] = true;
  95776. };
  95777. var serializeMesh = function (mesh, serializationScene) {
  95778. var serializationObject = {};
  95779. // Geometry
  95780. var geometry = mesh._geometry;
  95781. if (geometry) {
  95782. if (!mesh.getScene().getGeometryByID(geometry.id)) {
  95783. // 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
  95784. serializeGeometry(geometry, serializationScene.geometries);
  95785. }
  95786. }
  95787. // Custom
  95788. if (mesh.serialize) {
  95789. mesh.serialize(serializationObject);
  95790. }
  95791. return serializationObject;
  95792. };
  95793. var finalizeSingleMesh = function (mesh, serializationObject) {
  95794. //only works if the mesh is already loaded
  95795. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NONE) {
  95796. //serialize material
  95797. if (mesh.material) {
  95798. if (mesh.material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_4__["MultiMaterial"]) {
  95799. serializationObject.multiMaterials = serializationObject.multiMaterials || [];
  95800. serializationObject.materials = serializationObject.materials || [];
  95801. if (!serializationObject.multiMaterials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  95802. serializationObject.multiMaterials.push(mesh.material.serialize());
  95803. var _loop_1 = function (submaterial) {
  95804. if (submaterial) {
  95805. if (!serializationObject.materials.some(function (mat) { return (mat.id === submaterial.id); })) {
  95806. serializationObject.materials.push(submaterial.serialize());
  95807. }
  95808. }
  95809. };
  95810. for (var _i = 0, _a = mesh.material.subMaterials; _i < _a.length; _i++) {
  95811. var submaterial = _a[_i];
  95812. _loop_1(submaterial);
  95813. }
  95814. }
  95815. }
  95816. else {
  95817. serializationObject.materials = serializationObject.materials || [];
  95818. if (!serializationObject.materials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  95819. serializationObject.materials.push(mesh.material.serialize());
  95820. }
  95821. }
  95822. }
  95823. //serialize geometry
  95824. var geometry = mesh._geometry;
  95825. if (geometry) {
  95826. if (!serializationObject.geometries) {
  95827. serializationObject.geometries = {};
  95828. serializationObject.geometries.boxes = [];
  95829. serializationObject.geometries.spheres = [];
  95830. serializationObject.geometries.cylinders = [];
  95831. serializationObject.geometries.toruses = [];
  95832. serializationObject.geometries.grounds = [];
  95833. serializationObject.geometries.planes = [];
  95834. serializationObject.geometries.torusKnots = [];
  95835. serializationObject.geometries.vertexData = [];
  95836. }
  95837. serializeGeometry(geometry, serializationObject.geometries);
  95838. }
  95839. // Skeletons
  95840. if (mesh.skeleton) {
  95841. serializationObject.skeletons = serializationObject.skeletons || [];
  95842. serializationObject.skeletons.push(mesh.skeleton.serialize());
  95843. }
  95844. //serialize the actual mesh
  95845. serializationObject.meshes = serializationObject.meshes || [];
  95846. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  95847. }
  95848. };
  95849. /**
  95850. * Class used to serialize a scene into a string
  95851. */
  95852. var SceneSerializer = /** @class */ (function () {
  95853. function SceneSerializer() {
  95854. }
  95855. /**
  95856. * Clear cache used by a previous serialization
  95857. */
  95858. SceneSerializer.ClearCache = function () {
  95859. serializedGeometries = [];
  95860. };
  95861. /**
  95862. * Serialize a scene into a JSON compatible object
  95863. * @param scene defines the scene to serialize
  95864. * @returns a JSON compatible object
  95865. */
  95866. SceneSerializer.Serialize = function (scene) {
  95867. var serializationObject = {};
  95868. SceneSerializer.ClearCache();
  95869. // Scene
  95870. serializationObject.useDelayedTextureLoading = scene.useDelayedTextureLoading;
  95871. serializationObject.autoClear = scene.autoClear;
  95872. serializationObject.clearColor = scene.clearColor.asArray();
  95873. serializationObject.ambientColor = scene.ambientColor.asArray();
  95874. serializationObject.gravity = scene.gravity.asArray();
  95875. serializationObject.collisionsEnabled = scene.collisionsEnabled;
  95876. // Fog
  95877. if (scene.fogMode && scene.fogMode !== 0) {
  95878. serializationObject.fogMode = scene.fogMode;
  95879. serializationObject.fogColor = scene.fogColor.asArray();
  95880. serializationObject.fogStart = scene.fogStart;
  95881. serializationObject.fogEnd = scene.fogEnd;
  95882. serializationObject.fogDensity = scene.fogDensity;
  95883. }
  95884. //Physics
  95885. if (scene.isPhysicsEnabled()) {
  95886. var physicEngine = scene.getPhysicsEngine();
  95887. if (physicEngine) {
  95888. serializationObject.physicsEnabled = true;
  95889. serializationObject.physicsGravity = physicEngine.gravity.asArray();
  95890. serializationObject.physicsEngine = physicEngine.getPhysicsPluginName();
  95891. }
  95892. }
  95893. // Metadata
  95894. if (scene.metadata) {
  95895. serializationObject.metadata = scene.metadata;
  95896. }
  95897. // Morph targets
  95898. serializationObject.morphTargetManagers = [];
  95899. for (var _i = 0, _a = scene.meshes; _i < _a.length; _i++) {
  95900. var abstractMesh = _a[_i];
  95901. var manager = abstractMesh.morphTargetManager;
  95902. if (manager) {
  95903. serializationObject.morphTargetManagers.push(manager.serialize());
  95904. }
  95905. }
  95906. // Lights
  95907. serializationObject.lights = [];
  95908. var index;
  95909. var light;
  95910. for (index = 0; index < scene.lights.length; index++) {
  95911. light = scene.lights[index];
  95912. if (!light.doNotSerialize) {
  95913. serializationObject.lights.push(light.serialize());
  95914. }
  95915. }
  95916. // Cameras
  95917. serializationObject.cameras = [];
  95918. for (index = 0; index < scene.cameras.length; index++) {
  95919. var camera = scene.cameras[index];
  95920. if (!camera.doNotSerialize) {
  95921. serializationObject.cameras.push(camera.serialize());
  95922. }
  95923. }
  95924. if (scene.activeCamera) {
  95925. serializationObject.activeCameraID = scene.activeCamera.id;
  95926. }
  95927. // Animations
  95928. _decorators__WEBPACK_IMPORTED_MODULE_5__["SerializationHelper"].AppendSerializedAnimations(scene, serializationObject);
  95929. // Reflection probes
  95930. if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
  95931. serializationObject.reflectionProbes = [];
  95932. for (index = 0; index < scene.reflectionProbes.length; index++) {
  95933. var reflectionProbe = scene.reflectionProbes[index];
  95934. serializationObject.reflectionProbes.push(reflectionProbe.serialize());
  95935. }
  95936. }
  95937. // Materials
  95938. serializationObject.materials = [];
  95939. serializationObject.multiMaterials = [];
  95940. var material;
  95941. for (index = 0; index < scene.materials.length; index++) {
  95942. material = scene.materials[index];
  95943. if (!material.doNotSerialize) {
  95944. serializationObject.materials.push(material.serialize());
  95945. }
  95946. }
  95947. // MultiMaterials
  95948. serializationObject.multiMaterials = [];
  95949. for (index = 0; index < scene.multiMaterials.length; index++) {
  95950. var multiMaterial = scene.multiMaterials[index];
  95951. serializationObject.multiMaterials.push(multiMaterial.serialize());
  95952. }
  95953. // Environment texture
  95954. if (scene.environmentTexture) {
  95955. serializationObject.environmentTexture = scene.environmentTexture.name;
  95956. }
  95957. // Skeletons
  95958. serializationObject.skeletons = [];
  95959. for (index = 0; index < scene.skeletons.length; index++) {
  95960. var skeleton = scene.skeletons[index];
  95961. if (!skeleton.doNotSerialize) {
  95962. serializationObject.skeletons.push(skeleton.serialize());
  95963. }
  95964. }
  95965. // Transform nodes
  95966. serializationObject.transformNodes = [];
  95967. for (index = 0; index < scene.transformNodes.length; index++) {
  95968. serializationObject.transformNodes.push(scene.transformNodes[index].serialize());
  95969. }
  95970. // Geometries
  95971. serializationObject.geometries = {};
  95972. serializationObject.geometries.boxes = [];
  95973. serializationObject.geometries.spheres = [];
  95974. serializationObject.geometries.cylinders = [];
  95975. serializationObject.geometries.toruses = [];
  95976. serializationObject.geometries.grounds = [];
  95977. serializationObject.geometries.planes = [];
  95978. serializationObject.geometries.torusKnots = [];
  95979. serializationObject.geometries.vertexData = [];
  95980. serializedGeometries = [];
  95981. var geometries = scene.getGeometries();
  95982. for (index = 0; index < geometries.length; index++) {
  95983. var geometry = geometries[index];
  95984. if (geometry.isReady()) {
  95985. serializeGeometry(geometry, serializationObject.geometries);
  95986. }
  95987. }
  95988. // Meshes
  95989. serializationObject.meshes = [];
  95990. for (index = 0; index < scene.meshes.length; index++) {
  95991. var abstractMesh = scene.meshes[index];
  95992. if (abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]) {
  95993. var mesh = abstractMesh;
  95994. if (!mesh.doNotSerialize) {
  95995. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NONE) {
  95996. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  95997. }
  95998. }
  95999. }
  96000. }
  96001. // Particles Systems
  96002. serializationObject.particleSystems = [];
  96003. for (index = 0; index < scene.particleSystems.length; index++) {
  96004. serializationObject.particleSystems.push(scene.particleSystems[index].serialize());
  96005. }
  96006. // Action Manager
  96007. if (scene.actionManager) {
  96008. serializationObject.actions = scene.actionManager.serialize("scene");
  96009. }
  96010. // Components
  96011. for (var _b = 0, _c = scene._serializableComponents; _b < _c.length; _b++) {
  96012. var component = _c[_b];
  96013. component.serialize(serializationObject);
  96014. }
  96015. return serializationObject;
  96016. };
  96017. /**
  96018. * Serialize a mesh into a JSON compatible object
  96019. * @param toSerialize defines the mesh to serialize
  96020. * @param withParents defines if parents must be serialized as well
  96021. * @param withChildren defines if children must be serialized as well
  96022. * @returns a JSON compatible object
  96023. */
  96024. SceneSerializer.SerializeMesh = function (toSerialize /* Mesh || Mesh[] */, withParents, withChildren) {
  96025. if (withParents === void 0) { withParents = false; }
  96026. if (withChildren === void 0) { withChildren = false; }
  96027. var serializationObject = {};
  96028. SceneSerializer.ClearCache();
  96029. toSerialize = (toSerialize instanceof Array) ? toSerialize : [toSerialize];
  96030. if (withParents || withChildren) {
  96031. //deliberate for loop! not for each, appended should be processed as well.
  96032. for (var i = 0; i < toSerialize.length; ++i) {
  96033. if (withChildren) {
  96034. toSerialize[i].getDescendants().forEach(function (node) {
  96035. if (node instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"] && (toSerialize.indexOf(node) < 0)) {
  96036. toSerialize.push(node);
  96037. }
  96038. });
  96039. }
  96040. //make sure the array doesn't contain the object already
  96041. if (withParents && toSerialize[i].parent && (toSerialize.indexOf(toSerialize[i].parent) < 0)) {
  96042. toSerialize.push(toSerialize[i].parent);
  96043. }
  96044. }
  96045. }
  96046. toSerialize.forEach(function (mesh) {
  96047. finalizeSingleMesh(mesh, serializationObject);
  96048. });
  96049. return serializationObject;
  96050. };
  96051. return SceneSerializer;
  96052. }());
  96053. /***/ }),
  96054. /***/ "./Misc/screenshotTools.ts":
  96055. /*!*********************************!*\
  96056. !*** ./Misc/screenshotTools.ts ***!
  96057. \*********************************/
  96058. /*! exports provided: ScreenshotTools */
  96059. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96060. "use strict";
  96061. __webpack_require__.r(__webpack_exports__);
  96062. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return ScreenshotTools; });
  96063. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  96064. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  96065. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  96066. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  96067. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  96068. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  96069. // Screenshots
  96070. var screenshotCanvas;
  96071. /**
  96072. * Class containing a set of static utilities functions for screenshots
  96073. */
  96074. var ScreenshotTools = /** @class */ (function () {
  96075. function ScreenshotTools() {
  96076. }
  96077. /**
  96078. * Captures a screenshot of the current rendering
  96079. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96080. * @param engine defines the rendering engine
  96081. * @param camera defines the source camera
  96082. * @param size This parameter can be set to a single number or to an object with the
  96083. * following (optional) properties: precision, width, height. If a single number is passed,
  96084. * it will be used for both width and height. If an object is passed, the screenshot size
  96085. * will be derived from the parameters. The precision property is a multiplier allowing
  96086. * rendering at a higher or lower resolution
  96087. * @param successCallback defines the callback receives a single parameter which contains the
  96088. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96089. * src parameter of an <img> to display it
  96090. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  96091. * Check your browser for supported MIME types
  96092. */
  96093. ScreenshotTools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  96094. if (mimeType === void 0) { mimeType = "image/png"; }
  96095. var width;
  96096. var height;
  96097. // If a precision value is specified
  96098. if (size.precision) {
  96099. width = Math.round(engine.getRenderWidth() * size.precision);
  96100. height = Math.round(width / engine.getAspectRatio(camera));
  96101. }
  96102. else if (size.width && size.height) {
  96103. width = size.width;
  96104. height = size.height;
  96105. }
  96106. //If passing only width, computing height to keep display canvas ratio.
  96107. else if (size.width && !size.height) {
  96108. width = size.width;
  96109. height = Math.round(width / engine.getAspectRatio(camera));
  96110. }
  96111. //If passing only height, computing width to keep display canvas ratio.
  96112. else if (size.height && !size.width) {
  96113. height = size.height;
  96114. width = Math.round(height * engine.getAspectRatio(camera));
  96115. }
  96116. //Assuming here that "size" parameter is a number
  96117. else if (!isNaN(size)) {
  96118. height = size;
  96119. width = size;
  96120. }
  96121. else {
  96122. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  96123. return;
  96124. }
  96125. if (!screenshotCanvas) {
  96126. screenshotCanvas = document.createElement('canvas');
  96127. }
  96128. screenshotCanvas.width = width;
  96129. screenshotCanvas.height = height;
  96130. var renderContext = screenshotCanvas.getContext("2d");
  96131. var ratio = engine.getRenderWidth() / engine.getRenderHeight();
  96132. var newWidth = width;
  96133. var newHeight = newWidth / ratio;
  96134. if (newHeight > height) {
  96135. newHeight = height;
  96136. newWidth = newHeight * ratio;
  96137. }
  96138. var offsetX = Math.max(0, width - newWidth) / 2;
  96139. var offsetY = Math.max(0, height - newHeight) / 2;
  96140. var renderingCanvas = engine.getRenderingCanvas();
  96141. if (renderContext && renderingCanvas) {
  96142. renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);
  96143. }
  96144. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].EncodeScreenshotCanvasData(successCallback, mimeType);
  96145. };
  96146. /**
  96147. * Generates an image screenshot from the specified camera.
  96148. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96149. * @param engine The engine to use for rendering
  96150. * @param camera The camera to use for rendering
  96151. * @param size This parameter can be set to a single number or to an object with the
  96152. * following (optional) properties: precision, width, height. If a single number is passed,
  96153. * it will be used for both width and height. If an object is passed, the screenshot size
  96154. * will be derived from the parameters. The precision property is a multiplier allowing
  96155. * rendering at a higher or lower resolution
  96156. * @param successCallback The callback receives a single parameter which contains the
  96157. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96158. * src parameter of an <img> to display it
  96159. * @param mimeType The MIME type of the screenshot image (default: image/png).
  96160. * Check your browser for supported MIME types
  96161. * @param samples Texture samples (default: 1)
  96162. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  96163. * @param fileName A name for for the downloaded file.
  96164. */
  96165. ScreenshotTools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  96166. if (mimeType === void 0) { mimeType = "image/png"; }
  96167. if (samples === void 0) { samples = 1; }
  96168. if (antialiasing === void 0) { antialiasing = false; }
  96169. var width;
  96170. var height;
  96171. //If a precision value is specified
  96172. if (size.precision) {
  96173. width = Math.round(engine.getRenderWidth() * size.precision);
  96174. height = Math.round(width / engine.getAspectRatio(camera));
  96175. size = { width: width, height: height };
  96176. }
  96177. else if (size.width && size.height) {
  96178. width = size.width;
  96179. height = size.height;
  96180. }
  96181. //If passing only width, computing height to keep display canvas ratio.
  96182. else if (size.width && !size.height) {
  96183. width = size.width;
  96184. height = Math.round(width / engine.getAspectRatio(camera));
  96185. size = { width: width, height: height };
  96186. }
  96187. //If passing only height, computing width to keep display canvas ratio.
  96188. else if (size.height && !size.width) {
  96189. height = size.height;
  96190. width = Math.round(height * engine.getAspectRatio(camera));
  96191. size = { width: width, height: height };
  96192. }
  96193. //Assuming here that "size" parameter is a number
  96194. else if (!isNaN(size)) {
  96195. height = size;
  96196. width = size;
  96197. }
  96198. else {
  96199. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  96200. return;
  96201. }
  96202. var scene = camera.getScene();
  96203. var previousCamera = null;
  96204. if (scene.activeCamera !== camera) {
  96205. previousCamera = scene.activeCamera;
  96206. scene.activeCamera = camera;
  96207. }
  96208. var renderCanvas = engine.getRenderingCanvas();
  96209. if (!renderCanvas) {
  96210. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("No rendering canvas found !");
  96211. return;
  96212. }
  96213. var originalSize = { width: renderCanvas.width, height: renderCanvas.height };
  96214. engine.setSize(width, height);
  96215. scene.render();
  96216. // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)
  96217. 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);
  96218. texture.renderList = null;
  96219. texture.samples = samples;
  96220. if (antialiasing) {
  96221. texture.addPostProcess(new _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__["FxaaPostProcess"]('antialiasing', 1.0, scene.activeCamera));
  96222. }
  96223. texture.onAfterRenderObservable.add(function () {
  96224. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].DumpFramebuffer(width, height, engine, successCallback, mimeType, fileName);
  96225. });
  96226. scene.incrementRenderId();
  96227. scene.resetCachedMaterial();
  96228. texture.render(true);
  96229. texture.dispose();
  96230. if (previousCamera) {
  96231. scene.activeCamera = previousCamera;
  96232. }
  96233. engine.setSize(originalSize.width, originalSize.height);
  96234. camera.getProjectionMatrix(true); // Force cache refresh;
  96235. };
  96236. return ScreenshotTools;
  96237. }());
  96238. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshot = ScreenshotTools.CreateScreenshot;
  96239. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshotUsingRenderTarget = ScreenshotTools.CreateScreenshotUsingRenderTarget;
  96240. /***/ }),
  96241. /***/ "./Misc/smartArray.ts":
  96242. /*!****************************!*\
  96243. !*** ./Misc/smartArray.ts ***!
  96244. \****************************/
  96245. /*! exports provided: SmartArray, SmartArrayNoDuplicate */
  96246. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96247. "use strict";
  96248. __webpack_require__.r(__webpack_exports__);
  96249. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return SmartArray; });
  96250. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return SmartArrayNoDuplicate; });
  96251. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  96252. /**
  96253. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  96254. */
  96255. var SmartArray = /** @class */ (function () {
  96256. /**
  96257. * Instantiates a Smart Array.
  96258. * @param capacity defines the default capacity of the array.
  96259. */
  96260. function SmartArray(capacity) {
  96261. /**
  96262. * The active length of the array.
  96263. */
  96264. this.length = 0;
  96265. this.data = new Array(capacity);
  96266. this._id = SmartArray._GlobalId++;
  96267. }
  96268. /**
  96269. * Pushes a value at the end of the active data.
  96270. * @param value defines the object to push in the array.
  96271. */
  96272. SmartArray.prototype.push = function (value) {
  96273. this.data[this.length++] = value;
  96274. if (this.length > this.data.length) {
  96275. this.data.length *= 2;
  96276. }
  96277. };
  96278. /**
  96279. * Iterates over the active data and apply the lambda to them.
  96280. * @param func defines the action to apply on each value.
  96281. */
  96282. SmartArray.prototype.forEach = function (func) {
  96283. for (var index = 0; index < this.length; index++) {
  96284. func(this.data[index]);
  96285. }
  96286. };
  96287. /**
  96288. * Sorts the full sets of data.
  96289. * @param compareFn defines the comparison function to apply.
  96290. */
  96291. SmartArray.prototype.sort = function (compareFn) {
  96292. this.data.sort(compareFn);
  96293. };
  96294. /**
  96295. * Resets the active data to an empty array.
  96296. */
  96297. SmartArray.prototype.reset = function () {
  96298. this.length = 0;
  96299. };
  96300. /**
  96301. * Releases all the data from the array as well as the array.
  96302. */
  96303. SmartArray.prototype.dispose = function () {
  96304. this.reset();
  96305. if (this.data) {
  96306. this.data.length = 0;
  96307. this.data = [];
  96308. }
  96309. };
  96310. /**
  96311. * Concats the active data with a given array.
  96312. * @param array defines the data to concatenate with.
  96313. */
  96314. SmartArray.prototype.concat = function (array) {
  96315. if (array.length === 0) {
  96316. return;
  96317. }
  96318. if (this.length + array.length > this.data.length) {
  96319. this.data.length = (this.length + array.length) * 2;
  96320. }
  96321. for (var index = 0; index < array.length; index++) {
  96322. this.data[this.length++] = (array.data || array)[index];
  96323. }
  96324. };
  96325. /**
  96326. * Returns the position of a value in the active data.
  96327. * @param value defines the value to find the index for
  96328. * @returns the index if found in the active data otherwise -1
  96329. */
  96330. SmartArray.prototype.indexOf = function (value) {
  96331. var position = this.data.indexOf(value);
  96332. if (position >= this.length) {
  96333. return -1;
  96334. }
  96335. return position;
  96336. };
  96337. /**
  96338. * Returns whether an element is part of the active data.
  96339. * @param value defines the value to look for
  96340. * @returns true if found in the active data otherwise false
  96341. */
  96342. SmartArray.prototype.contains = function (value) {
  96343. return this.indexOf(value) !== -1;
  96344. };
  96345. // Statics
  96346. SmartArray._GlobalId = 0;
  96347. return SmartArray;
  96348. }());
  96349. /**
  96350. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  96351. * The data in this array can only be present once
  96352. */
  96353. var SmartArrayNoDuplicate = /** @class */ (function (_super) {
  96354. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SmartArrayNoDuplicate, _super);
  96355. function SmartArrayNoDuplicate() {
  96356. var _this = _super !== null && _super.apply(this, arguments) || this;
  96357. _this._duplicateId = 0;
  96358. return _this;
  96359. }
  96360. /**
  96361. * Pushes a value at the end of the active data.
  96362. * THIS DOES NOT PREVENT DUPPLICATE DATA
  96363. * @param value defines the object to push in the array.
  96364. */
  96365. SmartArrayNoDuplicate.prototype.push = function (value) {
  96366. _super.prototype.push.call(this, value);
  96367. if (!value.__smartArrayFlags) {
  96368. value.__smartArrayFlags = {};
  96369. }
  96370. value.__smartArrayFlags[this._id] = this._duplicateId;
  96371. };
  96372. /**
  96373. * Pushes a value at the end of the active data.
  96374. * If the data is already present, it won t be added again
  96375. * @param value defines the object to push in the array.
  96376. * @returns true if added false if it was already present
  96377. */
  96378. SmartArrayNoDuplicate.prototype.pushNoDuplicate = function (value) {
  96379. if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
  96380. return false;
  96381. }
  96382. this.push(value);
  96383. return true;
  96384. };
  96385. /**
  96386. * Resets the active data to an empty array.
  96387. */
  96388. SmartArrayNoDuplicate.prototype.reset = function () {
  96389. _super.prototype.reset.call(this);
  96390. this._duplicateId++;
  96391. };
  96392. /**
  96393. * Concats the active data with a given array.
  96394. * This ensures no dupplicate will be present in the result.
  96395. * @param array defines the data to concatenate with.
  96396. */
  96397. SmartArrayNoDuplicate.prototype.concatWithNoDuplicate = function (array) {
  96398. if (array.length === 0) {
  96399. return;
  96400. }
  96401. if (this.length + array.length > this.data.length) {
  96402. this.data.length = (this.length + array.length) * 2;
  96403. }
  96404. for (var index = 0; index < array.length; index++) {
  96405. var item = (array.data || array)[index];
  96406. this.pushNoDuplicate(item);
  96407. }
  96408. };
  96409. return SmartArrayNoDuplicate;
  96410. }(SmartArray));
  96411. /***/ }),
  96412. /***/ "./Misc/stringDictionary.ts":
  96413. /*!**********************************!*\
  96414. !*** ./Misc/stringDictionary.ts ***!
  96415. \**********************************/
  96416. /*! exports provided: StringDictionary */
  96417. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96418. "use strict";
  96419. __webpack_require__.r(__webpack_exports__);
  96420. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return StringDictionary; });
  96421. /**
  96422. * This class implement a typical dictionary using a string as key and the generic type T as value.
  96423. * The underlying implementation relies on an associative array to ensure the best performances.
  96424. * The value can be anything including 'null' but except 'undefined'
  96425. */
  96426. var StringDictionary = /** @class */ (function () {
  96427. function StringDictionary() {
  96428. this._count = 0;
  96429. this._data = {};
  96430. }
  96431. /**
  96432. * This will clear this dictionary and copy the content from the 'source' one.
  96433. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  96434. * @param source the dictionary to take the content from and copy to this dictionary
  96435. */
  96436. StringDictionary.prototype.copyFrom = function (source) {
  96437. var _this = this;
  96438. this.clear();
  96439. source.forEach(function (t, v) { return _this.add(t, v); });
  96440. };
  96441. /**
  96442. * Get a value based from its key
  96443. * @param key the given key to get the matching value from
  96444. * @return the value if found, otherwise undefined is returned
  96445. */
  96446. StringDictionary.prototype.get = function (key) {
  96447. var val = this._data[key];
  96448. if (val !== undefined) {
  96449. return val;
  96450. }
  96451. return undefined;
  96452. };
  96453. /**
  96454. * Get a value from its key or add it if it doesn't exist.
  96455. * This method will ensure you that a given key/data will be present in the dictionary.
  96456. * @param key the given key to get the matching value from
  96457. * @param factory the factory that will create the value if the key is not present in the dictionary.
  96458. * The factory will only be invoked if there's no data for the given key.
  96459. * @return the value corresponding to the key.
  96460. */
  96461. StringDictionary.prototype.getOrAddWithFactory = function (key, factory) {
  96462. var val = this.get(key);
  96463. if (val !== undefined) {
  96464. return val;
  96465. }
  96466. val = factory(key);
  96467. if (val) {
  96468. this.add(key, val);
  96469. }
  96470. return val;
  96471. };
  96472. /**
  96473. * Get a value from its key if present in the dictionary otherwise add it
  96474. * @param key the key to get the value from
  96475. * @param val if there's no such key/value pair in the dictionary add it with this value
  96476. * @return the value corresponding to the key
  96477. */
  96478. StringDictionary.prototype.getOrAdd = function (key, val) {
  96479. var curVal = this.get(key);
  96480. if (curVal !== undefined) {
  96481. return curVal;
  96482. }
  96483. this.add(key, val);
  96484. return val;
  96485. };
  96486. /**
  96487. * Check if there's a given key in the dictionary
  96488. * @param key the key to check for
  96489. * @return true if the key is present, false otherwise
  96490. */
  96491. StringDictionary.prototype.contains = function (key) {
  96492. return this._data[key] !== undefined;
  96493. };
  96494. /**
  96495. * Add a new key and its corresponding value
  96496. * @param key the key to add
  96497. * @param value the value corresponding to the key
  96498. * @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
  96499. */
  96500. StringDictionary.prototype.add = function (key, value) {
  96501. if (this._data[key] !== undefined) {
  96502. return false;
  96503. }
  96504. this._data[key] = value;
  96505. ++this._count;
  96506. return true;
  96507. };
  96508. /**
  96509. * Update a specific value associated to a key
  96510. * @param key defines the key to use
  96511. * @param value defines the value to store
  96512. * @returns true if the value was updated (or false if the key was not found)
  96513. */
  96514. StringDictionary.prototype.set = function (key, value) {
  96515. if (this._data[key] === undefined) {
  96516. return false;
  96517. }
  96518. this._data[key] = value;
  96519. return true;
  96520. };
  96521. /**
  96522. * Get the element of the given key and remove it from the dictionary
  96523. * @param key defines the key to search
  96524. * @returns the value associated with the key or null if not found
  96525. */
  96526. StringDictionary.prototype.getAndRemove = function (key) {
  96527. var val = this.get(key);
  96528. if (val !== undefined) {
  96529. delete this._data[key];
  96530. --this._count;
  96531. return val;
  96532. }
  96533. return null;
  96534. };
  96535. /**
  96536. * Remove a key/value from the dictionary.
  96537. * @param key the key to remove
  96538. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  96539. */
  96540. StringDictionary.prototype.remove = function (key) {
  96541. if (this.contains(key)) {
  96542. delete this._data[key];
  96543. --this._count;
  96544. return true;
  96545. }
  96546. return false;
  96547. };
  96548. /**
  96549. * Clear the whole content of the dictionary
  96550. */
  96551. StringDictionary.prototype.clear = function () {
  96552. this._data = {};
  96553. this._count = 0;
  96554. };
  96555. Object.defineProperty(StringDictionary.prototype, "count", {
  96556. /**
  96557. * Gets the current count
  96558. */
  96559. get: function () {
  96560. return this._count;
  96561. },
  96562. enumerable: true,
  96563. configurable: true
  96564. });
  96565. /**
  96566. * Execute a callback on each key/val of the dictionary.
  96567. * Note that you can remove any element in this dictionary in the callback implementation
  96568. * @param callback the callback to execute on a given key/value pair
  96569. */
  96570. StringDictionary.prototype.forEach = function (callback) {
  96571. for (var cur in this._data) {
  96572. var val = this._data[cur];
  96573. callback(cur, val);
  96574. }
  96575. };
  96576. /**
  96577. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  96578. * If the callback returns null or undefined the method will iterate to the next key/value pair
  96579. * Note that you can remove any element in this dictionary in the callback implementation
  96580. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  96581. * @returns the first item
  96582. */
  96583. StringDictionary.prototype.first = function (callback) {
  96584. for (var cur in this._data) {
  96585. var val = this._data[cur];
  96586. var res = callback(cur, val);
  96587. if (res) {
  96588. return res;
  96589. }
  96590. }
  96591. return null;
  96592. };
  96593. return StringDictionary;
  96594. }());
  96595. /***/ }),
  96596. /***/ "./Misc/tags.ts":
  96597. /*!**********************!*\
  96598. !*** ./Misc/tags.ts ***!
  96599. \**********************/
  96600. /*! exports provided: Tags */
  96601. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96602. "use strict";
  96603. __webpack_require__.r(__webpack_exports__);
  96604. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return Tags; });
  96605. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  96606. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  96607. /**
  96608. * Class used to store custom tags
  96609. */
  96610. var Tags = /** @class */ (function () {
  96611. function Tags() {
  96612. }
  96613. /**
  96614. * Adds support for tags on the given object
  96615. * @param obj defines the object to use
  96616. */
  96617. Tags.EnableFor = function (obj) {
  96618. obj._tags = obj._tags || {};
  96619. obj.hasTags = function () {
  96620. return Tags.HasTags(obj);
  96621. };
  96622. obj.addTags = function (tagsString) {
  96623. return Tags.AddTagsTo(obj, tagsString);
  96624. };
  96625. obj.removeTags = function (tagsString) {
  96626. return Tags.RemoveTagsFrom(obj, tagsString);
  96627. };
  96628. obj.matchesTagsQuery = function (tagsQuery) {
  96629. return Tags.MatchesQuery(obj, tagsQuery);
  96630. };
  96631. };
  96632. /**
  96633. * Removes tags support
  96634. * @param obj defines the object to use
  96635. */
  96636. Tags.DisableFor = function (obj) {
  96637. delete obj._tags;
  96638. delete obj.hasTags;
  96639. delete obj.addTags;
  96640. delete obj.removeTags;
  96641. delete obj.matchesTagsQuery;
  96642. };
  96643. /**
  96644. * Gets a boolean indicating if the given object has tags
  96645. * @param obj defines the object to use
  96646. * @returns a boolean
  96647. */
  96648. Tags.HasTags = function (obj) {
  96649. if (!obj._tags) {
  96650. return false;
  96651. }
  96652. return !_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsEmpty(obj._tags);
  96653. };
  96654. /**
  96655. * Gets the tags available on a given object
  96656. * @param obj defines the object to use
  96657. * @param asString defines if the tags must be returned as a string instead of an array of strings
  96658. * @returns the tags
  96659. */
  96660. Tags.GetTags = function (obj, asString) {
  96661. if (asString === void 0) { asString = true; }
  96662. if (!obj._tags) {
  96663. return null;
  96664. }
  96665. if (asString) {
  96666. var tagsArray = [];
  96667. for (var tag in obj._tags) {
  96668. if (obj._tags.hasOwnProperty(tag) && obj._tags[tag] === true) {
  96669. tagsArray.push(tag);
  96670. }
  96671. }
  96672. return tagsArray.join(" ");
  96673. }
  96674. else {
  96675. return obj._tags;
  96676. }
  96677. };
  96678. /**
  96679. * Adds tags to an object
  96680. * @param obj defines the object to use
  96681. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  96682. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  96683. */
  96684. Tags.AddTagsTo = function (obj, tagsString) {
  96685. if (!tagsString) {
  96686. return;
  96687. }
  96688. if (typeof tagsString !== "string") {
  96689. return;
  96690. }
  96691. var tags = tagsString.split(" ");
  96692. tags.forEach(function (tag, index, array) {
  96693. Tags._AddTagTo(obj, tag);
  96694. });
  96695. };
  96696. /**
  96697. * @hidden
  96698. */
  96699. Tags._AddTagTo = function (obj, tag) {
  96700. tag = tag.trim();
  96701. if (tag === "" || tag === "true" || tag === "false") {
  96702. return;
  96703. }
  96704. if (tag.match(/[\s]/) || tag.match(/^([!]|([|]|[&]){2})/)) {
  96705. return;
  96706. }
  96707. Tags.EnableFor(obj);
  96708. obj._tags[tag] = true;
  96709. };
  96710. /**
  96711. * Removes specific tags from a specific object
  96712. * @param obj defines the object to use
  96713. * @param tagsString defines the tags to remove
  96714. */
  96715. Tags.RemoveTagsFrom = function (obj, tagsString) {
  96716. if (!Tags.HasTags(obj)) {
  96717. return;
  96718. }
  96719. var tags = tagsString.split(" ");
  96720. for (var t in tags) {
  96721. Tags._RemoveTagFrom(obj, tags[t]);
  96722. }
  96723. };
  96724. /**
  96725. * @hidden
  96726. */
  96727. Tags._RemoveTagFrom = function (obj, tag) {
  96728. delete obj._tags[tag];
  96729. };
  96730. /**
  96731. * Defines if tags hosted on an object match a given query
  96732. * @param obj defines the object to use
  96733. * @param tagsQuery defines the tag query
  96734. * @returns a boolean
  96735. */
  96736. Tags.MatchesQuery = function (obj, tagsQuery) {
  96737. if (tagsQuery === undefined) {
  96738. return true;
  96739. }
  96740. if (tagsQuery === "") {
  96741. return Tags.HasTags(obj);
  96742. }
  96743. return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__["AndOrNotEvaluator"].Eval(tagsQuery, function (r) { return Tags.HasTags(obj) && obj._tags[r]; });
  96744. };
  96745. return Tags;
  96746. }());
  96747. /***/ }),
  96748. /***/ "./Misc/textureTools.ts":
  96749. /*!******************************!*\
  96750. !*** ./Misc/textureTools.ts ***!
  96751. \******************************/
  96752. /*! exports provided: TextureTools */
  96753. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96754. "use strict";
  96755. __webpack_require__.r(__webpack_exports__);
  96756. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return TextureTools; });
  96757. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  96758. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  96759. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  96760. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  96761. /**
  96762. * Class used to host texture specific utilities
  96763. */
  96764. var TextureTools = /** @class */ (function () {
  96765. function TextureTools() {
  96766. }
  96767. /**
  96768. * Uses the GPU to create a copy texture rescaled at a given size
  96769. * @param texture Texture to copy from
  96770. * @param width defines the desired width
  96771. * @param height defines the desired height
  96772. * @param useBilinearMode defines if bilinear mode has to be used
  96773. * @return the generated texture
  96774. */
  96775. TextureTools.CreateResizedCopy = function (texture, width, height, useBilinearMode) {
  96776. if (useBilinearMode === void 0) { useBilinearMode = true; }
  96777. var scene = texture.getScene();
  96778. var engine = scene.getEngine();
  96779. 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);
  96780. rtt.wrapU = texture.wrapU;
  96781. rtt.wrapV = texture.wrapV;
  96782. rtt.uOffset = texture.uOffset;
  96783. rtt.vOffset = texture.vOffset;
  96784. rtt.uScale = texture.uScale;
  96785. rtt.vScale = texture.vScale;
  96786. rtt.uAng = texture.uAng;
  96787. rtt.vAng = texture.vAng;
  96788. rtt.wAng = texture.wAng;
  96789. rtt.coordinatesIndex = texture.coordinatesIndex;
  96790. rtt.level = texture.level;
  96791. rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;
  96792. rtt._texture.isReady = false;
  96793. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  96794. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  96795. 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);
  96796. passPostProcess.getEffect().executeWhenCompiled(function () {
  96797. passPostProcess.onApply = function (effect) {
  96798. effect.setTexture("textureSampler", texture);
  96799. };
  96800. var internalTexture = rtt.getInternalTexture();
  96801. if (internalTexture) {
  96802. scene.postProcessManager.directRender([passPostProcess], internalTexture);
  96803. engine.unBindFramebuffer(internalTexture);
  96804. rtt.disposeFramebufferObjects();
  96805. passPostProcess.dispose();
  96806. internalTexture.isReady = true;
  96807. }
  96808. });
  96809. return rtt;
  96810. };
  96811. /**
  96812. * Gets an environment BRDF texture for a given scene
  96813. * @param scene defines the hosting scene
  96814. * @returns the environment BRDF texture
  96815. */
  96816. TextureTools.GetEnvironmentBRDFTexture = function (scene) {
  96817. if (!scene._environmentBRDFTexture) {
  96818. 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);
  96819. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  96820. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  96821. scene._environmentBRDFTexture = texture;
  96822. }
  96823. return scene._environmentBRDFTexture;
  96824. };
  96825. 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=";
  96826. return TextureTools;
  96827. }());
  96828. /***/ }),
  96829. /***/ "./Misc/tga.ts":
  96830. /*!*********************!*\
  96831. !*** ./Misc/tga.ts ***!
  96832. \*********************/
  96833. /*! exports provided: TGATools */
  96834. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96835. "use strict";
  96836. __webpack_require__.r(__webpack_exports__);
  96837. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return TGATools; });
  96838. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  96839. /**
  96840. * Based on jsTGALoader - Javascript loader for TGA file
  96841. * By Vincent Thibault
  96842. * @see http://blog.robrowser.com/javascript-tga-loader.html
  96843. */
  96844. var TGATools = /** @class */ (function () {
  96845. function TGATools() {
  96846. }
  96847. /**
  96848. * Gets the header of a TGA file
  96849. * @param data defines the TGA data
  96850. * @returns the header
  96851. */
  96852. TGATools.GetTGAHeader = function (data) {
  96853. var offset = 0;
  96854. var header = {
  96855. id_length: data[offset++],
  96856. colormap_type: data[offset++],
  96857. image_type: data[offset++],
  96858. colormap_index: data[offset++] | data[offset++] << 8,
  96859. colormap_length: data[offset++] | data[offset++] << 8,
  96860. colormap_size: data[offset++],
  96861. origin: [
  96862. data[offset++] | data[offset++] << 8,
  96863. data[offset++] | data[offset++] << 8
  96864. ],
  96865. width: data[offset++] | data[offset++] << 8,
  96866. height: data[offset++] | data[offset++] << 8,
  96867. pixel_size: data[offset++],
  96868. flags: data[offset++]
  96869. };
  96870. return header;
  96871. };
  96872. /**
  96873. * Uploads TGA content to a Babylon Texture
  96874. * @hidden
  96875. */
  96876. TGATools.UploadContent = function (texture, data) {
  96877. // Not enough data to contain header ?
  96878. if (data.length < 19) {
  96879. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data to contain header");
  96880. return;
  96881. }
  96882. // Read Header
  96883. var offset = 18;
  96884. var header = TGATools.GetTGAHeader(data);
  96885. // Assume it's a valid Targa file.
  96886. if (header.id_length + offset > data.length) {
  96887. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data");
  96888. return;
  96889. }
  96890. // Skip not needed data
  96891. offset += header.id_length;
  96892. var use_rle = false;
  96893. var use_pal = false;
  96894. var use_grey = false;
  96895. // Get some informations.
  96896. switch (header.image_type) {
  96897. case TGATools._TYPE_RLE_INDEXED:
  96898. use_rle = true;
  96899. case TGATools._TYPE_INDEXED:
  96900. use_pal = true;
  96901. break;
  96902. case TGATools._TYPE_RLE_RGB:
  96903. use_rle = true;
  96904. case TGATools._TYPE_RGB:
  96905. // use_rgb = true;
  96906. break;
  96907. case TGATools._TYPE_RLE_GREY:
  96908. use_rle = true;
  96909. case TGATools._TYPE_GREY:
  96910. use_grey = true;
  96911. break;
  96912. }
  96913. var pixel_data;
  96914. // var numAlphaBits = header.flags & 0xf;
  96915. var pixel_size = header.pixel_size >> 3;
  96916. var pixel_total = header.width * header.height * pixel_size;
  96917. // Read palettes
  96918. var palettes;
  96919. if (use_pal) {
  96920. palettes = data.subarray(offset, offset += header.colormap_length * (header.colormap_size >> 3));
  96921. }
  96922. // Read LRE
  96923. if (use_rle) {
  96924. pixel_data = new Uint8Array(pixel_total);
  96925. var c, count, i;
  96926. var localOffset = 0;
  96927. var pixels = new Uint8Array(pixel_size);
  96928. while (offset < pixel_total && localOffset < pixel_total) {
  96929. c = data[offset++];
  96930. count = (c & 0x7f) + 1;
  96931. // RLE pixels
  96932. if (c & 0x80) {
  96933. // Bind pixel tmp array
  96934. for (i = 0; i < pixel_size; ++i) {
  96935. pixels[i] = data[offset++];
  96936. }
  96937. // Copy pixel array
  96938. for (i = 0; i < count; ++i) {
  96939. pixel_data.set(pixels, localOffset + i * pixel_size);
  96940. }
  96941. localOffset += pixel_size * count;
  96942. }
  96943. // Raw pixels
  96944. else {
  96945. count *= pixel_size;
  96946. for (i = 0; i < count; ++i) {
  96947. pixel_data[localOffset + i] = data[offset++];
  96948. }
  96949. localOffset += count;
  96950. }
  96951. }
  96952. }
  96953. // RAW Pixels
  96954. else {
  96955. pixel_data = data.subarray(offset, offset += (use_pal ? header.width * header.height : pixel_total));
  96956. }
  96957. // Load to texture
  96958. var x_start, y_start, x_step, y_step, y_end, x_end;
  96959. switch ((header.flags & TGATools._ORIGIN_MASK) >> TGATools._ORIGIN_SHIFT) {
  96960. default:
  96961. case TGATools._ORIGIN_UL:
  96962. x_start = 0;
  96963. x_step = 1;
  96964. x_end = header.width;
  96965. y_start = 0;
  96966. y_step = 1;
  96967. y_end = header.height;
  96968. break;
  96969. case TGATools._ORIGIN_BL:
  96970. x_start = 0;
  96971. x_step = 1;
  96972. x_end = header.width;
  96973. y_start = header.height - 1;
  96974. y_step = -1;
  96975. y_end = -1;
  96976. break;
  96977. case TGATools._ORIGIN_UR:
  96978. x_start = header.width - 1;
  96979. x_step = -1;
  96980. x_end = -1;
  96981. y_start = 0;
  96982. y_step = 1;
  96983. y_end = header.height;
  96984. break;
  96985. case TGATools._ORIGIN_BR:
  96986. x_start = header.width - 1;
  96987. x_step = -1;
  96988. x_end = -1;
  96989. y_start = header.height - 1;
  96990. y_step = -1;
  96991. y_end = -1;
  96992. break;
  96993. }
  96994. // Load the specify method
  96995. var func = '_getImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
  96996. var imageData = TGATools[func](header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end);
  96997. var engine = texture.getEngine();
  96998. engine._uploadDataToTextureDirectly(texture, imageData);
  96999. };
  97000. /** @hidden */
  97001. TGATools._getImageData8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  97002. var image = pixel_data, colormap = palettes;
  97003. var width = header.width, height = header.height;
  97004. var color, i = 0, x, y;
  97005. var imageData = new Uint8Array(width * height * 4);
  97006. for (y = y_start; y !== y_end; y += y_step) {
  97007. for (x = x_start; x !== x_end; x += x_step, i++) {
  97008. color = image[i];
  97009. imageData[(x + width * y) * 4 + 3] = 255;
  97010. imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0];
  97011. imageData[(x + width * y) * 4 + 1] = colormap[(color * 3) + 1];
  97012. imageData[(x + width * y) * 4 + 0] = colormap[(color * 3) + 2];
  97013. }
  97014. }
  97015. return imageData;
  97016. };
  97017. /** @hidden */
  97018. TGATools._getImageData16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  97019. var image = pixel_data;
  97020. var width = header.width, height = header.height;
  97021. var color, i = 0, x, y;
  97022. var imageData = new Uint8Array(width * height * 4);
  97023. for (y = y_start; y !== y_end; y += y_step) {
  97024. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  97025. color = image[i + 0] + (image[i + 1] << 8); // Inversed ?
  97026. var r = (((color & 0x7C00) >> 10) * 255) / 0x1F | 0;
  97027. var g = (((color & 0x03E0) >> 5) * 255) / 0x1F | 0;
  97028. var b = ((color & 0x001F) * 255) / 0x1F | 0;
  97029. imageData[(x + width * y) * 4 + 0] = r;
  97030. imageData[(x + width * y) * 4 + 1] = g;
  97031. imageData[(x + width * y) * 4 + 2] = b;
  97032. imageData[(x + width * y) * 4 + 3] = (color & 0x8000) ? 0 : 255;
  97033. }
  97034. }
  97035. return imageData;
  97036. };
  97037. /** @hidden */
  97038. TGATools._getImageData24bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  97039. var image = pixel_data;
  97040. var width = header.width, height = header.height;
  97041. var i = 0, x, y;
  97042. var imageData = new Uint8Array(width * height * 4);
  97043. for (y = y_start; y !== y_end; y += y_step) {
  97044. for (x = x_start; x !== x_end; x += x_step, i += 3) {
  97045. imageData[(x + width * y) * 4 + 3] = 255;
  97046. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  97047. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  97048. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  97049. }
  97050. }
  97051. return imageData;
  97052. };
  97053. /** @hidden */
  97054. TGATools._getImageData32bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  97055. var image = pixel_data;
  97056. var width = header.width, height = header.height;
  97057. var i = 0, x, y;
  97058. var imageData = new Uint8Array(width * height * 4);
  97059. for (y = y_start; y !== y_end; y += y_step) {
  97060. for (x = x_start; x !== x_end; x += x_step, i += 4) {
  97061. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  97062. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  97063. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  97064. imageData[(x + width * y) * 4 + 3] = image[i + 3];
  97065. }
  97066. }
  97067. return imageData;
  97068. };
  97069. /** @hidden */
  97070. TGATools._getImageDataGrey8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  97071. var image = pixel_data;
  97072. var width = header.width, height = header.height;
  97073. var color, i = 0, x, y;
  97074. var imageData = new Uint8Array(width * height * 4);
  97075. for (y = y_start; y !== y_end; y += y_step) {
  97076. for (x = x_start; x !== x_end; x += x_step, i++) {
  97077. color = image[i];
  97078. imageData[(x + width * y) * 4 + 0] = color;
  97079. imageData[(x + width * y) * 4 + 1] = color;
  97080. imageData[(x + width * y) * 4 + 2] = color;
  97081. imageData[(x + width * y) * 4 + 3] = 255;
  97082. }
  97083. }
  97084. return imageData;
  97085. };
  97086. /** @hidden */
  97087. TGATools._getImageDataGrey16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  97088. var image = pixel_data;
  97089. var width = header.width, height = header.height;
  97090. var i = 0, x, y;
  97091. var imageData = new Uint8Array(width * height * 4);
  97092. for (y = y_start; y !== y_end; y += y_step) {
  97093. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  97094. imageData[(x + width * y) * 4 + 0] = image[i + 0];
  97095. imageData[(x + width * y) * 4 + 1] = image[i + 0];
  97096. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  97097. imageData[(x + width * y) * 4 + 3] = image[i + 1];
  97098. }
  97099. }
  97100. return imageData;
  97101. };
  97102. //private static _TYPE_NO_DATA = 0;
  97103. TGATools._TYPE_INDEXED = 1;
  97104. TGATools._TYPE_RGB = 2;
  97105. TGATools._TYPE_GREY = 3;
  97106. TGATools._TYPE_RLE_INDEXED = 9;
  97107. TGATools._TYPE_RLE_RGB = 10;
  97108. TGATools._TYPE_RLE_GREY = 11;
  97109. TGATools._ORIGIN_MASK = 0x30;
  97110. TGATools._ORIGIN_SHIFT = 0x04;
  97111. TGATools._ORIGIN_BL = 0x00;
  97112. TGATools._ORIGIN_BR = 0x01;
  97113. TGATools._ORIGIN_UL = 0x02;
  97114. TGATools._ORIGIN_UR = 0x03;
  97115. return TGATools;
  97116. }());
  97117. /***/ }),
  97118. /***/ "./Misc/tools.ts":
  97119. /*!***********************!*\
  97120. !*** ./Misc/tools.ts ***!
  97121. \***********************/
  97122. /*! exports provided: ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop */
  97123. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97124. "use strict";
  97125. __webpack_require__.r(__webpack_exports__);
  97126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return ColorGradient; });
  97127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return Color3Gradient; });
  97128. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return FactorGradient; });
  97129. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return LoadFileError; });
  97130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return RetryStrategy; });
  97131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return Tools; });
  97132. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return PerfCounter; });
  97133. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "className", function() { return className; });
  97134. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return AsyncLoop; });
  97135. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  97136. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  97137. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  97138. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  97139. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  97140. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  97141. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  97142. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  97143. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  97144. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  97145. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  97146. /** Class used to store color4 gradient */
  97147. var ColorGradient = /** @class */ (function () {
  97148. function ColorGradient() {
  97149. }
  97150. /**
  97151. * Will get a color picked randomly between color1 and color2.
  97152. * If color2 is undefined then color1 will be used
  97153. * @param result defines the target Color4 to store the result in
  97154. */
  97155. ColorGradient.prototype.getColorToRef = function (result) {
  97156. if (!this.color2) {
  97157. result.copyFrom(this.color1);
  97158. return;
  97159. }
  97160. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].LerpToRef(this.color1, this.color2, Math.random(), result);
  97161. };
  97162. return ColorGradient;
  97163. }());
  97164. /** Class used to store color 3 gradient */
  97165. var Color3Gradient = /** @class */ (function () {
  97166. function Color3Gradient() {
  97167. }
  97168. return Color3Gradient;
  97169. }());
  97170. /** Class used to store factor gradient */
  97171. var FactorGradient = /** @class */ (function () {
  97172. function FactorGradient() {
  97173. }
  97174. /**
  97175. * Will get a number picked randomly between factor1 and factor2.
  97176. * If factor2 is undefined then factor1 will be used
  97177. * @returns the picked number
  97178. */
  97179. FactorGradient.prototype.getFactor = function () {
  97180. if (this.factor2 === undefined) {
  97181. return this.factor1;
  97182. }
  97183. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Lerp(this.factor1, this.factor2, Math.random());
  97184. };
  97185. return FactorGradient;
  97186. }());
  97187. /**
  97188. * @ignore
  97189. * Application error to support additional information when loading a file
  97190. */
  97191. var LoadFileError = /** @class */ (function (_super) {
  97192. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LoadFileError, _super);
  97193. /**
  97194. * Creates a new LoadFileError
  97195. * @param message defines the message of the error
  97196. * @param request defines the optional XHR request
  97197. */
  97198. function LoadFileError(message,
  97199. /** defines the optional XHR request */
  97200. request) {
  97201. var _this = _super.call(this, message) || this;
  97202. _this.request = request;
  97203. _this.name = "LoadFileError";
  97204. LoadFileError._setPrototypeOf(_this, LoadFileError.prototype);
  97205. return _this;
  97206. }
  97207. // See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript
  97208. // and https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  97209. // Polyfill for Object.setPrototypeOf if necessary.
  97210. LoadFileError._setPrototypeOf = Object.setPrototypeOf || (function (o, proto) { o.__proto__ = proto; return o; });
  97211. return LoadFileError;
  97212. }(Error));
  97213. /**
  97214. * Class used to define a retry strategy when error happens while loading assets
  97215. */
  97216. var RetryStrategy = /** @class */ (function () {
  97217. function RetryStrategy() {
  97218. }
  97219. /**
  97220. * Function used to defines an exponential back off strategy
  97221. * @param maxRetries defines the maximum number of retries (3 by default)
  97222. * @param baseInterval defines the interval between retries
  97223. * @returns the strategy function to use
  97224. */
  97225. RetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
  97226. if (maxRetries === void 0) { maxRetries = 3; }
  97227. if (baseInterval === void 0) { baseInterval = 500; }
  97228. return function (url, request, retryIndex) {
  97229. if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
  97230. return -1;
  97231. }
  97232. return Math.pow(2, retryIndex) * baseInterval;
  97233. };
  97234. };
  97235. return RetryStrategy;
  97236. }());
  97237. // Screenshots
  97238. var screenshotCanvas;
  97239. /**
  97240. * Class containing a set of static utilities functions
  97241. */
  97242. var Tools = /** @class */ (function () {
  97243. function Tools() {
  97244. }
  97245. /**
  97246. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  97247. * @param u defines the coordinate on X axis
  97248. * @param v defines the coordinate on Y axis
  97249. * @param width defines the width of the source data
  97250. * @param height defines the height of the source data
  97251. * @param pixels defines the source byte array
  97252. * @param color defines the output color
  97253. */
  97254. Tools.FetchToRef = function (u, v, width, height, pixels, color) {
  97255. var wrappedU = ((Math.abs(u) * width) % width) | 0;
  97256. var wrappedV = ((Math.abs(v) * height) % height) | 0;
  97257. var position = (wrappedU + wrappedV * width) * 4;
  97258. color.r = pixels[position] / 255;
  97259. color.g = pixels[position + 1] / 255;
  97260. color.b = pixels[position + 2] / 255;
  97261. color.a = pixels[position + 3] / 255;
  97262. };
  97263. /**
  97264. * Interpolates between a and b via alpha
  97265. * @param a The lower value (returned when alpha = 0)
  97266. * @param b The upper value (returned when alpha = 1)
  97267. * @param alpha The interpolation-factor
  97268. * @return The mixed value
  97269. */
  97270. Tools.Mix = function (a, b, alpha) {
  97271. return a * (1 - alpha) + b * alpha;
  97272. };
  97273. /**
  97274. * Tries to instantiate a new object from a given class name
  97275. * @param className defines the class name to instantiate
  97276. * @returns the new object or null if the system was not able to do the instantiation
  97277. */
  97278. Tools.Instantiate = function (className) {
  97279. if (Tools.RegisteredExternalClasses && Tools.RegisteredExternalClasses[className]) {
  97280. return Tools.RegisteredExternalClasses[className];
  97281. }
  97282. var internalClass = _typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass(className);
  97283. if (internalClass) {
  97284. return internalClass;
  97285. }
  97286. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(className + " not found, you may have missed an import.");
  97287. var arr = className.split(".");
  97288. var fn = (window || this);
  97289. for (var i = 0, len = arr.length; i < len; i++) {
  97290. fn = fn[arr[i]];
  97291. }
  97292. if (typeof fn !== "function") {
  97293. return null;
  97294. }
  97295. return fn;
  97296. };
  97297. /**
  97298. * Provides a slice function that will work even on IE
  97299. * @param data defines the array to slice
  97300. * @param start defines the start of the data (optional)
  97301. * @param end defines the end of the data (optional)
  97302. * @returns the new sliced array
  97303. */
  97304. Tools.Slice = function (data, start, end) {
  97305. if (data.slice) {
  97306. return data.slice(start, end);
  97307. }
  97308. return Array.prototype.slice.call(data, start, end);
  97309. };
  97310. /**
  97311. * Polyfill for setImmediate
  97312. * @param action defines the action to execute after the current execution block
  97313. */
  97314. Tools.SetImmediate = function (action) {
  97315. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && window.setImmediate) {
  97316. window.setImmediate(action);
  97317. }
  97318. else {
  97319. setTimeout(action, 1);
  97320. }
  97321. };
  97322. /**
  97323. * Function indicating if a number is an exponent of 2
  97324. * @param value defines the value to test
  97325. * @returns true if the value is an exponent of 2
  97326. */
  97327. Tools.IsExponentOfTwo = function (value) {
  97328. var count = 1;
  97329. do {
  97330. count *= 2;
  97331. } while (count < value);
  97332. return count === value;
  97333. };
  97334. /**
  97335. * Returns the nearest 32-bit single precision float representation of a Number
  97336. * @param value A Number. If the parameter is of a different type, it will get converted
  97337. * to a number or to NaN if it cannot be converted
  97338. * @returns number
  97339. */
  97340. Tools.FloatRound = function (value) {
  97341. if (Math.fround) {
  97342. return Math.fround(value);
  97343. }
  97344. return (Tools._tmpFloatArray[0] = value);
  97345. };
  97346. /**
  97347. * Find the next highest power of two.
  97348. * @param x Number to start search from.
  97349. * @return Next highest power of two.
  97350. */
  97351. Tools.CeilingPOT = function (x) {
  97352. x--;
  97353. x |= x >> 1;
  97354. x |= x >> 2;
  97355. x |= x >> 4;
  97356. x |= x >> 8;
  97357. x |= x >> 16;
  97358. x++;
  97359. return x;
  97360. };
  97361. /**
  97362. * Find the next lowest power of two.
  97363. * @param x Number to start search from.
  97364. * @return Next lowest power of two.
  97365. */
  97366. Tools.FloorPOT = function (x) {
  97367. x = x | (x >> 1);
  97368. x = x | (x >> 2);
  97369. x = x | (x >> 4);
  97370. x = x | (x >> 8);
  97371. x = x | (x >> 16);
  97372. return x - (x >> 1);
  97373. };
  97374. /**
  97375. * Find the nearest power of two.
  97376. * @param x Number to start search from.
  97377. * @return Next nearest power of two.
  97378. */
  97379. Tools.NearestPOT = function (x) {
  97380. var c = Tools.CeilingPOT(x);
  97381. var f = Tools.FloorPOT(x);
  97382. return (c - x) > (x - f) ? f : c;
  97383. };
  97384. /**
  97385. * Get the closest exponent of two
  97386. * @param value defines the value to approximate
  97387. * @param max defines the maximum value to return
  97388. * @param mode defines how to define the closest value
  97389. * @returns closest exponent of two of the given value
  97390. */
  97391. Tools.GetExponentOfTwo = function (value, max, mode) {
  97392. if (mode === void 0) { mode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST; }
  97393. var pot;
  97394. switch (mode) {
  97395. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_FLOOR:
  97396. pot = Tools.FloorPOT(value);
  97397. break;
  97398. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST:
  97399. pot = Tools.NearestPOT(value);
  97400. break;
  97401. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_CEILING:
  97402. default:
  97403. pot = Tools.CeilingPOT(value);
  97404. break;
  97405. }
  97406. return Math.min(pot, max);
  97407. };
  97408. /**
  97409. * Extracts the filename from a path
  97410. * @param path defines the path to use
  97411. * @returns the filename
  97412. */
  97413. Tools.GetFilename = function (path) {
  97414. var index = path.lastIndexOf("/");
  97415. if (index < 0) {
  97416. return path;
  97417. }
  97418. return path.substring(index + 1);
  97419. };
  97420. /**
  97421. * Extracts the "folder" part of a path (everything before the filename).
  97422. * @param uri The URI to extract the info from
  97423. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  97424. * @returns The "folder" part of the path
  97425. */
  97426. Tools.GetFolderPath = function (uri, returnUnchangedIfNoSlash) {
  97427. if (returnUnchangedIfNoSlash === void 0) { returnUnchangedIfNoSlash = false; }
  97428. var index = uri.lastIndexOf("/");
  97429. if (index < 0) {
  97430. if (returnUnchangedIfNoSlash) {
  97431. return uri;
  97432. }
  97433. return "";
  97434. }
  97435. return uri.substring(0, index + 1);
  97436. };
  97437. /**
  97438. * Convert an angle in radians to degrees
  97439. * @param angle defines the angle to convert
  97440. * @returns the angle in degrees
  97441. */
  97442. Tools.ToDegrees = function (angle) {
  97443. return angle * 180 / Math.PI;
  97444. };
  97445. /**
  97446. * Convert an angle in degrees to radians
  97447. * @param angle defines the angle to convert
  97448. * @returns the angle in radians
  97449. */
  97450. Tools.ToRadians = function (angle) {
  97451. return angle * Math.PI / 180;
  97452. };
  97453. /**
  97454. * Encode a buffer to a base64 string
  97455. * @param buffer defines the buffer to encode
  97456. * @returns the encoded string
  97457. */
  97458. Tools.EncodeArrayBufferTobase64 = function (buffer) {
  97459. var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  97460. var output = "";
  97461. var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  97462. var i = 0;
  97463. var bytes = new Uint8Array(buffer);
  97464. while (i < bytes.length) {
  97465. chr1 = bytes[i++];
  97466. chr2 = i < bytes.length ? bytes[i++] : Number.NaN; // Not sure if the index
  97467. chr3 = i < bytes.length ? bytes[i++] : Number.NaN; // checks are needed here
  97468. enc1 = chr1 >> 2;
  97469. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  97470. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  97471. enc4 = chr3 & 63;
  97472. if (isNaN(chr2)) {
  97473. enc3 = enc4 = 64;
  97474. }
  97475. else if (isNaN(chr3)) {
  97476. enc4 = 64;
  97477. }
  97478. output += keyStr.charAt(enc1) + keyStr.charAt(enc2) +
  97479. keyStr.charAt(enc3) + keyStr.charAt(enc4);
  97480. }
  97481. return "data:image/png;base64," + output;
  97482. };
  97483. /**
  97484. * Extracts minimum and maximum values from a list of indexed positions
  97485. * @param positions defines the positions to use
  97486. * @param indices defines the indices to the positions
  97487. * @param indexStart defines the start index
  97488. * @param indexCount defines the end index
  97489. * @param bias defines bias value to add to the result
  97490. * @return minimum and maximum values
  97491. */
  97492. Tools.ExtractMinAndMaxIndexed = function (positions, indices, indexStart, indexCount, bias) {
  97493. if (bias === void 0) { bias = null; }
  97494. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  97495. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  97496. for (var index = indexStart; index < indexStart + indexCount; index++) {
  97497. var offset = indices[index] * 3;
  97498. var x = positions[offset];
  97499. var y = positions[offset + 1];
  97500. var z = positions[offset + 2];
  97501. minimum.minimizeInPlaceFromFloats(x, y, z);
  97502. maximum.maximizeInPlaceFromFloats(x, y, z);
  97503. }
  97504. if (bias) {
  97505. minimum.x -= minimum.x * bias.x + bias.y;
  97506. minimum.y -= minimum.y * bias.x + bias.y;
  97507. minimum.z -= minimum.z * bias.x + bias.y;
  97508. maximum.x += maximum.x * bias.x + bias.y;
  97509. maximum.y += maximum.y * bias.x + bias.y;
  97510. maximum.z += maximum.z * bias.x + bias.y;
  97511. }
  97512. return {
  97513. minimum: minimum,
  97514. maximum: maximum
  97515. };
  97516. };
  97517. /**
  97518. * Extracts minimum and maximum values from a list of positions
  97519. * @param positions defines the positions to use
  97520. * @param start defines the start index in the positions array
  97521. * @param count defines the number of positions to handle
  97522. * @param bias defines bias value to add to the result
  97523. * @param stride defines the stride size to use (distance between two positions in the positions array)
  97524. * @return minimum and maximum values
  97525. */
  97526. Tools.ExtractMinAndMax = function (positions, start, count, bias, stride) {
  97527. if (bias === void 0) { bias = null; }
  97528. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  97529. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  97530. if (!stride) {
  97531. stride = 3;
  97532. }
  97533. for (var index = start, offset = start * stride; index < start + count; index++, offset += stride) {
  97534. var x = positions[offset];
  97535. var y = positions[offset + 1];
  97536. var z = positions[offset + 2];
  97537. minimum.minimizeInPlaceFromFloats(x, y, z);
  97538. maximum.maximizeInPlaceFromFloats(x, y, z);
  97539. }
  97540. if (bias) {
  97541. minimum.x -= minimum.x * bias.x + bias.y;
  97542. minimum.y -= minimum.y * bias.x + bias.y;
  97543. minimum.z -= minimum.z * bias.x + bias.y;
  97544. maximum.x += maximum.x * bias.x + bias.y;
  97545. maximum.y += maximum.y * bias.x + bias.y;
  97546. maximum.z += maximum.z * bias.x + bias.y;
  97547. }
  97548. return {
  97549. minimum: minimum,
  97550. maximum: maximum
  97551. };
  97552. };
  97553. /**
  97554. * Returns an array if obj is not an array
  97555. * @param obj defines the object to evaluate as an array
  97556. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  97557. * @returns either obj directly if obj is an array or a new array containing obj
  97558. */
  97559. Tools.MakeArray = function (obj, allowsNullUndefined) {
  97560. if (allowsNullUndefined !== true && (obj === undefined || obj == null)) {
  97561. return null;
  97562. }
  97563. return Array.isArray(obj) ? obj : [obj];
  97564. };
  97565. /**
  97566. * Gets the pointer prefix to use
  97567. * @returns "pointer" if touch is enabled. Else returns "mouse"
  97568. */
  97569. Tools.GetPointerPrefix = function () {
  97570. var eventPrefix = "pointer";
  97571. // Check if pointer events are supported
  97572. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && !window.PointerEvent && !navigator.pointerEnabled) {
  97573. eventPrefix = "mouse";
  97574. }
  97575. return eventPrefix;
  97576. };
  97577. /**
  97578. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97579. * @param func - the function to be called
  97580. * @param requester - the object that will request the next frame. Falls back to window.
  97581. * @returns frame number
  97582. */
  97583. Tools.QueueNewFrame = function (func, requester) {
  97584. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  97585. return setTimeout(func, 16);
  97586. }
  97587. if (!requester) {
  97588. requester = window;
  97589. }
  97590. if (requester.requestAnimationFrame) {
  97591. return requester.requestAnimationFrame(func);
  97592. }
  97593. else if (requester.msRequestAnimationFrame) {
  97594. return requester.msRequestAnimationFrame(func);
  97595. }
  97596. else if (requester.webkitRequestAnimationFrame) {
  97597. return requester.webkitRequestAnimationFrame(func);
  97598. }
  97599. else if (requester.mozRequestAnimationFrame) {
  97600. return requester.mozRequestAnimationFrame(func);
  97601. }
  97602. else if (requester.oRequestAnimationFrame) {
  97603. return requester.oRequestAnimationFrame(func);
  97604. }
  97605. else {
  97606. return window.setTimeout(func, 16);
  97607. }
  97608. };
  97609. /**
  97610. * Ask the browser to promote the current element to fullscreen rendering mode
  97611. * @param element defines the DOM element to promote
  97612. */
  97613. Tools.RequestFullscreen = function (element) {
  97614. var requestFunction = element.requestFullscreen || element.msRequestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen;
  97615. if (!requestFunction) {
  97616. return;
  97617. }
  97618. requestFunction.call(element);
  97619. };
  97620. /**
  97621. * Asks the browser to exit fullscreen mode
  97622. */
  97623. Tools.ExitFullscreen = function () {
  97624. if (document.exitFullscreen) {
  97625. document.exitFullscreen();
  97626. }
  97627. else if (document.mozCancelFullScreen) {
  97628. document.mozCancelFullScreen();
  97629. }
  97630. else if (document.webkitCancelFullScreen) {
  97631. document.webkitCancelFullScreen();
  97632. }
  97633. else if (document.msCancelFullScreen) {
  97634. document.msCancelFullScreen();
  97635. }
  97636. };
  97637. /**
  97638. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  97639. * @param url define the url we are trying
  97640. * @param element define the dom element where to configure the cors policy
  97641. */
  97642. Tools.SetCorsBehavior = function (url, element) {
  97643. if (url && url.indexOf("data:") === 0) {
  97644. return;
  97645. }
  97646. if (Tools.CorsBehavior) {
  97647. if (typeof (Tools.CorsBehavior) === 'string' || Tools.CorsBehavior instanceof String) {
  97648. element.crossOrigin = Tools.CorsBehavior;
  97649. }
  97650. else {
  97651. var result = Tools.CorsBehavior(url);
  97652. if (result) {
  97653. element.crossOrigin = result;
  97654. }
  97655. }
  97656. }
  97657. };
  97658. // External files
  97659. /**
  97660. * Removes unwanted characters from an url
  97661. * @param url defines the url to clean
  97662. * @returns the cleaned url
  97663. */
  97664. Tools.CleanUrl = function (url) {
  97665. url = url.replace(/#/mg, "%23");
  97666. return url;
  97667. };
  97668. /**
  97669. * Loads an image as an HTMLImageElement.
  97670. * @param input url string, ArrayBuffer, or Blob to load
  97671. * @param onLoad callback called when the image successfully loads
  97672. * @param onError callback called when the image fails to load
  97673. * @param offlineProvider offline provider for caching
  97674. * @returns the HTMLImageElement of the loaded image
  97675. */
  97676. Tools.LoadImage = function (input, onLoad, onError, offlineProvider) {
  97677. var url;
  97678. var usingObjectURL = false;
  97679. if (input instanceof ArrayBuffer) {
  97680. url = URL.createObjectURL(new Blob([input]));
  97681. usingObjectURL = true;
  97682. }
  97683. else if (input instanceof Blob) {
  97684. url = URL.createObjectURL(input);
  97685. usingObjectURL = true;
  97686. }
  97687. else {
  97688. url = Tools.CleanUrl(input);
  97689. url = Tools.PreprocessUrl(input);
  97690. }
  97691. var img = new Image();
  97692. Tools.SetCorsBehavior(url, img);
  97693. var loadHandler = function () {
  97694. if (usingObjectURL && img.src) {
  97695. URL.revokeObjectURL(img.src);
  97696. }
  97697. img.removeEventListener("load", loadHandler);
  97698. img.removeEventListener("error", errorHandler);
  97699. onLoad(img);
  97700. };
  97701. var errorHandler = function (err) {
  97702. if (usingObjectURL && img.src) {
  97703. URL.revokeObjectURL(img.src);
  97704. }
  97705. img.removeEventListener("load", loadHandler);
  97706. img.removeEventListener("error", errorHandler);
  97707. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error while trying to load image: " + input);
  97708. if (onError) {
  97709. onError("Error while trying to load image: " + input, err);
  97710. }
  97711. };
  97712. img.addEventListener("load", loadHandler);
  97713. img.addEventListener("error", errorHandler);
  97714. var noOfflineSupport = function () {
  97715. img.src = url;
  97716. };
  97717. var loadFromOfflineSupport = function () {
  97718. if (offlineProvider) {
  97719. offlineProvider.loadImage(url, img);
  97720. }
  97721. };
  97722. if (url.substr(0, 5) !== "data:" && offlineProvider && offlineProvider.enableTexturesOffline) {
  97723. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);
  97724. }
  97725. else {
  97726. if (url.indexOf("file:") !== -1) {
  97727. var textureName = decodeURIComponent(url.substring(5).toLowerCase());
  97728. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]) {
  97729. try {
  97730. var blobURL;
  97731. try {
  97732. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  97733. }
  97734. catch (ex) {
  97735. // Chrome doesn't support oneTimeOnly parameter
  97736. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  97737. }
  97738. img.src = blobURL;
  97739. usingObjectURL = true;
  97740. }
  97741. catch (e) {
  97742. img.src = "";
  97743. }
  97744. return img;
  97745. }
  97746. }
  97747. noOfflineSupport();
  97748. }
  97749. return img;
  97750. };
  97751. /**
  97752. * Loads a file
  97753. * @param url url string, ArrayBuffer, or Blob to load
  97754. * @param onSuccess callback called when the file successfully loads
  97755. * @param onProgress callback called while file is loading (if the server supports this mode)
  97756. * @param offlineProvider defines the offline provider for caching
  97757. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  97758. * @param onError callback called when the file fails to load
  97759. * @returns a file request object
  97760. */
  97761. Tools.LoadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  97762. url = Tools.CleanUrl(url);
  97763. url = Tools.PreprocessUrl(url);
  97764. // If file and file input are set
  97765. if (url.indexOf("file:") !== -1) {
  97766. var fileName = decodeURIComponent(url.substring(5).toLowerCase());
  97767. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName]) {
  97768. return Tools.ReadFile(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName], onSuccess, onProgress, useArrayBuffer);
  97769. }
  97770. }
  97771. var loadUrl = Tools.BaseUrl + url;
  97772. var aborted = false;
  97773. var fileRequest = {
  97774. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  97775. abort: function () { return aborted = true; },
  97776. };
  97777. var requestFile = function () {
  97778. var request = new XMLHttpRequest();
  97779. var retryHandle = null;
  97780. fileRequest.abort = function () {
  97781. aborted = true;
  97782. if (request.readyState !== (XMLHttpRequest.DONE || 4)) {
  97783. request.abort();
  97784. }
  97785. if (retryHandle !== null) {
  97786. clearTimeout(retryHandle);
  97787. retryHandle = null;
  97788. }
  97789. };
  97790. var retryLoop = function (retryIndex) {
  97791. request.open('GET', loadUrl, true);
  97792. if (useArrayBuffer) {
  97793. request.responseType = "arraybuffer";
  97794. }
  97795. if (onProgress) {
  97796. request.addEventListener("progress", onProgress);
  97797. }
  97798. var onLoadEnd = function () {
  97799. request.removeEventListener("loadend", onLoadEnd);
  97800. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  97801. fileRequest.onCompleteObservable.clear();
  97802. };
  97803. request.addEventListener("loadend", onLoadEnd);
  97804. var onReadyStateChange = function () {
  97805. if (aborted) {
  97806. return;
  97807. }
  97808. // In case of undefined state in some browsers.
  97809. if (request.readyState === (XMLHttpRequest.DONE || 4)) {
  97810. // Some browsers have issues where onreadystatechange can be called multiple times with the same value.
  97811. request.removeEventListener("readystatechange", onReadyStateChange);
  97812. if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() || Tools.IsFileURL()))) {
  97813. onSuccess(!useArrayBuffer ? request.responseText : request.response, request.responseURL);
  97814. return;
  97815. }
  97816. var retryStrategy = Tools.DefaultRetryStrategy;
  97817. if (retryStrategy) {
  97818. var waitTime = retryStrategy(loadUrl, request, retryIndex);
  97819. if (waitTime !== -1) {
  97820. // Prevent the request from completing for retry.
  97821. request.removeEventListener("loadend", onLoadEnd);
  97822. request = new XMLHttpRequest();
  97823. retryHandle = setTimeout(function () { return retryLoop(retryIndex + 1); }, waitTime);
  97824. return;
  97825. }
  97826. }
  97827. var e = new LoadFileError("Error status: " + request.status + " " + request.statusText + " - Unable to load " + loadUrl, request);
  97828. if (onError) {
  97829. onError(request, e);
  97830. }
  97831. else {
  97832. throw e;
  97833. }
  97834. }
  97835. };
  97836. request.addEventListener("readystatechange", onReadyStateChange);
  97837. if (Tools.UseCustomRequestHeaders) {
  97838. Tools.InjectCustomRequestHeaders(request);
  97839. }
  97840. request.send();
  97841. };
  97842. retryLoop(0);
  97843. };
  97844. // Caching all files
  97845. if (offlineProvider && offlineProvider.enableSceneOffline) {
  97846. var noOfflineSupport_1 = function (request) {
  97847. if (request && request.status > 400) {
  97848. if (onError) {
  97849. onError(request);
  97850. }
  97851. }
  97852. else {
  97853. if (!aborted) {
  97854. requestFile();
  97855. }
  97856. }
  97857. };
  97858. var loadFromOfflineSupport = function () {
  97859. // TODO: database needs to support aborting and should return a IFileRequest
  97860. if (aborted) {
  97861. return;
  97862. }
  97863. if (offlineProvider) {
  97864. offlineProvider.loadFile(url, function (data) {
  97865. if (!aborted) {
  97866. onSuccess(data);
  97867. }
  97868. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  97869. }, onProgress ? function (event) {
  97870. if (!aborted) {
  97871. onProgress(event);
  97872. }
  97873. } : undefined, noOfflineSupport_1, useArrayBuffer);
  97874. }
  97875. };
  97876. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport_1);
  97877. }
  97878. else {
  97879. requestFile();
  97880. }
  97881. return fileRequest;
  97882. };
  97883. /**
  97884. * Load a script (identified by an url). When the url returns, the
  97885. * content of this file is added into a new script element, attached to the DOM (body element)
  97886. * @param scriptUrl defines the url of the script to laod
  97887. * @param onSuccess defines the callback called when the script is loaded
  97888. * @param onError defines the callback to call if an error occurs
  97889. */
  97890. Tools.LoadScript = function (scriptUrl, onSuccess, onError) {
  97891. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  97892. return;
  97893. }
  97894. var head = document.getElementsByTagName('head')[0];
  97895. var script = document.createElement('script');
  97896. script.type = 'text/javascript';
  97897. script.src = scriptUrl;
  97898. script.onload = function () {
  97899. if (onSuccess) {
  97900. onSuccess();
  97901. }
  97902. };
  97903. script.onerror = function (e) {
  97904. if (onError) {
  97905. onError("Unable to load script '" + scriptUrl + "'", e);
  97906. }
  97907. };
  97908. head.appendChild(script);
  97909. };
  97910. /**
  97911. * Loads a file from a blob
  97912. * @param fileToLoad defines the blob to use
  97913. * @param callback defines the callback to call when data is loaded
  97914. * @param progressCallback defines the callback to call during loading process
  97915. * @returns a file request object
  97916. */
  97917. Tools.ReadFileAsDataURL = function (fileToLoad, callback, progressCallback) {
  97918. var reader = new FileReader();
  97919. var request = {
  97920. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  97921. abort: function () { return reader.abort(); },
  97922. };
  97923. reader.onloadend = function (e) {
  97924. request.onCompleteObservable.notifyObservers(request);
  97925. };
  97926. reader.onload = function (e) {
  97927. //target doesn't have result from ts 1.3
  97928. callback(e.target['result']);
  97929. };
  97930. reader.onprogress = progressCallback;
  97931. reader.readAsDataURL(fileToLoad);
  97932. return request;
  97933. };
  97934. /**
  97935. * Loads a file
  97936. * @param fileToLoad defines the file to load
  97937. * @param callback defines the callback to call when data is loaded
  97938. * @param progressCallBack defines the callback to call during loading process
  97939. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  97940. * @returns a file request object
  97941. */
  97942. Tools.ReadFile = function (fileToLoad, callback, progressCallBack, useArrayBuffer) {
  97943. var reader = new FileReader();
  97944. var request = {
  97945. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  97946. abort: function () { return reader.abort(); },
  97947. };
  97948. reader.onloadend = function (e) { return request.onCompleteObservable.notifyObservers(request); };
  97949. reader.onerror = function (e) {
  97950. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log("Error while reading file: " + fileToLoad.name);
  97951. callback(JSON.stringify({ autoClear: true, clearColor: [1, 0, 0], ambientColor: [0, 0, 0], gravity: [0, -9.807, 0], meshes: [], cameras: [], lights: [] }));
  97952. };
  97953. reader.onload = function (e) {
  97954. //target doesn't have result from ts 1.3
  97955. callback(e.target['result']);
  97956. };
  97957. if (progressCallBack) {
  97958. reader.onprogress = progressCallBack;
  97959. }
  97960. if (!useArrayBuffer) {
  97961. // Asynchronous read
  97962. reader.readAsText(fileToLoad);
  97963. }
  97964. else {
  97965. reader.readAsArrayBuffer(fileToLoad);
  97966. }
  97967. return request;
  97968. };
  97969. /**
  97970. * Creates a data url from a given string content
  97971. * @param content defines the content to convert
  97972. * @returns the new data url link
  97973. */
  97974. Tools.FileAsURL = function (content) {
  97975. var fileBlob = new Blob([content]);
  97976. var url = window.URL || window.webkitURL;
  97977. var link = url.createObjectURL(fileBlob);
  97978. return link;
  97979. };
  97980. /**
  97981. * Format the given number to a specific decimal format
  97982. * @param value defines the number to format
  97983. * @param decimals defines the number of decimals to use
  97984. * @returns the formatted string
  97985. */
  97986. Tools.Format = function (value, decimals) {
  97987. if (decimals === void 0) { decimals = 2; }
  97988. return value.toFixed(decimals);
  97989. };
  97990. /**
  97991. * Checks if a given vector is inside a specific range
  97992. * @param v defines the vector to test
  97993. * @param min defines the minimum range
  97994. * @param max defines the maximum range
  97995. */
  97996. Tools.CheckExtends = function (v, min, max) {
  97997. min.minimizeInPlace(v);
  97998. max.maximizeInPlace(v);
  97999. };
  98000. /**
  98001. * Tries to copy an object by duplicating every property
  98002. * @param source defines the source object
  98003. * @param destination defines the target object
  98004. * @param doNotCopyList defines a list of properties to avoid
  98005. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98006. */
  98007. Tools.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  98008. _deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source, destination, doNotCopyList, mustCopyList);
  98009. };
  98010. /**
  98011. * Gets a boolean indicating if the given object has no own property
  98012. * @param obj defines the object to test
  98013. * @returns true if object has no own property
  98014. */
  98015. Tools.IsEmpty = function (obj) {
  98016. for (var i in obj) {
  98017. if (obj.hasOwnProperty(i)) {
  98018. return false;
  98019. }
  98020. }
  98021. return true;
  98022. };
  98023. /**
  98024. * Function used to register events at window level
  98025. * @param events defines the events to register
  98026. */
  98027. Tools.RegisterTopRootEvents = function (events) {
  98028. for (var index = 0; index < events.length; index++) {
  98029. var event = events[index];
  98030. window.addEventListener(event.name, event.handler, false);
  98031. try {
  98032. if (window.parent) {
  98033. window.parent.addEventListener(event.name, event.handler, false);
  98034. }
  98035. }
  98036. catch (e) {
  98037. // Silently fails...
  98038. }
  98039. }
  98040. };
  98041. /**
  98042. * Function used to unregister events from window level
  98043. * @param events defines the events to unregister
  98044. */
  98045. Tools.UnregisterTopRootEvents = function (events) {
  98046. for (var index = 0; index < events.length; index++) {
  98047. var event = events[index];
  98048. window.removeEventListener(event.name, event.handler);
  98049. try {
  98050. if (window.parent) {
  98051. window.parent.removeEventListener(event.name, event.handler);
  98052. }
  98053. }
  98054. catch (e) {
  98055. // Silently fails...
  98056. }
  98057. }
  98058. };
  98059. /**
  98060. * Dumps the current bound framebuffer
  98061. * @param width defines the rendering width
  98062. * @param height defines the rendering height
  98063. * @param engine defines the hosting engine
  98064. * @param successCallback defines the callback triggered once the data are available
  98065. * @param mimeType defines the mime type of the result
  98066. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  98067. */
  98068. Tools.DumpFramebuffer = function (width, height, engine, successCallback, mimeType, fileName) {
  98069. if (mimeType === void 0) { mimeType = "image/png"; }
  98070. // Read the contents of the framebuffer
  98071. var numberOfChannelsByLine = width * 4;
  98072. var halfHeight = height / 2;
  98073. //Reading datas from WebGL
  98074. var data = engine.readPixels(0, 0, width, height);
  98075. //To flip image on Y axis.
  98076. for (var i = 0; i < halfHeight; i++) {
  98077. for (var j = 0; j < numberOfChannelsByLine; j++) {
  98078. var currentCell = j + i * numberOfChannelsByLine;
  98079. var targetLine = height - i - 1;
  98080. var targetCell = j + targetLine * numberOfChannelsByLine;
  98081. var temp = data[currentCell];
  98082. data[currentCell] = data[targetCell];
  98083. data[targetCell] = temp;
  98084. }
  98085. }
  98086. // Create a 2D canvas to store the result
  98087. if (!screenshotCanvas) {
  98088. screenshotCanvas = document.createElement('canvas');
  98089. }
  98090. screenshotCanvas.width = width;
  98091. screenshotCanvas.height = height;
  98092. var context = screenshotCanvas.getContext('2d');
  98093. if (context) {
  98094. // Copy the pixels to a 2D canvas
  98095. var imageData = context.createImageData(width, height);
  98096. var castData = (imageData.data);
  98097. castData.set(data);
  98098. context.putImageData(imageData, 0, 0);
  98099. Tools.EncodeScreenshotCanvasData(successCallback, mimeType, fileName);
  98100. }
  98101. };
  98102. /**
  98103. * Converts the canvas data to blob.
  98104. * This acts as a polyfill for browsers not supporting the to blob function.
  98105. * @param canvas Defines the canvas to extract the data from
  98106. * @param successCallback Defines the callback triggered once the data are available
  98107. * @param mimeType Defines the mime type of the result
  98108. */
  98109. Tools.ToBlob = function (canvas, successCallback, mimeType) {
  98110. if (mimeType === void 0) { mimeType = "image/png"; }
  98111. // We need HTMLCanvasElement.toBlob for HD screenshots
  98112. if (!canvas.toBlob) {
  98113. // low performance polyfill based on toDataURL (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
  98114. canvas.toBlob = function (callback, type, quality) {
  98115. var _this = this;
  98116. setTimeout(function () {
  98117. var binStr = atob(_this.toDataURL(type, quality).split(',')[1]), len = binStr.length, arr = new Uint8Array(len);
  98118. for (var i = 0; i < len; i++) {
  98119. arr[i] = binStr.charCodeAt(i);
  98120. }
  98121. callback(new Blob([arr]));
  98122. });
  98123. };
  98124. }
  98125. canvas.toBlob(function (blob) {
  98126. successCallback(blob);
  98127. }, mimeType);
  98128. };
  98129. /**
  98130. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  98131. * @param successCallback defines the callback triggered once the data are available
  98132. * @param mimeType defines the mime type of the result
  98133. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  98134. */
  98135. Tools.EncodeScreenshotCanvasData = function (successCallback, mimeType, fileName) {
  98136. if (mimeType === void 0) { mimeType = "image/png"; }
  98137. if (successCallback) {
  98138. var base64Image = screenshotCanvas.toDataURL(mimeType);
  98139. successCallback(base64Image);
  98140. }
  98141. else {
  98142. this.ToBlob(screenshotCanvas, function (blob) {
  98143. //Creating a link if the browser have the download attribute on the a tag, to automatically start download generated image.
  98144. if (("download" in document.createElement("a"))) {
  98145. if (!fileName) {
  98146. var date = new Date();
  98147. var stringDate = (date.getFullYear() + "-" + (date.getMonth() + 1)).slice(2) + "-" + date.getDate() + "_" + date.getHours() + "-" + ('0' + date.getMinutes()).slice(-2);
  98148. fileName = "screenshot_" + stringDate + ".png";
  98149. }
  98150. Tools.Download(blob, fileName);
  98151. }
  98152. else {
  98153. var url = URL.createObjectURL(blob);
  98154. var newWindow = window.open("");
  98155. if (!newWindow) {
  98156. return;
  98157. }
  98158. var img = newWindow.document.createElement("img");
  98159. img.onload = function () {
  98160. // no longer need to read the blob so it's revoked
  98161. URL.revokeObjectURL(url);
  98162. };
  98163. img.src = url;
  98164. newWindow.document.body.appendChild(img);
  98165. }
  98166. }, mimeType);
  98167. }
  98168. };
  98169. /**
  98170. * Downloads a blob in the browser
  98171. * @param blob defines the blob to download
  98172. * @param fileName defines the name of the downloaded file
  98173. */
  98174. Tools.Download = function (blob, fileName) {
  98175. if (navigator && navigator.msSaveBlob) {
  98176. navigator.msSaveBlob(blob, fileName);
  98177. return;
  98178. }
  98179. var url = window.URL.createObjectURL(blob);
  98180. var a = document.createElement("a");
  98181. document.body.appendChild(a);
  98182. a.style.display = "none";
  98183. a.href = url;
  98184. a.download = fileName;
  98185. a.addEventListener("click", function () {
  98186. if (a.parentElement) {
  98187. a.parentElement.removeChild(a);
  98188. }
  98189. });
  98190. a.click();
  98191. window.URL.revokeObjectURL(url);
  98192. };
  98193. /**
  98194. * Captures a screenshot of the current rendering
  98195. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98196. * @param engine defines the rendering engine
  98197. * @param camera defines the source camera
  98198. * @param size This parameter can be set to a single number or to an object with the
  98199. * following (optional) properties: precision, width, height. If a single number is passed,
  98200. * it will be used for both width and height. If an object is passed, the screenshot size
  98201. * will be derived from the parameters. The precision property is a multiplier allowing
  98202. * rendering at a higher or lower resolution
  98203. * @param successCallback defines the callback receives a single parameter which contains the
  98204. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98205. * src parameter of an <img> to display it
  98206. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98207. * Check your browser for supported MIME types
  98208. */
  98209. Tools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  98210. if (mimeType === void 0) { mimeType = "image/png"; }
  98211. throw "Import ScreenshotTools before creating screenshot.";
  98212. };
  98213. /**
  98214. * Generates an image screenshot from the specified camera.
  98215. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98216. * @param engine The engine to use for rendering
  98217. * @param camera The camera to use for rendering
  98218. * @param size This parameter can be set to a single number or to an object with the
  98219. * following (optional) properties: precision, width, height. If a single number is passed,
  98220. * it will be used for both width and height. If an object is passed, the screenshot size
  98221. * will be derived from the parameters. The precision property is a multiplier allowing
  98222. * rendering at a higher or lower resolution
  98223. * @param successCallback The callback receives a single parameter which contains the
  98224. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98225. * src parameter of an <img> to display it
  98226. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98227. * Check your browser for supported MIME types
  98228. * @param samples Texture samples (default: 1)
  98229. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98230. * @param fileName A name for for the downloaded file.
  98231. */
  98232. Tools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  98233. if (mimeType === void 0) { mimeType = "image/png"; }
  98234. if (samples === void 0) { samples = 1; }
  98235. if (antialiasing === void 0) { antialiasing = false; }
  98236. throw "Import ScreenshotTools before creating screenshot.";
  98237. };
  98238. /**
  98239. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98240. * Be aware Math.random() could cause collisions, but:
  98241. * "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"
  98242. * @returns a pseudo random id
  98243. */
  98244. Tools.RandomId = function () {
  98245. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  98246. var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
  98247. return v.toString(16);
  98248. });
  98249. };
  98250. /**
  98251. * Test if the given uri is a base64 string
  98252. * @param uri The uri to test
  98253. * @return True if the uri is a base64 string or false otherwise
  98254. */
  98255. Tools.IsBase64 = function (uri) {
  98256. return uri.length < 5 ? false : uri.substr(0, 5) === "data:";
  98257. };
  98258. /**
  98259. * Decode the given base64 uri.
  98260. * @param uri The uri to decode
  98261. * @return The decoded base64 data.
  98262. */
  98263. Tools.DecodeBase64 = function (uri) {
  98264. var decodedString = atob(uri.split(",")[1]);
  98265. var bufferLength = decodedString.length;
  98266. var bufferView = new Uint8Array(new ArrayBuffer(bufferLength));
  98267. for (var i = 0; i < bufferLength; i++) {
  98268. bufferView[i] = decodedString.charCodeAt(i);
  98269. }
  98270. return bufferView.buffer;
  98271. };
  98272. Object.defineProperty(Tools, "errorsCount", {
  98273. /**
  98274. * Gets a value indicating the number of loading errors
  98275. * @ignorenaming
  98276. */
  98277. get: function () {
  98278. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].errorsCount;
  98279. },
  98280. enumerable: true,
  98281. configurable: true
  98282. });
  98283. /**
  98284. * Log a message to the console
  98285. * @param message defines the message to log
  98286. */
  98287. Tools.Log = function (message) {
  98288. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log(message);
  98289. };
  98290. /**
  98291. * Write a warning message to the console
  98292. * @param message defines the message to log
  98293. */
  98294. Tools.Warn = function (message) {
  98295. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(message);
  98296. };
  98297. /**
  98298. * Write an error message to the console
  98299. * @param message defines the message to log
  98300. */
  98301. Tools.Error = function (message) {
  98302. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error(message);
  98303. };
  98304. Object.defineProperty(Tools, "LogCache", {
  98305. /**
  98306. * Gets current log cache (list of logs)
  98307. */
  98308. get: function () {
  98309. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogCache;
  98310. },
  98311. enumerable: true,
  98312. configurable: true
  98313. });
  98314. /**
  98315. * Clears the log cache
  98316. */
  98317. Tools.ClearLogCache = function () {
  98318. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ClearLogCache();
  98319. };
  98320. Object.defineProperty(Tools, "LogLevels", {
  98321. /**
  98322. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  98323. */
  98324. set: function (level) {
  98325. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogLevels = level;
  98326. },
  98327. enumerable: true,
  98328. configurable: true
  98329. });
  98330. /**
  98331. * Checks if the loaded document was accessed via `file:`-Protocol.
  98332. * @returns boolean
  98333. */
  98334. Tools.IsFileURL = function () {
  98335. return location.protocol === "file:";
  98336. };
  98337. Object.defineProperty(Tools, "PerformanceLogLevel", {
  98338. /**
  98339. * Sets the current performance log level
  98340. */
  98341. set: function (level) {
  98342. if ((level & Tools.PerformanceUserMarkLogLevel) === Tools.PerformanceUserMarkLogLevel) {
  98343. Tools.StartPerformanceCounter = Tools._StartUserMark;
  98344. Tools.EndPerformanceCounter = Tools._EndUserMark;
  98345. return;
  98346. }
  98347. if ((level & Tools.PerformanceConsoleLogLevel) === Tools.PerformanceConsoleLogLevel) {
  98348. Tools.StartPerformanceCounter = Tools._StartPerformanceConsole;
  98349. Tools.EndPerformanceCounter = Tools._EndPerformanceConsole;
  98350. return;
  98351. }
  98352. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  98353. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  98354. },
  98355. enumerable: true,
  98356. configurable: true
  98357. });
  98358. Tools._StartPerformanceCounterDisabled = function (counterName, condition) {
  98359. };
  98360. Tools._EndPerformanceCounterDisabled = function (counterName, condition) {
  98361. };
  98362. Tools._StartUserMark = function (counterName, condition) {
  98363. if (condition === void 0) { condition = true; }
  98364. if (!Tools._performance) {
  98365. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  98366. return;
  98367. }
  98368. Tools._performance = window.performance;
  98369. }
  98370. if (!condition || !Tools._performance.mark) {
  98371. return;
  98372. }
  98373. Tools._performance.mark(counterName + "-Begin");
  98374. };
  98375. Tools._EndUserMark = function (counterName, condition) {
  98376. if (condition === void 0) { condition = true; }
  98377. if (!condition || !Tools._performance.mark) {
  98378. return;
  98379. }
  98380. Tools._performance.mark(counterName + "-End");
  98381. Tools._performance.measure(counterName, counterName + "-Begin", counterName + "-End");
  98382. };
  98383. Tools._StartPerformanceConsole = function (counterName, condition) {
  98384. if (condition === void 0) { condition = true; }
  98385. if (!condition) {
  98386. return;
  98387. }
  98388. Tools._StartUserMark(counterName, condition);
  98389. if (console.time) {
  98390. console.time(counterName);
  98391. }
  98392. };
  98393. Tools._EndPerformanceConsole = function (counterName, condition) {
  98394. if (condition === void 0) { condition = true; }
  98395. if (!condition) {
  98396. return;
  98397. }
  98398. Tools._EndUserMark(counterName, condition);
  98399. if (console.time) {
  98400. console.timeEnd(counterName);
  98401. }
  98402. };
  98403. /**
  98404. * Injects the @see CustomRequestHeaders into the given request
  98405. * @param request the request that should be used for injection
  98406. */
  98407. Tools.InjectCustomRequestHeaders = function (request) {
  98408. for (var key in Tools.CustomRequestHeaders) {
  98409. var val = Tools.CustomRequestHeaders[key];
  98410. if (val) {
  98411. request.setRequestHeader(key, val);
  98412. }
  98413. }
  98414. };
  98415. Object.defineProperty(Tools, "Now", {
  98416. /**
  98417. * Gets either window.performance.now() if supported or Date.now() else
  98418. */
  98419. get: function () {
  98420. return _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  98421. },
  98422. enumerable: true,
  98423. configurable: true
  98424. });
  98425. /**
  98426. * This method will return the name of the class used to create the instance of the given object.
  98427. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  98428. * @param object the object to get the class name from
  98429. * @param isType defines if the object is actually a type
  98430. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  98431. */
  98432. Tools.GetClassName = function (object, isType) {
  98433. if (isType === void 0) { isType = false; }
  98434. var name = null;
  98435. if (!isType && object.getClassName) {
  98436. name = object.getClassName();
  98437. }
  98438. else {
  98439. if (object instanceof Object) {
  98440. var classObj = isType ? object : Object.getPrototypeOf(object);
  98441. name = classObj.constructor["__bjsclassName__"];
  98442. }
  98443. if (!name) {
  98444. name = typeof object;
  98445. }
  98446. }
  98447. return name;
  98448. };
  98449. /**
  98450. * Gets the first element of an array satisfying a given predicate
  98451. * @param array defines the array to browse
  98452. * @param predicate defines the predicate to use
  98453. * @returns null if not found or the element
  98454. */
  98455. Tools.First = function (array, predicate) {
  98456. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  98457. var el = array_1[_i];
  98458. if (predicate(el)) {
  98459. return el;
  98460. }
  98461. }
  98462. return null;
  98463. };
  98464. /**
  98465. * This method will return the name of the full name of the class, including its owning module (if any).
  98466. * 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).
  98467. * @param object the object to get the class name from
  98468. * @param isType defines if the object is actually a type
  98469. * @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.
  98470. * @ignorenaming
  98471. */
  98472. Tools.getFullClassName = function (object, isType) {
  98473. if (isType === void 0) { isType = false; }
  98474. var className = null;
  98475. var moduleName = null;
  98476. if (!isType && object.getClassName) {
  98477. className = object.getClassName();
  98478. }
  98479. else {
  98480. if (object instanceof Object) {
  98481. var classObj = isType ? object : Object.getPrototypeOf(object);
  98482. className = classObj.constructor["__bjsclassName__"];
  98483. moduleName = classObj.constructor["__bjsmoduleName__"];
  98484. }
  98485. if (!className) {
  98486. className = typeof object;
  98487. }
  98488. }
  98489. if (!className) {
  98490. return null;
  98491. }
  98492. return ((moduleName != null) ? (moduleName + ".") : "") + className;
  98493. };
  98494. /**
  98495. * Returns a promise that resolves after the given amount of time.
  98496. * @param delay Number of milliseconds to delay
  98497. * @returns Promise that resolves after the given amount of time
  98498. */
  98499. Tools.DelayAsync = function (delay) {
  98500. return new Promise(function (resolve) {
  98501. setTimeout(function () {
  98502. resolve();
  98503. }, delay);
  98504. });
  98505. };
  98506. /**
  98507. * Gets the current gradient from an array of IValueGradient
  98508. * @param ratio defines the current ratio to get
  98509. * @param gradients defines the array of IValueGradient
  98510. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  98511. */
  98512. Tools.GetCurrentGradient = function (ratio, gradients, updateFunc) {
  98513. for (var gradientIndex = 0; gradientIndex < gradients.length - 1; gradientIndex++) {
  98514. var currentGradient = gradients[gradientIndex];
  98515. var nextGradient = gradients[gradientIndex + 1];
  98516. if (ratio >= currentGradient.gradient && ratio <= nextGradient.gradient) {
  98517. var scale = (ratio - currentGradient.gradient) / (nextGradient.gradient - currentGradient.gradient);
  98518. updateFunc(currentGradient, nextGradient, scale);
  98519. return;
  98520. }
  98521. }
  98522. // Use last index if over
  98523. var lastIndex = gradients.length - 1;
  98524. updateFunc(gradients[lastIndex], gradients[lastIndex], 1.0);
  98525. };
  98526. /**
  98527. * Gets or sets the base URL to use to load assets
  98528. */
  98529. Tools.BaseUrl = "";
  98530. /**
  98531. * Enable/Disable Custom HTTP Request Headers globally.
  98532. * default = false
  98533. * @see CustomRequestHeaders
  98534. */
  98535. Tools.UseCustomRequestHeaders = false;
  98536. /**
  98537. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  98538. * i.e. when loading files, where the server/service expects an Authorization header.
  98539. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  98540. */
  98541. Tools.CustomRequestHeaders = {};
  98542. /**
  98543. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  98544. */
  98545. Tools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff();
  98546. /**
  98547. * Default behaviour for cors in the application.
  98548. * It can be a string if the expected behavior is identical in the entire app.
  98549. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  98550. */
  98551. Tools.CorsBehavior = "anonymous";
  98552. /**
  98553. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98554. * @ignorenaming
  98555. */
  98556. Tools.UseFallbackTexture = true;
  98557. /**
  98558. * Use this object to register external classes like custom textures or material
  98559. * to allow the laoders to instantiate them
  98560. */
  98561. Tools.RegisteredExternalClasses = {};
  98562. /**
  98563. * Texture content used if a texture cannot loaded
  98564. * @ignorenaming
  98565. */
  98566. 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";
  98567. Tools._tmpFloatArray = new Float32Array(1);
  98568. /**
  98569. * Extracts text content from a DOM element hierarchy
  98570. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  98571. */
  98572. Tools.GetDOMTextContent = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].GetDOMTextContent;
  98573. /**
  98574. * Gets or sets a function used to pre-process url before using them to load assets
  98575. */
  98576. Tools.PreprocessUrl = function (url) {
  98577. return url;
  98578. };
  98579. // Logs
  98580. /**
  98581. * No log
  98582. */
  98583. Tools.NoneLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].NoneLogLevel;
  98584. /**
  98585. * Only message logs
  98586. */
  98587. Tools.MessageLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].MessageLogLevel;
  98588. /**
  98589. * Only warning logs
  98590. */
  98591. Tools.WarningLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].WarningLogLevel;
  98592. /**
  98593. * Only error logs
  98594. */
  98595. Tools.ErrorLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ErrorLogLevel;
  98596. /**
  98597. * All logs
  98598. */
  98599. Tools.AllLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].AllLogLevel;
  98600. /**
  98601. * Checks if the window object exists
  98602. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  98603. */
  98604. Tools.IsWindowObjectExist = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist;
  98605. // Performances
  98606. /**
  98607. * No performance log
  98608. */
  98609. Tools.PerformanceNoneLogLevel = 0;
  98610. /**
  98611. * Use user marks to log performance
  98612. */
  98613. Tools.PerformanceUserMarkLogLevel = 1;
  98614. /**
  98615. * Log performance to the console
  98616. */
  98617. Tools.PerformanceConsoleLogLevel = 2;
  98618. /**
  98619. * Starts a performance counter
  98620. */
  98621. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  98622. /**
  98623. * Ends a specific performance coutner
  98624. */
  98625. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  98626. return Tools;
  98627. }());
  98628. /**
  98629. * This class is used to track a performance counter which is number based.
  98630. * The user has access to many properties which give statistics of different nature.
  98631. *
  98632. * The implementer can track two kinds of Performance Counter: time and count.
  98633. * 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.
  98634. * 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.
  98635. */
  98636. var PerfCounter = /** @class */ (function () {
  98637. /**
  98638. * Creates a new counter
  98639. */
  98640. function PerfCounter() {
  98641. this._startMonitoringTime = 0;
  98642. this._min = 0;
  98643. this._max = 0;
  98644. this._average = 0;
  98645. this._lastSecAverage = 0;
  98646. this._current = 0;
  98647. this._totalValueCount = 0;
  98648. this._totalAccumulated = 0;
  98649. this._lastSecAccumulated = 0;
  98650. this._lastSecTime = 0;
  98651. this._lastSecValueCount = 0;
  98652. }
  98653. Object.defineProperty(PerfCounter.prototype, "min", {
  98654. /**
  98655. * Returns the smallest value ever
  98656. */
  98657. get: function () {
  98658. return this._min;
  98659. },
  98660. enumerable: true,
  98661. configurable: true
  98662. });
  98663. Object.defineProperty(PerfCounter.prototype, "max", {
  98664. /**
  98665. * Returns the biggest value ever
  98666. */
  98667. get: function () {
  98668. return this._max;
  98669. },
  98670. enumerable: true,
  98671. configurable: true
  98672. });
  98673. Object.defineProperty(PerfCounter.prototype, "average", {
  98674. /**
  98675. * Returns the average value since the performance counter is running
  98676. */
  98677. get: function () {
  98678. return this._average;
  98679. },
  98680. enumerable: true,
  98681. configurable: true
  98682. });
  98683. Object.defineProperty(PerfCounter.prototype, "lastSecAverage", {
  98684. /**
  98685. * Returns the average value of the last second the counter was monitored
  98686. */
  98687. get: function () {
  98688. return this._lastSecAverage;
  98689. },
  98690. enumerable: true,
  98691. configurable: true
  98692. });
  98693. Object.defineProperty(PerfCounter.prototype, "current", {
  98694. /**
  98695. * Returns the current value
  98696. */
  98697. get: function () {
  98698. return this._current;
  98699. },
  98700. enumerable: true,
  98701. configurable: true
  98702. });
  98703. Object.defineProperty(PerfCounter.prototype, "total", {
  98704. /**
  98705. * Gets the accumulated total
  98706. */
  98707. get: function () {
  98708. return this._totalAccumulated;
  98709. },
  98710. enumerable: true,
  98711. configurable: true
  98712. });
  98713. Object.defineProperty(PerfCounter.prototype, "count", {
  98714. /**
  98715. * Gets the total value count
  98716. */
  98717. get: function () {
  98718. return this._totalValueCount;
  98719. },
  98720. enumerable: true,
  98721. configurable: true
  98722. });
  98723. /**
  98724. * Call this method to start monitoring a new frame.
  98725. * 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.
  98726. */
  98727. PerfCounter.prototype.fetchNewFrame = function () {
  98728. this._totalValueCount++;
  98729. this._current = 0;
  98730. this._lastSecValueCount++;
  98731. };
  98732. /**
  98733. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  98734. * @param newCount the count value to add to the monitored count
  98735. * @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.
  98736. */
  98737. PerfCounter.prototype.addCount = function (newCount, fetchResult) {
  98738. if (!PerfCounter.Enabled) {
  98739. return;
  98740. }
  98741. this._current += newCount;
  98742. if (fetchResult) {
  98743. this._fetchResult();
  98744. }
  98745. };
  98746. /**
  98747. * Start monitoring this performance counter
  98748. */
  98749. PerfCounter.prototype.beginMonitoring = function () {
  98750. if (!PerfCounter.Enabled) {
  98751. return;
  98752. }
  98753. this._startMonitoringTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  98754. };
  98755. /**
  98756. * Compute the time lapsed since the previous beginMonitoring() call.
  98757. * @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
  98758. */
  98759. PerfCounter.prototype.endMonitoring = function (newFrame) {
  98760. if (newFrame === void 0) { newFrame = true; }
  98761. if (!PerfCounter.Enabled) {
  98762. return;
  98763. }
  98764. if (newFrame) {
  98765. this.fetchNewFrame();
  98766. }
  98767. var currentTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  98768. this._current = currentTime - this._startMonitoringTime;
  98769. if (newFrame) {
  98770. this._fetchResult();
  98771. }
  98772. };
  98773. PerfCounter.prototype._fetchResult = function () {
  98774. this._totalAccumulated += this._current;
  98775. this._lastSecAccumulated += this._current;
  98776. // Min/Max update
  98777. this._min = Math.min(this._min, this._current);
  98778. this._max = Math.max(this._max, this._current);
  98779. this._average = this._totalAccumulated / this._totalValueCount;
  98780. // Reset last sec?
  98781. var now = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  98782. if ((now - this._lastSecTime) > 1000) {
  98783. this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount;
  98784. this._lastSecTime = now;
  98785. this._lastSecAccumulated = 0;
  98786. this._lastSecValueCount = 0;
  98787. }
  98788. };
  98789. /**
  98790. * Gets or sets a global boolean to turn on and off all the counters
  98791. */
  98792. PerfCounter.Enabled = true;
  98793. return PerfCounter;
  98794. }());
  98795. /**
  98796. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  98797. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  98798. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  98799. * @param name The name of the class, case should be preserved
  98800. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  98801. */
  98802. function className(name, module) {
  98803. return function (target) {
  98804. target["__bjsclassName__"] = name;
  98805. target["__bjsmoduleName__"] = (module != null) ? module : null;
  98806. };
  98807. }
  98808. /**
  98809. * An implementation of a loop for asynchronous functions.
  98810. */
  98811. var AsyncLoop = /** @class */ (function () {
  98812. /**
  98813. * Constructor.
  98814. * @param iterations the number of iterations.
  98815. * @param func the function to run each iteration
  98816. * @param successCallback the callback that will be called upon succesful execution
  98817. * @param offset starting offset.
  98818. */
  98819. function AsyncLoop(
  98820. /**
  98821. * Defines the number of iterations for the loop
  98822. */
  98823. iterations, func, successCallback, offset) {
  98824. if (offset === void 0) { offset = 0; }
  98825. this.iterations = iterations;
  98826. this.index = offset - 1;
  98827. this._done = false;
  98828. this._fn = func;
  98829. this._successCallback = successCallback;
  98830. }
  98831. /**
  98832. * Execute the next iteration. Must be called after the last iteration was finished.
  98833. */
  98834. AsyncLoop.prototype.executeNext = function () {
  98835. if (!this._done) {
  98836. if (this.index + 1 < this.iterations) {
  98837. ++this.index;
  98838. this._fn(this);
  98839. }
  98840. else {
  98841. this.breakLoop();
  98842. }
  98843. }
  98844. };
  98845. /**
  98846. * Break the loop and run the success callback.
  98847. */
  98848. AsyncLoop.prototype.breakLoop = function () {
  98849. this._done = true;
  98850. this._successCallback();
  98851. };
  98852. /**
  98853. * Create and run an async loop.
  98854. * @param iterations the number of iterations.
  98855. * @param fn the function to run each iteration
  98856. * @param successCallback the callback that will be called upon succesful execution
  98857. * @param offset starting offset.
  98858. * @returns the created async loop object
  98859. */
  98860. AsyncLoop.Run = function (iterations, fn, successCallback, offset) {
  98861. if (offset === void 0) { offset = 0; }
  98862. var loop = new AsyncLoop(iterations, fn, successCallback, offset);
  98863. loop.executeNext();
  98864. return loop;
  98865. };
  98866. /**
  98867. * A for-loop that will run a given number of iterations synchronous and the rest async.
  98868. * @param iterations total number of iterations
  98869. * @param syncedIterations number of synchronous iterations in each async iteration.
  98870. * @param fn the function to call each iteration.
  98871. * @param callback a success call back that will be called when iterating stops.
  98872. * @param breakFunction a break condition (optional)
  98873. * @param timeout timeout settings for the setTimeout function. default - 0.
  98874. * @returns the created async loop object
  98875. */
  98876. AsyncLoop.SyncAsyncForLoop = function (iterations, syncedIterations, fn, callback, breakFunction, timeout) {
  98877. if (timeout === void 0) { timeout = 0; }
  98878. return AsyncLoop.Run(Math.ceil(iterations / syncedIterations), function (loop) {
  98879. if (breakFunction && breakFunction()) {
  98880. loop.breakLoop();
  98881. }
  98882. else {
  98883. setTimeout(function () {
  98884. for (var i = 0; i < syncedIterations; ++i) {
  98885. var iteration = (loop.index * syncedIterations) + i;
  98886. if (iteration >= iterations) {
  98887. break;
  98888. }
  98889. fn(iteration);
  98890. if (breakFunction && breakFunction()) {
  98891. loop.breakLoop();
  98892. break;
  98893. }
  98894. }
  98895. loop.executeNext();
  98896. }, timeout);
  98897. }
  98898. }, callback);
  98899. };
  98900. return AsyncLoop;
  98901. }());
  98902. /***/ }),
  98903. /***/ "./Misc/typeStore.ts":
  98904. /*!***************************!*\
  98905. !*** ./Misc/typeStore.ts ***!
  98906. \***************************/
  98907. /*! exports provided: _TypeStore */
  98908. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98909. "use strict";
  98910. __webpack_require__.r(__webpack_exports__);
  98911. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _TypeStore; });
  98912. /** @hidden */
  98913. var _TypeStore = /** @class */ (function () {
  98914. function _TypeStore() {
  98915. }
  98916. /** @hidden */
  98917. _TypeStore.GetClass = function (fqdn) {
  98918. if (this.RegisteredTypes && this.RegisteredTypes[fqdn]) {
  98919. return this.RegisteredTypes[fqdn];
  98920. }
  98921. return null;
  98922. };
  98923. /** @hidden */
  98924. _TypeStore.RegisteredTypes = {};
  98925. return _TypeStore;
  98926. }());
  98927. /***/ }),
  98928. /***/ "./Misc/videoRecorder.ts":
  98929. /*!*******************************!*\
  98930. !*** ./Misc/videoRecorder.ts ***!
  98931. \*******************************/
  98932. /*! exports provided: VideoRecorder */
  98933. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98934. "use strict";
  98935. __webpack_require__.r(__webpack_exports__);
  98936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return VideoRecorder; });
  98937. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  98938. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  98939. /**
  98940. * This can helps recording videos from BabylonJS.
  98941. * This is based on the available WebRTC functionalities of the browser.
  98942. *
  98943. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  98944. */
  98945. var VideoRecorder = /** @class */ (function () {
  98946. /**
  98947. * Create a new VideoCapture object which can help converting what you see in Babylon to
  98948. * a video file.
  98949. * @param engine Defines the BabylonJS Engine you wish to record
  98950. * @param options Defines options that can be used to customized the capture
  98951. */
  98952. function VideoRecorder(engine, options) {
  98953. if (options === void 0) { options = null; }
  98954. if (!VideoRecorder.IsSupported(engine)) {
  98955. throw "Your browser does not support recording so far.";
  98956. }
  98957. var canvas = engine.getRenderingCanvas();
  98958. if (!canvas) {
  98959. throw "The babylon engine must have a canvas to be recorded";
  98960. }
  98961. this._canvas = canvas;
  98962. this._canvas.isRecording = false;
  98963. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, VideoRecorder._defaultOptions, options);
  98964. var stream = this._canvas.captureStream(this._options.fps);
  98965. this._mediaRecorder = new MediaRecorder(stream, { mimeType: this._options.mimeType });
  98966. this._mediaRecorder.ondataavailable = this._handleDataAvailable.bind(this);
  98967. this._mediaRecorder.onerror = this._handleError.bind(this);
  98968. this._mediaRecorder.onstop = this._handleStop.bind(this);
  98969. }
  98970. /**
  98971. * Returns wehther or not the VideoRecorder is available in your browser.
  98972. * @param engine Defines the Babylon Engine to check the support for
  98973. * @returns true if supported otherwise false
  98974. */
  98975. VideoRecorder.IsSupported = function (engine) {
  98976. var canvas = engine.getRenderingCanvas();
  98977. return (!!canvas && typeof canvas.captureStream === "function");
  98978. };
  98979. Object.defineProperty(VideoRecorder.prototype, "isRecording", {
  98980. /**
  98981. * True wether a recording is already in progress.
  98982. */
  98983. get: function () {
  98984. return !!this._canvas && this._canvas.isRecording;
  98985. },
  98986. enumerable: true,
  98987. configurable: true
  98988. });
  98989. /**
  98990. * Stops the current recording before the default capture timeout passed in the startRecording
  98991. * functions.
  98992. */
  98993. VideoRecorder.prototype.stopRecording = function () {
  98994. if (!this._canvas || !this._mediaRecorder) {
  98995. return;
  98996. }
  98997. if (!this.isRecording) {
  98998. return;
  98999. }
  99000. this._canvas.isRecording = false;
  99001. this._mediaRecorder.stop();
  99002. };
  99003. /**
  99004. * Starts recording the canvas for a max duration specified in parameters.
  99005. * @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.
  99006. * @param maxDuration Defines the maximum recording time in seconds.
  99007. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  99008. * @return a promise callback at the end of the recording with the video data in Blob.
  99009. */
  99010. VideoRecorder.prototype.startRecording = function (fileName, maxDuration) {
  99011. var _this = this;
  99012. if (fileName === void 0) { fileName = "babylonjs.webm"; }
  99013. if (maxDuration === void 0) { maxDuration = 7; }
  99014. if (!this._canvas || !this._mediaRecorder) {
  99015. throw "Recorder has already been disposed";
  99016. }
  99017. if (this.isRecording) {
  99018. throw "Recording already in progress";
  99019. }
  99020. if (maxDuration > 0) {
  99021. setTimeout(function () {
  99022. _this.stopRecording();
  99023. }, maxDuration * 1000);
  99024. }
  99025. this._fileName = fileName;
  99026. this._recordedChunks = [];
  99027. this._resolve = null;
  99028. this._reject = null;
  99029. this._canvas.isRecording = true;
  99030. this._mediaRecorder.start(this._options.recordChunckSize);
  99031. return new Promise(function (resolve, reject) {
  99032. _this._resolve = resolve;
  99033. _this._reject = reject;
  99034. });
  99035. };
  99036. /**
  99037. * Releases internal resources used during the recording.
  99038. */
  99039. VideoRecorder.prototype.dispose = function () {
  99040. this._canvas = null;
  99041. this._mediaRecorder = null;
  99042. this._recordedChunks = [];
  99043. this._fileName = null;
  99044. this._resolve = null;
  99045. this._reject = null;
  99046. };
  99047. VideoRecorder.prototype._handleDataAvailable = function (event) {
  99048. if (event.data.size > 0) {
  99049. this._recordedChunks.push(event.data);
  99050. }
  99051. };
  99052. VideoRecorder.prototype._handleError = function (event) {
  99053. this.stopRecording();
  99054. if (this._reject) {
  99055. this._reject(event.error);
  99056. }
  99057. else {
  99058. throw new event.error();
  99059. }
  99060. };
  99061. VideoRecorder.prototype._handleStop = function () {
  99062. this.stopRecording();
  99063. var superBuffer = new Blob(this._recordedChunks);
  99064. if (this._resolve) {
  99065. this._resolve(superBuffer);
  99066. }
  99067. window.URL.createObjectURL(superBuffer);
  99068. if (this._fileName) {
  99069. _tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Download(superBuffer, this._fileName);
  99070. }
  99071. };
  99072. VideoRecorder._defaultOptions = {
  99073. mimeType: "video/webm",
  99074. fps: 25,
  99075. recordChunckSize: 3000
  99076. };
  99077. return VideoRecorder;
  99078. }());
  99079. /***/ }),
  99080. /***/ "./Misc/virtualJoystick.ts":
  99081. /*!*********************************!*\
  99082. !*** ./Misc/virtualJoystick.ts ***!
  99083. \*********************************/
  99084. /*! exports provided: JoystickAxis, VirtualJoystick */
  99085. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99086. "use strict";
  99087. __webpack_require__.r(__webpack_exports__);
  99088. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return JoystickAxis; });
  99089. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return VirtualJoystick; });
  99090. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  99091. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  99092. // Mainly based on these 2 articles :
  99093. // 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
  99094. // & on Seb Lee-Delisle original work: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/
  99095. /**
  99096. * Defines the potential axis of a Joystick
  99097. */
  99098. var JoystickAxis;
  99099. (function (JoystickAxis) {
  99100. /** X axis */
  99101. JoystickAxis[JoystickAxis["X"] = 0] = "X";
  99102. /** Y axis */
  99103. JoystickAxis[JoystickAxis["Y"] = 1] = "Y";
  99104. /** Z axis */
  99105. JoystickAxis[JoystickAxis["Z"] = 2] = "Z";
  99106. })(JoystickAxis || (JoystickAxis = {}));
  99107. /**
  99108. * Class used to define virtual joystick (used in touch mode)
  99109. */
  99110. var VirtualJoystick = /** @class */ (function () {
  99111. /**
  99112. * Creates a new virtual joystick
  99113. * @param leftJoystick defines that the joystick is for left hand (false by default)
  99114. */
  99115. function VirtualJoystick(leftJoystick) {
  99116. var _this = this;
  99117. if (leftJoystick) {
  99118. this._leftJoystick = true;
  99119. }
  99120. else {
  99121. this._leftJoystick = false;
  99122. }
  99123. VirtualJoystick._globalJoystickIndex++;
  99124. // By default left & right arrow keys are moving the X
  99125. // and up & down keys are moving the Y
  99126. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  99127. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  99128. this.reverseLeftRight = false;
  99129. this.reverseUpDown = false;
  99130. // collections of pointers
  99131. this._touches = new _stringDictionary__WEBPACK_IMPORTED_MODULE_1__["StringDictionary"]();
  99132. this.deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  99133. this._joystickSensibility = 25;
  99134. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  99135. this._onResize = function (evt) {
  99136. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  99137. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  99138. if (VirtualJoystick.Canvas) {
  99139. VirtualJoystick.Canvas.width = VirtualJoystick.vjCanvasWidth;
  99140. VirtualJoystick.Canvas.height = VirtualJoystick.vjCanvasHeight;
  99141. }
  99142. VirtualJoystick.halfWidth = VirtualJoystick.vjCanvasWidth / 2;
  99143. };
  99144. // injecting a canvas element on top of the canvas 3D game
  99145. if (!VirtualJoystick.Canvas) {
  99146. window.addEventListener("resize", this._onResize, false);
  99147. VirtualJoystick.Canvas = document.createElement("canvas");
  99148. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  99149. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  99150. VirtualJoystick.Canvas.width = window.innerWidth;
  99151. VirtualJoystick.Canvas.height = window.innerHeight;
  99152. VirtualJoystick.Canvas.style.width = "100%";
  99153. VirtualJoystick.Canvas.style.height = "100%";
  99154. VirtualJoystick.Canvas.style.position = "absolute";
  99155. VirtualJoystick.Canvas.style.backgroundColor = "transparent";
  99156. VirtualJoystick.Canvas.style.top = "0px";
  99157. VirtualJoystick.Canvas.style.left = "0px";
  99158. VirtualJoystick.Canvas.style.zIndex = "5";
  99159. VirtualJoystick.Canvas.style.msTouchAction = "none";
  99160. // Support for jQuery PEP polyfill
  99161. VirtualJoystick.Canvas.setAttribute("touch-action", "none");
  99162. var context = VirtualJoystick.Canvas.getContext('2d');
  99163. if (!context) {
  99164. throw new Error("Unable to create canvas for virtual joystick");
  99165. }
  99166. VirtualJoystick.vjCanvasContext = context;
  99167. VirtualJoystick.vjCanvasContext.strokeStyle = "#ffffff";
  99168. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  99169. document.body.appendChild(VirtualJoystick.Canvas);
  99170. }
  99171. VirtualJoystick.halfWidth = VirtualJoystick.Canvas.width / 2;
  99172. this.pressed = false;
  99173. // default joystick color
  99174. this._joystickColor = "cyan";
  99175. this._joystickPointerID = -1;
  99176. // current joystick position
  99177. this._joystickPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  99178. this._joystickPreviousPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  99179. // origin joystick position
  99180. this._joystickPointerStartPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  99181. this._deltaJoystickVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  99182. this._onPointerDownHandlerRef = function (evt) {
  99183. _this._onPointerDown(evt);
  99184. };
  99185. this._onPointerMoveHandlerRef = function (evt) {
  99186. _this._onPointerMove(evt);
  99187. };
  99188. this._onPointerUpHandlerRef = function (evt) {
  99189. _this._onPointerUp(evt);
  99190. };
  99191. VirtualJoystick.Canvas.addEventListener('pointerdown', this._onPointerDownHandlerRef, false);
  99192. VirtualJoystick.Canvas.addEventListener('pointermove', this._onPointerMoveHandlerRef, false);
  99193. VirtualJoystick.Canvas.addEventListener('pointerup', this._onPointerUpHandlerRef, false);
  99194. VirtualJoystick.Canvas.addEventListener('pointerout', this._onPointerUpHandlerRef, false);
  99195. VirtualJoystick.Canvas.addEventListener("contextmenu", function (evt) {
  99196. evt.preventDefault(); // Disables system menu
  99197. }, false);
  99198. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  99199. }
  99200. /**
  99201. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  99202. * @param newJoystickSensibility defines the new sensibility
  99203. */
  99204. VirtualJoystick.prototype.setJoystickSensibility = function (newJoystickSensibility) {
  99205. this._joystickSensibility = newJoystickSensibility;
  99206. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  99207. };
  99208. VirtualJoystick.prototype._onPointerDown = function (e) {
  99209. var positionOnScreenCondition;
  99210. e.preventDefault();
  99211. if (this._leftJoystick === true) {
  99212. positionOnScreenCondition = (e.clientX < VirtualJoystick.halfWidth);
  99213. }
  99214. else {
  99215. positionOnScreenCondition = (e.clientX > VirtualJoystick.halfWidth);
  99216. }
  99217. if (positionOnScreenCondition && this._joystickPointerID < 0) {
  99218. // First contact will be dedicated to the virtual joystick
  99219. this._joystickPointerID = e.pointerId;
  99220. this._joystickPointerStartPos.x = e.clientX;
  99221. this._joystickPointerStartPos.y = e.clientY;
  99222. this._joystickPointerPos = this._joystickPointerStartPos.clone();
  99223. this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone();
  99224. this._deltaJoystickVector.x = 0;
  99225. this._deltaJoystickVector.y = 0;
  99226. this.pressed = true;
  99227. this._touches.add(e.pointerId.toString(), e);
  99228. }
  99229. else {
  99230. // You can only trigger the action buttons with a joystick declared
  99231. if (VirtualJoystick._globalJoystickIndex < 2 && this._action) {
  99232. this._action();
  99233. this._touches.add(e.pointerId.toString(), { x: e.clientX, y: e.clientY, prevX: e.clientX, prevY: e.clientY });
  99234. }
  99235. }
  99236. };
  99237. VirtualJoystick.prototype._onPointerMove = function (e) {
  99238. // If the current pointer is the one associated to the joystick (first touch contact)
  99239. if (this._joystickPointerID == e.pointerId) {
  99240. this._joystickPointerPos.x = e.clientX;
  99241. this._joystickPointerPos.y = e.clientY;
  99242. this._deltaJoystickVector = this._joystickPointerPos.clone();
  99243. this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos);
  99244. var directionLeftRight = this.reverseLeftRight ? -1 : 1;
  99245. var deltaJoystickX = directionLeftRight * this._deltaJoystickVector.x / this._inversedSensibility;
  99246. switch (this._axisTargetedByLeftAndRight) {
  99247. case JoystickAxis.X:
  99248. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickX));
  99249. break;
  99250. case JoystickAxis.Y:
  99251. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickX));
  99252. break;
  99253. case JoystickAxis.Z:
  99254. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickX));
  99255. break;
  99256. }
  99257. var directionUpDown = this.reverseUpDown ? 1 : -1;
  99258. var deltaJoystickY = directionUpDown * this._deltaJoystickVector.y / this._inversedSensibility;
  99259. switch (this._axisTargetedByUpAndDown) {
  99260. case JoystickAxis.X:
  99261. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickY));
  99262. break;
  99263. case JoystickAxis.Y:
  99264. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickY));
  99265. break;
  99266. case JoystickAxis.Z:
  99267. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickY));
  99268. break;
  99269. }
  99270. }
  99271. else {
  99272. var data = this._touches.get(e.pointerId.toString());
  99273. if (data) {
  99274. data.x = e.clientX;
  99275. data.y = e.clientY;
  99276. }
  99277. }
  99278. };
  99279. VirtualJoystick.prototype._onPointerUp = function (e) {
  99280. if (this._joystickPointerID == e.pointerId) {
  99281. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPointerStartPos.x - 64, this._joystickPointerStartPos.y - 64, 128, 128);
  99282. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x - 42, this._joystickPreviousPointerPos.y - 42, 84, 84);
  99283. this._joystickPointerID = -1;
  99284. this.pressed = false;
  99285. }
  99286. else {
  99287. var touch = this._touches.get(e.pointerId.toString());
  99288. if (touch) {
  99289. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  99290. }
  99291. }
  99292. this._deltaJoystickVector.x = 0;
  99293. this._deltaJoystickVector.y = 0;
  99294. this._touches.remove(e.pointerId.toString());
  99295. };
  99296. /**
  99297. * Change the color of the virtual joystick
  99298. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  99299. */
  99300. VirtualJoystick.prototype.setJoystickColor = function (newColor) {
  99301. this._joystickColor = newColor;
  99302. };
  99303. /**
  99304. * Defines a callback to call when the joystick is touched
  99305. * @param action defines the callback
  99306. */
  99307. VirtualJoystick.prototype.setActionOnTouch = function (action) {
  99308. this._action = action;
  99309. };
  99310. /**
  99311. * Defines which axis you'd like to control for left & right
  99312. * @param axis defines the axis to use
  99313. */
  99314. VirtualJoystick.prototype.setAxisForLeftRight = function (axis) {
  99315. switch (axis) {
  99316. case JoystickAxis.X:
  99317. case JoystickAxis.Y:
  99318. case JoystickAxis.Z:
  99319. this._axisTargetedByLeftAndRight = axis;
  99320. break;
  99321. default:
  99322. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  99323. break;
  99324. }
  99325. };
  99326. /**
  99327. * Defines which axis you'd like to control for up & down
  99328. * @param axis defines the axis to use
  99329. */
  99330. VirtualJoystick.prototype.setAxisForUpDown = function (axis) {
  99331. switch (axis) {
  99332. case JoystickAxis.X:
  99333. case JoystickAxis.Y:
  99334. case JoystickAxis.Z:
  99335. this._axisTargetedByUpAndDown = axis;
  99336. break;
  99337. default:
  99338. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  99339. break;
  99340. }
  99341. };
  99342. VirtualJoystick.prototype._drawVirtualJoystick = function () {
  99343. var _this = this;
  99344. if (this.pressed) {
  99345. this._touches.forEach(function (key, touch) {
  99346. if (touch.pointerId === _this._joystickPointerID) {
  99347. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPointerStartPos.x - 64, _this._joystickPointerStartPos.y - 64, 128, 128);
  99348. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPreviousPointerPos.x - 42, _this._joystickPreviousPointerPos.y - 42, 84, 84);
  99349. VirtualJoystick.vjCanvasContext.beginPath();
  99350. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  99351. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  99352. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 40, 0, Math.PI * 2, true);
  99353. VirtualJoystick.vjCanvasContext.stroke();
  99354. VirtualJoystick.vjCanvasContext.closePath();
  99355. VirtualJoystick.vjCanvasContext.beginPath();
  99356. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  99357. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  99358. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 60, 0, Math.PI * 2, true);
  99359. VirtualJoystick.vjCanvasContext.stroke();
  99360. VirtualJoystick.vjCanvasContext.closePath();
  99361. VirtualJoystick.vjCanvasContext.beginPath();
  99362. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  99363. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerPos.x, _this._joystickPointerPos.y, 40, 0, Math.PI * 2, true);
  99364. VirtualJoystick.vjCanvasContext.stroke();
  99365. VirtualJoystick.vjCanvasContext.closePath();
  99366. _this._joystickPreviousPointerPos = _this._joystickPointerPos.clone();
  99367. }
  99368. else {
  99369. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  99370. VirtualJoystick.vjCanvasContext.beginPath();
  99371. VirtualJoystick.vjCanvasContext.fillStyle = "white";
  99372. VirtualJoystick.vjCanvasContext.beginPath();
  99373. VirtualJoystick.vjCanvasContext.strokeStyle = "red";
  99374. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  99375. VirtualJoystick.vjCanvasContext.arc(touch.x, touch.y, 40, 0, Math.PI * 2, true);
  99376. VirtualJoystick.vjCanvasContext.stroke();
  99377. VirtualJoystick.vjCanvasContext.closePath();
  99378. touch.prevX = touch.x;
  99379. touch.prevY = touch.y;
  99380. }
  99381. });
  99382. }
  99383. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  99384. };
  99385. /**
  99386. * Release internal HTML canvas
  99387. */
  99388. VirtualJoystick.prototype.releaseCanvas = function () {
  99389. if (VirtualJoystick.Canvas) {
  99390. VirtualJoystick.Canvas.removeEventListener('pointerdown', this._onPointerDownHandlerRef);
  99391. VirtualJoystick.Canvas.removeEventListener('pointermove', this._onPointerMoveHandlerRef);
  99392. VirtualJoystick.Canvas.removeEventListener('pointerup', this._onPointerUpHandlerRef);
  99393. VirtualJoystick.Canvas.removeEventListener('pointerout', this._onPointerUpHandlerRef);
  99394. window.removeEventListener("resize", this._onResize);
  99395. document.body.removeChild(VirtualJoystick.Canvas);
  99396. VirtualJoystick.Canvas = null;
  99397. }
  99398. };
  99399. // Used to draw the virtual joystick inside a 2D canvas on top of the WebGL rendering canvas
  99400. VirtualJoystick._globalJoystickIndex = 0;
  99401. return VirtualJoystick;
  99402. }());
  99403. /***/ }),
  99404. /***/ "./Misc/workerPool.ts":
  99405. /*!****************************!*\
  99406. !*** ./Misc/workerPool.ts ***!
  99407. \****************************/
  99408. /*! exports provided: WorkerPool */
  99409. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99410. "use strict";
  99411. __webpack_require__.r(__webpack_exports__);
  99412. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return WorkerPool; });
  99413. /**
  99414. * Helper class to push actions to a pool of workers.
  99415. */
  99416. var WorkerPool = /** @class */ (function () {
  99417. /**
  99418. * Constructor
  99419. * @param workers Array of workers to use for actions
  99420. */
  99421. function WorkerPool(workers) {
  99422. this._pendingActions = new Array();
  99423. this._workerInfos = workers.map(function (worker) { return ({
  99424. worker: worker,
  99425. active: false
  99426. }); });
  99427. }
  99428. /**
  99429. * Terminates all workers and clears any pending actions.
  99430. */
  99431. WorkerPool.prototype.dispose = function () {
  99432. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  99433. var workerInfo = _a[_i];
  99434. workerInfo.worker.terminate();
  99435. }
  99436. delete this._workerInfos;
  99437. delete this._pendingActions;
  99438. };
  99439. /**
  99440. * Pushes an action to the worker pool. If all the workers are active, the action will be
  99441. * pended until a worker has completed its action.
  99442. * @param action The action to perform. Call onComplete when the action is complete.
  99443. */
  99444. WorkerPool.prototype.push = function (action) {
  99445. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  99446. var workerInfo = _a[_i];
  99447. if (!workerInfo.active) {
  99448. this._execute(workerInfo, action);
  99449. return;
  99450. }
  99451. }
  99452. this._pendingActions.push(action);
  99453. };
  99454. WorkerPool.prototype._execute = function (workerInfo, action) {
  99455. var _this = this;
  99456. workerInfo.active = true;
  99457. action(workerInfo.worker, function () {
  99458. workerInfo.active = false;
  99459. var nextAction = _this._pendingActions.shift();
  99460. if (nextAction) {
  99461. _this._execute(workerInfo, nextAction);
  99462. }
  99463. });
  99464. };
  99465. return WorkerPool;
  99466. }());
  99467. /***/ }),
  99468. /***/ "./Morph/index.ts":
  99469. /*!************************!*\
  99470. !*** ./Morph/index.ts ***!
  99471. \************************/
  99472. /*! exports provided: MorphTarget, MorphTargetManager */
  99473. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99474. "use strict";
  99475. __webpack_require__.r(__webpack_exports__);
  99476. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  99477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _morphTarget__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  99478. /* harmony import */ var _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./morphTargetManager */ "./Morph/morphTargetManager.ts");
  99479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__["MorphTargetManager"]; });
  99480. /***/ }),
  99481. /***/ "./Morph/morphTarget.ts":
  99482. /*!******************************!*\
  99483. !*** ./Morph/morphTarget.ts ***!
  99484. \******************************/
  99485. /*! exports provided: MorphTarget */
  99486. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99487. "use strict";
  99488. __webpack_require__.r(__webpack_exports__);
  99489. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return MorphTarget; });
  99490. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  99491. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  99492. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  99493. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  99494. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  99495. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  99496. /**
  99497. * Defines a target to use with MorphTargetManager
  99498. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  99499. */
  99500. var MorphTarget = /** @class */ (function () {
  99501. /**
  99502. * Creates a new MorphTarget
  99503. * @param name defines the name of the target
  99504. * @param influence defines the influence to use
  99505. */
  99506. function MorphTarget(
  99507. /** defines the name of the target */
  99508. name, influence, scene) {
  99509. if (influence === void 0) { influence = 0; }
  99510. if (scene === void 0) { scene = null; }
  99511. this.name = name;
  99512. /**
  99513. * Gets or sets the list of animations
  99514. */
  99515. this.animations = new Array();
  99516. this._positions = null;
  99517. this._normals = null;
  99518. this._tangents = null;
  99519. /**
  99520. * Observable raised when the influence changes
  99521. */
  99522. this.onInfluenceChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  99523. /** @hidden */
  99524. this._onDataLayoutChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  99525. this._animationPropertiesOverride = null;
  99526. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  99527. this.influence = influence;
  99528. }
  99529. Object.defineProperty(MorphTarget.prototype, "influence", {
  99530. /**
  99531. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  99532. */
  99533. get: function () {
  99534. return this._influence;
  99535. },
  99536. set: function (influence) {
  99537. if (this._influence === influence) {
  99538. return;
  99539. }
  99540. var previous = this._influence;
  99541. this._influence = influence;
  99542. if (this.onInfluenceChanged.hasObservers) {
  99543. this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);
  99544. }
  99545. },
  99546. enumerable: true,
  99547. configurable: true
  99548. });
  99549. Object.defineProperty(MorphTarget.prototype, "animationPropertiesOverride", {
  99550. /**
  99551. * Gets or sets the animation properties override
  99552. */
  99553. get: function () {
  99554. if (!this._animationPropertiesOverride && this._scene) {
  99555. return this._scene.animationPropertiesOverride;
  99556. }
  99557. return this._animationPropertiesOverride;
  99558. },
  99559. set: function (value) {
  99560. this._animationPropertiesOverride = value;
  99561. },
  99562. enumerable: true,
  99563. configurable: true
  99564. });
  99565. Object.defineProperty(MorphTarget.prototype, "hasPositions", {
  99566. /**
  99567. * Gets a boolean defining if the target contains position data
  99568. */
  99569. get: function () {
  99570. return !!this._positions;
  99571. },
  99572. enumerable: true,
  99573. configurable: true
  99574. });
  99575. Object.defineProperty(MorphTarget.prototype, "hasNormals", {
  99576. /**
  99577. * Gets a boolean defining if the target contains normal data
  99578. */
  99579. get: function () {
  99580. return !!this._normals;
  99581. },
  99582. enumerable: true,
  99583. configurable: true
  99584. });
  99585. Object.defineProperty(MorphTarget.prototype, "hasTangents", {
  99586. /**
  99587. * Gets a boolean defining if the target contains tangent data
  99588. */
  99589. get: function () {
  99590. return !!this._tangents;
  99591. },
  99592. enumerable: true,
  99593. configurable: true
  99594. });
  99595. /**
  99596. * Affects position data to this target
  99597. * @param data defines the position data to use
  99598. */
  99599. MorphTarget.prototype.setPositions = function (data) {
  99600. var hadPositions = this.hasPositions;
  99601. this._positions = data;
  99602. if (hadPositions !== this.hasPositions) {
  99603. this._onDataLayoutChanged.notifyObservers(undefined);
  99604. }
  99605. };
  99606. /**
  99607. * Gets the position data stored in this target
  99608. * @returns a FloatArray containing the position data (or null if not present)
  99609. */
  99610. MorphTarget.prototype.getPositions = function () {
  99611. return this._positions;
  99612. };
  99613. /**
  99614. * Affects normal data to this target
  99615. * @param data defines the normal data to use
  99616. */
  99617. MorphTarget.prototype.setNormals = function (data) {
  99618. var hadNormals = this.hasNormals;
  99619. this._normals = data;
  99620. if (hadNormals !== this.hasNormals) {
  99621. this._onDataLayoutChanged.notifyObservers(undefined);
  99622. }
  99623. };
  99624. /**
  99625. * Gets the normal data stored in this target
  99626. * @returns a FloatArray containing the normal data (or null if not present)
  99627. */
  99628. MorphTarget.prototype.getNormals = function () {
  99629. return this._normals;
  99630. };
  99631. /**
  99632. * Affects tangent data to this target
  99633. * @param data defines the tangent data to use
  99634. */
  99635. MorphTarget.prototype.setTangents = function (data) {
  99636. var hadTangents = this.hasTangents;
  99637. this._tangents = data;
  99638. if (hadTangents !== this.hasTangents) {
  99639. this._onDataLayoutChanged.notifyObservers(undefined);
  99640. }
  99641. };
  99642. /**
  99643. * Gets the tangent data stored in this target
  99644. * @returns a FloatArray containing the tangent data (or null if not present)
  99645. */
  99646. MorphTarget.prototype.getTangents = function () {
  99647. return this._tangents;
  99648. };
  99649. /**
  99650. * Serializes the current target into a Serialization object
  99651. * @returns the serialized object
  99652. */
  99653. MorphTarget.prototype.serialize = function () {
  99654. var serializationObject = {};
  99655. serializationObject.name = this.name;
  99656. serializationObject.influence = this.influence;
  99657. serializationObject.positions = Array.prototype.slice.call(this.getPositions());
  99658. if (this.id != null) {
  99659. serializationObject.id = this.id;
  99660. }
  99661. if (this.hasNormals) {
  99662. serializationObject.normals = Array.prototype.slice.call(this.getNormals());
  99663. }
  99664. if (this.hasTangents) {
  99665. serializationObject.tangents = Array.prototype.slice.call(this.getTangents());
  99666. }
  99667. // Animations
  99668. _Misc_decorators__WEBPACK_IMPORTED_MODULE_5__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  99669. return serializationObject;
  99670. };
  99671. /**
  99672. * Returns the string "MorphTarget"
  99673. * @returns "MorphTarget"
  99674. */
  99675. MorphTarget.prototype.getClassName = function () {
  99676. return "MorphTarget";
  99677. };
  99678. // Statics
  99679. /**
  99680. * Creates a new target from serialized data
  99681. * @param serializationObject defines the serialized data to use
  99682. * @returns a new MorphTarget
  99683. */
  99684. MorphTarget.Parse = function (serializationObject) {
  99685. var result = new MorphTarget(serializationObject.name, serializationObject.influence);
  99686. result.setPositions(serializationObject.positions);
  99687. if (serializationObject.id != null) {
  99688. result.id = serializationObject.id;
  99689. }
  99690. if (serializationObject.normals) {
  99691. result.setNormals(serializationObject.normals);
  99692. }
  99693. if (serializationObject.tangents) {
  99694. result.setTangents(serializationObject.tangents);
  99695. }
  99696. // Animations
  99697. if (serializationObject.animations) {
  99698. for (var animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {
  99699. var parsedAnimation = serializationObject.animations[animationIndex];
  99700. result.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].Parse(parsedAnimation));
  99701. }
  99702. }
  99703. return result;
  99704. };
  99705. /**
  99706. * Creates a MorphTarget from mesh data
  99707. * @param mesh defines the source mesh
  99708. * @param name defines the name to use for the new target
  99709. * @param influence defines the influence to attach to the target
  99710. * @returns a new MorphTarget
  99711. */
  99712. MorphTarget.FromMesh = function (mesh, name, influence) {
  99713. if (!name) {
  99714. name = mesh.name;
  99715. }
  99716. var result = new MorphTarget(name, influence, mesh.getScene());
  99717. result.setPositions(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  99718. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  99719. result.setNormals(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  99720. }
  99721. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  99722. result.setTangents(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  99723. }
  99724. return result;
  99725. };
  99726. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  99727. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_5__["serialize"])()
  99728. ], MorphTarget.prototype, "id", void 0);
  99729. return MorphTarget;
  99730. }());
  99731. /***/ }),
  99732. /***/ "./Morph/morphTargetManager.ts":
  99733. /*!*************************************!*\
  99734. !*** ./Morph/morphTargetManager.ts ***!
  99735. \*************************************/
  99736. /*! exports provided: MorphTargetManager */
  99737. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99738. "use strict";
  99739. __webpack_require__.r(__webpack_exports__);
  99740. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return MorphTargetManager; });
  99741. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  99742. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  99743. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  99744. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  99745. /**
  99746. * This class is used to deform meshes using morphing between different targets
  99747. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  99748. */
  99749. var MorphTargetManager = /** @class */ (function () {
  99750. /**
  99751. * Creates a new MorphTargetManager
  99752. * @param scene defines the current scene
  99753. */
  99754. function MorphTargetManager(scene) {
  99755. if (scene === void 0) { scene = null; }
  99756. this._targets = new Array();
  99757. this._targetInfluenceChangedObservers = new Array();
  99758. this._targetDataLayoutChangedObservers = new Array();
  99759. this._activeTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  99760. this._supportsNormals = false;
  99761. this._supportsTangents = false;
  99762. this._vertexCount = 0;
  99763. this._uniqueId = 0;
  99764. this._tempInfluences = new Array();
  99765. if (!scene) {
  99766. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  99767. }
  99768. this._scene = scene;
  99769. if (this._scene) {
  99770. this._scene.morphTargetManagers.push(this);
  99771. this._uniqueId = this._scene.getUniqueId();
  99772. }
  99773. }
  99774. Object.defineProperty(MorphTargetManager.prototype, "uniqueId", {
  99775. /**
  99776. * Gets the unique ID of this manager
  99777. */
  99778. get: function () {
  99779. return this._uniqueId;
  99780. },
  99781. enumerable: true,
  99782. configurable: true
  99783. });
  99784. Object.defineProperty(MorphTargetManager.prototype, "vertexCount", {
  99785. /**
  99786. * Gets the number of vertices handled by this manager
  99787. */
  99788. get: function () {
  99789. return this._vertexCount;
  99790. },
  99791. enumerable: true,
  99792. configurable: true
  99793. });
  99794. Object.defineProperty(MorphTargetManager.prototype, "supportsNormals", {
  99795. /**
  99796. * Gets a boolean indicating if this manager supports morphing of normals
  99797. */
  99798. get: function () {
  99799. return this._supportsNormals;
  99800. },
  99801. enumerable: true,
  99802. configurable: true
  99803. });
  99804. Object.defineProperty(MorphTargetManager.prototype, "supportsTangents", {
  99805. /**
  99806. * Gets a boolean indicating if this manager supports morphing of tangents
  99807. */
  99808. get: function () {
  99809. return this._supportsTangents;
  99810. },
  99811. enumerable: true,
  99812. configurable: true
  99813. });
  99814. Object.defineProperty(MorphTargetManager.prototype, "numTargets", {
  99815. /**
  99816. * Gets the number of targets stored in this manager
  99817. */
  99818. get: function () {
  99819. return this._targets.length;
  99820. },
  99821. enumerable: true,
  99822. configurable: true
  99823. });
  99824. Object.defineProperty(MorphTargetManager.prototype, "numInfluencers", {
  99825. /**
  99826. * Gets the number of influencers (ie. the number of targets with influences > 0)
  99827. */
  99828. get: function () {
  99829. return this._activeTargets.length;
  99830. },
  99831. enumerable: true,
  99832. configurable: true
  99833. });
  99834. Object.defineProperty(MorphTargetManager.prototype, "influences", {
  99835. /**
  99836. * Gets the list of influences (one per target)
  99837. */
  99838. get: function () {
  99839. return this._influences;
  99840. },
  99841. enumerable: true,
  99842. configurable: true
  99843. });
  99844. /**
  99845. * Gets the active target at specified index. An active target is a target with an influence > 0
  99846. * @param index defines the index to check
  99847. * @returns the requested target
  99848. */
  99849. MorphTargetManager.prototype.getActiveTarget = function (index) {
  99850. return this._activeTargets.data[index];
  99851. };
  99852. /**
  99853. * Gets the target at specified index
  99854. * @param index defines the index to check
  99855. * @returns the requested target
  99856. */
  99857. MorphTargetManager.prototype.getTarget = function (index) {
  99858. return this._targets[index];
  99859. };
  99860. /**
  99861. * Add a new target to this manager
  99862. * @param target defines the target to add
  99863. */
  99864. MorphTargetManager.prototype.addTarget = function (target) {
  99865. var _this = this;
  99866. this._targets.push(target);
  99867. this._targetInfluenceChangedObservers.push(target.onInfluenceChanged.add(function (needUpdate) {
  99868. _this._syncActiveTargets(needUpdate);
  99869. }));
  99870. this._targetDataLayoutChangedObservers.push(target._onDataLayoutChanged.add(function () {
  99871. _this._syncActiveTargets(true);
  99872. }));
  99873. this._syncActiveTargets(true);
  99874. };
  99875. /**
  99876. * Removes a target from the manager
  99877. * @param target defines the target to remove
  99878. */
  99879. MorphTargetManager.prototype.removeTarget = function (target) {
  99880. var index = this._targets.indexOf(target);
  99881. if (index >= 0) {
  99882. this._targets.splice(index, 1);
  99883. target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);
  99884. target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);
  99885. this._syncActiveTargets(true);
  99886. }
  99887. };
  99888. /**
  99889. * Serializes the current manager into a Serialization object
  99890. * @returns the serialized object
  99891. */
  99892. MorphTargetManager.prototype.serialize = function () {
  99893. var serializationObject = {};
  99894. serializationObject.id = this.uniqueId;
  99895. serializationObject.targets = [];
  99896. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  99897. var target = _a[_i];
  99898. serializationObject.targets.push(target.serialize());
  99899. }
  99900. return serializationObject;
  99901. };
  99902. MorphTargetManager.prototype._syncActiveTargets = function (needUpdate) {
  99903. var influenceCount = 0;
  99904. this._activeTargets.reset();
  99905. this._supportsNormals = true;
  99906. this._supportsTangents = true;
  99907. this._vertexCount = 0;
  99908. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  99909. var target = _a[_i];
  99910. if (target.influence === 0) {
  99911. continue;
  99912. }
  99913. this._activeTargets.push(target);
  99914. this._tempInfluences[influenceCount++] = target.influence;
  99915. this._supportsNormals = this._supportsNormals && target.hasNormals;
  99916. this._supportsTangents = this._supportsTangents && target.hasTangents;
  99917. var positions = target.getPositions();
  99918. if (positions) {
  99919. var vertexCount = positions.length / 3;
  99920. if (this._vertexCount === 0) {
  99921. this._vertexCount = vertexCount;
  99922. }
  99923. else if (this._vertexCount !== vertexCount) {
  99924. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Incompatible target. Targets must all have the same vertices count.");
  99925. return;
  99926. }
  99927. }
  99928. }
  99929. if (!this._influences || this._influences.length !== influenceCount) {
  99930. this._influences = new Float32Array(influenceCount);
  99931. }
  99932. for (var index = 0; index < influenceCount; index++) {
  99933. this._influences[index] = this._tempInfluences[index];
  99934. }
  99935. if (needUpdate) {
  99936. this.synchronize();
  99937. }
  99938. };
  99939. /**
  99940. * Syncrhonize the targets with all the meshes using this morph target manager
  99941. */
  99942. MorphTargetManager.prototype.synchronize = function () {
  99943. if (!this._scene) {
  99944. return;
  99945. }
  99946. // Flag meshes as dirty to resync with the active targets
  99947. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  99948. var mesh = _a[_i];
  99949. if (mesh.morphTargetManager === this) {
  99950. mesh._syncGeometryWithMorphTargetManager();
  99951. }
  99952. }
  99953. };
  99954. // Statics
  99955. /**
  99956. * Creates a new MorphTargetManager from serialized data
  99957. * @param serializationObject defines the serialized data
  99958. * @param scene defines the hosting scene
  99959. * @returns the new MorphTargetManager
  99960. */
  99961. MorphTargetManager.Parse = function (serializationObject, scene) {
  99962. var result = new MorphTargetManager(scene);
  99963. result._uniqueId = serializationObject.id;
  99964. for (var _i = 0, _a = serializationObject.targets; _i < _a.length; _i++) {
  99965. var targetData = _a[_i];
  99966. result.addTarget(_morphTarget__WEBPACK_IMPORTED_MODULE_3__["MorphTarget"].Parse(targetData));
  99967. }
  99968. return result;
  99969. };
  99970. return MorphTargetManager;
  99971. }());
  99972. /***/ }),
  99973. /***/ "./Offline/database.ts":
  99974. /*!*****************************!*\
  99975. !*** ./Offline/database.ts ***!
  99976. \*****************************/
  99977. /*! exports provided: Database */
  99978. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99979. "use strict";
  99980. __webpack_require__.r(__webpack_exports__);
  99981. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return Database; });
  99982. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  99983. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  99984. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tga */ "./Misc/tga.ts");
  99985. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  99986. // Sets the default offline provider to Babylon.js
  99987. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].OfflineProviderFactory = function (urlToScene, callbackManifestChecked, disableManifestCheck) {
  99988. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  99989. return new Database(urlToScene, callbackManifestChecked, disableManifestCheck);
  99990. };
  99991. /**
  99992. * Class used to enable access to IndexedDB
  99993. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  99994. */
  99995. var Database = /** @class */ (function () {
  99996. /**
  99997. * Creates a new Database
  99998. * @param urlToScene defines the url to load the scene
  99999. * @param callbackManifestChecked defines the callback to use when manifest is checked
  100000. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  100001. */
  100002. function Database(urlToScene, callbackManifestChecked, disableManifestCheck) {
  100003. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  100004. var _this = this;
  100005. // Handling various flavors of prefixed version of IndexedDB
  100006. this._idbFactory = (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);
  100007. this._callbackManifestChecked = callbackManifestChecked;
  100008. this._currentSceneUrl = Database._ReturnFullUrlLocation(urlToScene);
  100009. this._db = null;
  100010. this._enableSceneOffline = false;
  100011. this._enableTexturesOffline = false;
  100012. this._manifestVersionFound = 0;
  100013. this._mustUpdateRessources = false;
  100014. this._hasReachedQuota = false;
  100015. if (!Database.IDBStorageEnabled) {
  100016. this._callbackManifestChecked(true);
  100017. }
  100018. else {
  100019. if (disableManifestCheck) {
  100020. this._enableSceneOffline = true;
  100021. this._enableTexturesOffline = true;
  100022. this._manifestVersionFound = 1;
  100023. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  100024. _this._callbackManifestChecked(true);
  100025. });
  100026. }
  100027. else {
  100028. this._checkManifestFile();
  100029. }
  100030. }
  100031. }
  100032. Object.defineProperty(Database.prototype, "enableSceneOffline", {
  100033. /**
  100034. * Gets a boolean indicating if scene must be saved in the database
  100035. */
  100036. get: function () {
  100037. return this._enableSceneOffline;
  100038. },
  100039. enumerable: true,
  100040. configurable: true
  100041. });
  100042. Object.defineProperty(Database.prototype, "enableTexturesOffline", {
  100043. /**
  100044. * Gets a boolean indicating if textures must be saved in the database
  100045. */
  100046. get: function () {
  100047. return this._enableTexturesOffline;
  100048. },
  100049. enumerable: true,
  100050. configurable: true
  100051. });
  100052. Database.prototype._checkManifestFile = function () {
  100053. var _this = this;
  100054. var noManifestFile = function () {
  100055. _this._enableSceneOffline = false;
  100056. _this._enableTexturesOffline = false;
  100057. _this._callbackManifestChecked(false);
  100058. };
  100059. var timeStampUsed = false;
  100060. var manifestURL = this._currentSceneUrl + ".manifest";
  100061. var xhr = new XMLHttpRequest();
  100062. if (navigator.onLine) {
  100063. // Adding a timestamp to by-pass browsers' cache
  100064. timeStampUsed = true;
  100065. manifestURL = manifestURL + (manifestURL.match(/\?/) == null ? "?" : "&") + Date.now();
  100066. }
  100067. xhr.open("GET", manifestURL, true);
  100068. xhr.addEventListener("load", function () {
  100069. if (xhr.status === 200 || Database._ValidateXHRData(xhr, 1)) {
  100070. try {
  100071. var manifestFile = JSON.parse(xhr.response);
  100072. _this._enableSceneOffline = manifestFile.enableSceneOffline;
  100073. _this._enableTexturesOffline = manifestFile.enableTexturesOffline && Database.IsUASupportingBlobStorage;
  100074. if (manifestFile.version && !isNaN(parseInt(manifestFile.version))) {
  100075. _this._manifestVersionFound = manifestFile.version;
  100076. }
  100077. if (_this._callbackManifestChecked) {
  100078. _this._callbackManifestChecked(true);
  100079. }
  100080. }
  100081. catch (ex) {
  100082. noManifestFile();
  100083. }
  100084. }
  100085. else {
  100086. noManifestFile();
  100087. }
  100088. }, false);
  100089. xhr.addEventListener("error", function () {
  100090. if (timeStampUsed) {
  100091. timeStampUsed = false;
  100092. // Let's retry without the timeStamp
  100093. // It could fail when coupled with HTML5 Offline API
  100094. var retryManifestURL = _this._currentSceneUrl + ".manifest";
  100095. xhr.open("GET", retryManifestURL, true);
  100096. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  100097. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  100098. }
  100099. xhr.send();
  100100. }
  100101. else {
  100102. noManifestFile();
  100103. }
  100104. }, false);
  100105. try {
  100106. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  100107. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  100108. }
  100109. xhr.send();
  100110. }
  100111. catch (ex) {
  100112. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error on XHR send request.");
  100113. this._callbackManifestChecked(false);
  100114. }
  100115. };
  100116. /**
  100117. * Open the database and make it available
  100118. * @param successCallback defines the callback to call on success
  100119. * @param errorCallback defines the callback to call on error
  100120. */
  100121. Database.prototype.open = function (successCallback, errorCallback) {
  100122. var _this = this;
  100123. var handleError = function () {
  100124. _this._isSupported = false;
  100125. if (errorCallback) {
  100126. errorCallback();
  100127. }
  100128. };
  100129. if (!this._idbFactory || !(this._enableSceneOffline || this._enableTexturesOffline)) {
  100130. // Your browser doesn't support IndexedDB
  100131. this._isSupported = false;
  100132. if (errorCallback) {
  100133. errorCallback();
  100134. }
  100135. }
  100136. else {
  100137. // If the DB hasn't been opened or created yet
  100138. if (!this._db) {
  100139. this._hasReachedQuota = false;
  100140. this._isSupported = true;
  100141. var request = this._idbFactory.open("babylonjs", 1);
  100142. // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB
  100143. request.onerror = function () {
  100144. handleError();
  100145. };
  100146. // executes when a version change transaction cannot complete due to other active transactions
  100147. request.onblocked = function () {
  100148. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("IDB request blocked. Please reload the page.");
  100149. handleError();
  100150. };
  100151. // DB has been opened successfully
  100152. request.onsuccess = function () {
  100153. _this._db = request.result;
  100154. successCallback();
  100155. };
  100156. // Initialization of the DB. Creating Scenes & Textures stores
  100157. request.onupgradeneeded = function (event) {
  100158. _this._db = (event.target).result;
  100159. if (_this._db) {
  100160. try {
  100161. _this._db.createObjectStore("scenes", { keyPath: "sceneUrl" });
  100162. _this._db.createObjectStore("versions", { keyPath: "sceneUrl" });
  100163. _this._db.createObjectStore("textures", { keyPath: "textureUrl" });
  100164. }
  100165. catch (ex) {
  100166. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while creating object stores. Exception: " + ex.message);
  100167. handleError();
  100168. }
  100169. }
  100170. };
  100171. }
  100172. // DB has already been created and opened
  100173. else {
  100174. if (successCallback) {
  100175. successCallback();
  100176. }
  100177. }
  100178. }
  100179. };
  100180. /**
  100181. * Loads an image from the database
  100182. * @param url defines the url to load from
  100183. * @param image defines the target DOM image
  100184. */
  100185. Database.prototype.loadImage = function (url, image) {
  100186. var _this = this;
  100187. var completeURL = Database._ReturnFullUrlLocation(url);
  100188. var saveAndLoadImage = function () {
  100189. if (!_this._hasReachedQuota && _this._db !== null) {
  100190. // the texture is not yet in the DB, let's try to save it
  100191. _this._saveImageIntoDBAsync(completeURL, image);
  100192. }
  100193. // If the texture is not in the DB and we've reached the DB quota limit
  100194. // let's load it directly from the web
  100195. else {
  100196. image.src = url;
  100197. }
  100198. };
  100199. if (!this._mustUpdateRessources) {
  100200. this._loadImageFromDBAsync(completeURL, image, saveAndLoadImage);
  100201. }
  100202. // First time we're download the images or update requested in the manifest file by a version change
  100203. else {
  100204. saveAndLoadImage();
  100205. }
  100206. };
  100207. Database.prototype._loadImageFromDBAsync = function (url, image, notInDBCallback) {
  100208. if (this._isSupported && this._db !== null) {
  100209. var texture;
  100210. var transaction = this._db.transaction(["textures"]);
  100211. transaction.onabort = function () {
  100212. image.src = url;
  100213. };
  100214. transaction.oncomplete = function () {
  100215. var blobTextureURL;
  100216. if (texture) {
  100217. var URL = window.URL || window.webkitURL;
  100218. blobTextureURL = URL.createObjectURL(texture.data);
  100219. image.onerror = function () {
  100220. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading image from blob URL: " + blobTextureURL + " switching back to web url: " + url);
  100221. image.src = url;
  100222. };
  100223. image.src = blobTextureURL;
  100224. }
  100225. else {
  100226. notInDBCallback();
  100227. }
  100228. };
  100229. var getRequest = transaction.objectStore("textures").get(url);
  100230. getRequest.onsuccess = function (event) {
  100231. texture = (event.target).result;
  100232. };
  100233. getRequest.onerror = function () {
  100234. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading texture " + url + " from DB.");
  100235. image.src = url;
  100236. };
  100237. }
  100238. else {
  100239. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  100240. image.src = url;
  100241. }
  100242. };
  100243. Database.prototype._saveImageIntoDBAsync = function (url, image) {
  100244. var _this = this;
  100245. if (this._isSupported) {
  100246. // In case of error (type not supported or quota exceeded), we're at least sending back XHR data to allow texture loading later on
  100247. var generateBlobUrl = function () {
  100248. var blobTextureURL;
  100249. if (blob) {
  100250. var URL = window.URL || window.webkitURL;
  100251. try {
  100252. blobTextureURL = URL.createObjectURL(blob);
  100253. }
  100254. // Chrome is raising a type error if we're setting the oneTimeOnly parameter
  100255. catch (ex) {
  100256. blobTextureURL = URL.createObjectURL(blob);
  100257. }
  100258. }
  100259. if (blobTextureURL) {
  100260. image.src = blobTextureURL;
  100261. }
  100262. };
  100263. if (Database.IsUASupportingBlobStorage) { // Create XHR
  100264. var xhr = new XMLHttpRequest(), blob;
  100265. xhr.open("GET", url, true);
  100266. xhr.responseType = "blob";
  100267. xhr.addEventListener("load", function () {
  100268. if (xhr.status === 200 && _this._db) {
  100269. // Blob as response (XHR2)
  100270. blob = xhr.response;
  100271. var transaction = _this._db.transaction(["textures"], "readwrite");
  100272. // the transaction could abort because of a QuotaExceededError error
  100273. transaction.onabort = function (event) {
  100274. try {
  100275. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  100276. var srcElement = (event.srcElement || event.target);
  100277. var error = srcElement.error;
  100278. if (error && error.name === "QuotaExceededError") {
  100279. _this._hasReachedQuota = true;
  100280. }
  100281. }
  100282. catch (ex) { }
  100283. generateBlobUrl();
  100284. };
  100285. transaction.oncomplete = function () {
  100286. generateBlobUrl();
  100287. };
  100288. var newTexture = { textureUrl: url, data: blob };
  100289. try {
  100290. // Put the blob into the dabase
  100291. var addRequest = transaction.objectStore("textures").put(newTexture);
  100292. addRequest.onsuccess = function () {
  100293. };
  100294. addRequest.onerror = function () {
  100295. generateBlobUrl();
  100296. };
  100297. }
  100298. catch (ex) {
  100299. // "DataCloneError" generated by Chrome when you try to inject blob into IndexedDB
  100300. if (ex.code === 25) {
  100301. Database.IsUASupportingBlobStorage = false;
  100302. _this._enableTexturesOffline = false;
  100303. }
  100304. image.src = url;
  100305. }
  100306. }
  100307. else {
  100308. image.src = url;
  100309. }
  100310. }, false);
  100311. xhr.addEventListener("error", function () {
  100312. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in XHR request in BABYLON.Database.");
  100313. image.src = url;
  100314. }, false);
  100315. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].CustomRequestHeaders) {
  100316. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  100317. }
  100318. xhr.send();
  100319. }
  100320. else {
  100321. image.src = url;
  100322. }
  100323. }
  100324. else {
  100325. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  100326. image.src = url;
  100327. }
  100328. };
  100329. Database.prototype._checkVersionFromDB = function (url, versionLoaded) {
  100330. var _this = this;
  100331. var updateVersion = function () {
  100332. // the version is not yet in the DB or we need to update it
  100333. _this._saveVersionIntoDBAsync(url, versionLoaded);
  100334. };
  100335. this._loadVersionFromDBAsync(url, versionLoaded, updateVersion);
  100336. };
  100337. Database.prototype._loadVersionFromDBAsync = function (url, callback, updateInDBCallback) {
  100338. var _this = this;
  100339. if (this._isSupported && this._db) {
  100340. var version;
  100341. try {
  100342. var transaction = this._db.transaction(["versions"]);
  100343. transaction.oncomplete = function () {
  100344. if (version) {
  100345. // If the version in the JSON file is different from the version in DB
  100346. if (_this._manifestVersionFound !== version.data) {
  100347. _this._mustUpdateRessources = true;
  100348. updateInDBCallback();
  100349. }
  100350. else {
  100351. callback(version.data);
  100352. }
  100353. }
  100354. // version was not found in DB
  100355. else {
  100356. _this._mustUpdateRessources = true;
  100357. updateInDBCallback();
  100358. }
  100359. };
  100360. transaction.onabort = function () {
  100361. callback(-1);
  100362. };
  100363. var getRequest = transaction.objectStore("versions").get(url);
  100364. getRequest.onsuccess = function (event) {
  100365. version = (event.target).result;
  100366. };
  100367. getRequest.onerror = function () {
  100368. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading version for scene " + url + " from DB.");
  100369. callback(-1);
  100370. };
  100371. }
  100372. catch (ex) {
  100373. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (READ OP). Exception: " + ex.message);
  100374. callback(-1);
  100375. }
  100376. }
  100377. else {
  100378. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  100379. callback(-1);
  100380. }
  100381. };
  100382. Database.prototype._saveVersionIntoDBAsync = function (url, callback) {
  100383. var _this = this;
  100384. if (this._isSupported && !this._hasReachedQuota && this._db) {
  100385. try {
  100386. // Open a transaction to the database
  100387. var transaction = this._db.transaction(["versions"], "readwrite");
  100388. // the transaction could abort because of a QuotaExceededError error
  100389. transaction.onabort = function (event) {
  100390. try { //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  100391. var error = event.srcElement['error'];
  100392. if (error && error.name === "QuotaExceededError") {
  100393. _this._hasReachedQuota = true;
  100394. }
  100395. }
  100396. catch (ex) { }
  100397. callback(-1);
  100398. };
  100399. transaction.oncomplete = function () {
  100400. callback(_this._manifestVersionFound);
  100401. };
  100402. var newVersion = { sceneUrl: url, data: this._manifestVersionFound };
  100403. // Put the scene into the database
  100404. var addRequest = transaction.objectStore("versions").put(newVersion);
  100405. addRequest.onsuccess = function () {
  100406. };
  100407. addRequest.onerror = function () {
  100408. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add version request in BABYLON.Database.");
  100409. };
  100410. }
  100411. catch (ex) {
  100412. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + ex.message);
  100413. callback(-1);
  100414. }
  100415. }
  100416. else {
  100417. callback(-1);
  100418. }
  100419. };
  100420. /**
  100421. * Loads a file from database
  100422. * @param url defines the URL to load from
  100423. * @param sceneLoaded defines a callback to call on success
  100424. * @param progressCallBack defines a callback to call when progress changed
  100425. * @param errorCallback defines a callback to call on error
  100426. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  100427. */
  100428. Database.prototype.loadFile = function (url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer) {
  100429. var _this = this;
  100430. var completeUrl = Database._ReturnFullUrlLocation(url);
  100431. var saveAndLoadFile = function () {
  100432. // the scene is not yet in the DB, let's try to save it
  100433. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  100434. };
  100435. this._checkVersionFromDB(completeUrl, function (version) {
  100436. if (version !== -1) {
  100437. if (!_this._mustUpdateRessources) {
  100438. _this._loadFileAsync(completeUrl, sceneLoaded, saveAndLoadFile);
  100439. }
  100440. else {
  100441. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  100442. }
  100443. }
  100444. else {
  100445. if (errorCallback) {
  100446. errorCallback();
  100447. }
  100448. }
  100449. });
  100450. };
  100451. Database.prototype._loadFileAsync = function (url, callback, notInDBCallback) {
  100452. if (this._isSupported && this._db) {
  100453. var targetStore;
  100454. if (url.indexOf(".babylon") !== -1) {
  100455. targetStore = "scenes";
  100456. }
  100457. else {
  100458. targetStore = "textures";
  100459. }
  100460. var file;
  100461. var transaction = this._db.transaction([targetStore]);
  100462. transaction.oncomplete = function () {
  100463. if (file) {
  100464. callback(file.data);
  100465. }
  100466. // file was not found in DB
  100467. else {
  100468. notInDBCallback();
  100469. }
  100470. };
  100471. transaction.onabort = function () {
  100472. notInDBCallback();
  100473. };
  100474. var getRequest = transaction.objectStore(targetStore).get(url);
  100475. getRequest.onsuccess = function (event) {
  100476. file = (event.target).result;
  100477. };
  100478. getRequest.onerror = function () {
  100479. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading file " + url + " from DB.");
  100480. notInDBCallback();
  100481. };
  100482. }
  100483. else {
  100484. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  100485. callback();
  100486. }
  100487. };
  100488. Database.prototype._saveFileAsync = function (url, callback, progressCallback, useArrayBuffer, errorCallback) {
  100489. var _this = this;
  100490. if (this._isSupported) {
  100491. var targetStore;
  100492. if (url.indexOf(".babylon") !== -1) {
  100493. targetStore = "scenes";
  100494. }
  100495. else {
  100496. targetStore = "textures";
  100497. }
  100498. // Create XHR
  100499. var xhr = new XMLHttpRequest();
  100500. var fileData;
  100501. xhr.open("GET", url + "?" + Date.now(), true);
  100502. if (useArrayBuffer) {
  100503. xhr.responseType = "arraybuffer";
  100504. }
  100505. if (progressCallback) {
  100506. xhr.onprogress = progressCallback;
  100507. }
  100508. xhr.addEventListener("load", function () {
  100509. if (xhr.status === 200 || (xhr.status < 400 && Database._ValidateXHRData(xhr, !useArrayBuffer ? 1 : 6))) {
  100510. // Blob as response (XHR2)
  100511. fileData = !useArrayBuffer ? xhr.responseText : xhr.response;
  100512. if (!_this._hasReachedQuota && _this._db) {
  100513. // Open a transaction to the database
  100514. var transaction = _this._db.transaction([targetStore], "readwrite");
  100515. // the transaction could abort because of a QuotaExceededError error
  100516. transaction.onabort = function (event) {
  100517. try {
  100518. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  100519. var error = event.srcElement['error'];
  100520. if (error && error.name === "QuotaExceededError") {
  100521. _this._hasReachedQuota = true;
  100522. }
  100523. }
  100524. catch (ex) { }
  100525. callback(fileData);
  100526. };
  100527. transaction.oncomplete = function () {
  100528. callback(fileData);
  100529. };
  100530. var newFile;
  100531. if (targetStore === "scenes") {
  100532. newFile = { sceneUrl: url, data: fileData, version: _this._manifestVersionFound };
  100533. }
  100534. else {
  100535. newFile = { textureUrl: url, data: fileData };
  100536. }
  100537. try {
  100538. // Put the scene into the database
  100539. var addRequest = transaction.objectStore(targetStore).put(newFile);
  100540. addRequest.onsuccess = function () {
  100541. };
  100542. addRequest.onerror = function () {
  100543. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add file request in BABYLON.Database.");
  100544. };
  100545. }
  100546. catch (ex) {
  100547. callback(fileData);
  100548. }
  100549. }
  100550. else {
  100551. callback(fileData);
  100552. }
  100553. }
  100554. else {
  100555. if (xhr.status >= 400 && errorCallback) {
  100556. errorCallback(xhr);
  100557. }
  100558. else {
  100559. callback();
  100560. }
  100561. }
  100562. }, false);
  100563. xhr.addEventListener("error", function () {
  100564. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("error on XHR request.");
  100565. callback();
  100566. }, false);
  100567. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  100568. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  100569. }
  100570. xhr.send();
  100571. }
  100572. else {
  100573. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or Babylon.js Database is not open.");
  100574. callback();
  100575. }
  100576. };
  100577. /**
  100578. * Validates if xhr data is correct
  100579. * @param xhr defines the request to validate
  100580. * @param dataType defines the expected data type
  100581. * @returns true if data is correct
  100582. */
  100583. Database._ValidateXHRData = function (xhr, dataType) {
  100584. // 1 for text (.babylon, manifest and shaders), 2 for TGA, 4 for DDS, 7 for all
  100585. if (dataType === void 0) { dataType = 7; }
  100586. try {
  100587. if (dataType & 1) {
  100588. if (xhr.responseText && xhr.responseText.length > 0) {
  100589. return true;
  100590. }
  100591. else if (dataType === 1) {
  100592. return false;
  100593. }
  100594. }
  100595. if (dataType & 2) {
  100596. // Check header width and height since there is no "TGA" magic number
  100597. var tgaHeader = _Misc_tga__WEBPACK_IMPORTED_MODULE_2__["TGATools"].GetTGAHeader(xhr.response);
  100598. if (tgaHeader.width && tgaHeader.height && tgaHeader.width > 0 && tgaHeader.height > 0) {
  100599. return true;
  100600. }
  100601. else if (dataType === 2) {
  100602. return false;
  100603. }
  100604. }
  100605. if (dataType & 4) {
  100606. // Check for the "DDS" magic number
  100607. var ddsHeader = new Uint8Array(xhr.response, 0, 3);
  100608. if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {
  100609. return true;
  100610. }
  100611. else {
  100612. return false;
  100613. }
  100614. }
  100615. }
  100616. catch (e) {
  100617. // Global protection
  100618. }
  100619. return false;
  100620. };
  100621. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  100622. Database.IsUASupportingBlobStorage = true;
  100623. /**
  100624. * Gets a boolean indicating if Database storate is enabled (off by default)
  100625. */
  100626. Database.IDBStorageEnabled = false;
  100627. Database._ParseURL = function (url) {
  100628. var a = document.createElement('a');
  100629. a.href = url;
  100630. var urlWithoutHash = url.substring(0, url.lastIndexOf("#"));
  100631. var fileName = url.substring(urlWithoutHash.lastIndexOf("/") + 1, url.length);
  100632. var absLocation = url.substring(0, url.indexOf(fileName, 0));
  100633. return absLocation;
  100634. };
  100635. Database._ReturnFullUrlLocation = function (url) {
  100636. if (url.indexOf("http:/") === -1 && url.indexOf("https:/") === -1) {
  100637. return (Database._ParseURL(window.location.href) + url);
  100638. }
  100639. else {
  100640. return url;
  100641. }
  100642. };
  100643. return Database;
  100644. }());
  100645. /***/ }),
  100646. /***/ "./Offline/index.ts":
  100647. /*!**************************!*\
  100648. !*** ./Offline/index.ts ***!
  100649. \**************************/
  100650. /*! exports provided: Database */
  100651. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100652. "use strict";
  100653. __webpack_require__.r(__webpack_exports__);
  100654. /* harmony import */ var _database__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database */ "./Offline/database.ts");
  100655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _database__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  100656. /***/ }),
  100657. /***/ "./Particles/EmitterTypes/boxParticleEmitter.ts":
  100658. /*!******************************************************!*\
  100659. !*** ./Particles/EmitterTypes/boxParticleEmitter.ts ***!
  100660. \******************************************************/
  100661. /*! exports provided: BoxParticleEmitter */
  100662. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100663. "use strict";
  100664. __webpack_require__.r(__webpack_exports__);
  100665. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return BoxParticleEmitter; });
  100666. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  100667. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  100668. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  100669. /**
  100670. * Particle emitter emitting particles from the inside of a box.
  100671. * It emits the particles randomly between 2 given directions.
  100672. */
  100673. var BoxParticleEmitter = /** @class */ (function () {
  100674. /**
  100675. * Creates a new instance BoxParticleEmitter
  100676. */
  100677. function BoxParticleEmitter() {
  100678. /**
  100679. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  100680. */
  100681. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  100682. /**
  100683. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  100684. */
  100685. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  100686. /**
  100687. * 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.
  100688. */
  100689. this.minEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-0.5, -0.5, -0.5);
  100690. /**
  100691. * 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.
  100692. */
  100693. this.maxEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.5, 0.5, 0.5);
  100694. }
  100695. /**
  100696. * Called by the particle System when the direction is computed for the created particle.
  100697. * @param worldMatrix is the world matrix of the particle system
  100698. * @param directionToUpdate is the direction vector to update with the result
  100699. * @param particle is the particle we are computed the direction for
  100700. */
  100701. BoxParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  100702. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  100703. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  100704. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  100705. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  100706. };
  100707. /**
  100708. * Called by the particle System when the position is computed for the created particle.
  100709. * @param worldMatrix is the world matrix of the particle system
  100710. * @param positionToUpdate is the position vector to update with the result
  100711. * @param particle is the particle we are computed the position for
  100712. */
  100713. BoxParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  100714. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.x, this.maxEmitBox.x);
  100715. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.y, this.maxEmitBox.y);
  100716. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
  100717. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  100718. };
  100719. /**
  100720. * Clones the current emitter and returns a copy of it
  100721. * @returns the new emitter
  100722. */
  100723. BoxParticleEmitter.prototype.clone = function () {
  100724. var newOne = new BoxParticleEmitter();
  100725. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  100726. return newOne;
  100727. };
  100728. /**
  100729. * Called by the GPUParticleSystem to setup the update shader
  100730. * @param effect defines the update shader
  100731. */
  100732. BoxParticleEmitter.prototype.applyToShader = function (effect) {
  100733. effect.setVector3("direction1", this.direction1);
  100734. effect.setVector3("direction2", this.direction2);
  100735. effect.setVector3("minEmitBox", this.minEmitBox);
  100736. effect.setVector3("maxEmitBox", this.maxEmitBox);
  100737. };
  100738. /**
  100739. * Returns a string to use to update the GPU particles update shader
  100740. * @returns a string containng the defines string
  100741. */
  100742. BoxParticleEmitter.prototype.getEffectDefines = function () {
  100743. return "#define BOXEMITTER";
  100744. };
  100745. /**
  100746. * Returns the string "BoxParticleEmitter"
  100747. * @returns a string containing the class name
  100748. */
  100749. BoxParticleEmitter.prototype.getClassName = function () {
  100750. return "BoxParticleEmitter";
  100751. };
  100752. /**
  100753. * Serializes the particle system to a JSON object.
  100754. * @returns the JSON object
  100755. */
  100756. BoxParticleEmitter.prototype.serialize = function () {
  100757. var serializationObject = {};
  100758. serializationObject.type = this.getClassName();
  100759. serializationObject.direction1 = this.direction1.asArray();
  100760. serializationObject.direction2 = this.direction2.asArray();
  100761. serializationObject.minEmitBox = this.minEmitBox.asArray();
  100762. serializationObject.maxEmitBox = this.maxEmitBox.asArray();
  100763. return serializationObject;
  100764. };
  100765. /**
  100766. * Parse properties from a JSON object
  100767. * @param serializationObject defines the JSON object
  100768. */
  100769. BoxParticleEmitter.prototype.parse = function (serializationObject) {
  100770. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  100771. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  100772. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.minEmitBox, 0, this.minEmitBox);
  100773. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.maxEmitBox, 0, this.maxEmitBox);
  100774. };
  100775. return BoxParticleEmitter;
  100776. }());
  100777. /***/ }),
  100778. /***/ "./Particles/EmitterTypes/coneParticleEmitter.ts":
  100779. /*!*******************************************************!*\
  100780. !*** ./Particles/EmitterTypes/coneParticleEmitter.ts ***!
  100781. \*******************************************************/
  100782. /*! exports provided: ConeParticleEmitter */
  100783. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100784. "use strict";
  100785. __webpack_require__.r(__webpack_exports__);
  100786. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return ConeParticleEmitter; });
  100787. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  100788. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  100789. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  100790. /**
  100791. * Particle emitter emitting particles from the inside of a cone.
  100792. * It emits the particles alongside the cone volume from the base to the particle.
  100793. * The emission direction might be randomized.
  100794. */
  100795. var ConeParticleEmitter = /** @class */ (function () {
  100796. /**
  100797. * Creates a new instance ConeParticleEmitter
  100798. * @param radius the radius of the emission cone (1 by default)
  100799. * @param angles the cone base angle (PI by default)
  100800. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  100801. */
  100802. function ConeParticleEmitter(radius, angle,
  100803. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  100804. directionRandomizer) {
  100805. if (radius === void 0) { radius = 1; }
  100806. if (angle === void 0) { angle = Math.PI; }
  100807. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  100808. this.directionRandomizer = directionRandomizer;
  100809. /**
  100810. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  100811. */
  100812. this.radiusRange = 1;
  100813. /**
  100814. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  100815. */
  100816. this.heightRange = 1;
  100817. /**
  100818. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  100819. */
  100820. this.emitFromSpawnPointOnly = false;
  100821. this.angle = angle;
  100822. this.radius = radius;
  100823. }
  100824. Object.defineProperty(ConeParticleEmitter.prototype, "radius", {
  100825. /**
  100826. * Gets or sets the radius of the emission cone
  100827. */
  100828. get: function () {
  100829. return this._radius;
  100830. },
  100831. set: function (value) {
  100832. this._radius = value;
  100833. this._buildHeight();
  100834. },
  100835. enumerable: true,
  100836. configurable: true
  100837. });
  100838. Object.defineProperty(ConeParticleEmitter.prototype, "angle", {
  100839. /**
  100840. * Gets or sets the angle of the emission cone
  100841. */
  100842. get: function () {
  100843. return this._angle;
  100844. },
  100845. set: function (value) {
  100846. this._angle = value;
  100847. this._buildHeight();
  100848. },
  100849. enumerable: true,
  100850. configurable: true
  100851. });
  100852. ConeParticleEmitter.prototype._buildHeight = function () {
  100853. if (this._angle !== 0) {
  100854. this._height = this._radius / Math.tan(this._angle / 2);
  100855. }
  100856. else {
  100857. this._height = 1;
  100858. }
  100859. };
  100860. /**
  100861. * Called by the particle System when the direction is computed for the created particle.
  100862. * @param worldMatrix is the world matrix of the particle system
  100863. * @param directionToUpdate is the direction vector to update with the result
  100864. * @param particle is the particle we are computed the direction for
  100865. */
  100866. ConeParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  100867. if (Math.abs(Math.cos(this._angle)) === 1.0) {
  100868. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(0, 1.0, 0, worldMatrix, directionToUpdate);
  100869. }
  100870. else {
  100871. // measure the direction Vector from the emitter to the particle.
  100872. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  100873. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  100874. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  100875. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  100876. direction.x += randX;
  100877. direction.y += randY;
  100878. direction.z += randZ;
  100879. direction.normalize();
  100880. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  100881. }
  100882. };
  100883. /**
  100884. * Called by the particle System when the position is computed for the created particle.
  100885. * @param worldMatrix is the world matrix of the particle system
  100886. * @param positionToUpdate is the position vector to update with the result
  100887. * @param particle is the particle we are computed the position for
  100888. */
  100889. ConeParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  100890. var s = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, Math.PI * 2);
  100891. var h;
  100892. if (!this.emitFromSpawnPointOnly) {
  100893. h = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.heightRange);
  100894. // Better distribution in a cone at normal angles.
  100895. h = 1 - h * h;
  100896. }
  100897. else {
  100898. h = 0.0001;
  100899. }
  100900. var radius = this._radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this._radius * this.radiusRange);
  100901. radius = radius * h;
  100902. var randX = radius * Math.sin(s);
  100903. var randZ = radius * Math.cos(s);
  100904. var randY = h * this._height;
  100905. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  100906. };
  100907. /**
  100908. * Clones the current emitter and returns a copy of it
  100909. * @returns the new emitter
  100910. */
  100911. ConeParticleEmitter.prototype.clone = function () {
  100912. var newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);
  100913. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  100914. return newOne;
  100915. };
  100916. /**
  100917. * Called by the GPUParticleSystem to setup the update shader
  100918. * @param effect defines the update shader
  100919. */
  100920. ConeParticleEmitter.prototype.applyToShader = function (effect) {
  100921. effect.setFloat2("radius", this._radius, this.radiusRange);
  100922. effect.setFloat("coneAngle", this._angle);
  100923. effect.setFloat2("height", this._height, this.heightRange);
  100924. effect.setFloat("directionRandomizer", this.directionRandomizer);
  100925. };
  100926. /**
  100927. * Returns a string to use to update the GPU particles update shader
  100928. * @returns a string containng the defines string
  100929. */
  100930. ConeParticleEmitter.prototype.getEffectDefines = function () {
  100931. var defines = "#define CONEEMITTER";
  100932. if (this.emitFromSpawnPointOnly) {
  100933. defines += "\n#define CONEEMITTERSPAWNPOINT";
  100934. }
  100935. return defines;
  100936. };
  100937. /**
  100938. * Returns the string "ConeParticleEmitter"
  100939. * @returns a string containing the class name
  100940. */
  100941. ConeParticleEmitter.prototype.getClassName = function () {
  100942. return "ConeParticleEmitter";
  100943. };
  100944. /**
  100945. * Serializes the particle system to a JSON object.
  100946. * @returns the JSON object
  100947. */
  100948. ConeParticleEmitter.prototype.serialize = function () {
  100949. var serializationObject = {};
  100950. serializationObject.type = this.getClassName();
  100951. serializationObject.radius = this._radius;
  100952. serializationObject.angle = this._angle;
  100953. serializationObject.directionRandomizer = this.directionRandomizer;
  100954. return serializationObject;
  100955. };
  100956. /**
  100957. * Parse properties from a JSON object
  100958. * @param serializationObject defines the JSON object
  100959. */
  100960. ConeParticleEmitter.prototype.parse = function (serializationObject) {
  100961. this.radius = serializationObject.radius;
  100962. this.angle = serializationObject.angle;
  100963. this.directionRandomizer = serializationObject.directionRandomizer;
  100964. };
  100965. return ConeParticleEmitter;
  100966. }());
  100967. /***/ }),
  100968. /***/ "./Particles/EmitterTypes/cylinderParticleEmitter.ts":
  100969. /*!***********************************************************!*\
  100970. !*** ./Particles/EmitterTypes/cylinderParticleEmitter.ts ***!
  100971. \***********************************************************/
  100972. /*! exports provided: CylinderParticleEmitter, CylinderDirectedParticleEmitter */
  100973. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100974. "use strict";
  100975. __webpack_require__.r(__webpack_exports__);
  100976. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return CylinderParticleEmitter; });
  100977. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return CylinderDirectedParticleEmitter; });
  100978. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  100979. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  100980. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  100981. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  100982. /**
  100983. * Particle emitter emitting particles from the inside of a cylinder.
  100984. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  100985. */
  100986. var CylinderParticleEmitter = /** @class */ (function () {
  100987. /**
  100988. * Creates a new instance CylinderParticleEmitter
  100989. * @param radius the radius of the emission cylinder (1 by default)
  100990. * @param height the height of the emission cylinder (1 by default)
  100991. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  100992. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  100993. */
  100994. function CylinderParticleEmitter(
  100995. /**
  100996. * The radius of the emission cylinder.
  100997. */
  100998. radius,
  100999. /**
  101000. * The height of the emission cylinder.
  101001. */
  101002. height,
  101003. /**
  101004. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101005. */
  101006. radiusRange,
  101007. /**
  101008. * How much to randomize the particle direction [0-1].
  101009. */
  101010. directionRandomizer) {
  101011. if (radius === void 0) { radius = 1; }
  101012. if (height === void 0) { height = 1; }
  101013. if (radiusRange === void 0) { radiusRange = 1; }
  101014. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  101015. this.radius = radius;
  101016. this.height = height;
  101017. this.radiusRange = radiusRange;
  101018. this.directionRandomizer = directionRandomizer;
  101019. }
  101020. /**
  101021. * Called by the particle System when the direction is computed for the created particle.
  101022. * @param worldMatrix is the world matrix of the particle system
  101023. * @param directionToUpdate is the direction vector to update with the result
  101024. * @param particle is the particle we are computed the direction for
  101025. */
  101026. CylinderParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101027. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  101028. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2);
  101029. var angle = Math.atan2(direction.x, direction.z);
  101030. angle += _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer;
  101031. direction.y = randY; // set direction y to rand y to mirror normal of cylinder surface
  101032. direction.x = Math.sin(angle);
  101033. direction.z = Math.cos(angle);
  101034. direction.normalize();
  101035. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  101036. };
  101037. /**
  101038. * Called by the particle System when the position is computed for the created particle.
  101039. * @param worldMatrix is the world matrix of the particle system
  101040. * @param positionToUpdate is the position vector to update with the result
  101041. * @param particle is the particle we are computed the position for
  101042. */
  101043. CylinderParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  101044. var yPos = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.height / 2, this.height / 2);
  101045. var angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  101046. // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html
  101047. var radiusDistribution = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1);
  101048. var positionRadius = Math.sqrt(radiusDistribution) * this.radius;
  101049. var xPos = positionRadius * Math.cos(angle);
  101050. var zPos = positionRadius * Math.sin(angle);
  101051. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, worldMatrix, positionToUpdate);
  101052. };
  101053. /**
  101054. * Clones the current emitter and returns a copy of it
  101055. * @returns the new emitter
  101056. */
  101057. CylinderParticleEmitter.prototype.clone = function () {
  101058. var newOne = new CylinderParticleEmitter(this.radius, this.directionRandomizer);
  101059. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  101060. return newOne;
  101061. };
  101062. /**
  101063. * Called by the GPUParticleSystem to setup the update shader
  101064. * @param effect defines the update shader
  101065. */
  101066. CylinderParticleEmitter.prototype.applyToShader = function (effect) {
  101067. effect.setFloat("radius", this.radius);
  101068. effect.setFloat("height", this.height);
  101069. effect.setFloat("radiusRange", this.radiusRange);
  101070. effect.setFloat("directionRandomizer", this.directionRandomizer);
  101071. };
  101072. /**
  101073. * Returns a string to use to update the GPU particles update shader
  101074. * @returns a string containng the defines string
  101075. */
  101076. CylinderParticleEmitter.prototype.getEffectDefines = function () {
  101077. return "#define CYLINDEREMITTER";
  101078. };
  101079. /**
  101080. * Returns the string "CylinderParticleEmitter"
  101081. * @returns a string containing the class name
  101082. */
  101083. CylinderParticleEmitter.prototype.getClassName = function () {
  101084. return "CylinderParticleEmitter";
  101085. };
  101086. /**
  101087. * Serializes the particle system to a JSON object.
  101088. * @returns the JSON object
  101089. */
  101090. CylinderParticleEmitter.prototype.serialize = function () {
  101091. var serializationObject = {};
  101092. serializationObject.type = this.getClassName();
  101093. serializationObject.radius = this.radius;
  101094. serializationObject.height = this.height;
  101095. serializationObject.radiusRange = this.radiusRange;
  101096. serializationObject.directionRandomizer = this.directionRandomizer;
  101097. return serializationObject;
  101098. };
  101099. /**
  101100. * Parse properties from a JSON object
  101101. * @param serializationObject defines the JSON object
  101102. */
  101103. CylinderParticleEmitter.prototype.parse = function (serializationObject) {
  101104. this.radius = serializationObject.radius;
  101105. this.height = serializationObject.height;
  101106. this.radiusRange = serializationObject.radiusRange;
  101107. this.directionRandomizer = serializationObject.directionRandomizer;
  101108. };
  101109. return CylinderParticleEmitter;
  101110. }());
  101111. /**
  101112. * Particle emitter emitting particles from the inside of a cylinder.
  101113. * It emits the particles randomly between two vectors.
  101114. */
  101115. var CylinderDirectedParticleEmitter = /** @class */ (function (_super) {
  101116. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderDirectedParticleEmitter, _super);
  101117. /**
  101118. * Creates a new instance CylinderDirectedParticleEmitter
  101119. * @param radius the radius of the emission cylinder (1 by default)
  101120. * @param height the height of the emission cylinder (1 by default)
  101121. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101122. * @param direction1 the min limit of the emission direction (up vector by default)
  101123. * @param direction2 the max limit of the emission direction (up vector by default)
  101124. */
  101125. function CylinderDirectedParticleEmitter(radius, height, radiusRange,
  101126. /**
  101127. * The min limit of the emission direction.
  101128. */
  101129. direction1,
  101130. /**
  101131. * The max limit of the emission direction.
  101132. */
  101133. direction2) {
  101134. if (radius === void 0) { radius = 1; }
  101135. if (height === void 0) { height = 1; }
  101136. if (radiusRange === void 0) { radiusRange = 1; }
  101137. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  101138. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  101139. var _this = _super.call(this, radius, height, radiusRange) || this;
  101140. _this.direction1 = direction1;
  101141. _this.direction2 = direction2;
  101142. return _this;
  101143. }
  101144. /**
  101145. * Called by the particle System when the direction is computed for the created particle.
  101146. * @param worldMatrix is the world matrix of the particle system
  101147. * @param directionToUpdate is the direction vector to update with the result
  101148. * @param particle is the particle we are computed the direction for
  101149. */
  101150. CylinderDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101151. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  101152. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  101153. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  101154. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  101155. };
  101156. /**
  101157. * Clones the current emitter and returns a copy of it
  101158. * @returns the new emitter
  101159. */
  101160. CylinderDirectedParticleEmitter.prototype.clone = function () {
  101161. var newOne = new CylinderDirectedParticleEmitter(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);
  101162. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  101163. return newOne;
  101164. };
  101165. /**
  101166. * Called by the GPUParticleSystem to setup the update shader
  101167. * @param effect defines the update shader
  101168. */
  101169. CylinderDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  101170. effect.setFloat("radius", this.radius);
  101171. effect.setFloat("height", this.height);
  101172. effect.setFloat("radiusRange", this.radiusRange);
  101173. effect.setVector3("direction1", this.direction1);
  101174. effect.setVector3("direction2", this.direction2);
  101175. };
  101176. /**
  101177. * Returns a string to use to update the GPU particles update shader
  101178. * @returns a string containng the defines string
  101179. */
  101180. CylinderDirectedParticleEmitter.prototype.getEffectDefines = function () {
  101181. return "#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER";
  101182. };
  101183. /**
  101184. * Returns the string "CylinderDirectedParticleEmitter"
  101185. * @returns a string containing the class name
  101186. */
  101187. CylinderDirectedParticleEmitter.prototype.getClassName = function () {
  101188. return "CylinderDirectedParticleEmitter";
  101189. };
  101190. /**
  101191. * Serializes the particle system to a JSON object.
  101192. * @returns the JSON object
  101193. */
  101194. CylinderDirectedParticleEmitter.prototype.serialize = function () {
  101195. var serializationObject = _super.prototype.serialize.call(this);
  101196. serializationObject.direction1 = this.direction1.asArray();
  101197. serializationObject.direction2 = this.direction2.asArray();
  101198. return serializationObject;
  101199. };
  101200. /**
  101201. * Parse properties from a JSON object
  101202. * @param serializationObject defines the JSON object
  101203. */
  101204. CylinderDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  101205. _super.prototype.parse.call(this, serializationObject);
  101206. this.direction1.copyFrom(serializationObject.direction1);
  101207. this.direction2.copyFrom(serializationObject.direction2);
  101208. };
  101209. return CylinderDirectedParticleEmitter;
  101210. }(CylinderParticleEmitter));
  101211. /***/ }),
  101212. /***/ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts":
  101213. /*!**************************************************************!*\
  101214. !*** ./Particles/EmitterTypes/hemisphericParticleEmitter.ts ***!
  101215. \**************************************************************/
  101216. /*! exports provided: HemisphericParticleEmitter */
  101217. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101218. "use strict";
  101219. __webpack_require__.r(__webpack_exports__);
  101220. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return HemisphericParticleEmitter; });
  101221. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101222. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101223. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101224. /**
  101225. * Particle emitter emitting particles from the inside of a hemisphere.
  101226. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  101227. */
  101228. var HemisphericParticleEmitter = /** @class */ (function () {
  101229. /**
  101230. * Creates a new instance HemisphericParticleEmitter
  101231. * @param radius the radius of the emission hemisphere (1 by default)
  101232. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101233. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  101234. */
  101235. function HemisphericParticleEmitter(
  101236. /**
  101237. * The radius of the emission hemisphere.
  101238. */
  101239. radius,
  101240. /**
  101241. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101242. */
  101243. radiusRange,
  101244. /**
  101245. * How much to randomize the particle direction [0-1].
  101246. */
  101247. directionRandomizer) {
  101248. if (radius === void 0) { radius = 1; }
  101249. if (radiusRange === void 0) { radiusRange = 1; }
  101250. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  101251. this.radius = radius;
  101252. this.radiusRange = radiusRange;
  101253. this.directionRandomizer = directionRandomizer;
  101254. }
  101255. /**
  101256. * Called by the particle System when the direction is computed for the created particle.
  101257. * @param worldMatrix is the world matrix of the particle system
  101258. * @param directionToUpdate is the direction vector to update with the result
  101259. * @param particle is the particle we are computed the direction for
  101260. */
  101261. HemisphericParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101262. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  101263. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101264. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101265. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101266. direction.x += randX;
  101267. direction.y += randY;
  101268. direction.z += randZ;
  101269. direction.normalize();
  101270. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  101271. };
  101272. /**
  101273. * Called by the particle System when the position is computed for the created particle.
  101274. * @param worldMatrix is the world matrix of the particle system
  101275. * @param positionToUpdate is the position vector to update with the result
  101276. * @param particle is the particle we are computed the position for
  101277. */
  101278. HemisphericParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  101279. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  101280. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  101281. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  101282. var theta = Math.acos(2 * v - 1);
  101283. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  101284. var randY = randRadius * Math.cos(theta);
  101285. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  101286. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, Math.abs(randY), randZ, worldMatrix, positionToUpdate);
  101287. };
  101288. /**
  101289. * Clones the current emitter and returns a copy of it
  101290. * @returns the new emitter
  101291. */
  101292. HemisphericParticleEmitter.prototype.clone = function () {
  101293. var newOne = new HemisphericParticleEmitter(this.radius, this.directionRandomizer);
  101294. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  101295. return newOne;
  101296. };
  101297. /**
  101298. * Called by the GPUParticleSystem to setup the update shader
  101299. * @param effect defines the update shader
  101300. */
  101301. HemisphericParticleEmitter.prototype.applyToShader = function (effect) {
  101302. effect.setFloat("radius", this.radius);
  101303. effect.setFloat("radiusRange", this.radiusRange);
  101304. effect.setFloat("directionRandomizer", this.directionRandomizer);
  101305. };
  101306. /**
  101307. * Returns a string to use to update the GPU particles update shader
  101308. * @returns a string containng the defines string
  101309. */
  101310. HemisphericParticleEmitter.prototype.getEffectDefines = function () {
  101311. return "#define HEMISPHERICEMITTER";
  101312. };
  101313. /**
  101314. * Returns the string "HemisphericParticleEmitter"
  101315. * @returns a string containing the class name
  101316. */
  101317. HemisphericParticleEmitter.prototype.getClassName = function () {
  101318. return "HemisphericParticleEmitter";
  101319. };
  101320. /**
  101321. * Serializes the particle system to a JSON object.
  101322. * @returns the JSON object
  101323. */
  101324. HemisphericParticleEmitter.prototype.serialize = function () {
  101325. var serializationObject = {};
  101326. serializationObject.type = this.getClassName();
  101327. serializationObject.radius = this.radius;
  101328. serializationObject.radiusRange = this.radiusRange;
  101329. serializationObject.directionRandomizer = this.directionRandomizer;
  101330. return serializationObject;
  101331. };
  101332. /**
  101333. * Parse properties from a JSON object
  101334. * @param serializationObject defines the JSON object
  101335. */
  101336. HemisphericParticleEmitter.prototype.parse = function (serializationObject) {
  101337. this.radius = serializationObject.radius;
  101338. this.radiusRange = serializationObject.radiusRange;
  101339. this.directionRandomizer = serializationObject.directionRandomizer;
  101340. };
  101341. return HemisphericParticleEmitter;
  101342. }());
  101343. /***/ }),
  101344. /***/ "./Particles/EmitterTypes/index.ts":
  101345. /*!*****************************************!*\
  101346. !*** ./Particles/EmitterTypes/index.ts ***!
  101347. \*****************************************/
  101348. /*! exports provided: BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  101349. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101350. "use strict";
  101351. __webpack_require__.r(__webpack_exports__);
  101352. /* harmony import */ var _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  101353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  101354. /* harmony import */ var _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./coneParticleEmitter */ "./Particles/EmitterTypes/coneParticleEmitter.ts");
  101355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  101356. /* harmony import */ var _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cylinderParticleEmitter */ "./Particles/EmitterTypes/cylinderParticleEmitter.ts");
  101357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"]; });
  101358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"]; });
  101359. /* harmony import */ var _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hemisphericParticleEmitter */ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts");
  101360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__["HemisphericParticleEmitter"]; });
  101361. /* harmony import */ var _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pointParticleEmitter */ "./Particles/EmitterTypes/pointParticleEmitter.ts");
  101362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__["PointParticleEmitter"]; });
  101363. /* harmony import */ var _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sphereParticleEmitter */ "./Particles/EmitterTypes/sphereParticleEmitter.ts");
  101364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereParticleEmitter"]; });
  101365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereDirectedParticleEmitter"]; });
  101366. /***/ }),
  101367. /***/ "./Particles/EmitterTypes/pointParticleEmitter.ts":
  101368. /*!********************************************************!*\
  101369. !*** ./Particles/EmitterTypes/pointParticleEmitter.ts ***!
  101370. \********************************************************/
  101371. /*! exports provided: PointParticleEmitter */
  101372. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101373. "use strict";
  101374. __webpack_require__.r(__webpack_exports__);
  101375. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return PointParticleEmitter; });
  101376. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101377. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101378. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101379. /**
  101380. * Particle emitter emitting particles from a point.
  101381. * It emits the particles randomly between 2 given directions.
  101382. */
  101383. var PointParticleEmitter = /** @class */ (function () {
  101384. /**
  101385. * Creates a new instance PointParticleEmitter
  101386. */
  101387. function PointParticleEmitter() {
  101388. /**
  101389. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101390. */
  101391. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  101392. /**
  101393. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101394. */
  101395. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  101396. }
  101397. /**
  101398. * Called by the particle System when the direction is computed for the created particle.
  101399. * @param worldMatrix is the world matrix of the particle system
  101400. * @param directionToUpdate is the direction vector to update with the result
  101401. * @param particle is the particle we are computed the direction for
  101402. */
  101403. PointParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101404. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  101405. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  101406. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  101407. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  101408. };
  101409. /**
  101410. * Called by the particle System when the position is computed for the created particle.
  101411. * @param worldMatrix is the world matrix of the particle system
  101412. * @param positionToUpdate is the position vector to update with the result
  101413. * @param particle is the particle we are computed the position for
  101414. */
  101415. PointParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  101416. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0, 0, 0, worldMatrix, positionToUpdate);
  101417. };
  101418. /**
  101419. * Clones the current emitter and returns a copy of it
  101420. * @returns the new emitter
  101421. */
  101422. PointParticleEmitter.prototype.clone = function () {
  101423. var newOne = new PointParticleEmitter();
  101424. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  101425. return newOne;
  101426. };
  101427. /**
  101428. * Called by the GPUParticleSystem to setup the update shader
  101429. * @param effect defines the update shader
  101430. */
  101431. PointParticleEmitter.prototype.applyToShader = function (effect) {
  101432. effect.setVector3("direction1", this.direction1);
  101433. effect.setVector3("direction2", this.direction2);
  101434. };
  101435. /**
  101436. * Returns a string to use to update the GPU particles update shader
  101437. * @returns a string containng the defines string
  101438. */
  101439. PointParticleEmitter.prototype.getEffectDefines = function () {
  101440. return "#define POINTEMITTER";
  101441. };
  101442. /**
  101443. * Returns the string "PointParticleEmitter"
  101444. * @returns a string containing the class name
  101445. */
  101446. PointParticleEmitter.prototype.getClassName = function () {
  101447. return "PointParticleEmitter";
  101448. };
  101449. /**
  101450. * Serializes the particle system to a JSON object.
  101451. * @returns the JSON object
  101452. */
  101453. PointParticleEmitter.prototype.serialize = function () {
  101454. var serializationObject = {};
  101455. serializationObject.type = this.getClassName();
  101456. serializationObject.direction1 = this.direction1.asArray();
  101457. serializationObject.direction2 = this.direction2.asArray();
  101458. return serializationObject;
  101459. };
  101460. /**
  101461. * Parse properties from a JSON object
  101462. * @param serializationObject defines the JSON object
  101463. */
  101464. PointParticleEmitter.prototype.parse = function (serializationObject) {
  101465. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  101466. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  101467. };
  101468. return PointParticleEmitter;
  101469. }());
  101470. /***/ }),
  101471. /***/ "./Particles/EmitterTypes/sphereParticleEmitter.ts":
  101472. /*!*********************************************************!*\
  101473. !*** ./Particles/EmitterTypes/sphereParticleEmitter.ts ***!
  101474. \*********************************************************/
  101475. /*! exports provided: SphereParticleEmitter, SphereDirectedParticleEmitter */
  101476. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101477. "use strict";
  101478. __webpack_require__.r(__webpack_exports__);
  101479. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return SphereParticleEmitter; });
  101480. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return SphereDirectedParticleEmitter; });
  101481. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  101482. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  101483. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  101484. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  101485. /**
  101486. * Particle emitter emitting particles from the inside of a sphere.
  101487. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  101488. */
  101489. var SphereParticleEmitter = /** @class */ (function () {
  101490. /**
  101491. * Creates a new instance SphereParticleEmitter
  101492. * @param radius the radius of the emission sphere (1 by default)
  101493. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101494. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  101495. */
  101496. function SphereParticleEmitter(
  101497. /**
  101498. * The radius of the emission sphere.
  101499. */
  101500. radius,
  101501. /**
  101502. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101503. */
  101504. radiusRange,
  101505. /**
  101506. * How much to randomize the particle direction [0-1].
  101507. */
  101508. directionRandomizer) {
  101509. if (radius === void 0) { radius = 1; }
  101510. if (radiusRange === void 0) { radiusRange = 1; }
  101511. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  101512. this.radius = radius;
  101513. this.radiusRange = radiusRange;
  101514. this.directionRandomizer = directionRandomizer;
  101515. }
  101516. /**
  101517. * Called by the particle System when the direction is computed for the created particle.
  101518. * @param worldMatrix is the world matrix of the particle system
  101519. * @param directionToUpdate is the direction vector to update with the result
  101520. * @param particle is the particle we are computed the direction for
  101521. */
  101522. SphereParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101523. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  101524. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101525. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101526. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  101527. direction.x += randX;
  101528. direction.y += randY;
  101529. direction.z += randZ;
  101530. direction.normalize();
  101531. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  101532. };
  101533. /**
  101534. * Called by the particle System when the position is computed for the created particle.
  101535. * @param worldMatrix is the world matrix of the particle system
  101536. * @param positionToUpdate is the position vector to update with the result
  101537. * @param particle is the particle we are computed the position for
  101538. */
  101539. SphereParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  101540. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  101541. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  101542. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  101543. var theta = Math.acos(2 * v - 1);
  101544. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  101545. var randY = randRadius * Math.cos(theta);
  101546. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  101547. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  101548. };
  101549. /**
  101550. * Clones the current emitter and returns a copy of it
  101551. * @returns the new emitter
  101552. */
  101553. SphereParticleEmitter.prototype.clone = function () {
  101554. var newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);
  101555. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  101556. return newOne;
  101557. };
  101558. /**
  101559. * Called by the GPUParticleSystem to setup the update shader
  101560. * @param effect defines the update shader
  101561. */
  101562. SphereParticleEmitter.prototype.applyToShader = function (effect) {
  101563. effect.setFloat("radius", this.radius);
  101564. effect.setFloat("radiusRange", this.radiusRange);
  101565. effect.setFloat("directionRandomizer", this.directionRandomizer);
  101566. };
  101567. /**
  101568. * Returns a string to use to update the GPU particles update shader
  101569. * @returns a string containng the defines string
  101570. */
  101571. SphereParticleEmitter.prototype.getEffectDefines = function () {
  101572. return "#define SPHEREEMITTER";
  101573. };
  101574. /**
  101575. * Returns the string "SphereParticleEmitter"
  101576. * @returns a string containing the class name
  101577. */
  101578. SphereParticleEmitter.prototype.getClassName = function () {
  101579. return "SphereParticleEmitter";
  101580. };
  101581. /**
  101582. * Serializes the particle system to a JSON object.
  101583. * @returns the JSON object
  101584. */
  101585. SphereParticleEmitter.prototype.serialize = function () {
  101586. var serializationObject = {};
  101587. serializationObject.type = this.getClassName();
  101588. serializationObject.radius = this.radius;
  101589. serializationObject.radiusRange = this.radiusRange;
  101590. serializationObject.directionRandomizer = this.directionRandomizer;
  101591. return serializationObject;
  101592. };
  101593. /**
  101594. * Parse properties from a JSON object
  101595. * @param serializationObject defines the JSON object
  101596. */
  101597. SphereParticleEmitter.prototype.parse = function (serializationObject) {
  101598. this.radius = serializationObject.radius;
  101599. this.radiusRange = serializationObject.radiusRange;
  101600. this.directionRandomizer = serializationObject.directionRandomizer;
  101601. };
  101602. return SphereParticleEmitter;
  101603. }());
  101604. /**
  101605. * Particle emitter emitting particles from the inside of a sphere.
  101606. * It emits the particles randomly between two vectors.
  101607. */
  101608. var SphereDirectedParticleEmitter = /** @class */ (function (_super) {
  101609. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SphereDirectedParticleEmitter, _super);
  101610. /**
  101611. * Creates a new instance SphereDirectedParticleEmitter
  101612. * @param radius the radius of the emission sphere (1 by default)
  101613. * @param direction1 the min limit of the emission direction (up vector by default)
  101614. * @param direction2 the max limit of the emission direction (up vector by default)
  101615. */
  101616. function SphereDirectedParticleEmitter(radius,
  101617. /**
  101618. * The min limit of the emission direction.
  101619. */
  101620. direction1,
  101621. /**
  101622. * The max limit of the emission direction.
  101623. */
  101624. direction2) {
  101625. if (radius === void 0) { radius = 1; }
  101626. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  101627. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  101628. var _this = _super.call(this, radius) || this;
  101629. _this.direction1 = direction1;
  101630. _this.direction2 = direction2;
  101631. return _this;
  101632. }
  101633. /**
  101634. * Called by the particle System when the direction is computed for the created particle.
  101635. * @param worldMatrix is the world matrix of the particle system
  101636. * @param directionToUpdate is the direction vector to update with the result
  101637. * @param particle is the particle we are computed the direction for
  101638. */
  101639. SphereDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  101640. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  101641. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  101642. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  101643. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  101644. };
  101645. /**
  101646. * Clones the current emitter and returns a copy of it
  101647. * @returns the new emitter
  101648. */
  101649. SphereDirectedParticleEmitter.prototype.clone = function () {
  101650. var newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);
  101651. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  101652. return newOne;
  101653. };
  101654. /**
  101655. * Called by the GPUParticleSystem to setup the update shader
  101656. * @param effect defines the update shader
  101657. */
  101658. SphereDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  101659. effect.setFloat("radius", this.radius);
  101660. effect.setFloat("radiusRange", this.radiusRange);
  101661. effect.setVector3("direction1", this.direction1);
  101662. effect.setVector3("direction2", this.direction2);
  101663. };
  101664. /**
  101665. * Returns a string to use to update the GPU particles update shader
  101666. * @returns a string containng the defines string
  101667. */
  101668. SphereDirectedParticleEmitter.prototype.getEffectDefines = function () {
  101669. return "#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER";
  101670. };
  101671. /**
  101672. * Returns the string "SphereDirectedParticleEmitter"
  101673. * @returns a string containing the class name
  101674. */
  101675. SphereDirectedParticleEmitter.prototype.getClassName = function () {
  101676. return "SphereDirectedParticleEmitter";
  101677. };
  101678. /**
  101679. * Serializes the particle system to a JSON object.
  101680. * @returns the JSON object
  101681. */
  101682. SphereDirectedParticleEmitter.prototype.serialize = function () {
  101683. var serializationObject = _super.prototype.serialize.call(this);
  101684. serializationObject.direction1 = this.direction1.asArray();
  101685. serializationObject.direction2 = this.direction2.asArray();
  101686. return serializationObject;
  101687. };
  101688. /**
  101689. * Parse properties from a JSON object
  101690. * @param serializationObject defines the JSON object
  101691. */
  101692. SphereDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  101693. _super.prototype.parse.call(this, serializationObject);
  101694. this.direction1.copyFrom(serializationObject.direction1);
  101695. this.direction2.copyFrom(serializationObject.direction2);
  101696. };
  101697. return SphereDirectedParticleEmitter;
  101698. }(SphereParticleEmitter));
  101699. /***/ }),
  101700. /***/ "./Particles/baseParticleSystem.ts":
  101701. /*!*****************************************!*\
  101702. !*** ./Particles/baseParticleSystem.ts ***!
  101703. \*****************************************/
  101704. /*! exports provided: BaseParticleSystem */
  101705. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101706. "use strict";
  101707. __webpack_require__.r(__webpack_exports__);
  101708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return BaseParticleSystem; });
  101709. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  101710. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  101711. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  101712. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  101713. /**
  101714. * This represents the base class for particle system in Babylon.
  101715. * 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.
  101716. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  101717. * @example https://doc.babylonjs.com/babylon101/particles
  101718. */
  101719. var BaseParticleSystem = /** @class */ (function () {
  101720. /**
  101721. * Instantiates a particle system.
  101722. * 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.
  101723. * @param name The name of the particle system
  101724. */
  101725. function BaseParticleSystem(name) {
  101726. /**
  101727. * List of animations used by the particle system.
  101728. */
  101729. this.animations = [];
  101730. /**
  101731. * The rendering group used by the Particle system to chose when to render.
  101732. */
  101733. this.renderingGroupId = 0;
  101734. /**
  101735. * The emitter represents the Mesh or position we are attaching the particle system to.
  101736. */
  101737. this.emitter = null;
  101738. /**
  101739. * The maximum number of particles to emit per frame
  101740. */
  101741. this.emitRate = 10;
  101742. /**
  101743. * If you want to launch only a few particles at once, that can be done, as well.
  101744. */
  101745. this.manualEmitCount = -1;
  101746. /**
  101747. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  101748. */
  101749. this.updateSpeed = 0.01;
  101750. /**
  101751. * The amount of time the particle system is running (depends of the overall update speed).
  101752. */
  101753. this.targetStopDuration = 0;
  101754. /**
  101755. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  101756. */
  101757. this.disposeOnStop = false;
  101758. /**
  101759. * Minimum power of emitting particles.
  101760. */
  101761. this.minEmitPower = 1;
  101762. /**
  101763. * Maximum power of emitting particles.
  101764. */
  101765. this.maxEmitPower = 1;
  101766. /**
  101767. * Minimum life time of emitting particles.
  101768. */
  101769. this.minLifeTime = 1;
  101770. /**
  101771. * Maximum life time of emitting particles.
  101772. */
  101773. this.maxLifeTime = 1;
  101774. /**
  101775. * Minimum Size of emitting particles.
  101776. */
  101777. this.minSize = 1;
  101778. /**
  101779. * Maximum Size of emitting particles.
  101780. */
  101781. this.maxSize = 1;
  101782. /**
  101783. * Minimum scale of emitting particles on X axis.
  101784. */
  101785. this.minScaleX = 1;
  101786. /**
  101787. * Maximum scale of emitting particles on X axis.
  101788. */
  101789. this.maxScaleX = 1;
  101790. /**
  101791. * Minimum scale of emitting particles on Y axis.
  101792. */
  101793. this.minScaleY = 1;
  101794. /**
  101795. * Maximum scale of emitting particles on Y axis.
  101796. */
  101797. this.maxScaleY = 1;
  101798. /**
  101799. * Gets or sets the minimal initial rotation in radians.
  101800. */
  101801. this.minInitialRotation = 0;
  101802. /**
  101803. * Gets or sets the maximal initial rotation in radians.
  101804. */
  101805. this.maxInitialRotation = 0;
  101806. /**
  101807. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  101808. */
  101809. this.minAngularSpeed = 0;
  101810. /**
  101811. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  101812. */
  101813. this.maxAngularSpeed = 0;
  101814. /**
  101815. * The layer mask we are rendering the particles through.
  101816. */
  101817. this.layerMask = 0x0FFFFFFF;
  101818. /**
  101819. * This can help using your own shader to render the particle system.
  101820. * The according effect will be created
  101821. */
  101822. this.customShader = null;
  101823. /**
  101824. * By default particle system starts as soon as they are created. This prevents the
  101825. * automatic start to happen and let you decide when to start emitting particles.
  101826. */
  101827. this.preventAutoStart = false;
  101828. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  101829. this.noiseStrength = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](10, 10, 10);
  101830. /**
  101831. * Callback triggered when the particle animation is ending.
  101832. */
  101833. this.onAnimationEnd = null;
  101834. /**
  101835. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  101836. */
  101837. this.blendMode = BaseParticleSystem.BLENDMODE_ONEONE;
  101838. /**
  101839. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  101840. * to override the particles.
  101841. */
  101842. this.forceDepthWrite = false;
  101843. /** 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 */
  101844. this.preWarmCycles = 0;
  101845. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  101846. this.preWarmStepOffset = 1;
  101847. /**
  101848. * 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)
  101849. */
  101850. this.spriteCellChangeSpeed = 1;
  101851. /**
  101852. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  101853. */
  101854. this.startSpriteCellID = 0;
  101855. /**
  101856. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  101857. */
  101858. this.endSpriteCellID = 0;
  101859. /**
  101860. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  101861. */
  101862. this.spriteCellWidth = 0;
  101863. /**
  101864. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  101865. */
  101866. this.spriteCellHeight = 0;
  101867. /**
  101868. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  101869. */
  101870. this.spriteRandomStartCell = false;
  101871. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  101872. this.translationPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  101873. /**
  101874. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  101875. */
  101876. this.beginAnimationOnStart = false;
  101877. /**
  101878. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  101879. */
  101880. this.beginAnimationFrom = 0;
  101881. /**
  101882. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  101883. */
  101884. this.beginAnimationTo = 60;
  101885. /**
  101886. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  101887. */
  101888. this.beginAnimationLoop = false;
  101889. /**
  101890. * You can use gravity if you want to give an orientation to your particles.
  101891. */
  101892. this.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  101893. this._colorGradients = null;
  101894. this._sizeGradients = null;
  101895. this._lifeTimeGradients = null;
  101896. this._angularSpeedGradients = null;
  101897. this._velocityGradients = null;
  101898. this._limitVelocityGradients = null;
  101899. this._dragGradients = null;
  101900. this._emitRateGradients = null;
  101901. this._startSizeGradients = null;
  101902. this._rampGradients = null;
  101903. this._colorRemapGradients = null;
  101904. this._alphaRemapGradients = null;
  101905. /**
  101906. * Defines the delay in milliseconds before starting the system (0 by default)
  101907. */
  101908. this.startDelay = 0;
  101909. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  101910. this.limitVelocityDamping = 0.4;
  101911. /**
  101912. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  101913. */
  101914. this.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  101915. /**
  101916. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  101917. */
  101918. this.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  101919. /**
  101920. * Color the particle will have at the end of its lifetime
  101921. */
  101922. this.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 1.0);
  101923. /**
  101924. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  101925. */
  101926. this.textureMask = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  101927. /** @hidden */
  101928. this._isSubEmitter = false;
  101929. /**
  101930. * Gets or sets the billboard mode to use when isBillboardBased = true.
  101931. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  101932. */
  101933. this.billboardMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  101934. this._isBillboardBased = true;
  101935. /**
  101936. * Local cache of defines for image processing.
  101937. */
  101938. this._imageProcessingConfigurationDefines = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingConfigurationDefines"]();
  101939. this.id = name;
  101940. this.name = name;
  101941. }
  101942. Object.defineProperty(BaseParticleSystem.prototype, "noiseTexture", {
  101943. /**
  101944. * Gets or sets a texture used to add random noise to particle positions
  101945. */
  101946. get: function () {
  101947. return this._noiseTexture;
  101948. },
  101949. set: function (value) {
  101950. if (this._noiseTexture === value) {
  101951. return;
  101952. }
  101953. this._noiseTexture = value;
  101954. this._reset();
  101955. },
  101956. enumerable: true,
  101957. configurable: true
  101958. });
  101959. Object.defineProperty(BaseParticleSystem.prototype, "isAnimationSheetEnabled", {
  101960. /**
  101961. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  101962. */
  101963. get: function () {
  101964. return this._isAnimationSheetEnabled;
  101965. },
  101966. set: function (value) {
  101967. if (this._isAnimationSheetEnabled == value) {
  101968. return;
  101969. }
  101970. this._isAnimationSheetEnabled = value;
  101971. this._reset();
  101972. },
  101973. enumerable: true,
  101974. configurable: true
  101975. });
  101976. /**
  101977. * Get hosting scene
  101978. * @returns the scene
  101979. */
  101980. BaseParticleSystem.prototype.getScene = function () {
  101981. return this._scene;
  101982. };
  101983. BaseParticleSystem.prototype._hasTargetStopDurationDependantGradient = function () {
  101984. return (this._startSizeGradients && this._startSizeGradients.length > 0)
  101985. || (this._emitRateGradients && this._emitRateGradients.length > 0)
  101986. || (this._lifeTimeGradients && this._lifeTimeGradients.length > 0);
  101987. };
  101988. /**
  101989. * Gets the current list of drag gradients.
  101990. * You must use addDragGradient and removeDragGradient to udpate this list
  101991. * @returns the list of drag gradients
  101992. */
  101993. BaseParticleSystem.prototype.getDragGradients = function () {
  101994. return this._dragGradients;
  101995. };
  101996. /**
  101997. * Gets the current list of limit velocity gradients.
  101998. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  101999. * @returns the list of limit velocity gradients
  102000. */
  102001. BaseParticleSystem.prototype.getLimitVelocityGradients = function () {
  102002. return this._limitVelocityGradients;
  102003. };
  102004. /**
  102005. * Gets the current list of color gradients.
  102006. * You must use addColorGradient and removeColorGradient to udpate this list
  102007. * @returns the list of color gradients
  102008. */
  102009. BaseParticleSystem.prototype.getColorGradients = function () {
  102010. return this._colorGradients;
  102011. };
  102012. /**
  102013. * Gets the current list of size gradients.
  102014. * You must use addSizeGradient and removeSizeGradient to udpate this list
  102015. * @returns the list of size gradients
  102016. */
  102017. BaseParticleSystem.prototype.getSizeGradients = function () {
  102018. return this._sizeGradients;
  102019. };
  102020. /**
  102021. * Gets the current list of color remap gradients.
  102022. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  102023. * @returns the list of color remap gradients
  102024. */
  102025. BaseParticleSystem.prototype.getColorRemapGradients = function () {
  102026. return this._colorRemapGradients;
  102027. };
  102028. /**
  102029. * Gets the current list of alpha remap gradients.
  102030. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  102031. * @returns the list of alpha remap gradients
  102032. */
  102033. BaseParticleSystem.prototype.getAlphaRemapGradients = function () {
  102034. return this._alphaRemapGradients;
  102035. };
  102036. /**
  102037. * Gets the current list of life time gradients.
  102038. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  102039. * @returns the list of life time gradients
  102040. */
  102041. BaseParticleSystem.prototype.getLifeTimeGradients = function () {
  102042. return this._lifeTimeGradients;
  102043. };
  102044. /**
  102045. * Gets the current list of angular speed gradients.
  102046. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  102047. * @returns the list of angular speed gradients
  102048. */
  102049. BaseParticleSystem.prototype.getAngularSpeedGradients = function () {
  102050. return this._angularSpeedGradients;
  102051. };
  102052. /**
  102053. * Gets the current list of velocity gradients.
  102054. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  102055. * @returns the list of velocity gradients
  102056. */
  102057. BaseParticleSystem.prototype.getVelocityGradients = function () {
  102058. return this._velocityGradients;
  102059. };
  102060. /**
  102061. * Gets the current list of start size gradients.
  102062. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  102063. * @returns the list of start size gradients
  102064. */
  102065. BaseParticleSystem.prototype.getStartSizeGradients = function () {
  102066. return this._startSizeGradients;
  102067. };
  102068. /**
  102069. * Gets the current list of emit rate gradients.
  102070. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  102071. * @returns the list of emit rate gradients
  102072. */
  102073. BaseParticleSystem.prototype.getEmitRateGradients = function () {
  102074. return this._emitRateGradients;
  102075. };
  102076. Object.defineProperty(BaseParticleSystem.prototype, "direction1", {
  102077. /**
  102078. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102079. * This only works when particleEmitterTyps is a BoxParticleEmitter
  102080. */
  102081. get: function () {
  102082. if (this.particleEmitterType.direction1) {
  102083. return this.particleEmitterType.direction1;
  102084. }
  102085. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  102086. },
  102087. set: function (value) {
  102088. if (this.particleEmitterType.direction1) {
  102089. this.particleEmitterType.direction1 = value;
  102090. }
  102091. },
  102092. enumerable: true,
  102093. configurable: true
  102094. });
  102095. Object.defineProperty(BaseParticleSystem.prototype, "direction2", {
  102096. /**
  102097. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102098. * This only works when particleEmitterTyps is a BoxParticleEmitter
  102099. */
  102100. get: function () {
  102101. if (this.particleEmitterType.direction2) {
  102102. return this.particleEmitterType.direction2;
  102103. }
  102104. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  102105. },
  102106. set: function (value) {
  102107. if (this.particleEmitterType.direction2) {
  102108. this.particleEmitterType.direction2 = value;
  102109. }
  102110. },
  102111. enumerable: true,
  102112. configurable: true
  102113. });
  102114. Object.defineProperty(BaseParticleSystem.prototype, "minEmitBox", {
  102115. /**
  102116. * 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.
  102117. * This only works when particleEmitterTyps is a BoxParticleEmitter
  102118. */
  102119. get: function () {
  102120. if (this.particleEmitterType.minEmitBox) {
  102121. return this.particleEmitterType.minEmitBox;
  102122. }
  102123. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  102124. },
  102125. set: function (value) {
  102126. if (this.particleEmitterType.minEmitBox) {
  102127. this.particleEmitterType.minEmitBox = value;
  102128. }
  102129. },
  102130. enumerable: true,
  102131. configurable: true
  102132. });
  102133. Object.defineProperty(BaseParticleSystem.prototype, "maxEmitBox", {
  102134. /**
  102135. * 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.
  102136. * This only works when particleEmitterTyps is a BoxParticleEmitter
  102137. */
  102138. get: function () {
  102139. if (this.particleEmitterType.maxEmitBox) {
  102140. return this.particleEmitterType.maxEmitBox;
  102141. }
  102142. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  102143. },
  102144. set: function (value) {
  102145. if (this.particleEmitterType.maxEmitBox) {
  102146. this.particleEmitterType.maxEmitBox = value;
  102147. }
  102148. },
  102149. enumerable: true,
  102150. configurable: true
  102151. });
  102152. Object.defineProperty(BaseParticleSystem.prototype, "isBillboardBased", {
  102153. /**
  102154. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  102155. */
  102156. get: function () {
  102157. return this._isBillboardBased;
  102158. },
  102159. set: function (value) {
  102160. if (this._isBillboardBased === value) {
  102161. return;
  102162. }
  102163. this._isBillboardBased = value;
  102164. this._reset();
  102165. },
  102166. enumerable: true,
  102167. configurable: true
  102168. });
  102169. Object.defineProperty(BaseParticleSystem.prototype, "imageProcessingConfiguration", {
  102170. /**
  102171. * Gets the image processing configuration used either in this material.
  102172. */
  102173. get: function () {
  102174. return this._imageProcessingConfiguration;
  102175. },
  102176. /**
  102177. * Sets the Default image processing configuration used either in the this material.
  102178. *
  102179. * If sets to null, the scene one is in use.
  102180. */
  102181. set: function (value) {
  102182. this._attachImageProcessingConfiguration(value);
  102183. },
  102184. enumerable: true,
  102185. configurable: true
  102186. });
  102187. /**
  102188. * Attaches a new image processing configuration to the Standard Material.
  102189. * @param configuration
  102190. */
  102191. BaseParticleSystem.prototype._attachImageProcessingConfiguration = function (configuration) {
  102192. if (configuration === this._imageProcessingConfiguration) {
  102193. return;
  102194. }
  102195. // Pick the scene configuration if needed.
  102196. if (!configuration) {
  102197. this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration;
  102198. }
  102199. else {
  102200. this._imageProcessingConfiguration = configuration;
  102201. }
  102202. };
  102203. /** @hidden */
  102204. BaseParticleSystem.prototype._reset = function () {
  102205. };
  102206. /** @hidden */
  102207. BaseParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  102208. if (!gradients) {
  102209. return this;
  102210. }
  102211. var index = 0;
  102212. for (var _i = 0, gradients_1 = gradients; _i < gradients_1.length; _i++) {
  102213. var valueGradient = gradients_1[_i];
  102214. if (valueGradient.gradient === gradient) {
  102215. gradients.splice(index, 1);
  102216. break;
  102217. }
  102218. index++;
  102219. }
  102220. if (texture) {
  102221. texture.dispose();
  102222. }
  102223. return this;
  102224. };
  102225. /**
  102226. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  102227. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  102228. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  102229. * @returns the emitter
  102230. */
  102231. BaseParticleSystem.prototype.createPointEmitter = function (direction1, direction2) {
  102232. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["PointParticleEmitter"]();
  102233. particleEmitter.direction1 = direction1;
  102234. particleEmitter.direction2 = direction2;
  102235. this.particleEmitterType = particleEmitter;
  102236. return particleEmitter;
  102237. };
  102238. /**
  102239. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  102240. * @param radius The radius of the hemisphere to emit from
  102241. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  102242. * @returns the emitter
  102243. */
  102244. BaseParticleSystem.prototype.createHemisphericEmitter = function (radius, radiusRange) {
  102245. if (radius === void 0) { radius = 1; }
  102246. if (radiusRange === void 0) { radiusRange = 1; }
  102247. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["HemisphericParticleEmitter"](radius, radiusRange);
  102248. this.particleEmitterType = particleEmitter;
  102249. return particleEmitter;
  102250. };
  102251. /**
  102252. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  102253. * @param radius The radius of the sphere to emit from
  102254. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  102255. * @returns the emitter
  102256. */
  102257. BaseParticleSystem.prototype.createSphereEmitter = function (radius, radiusRange) {
  102258. if (radius === void 0) { radius = 1; }
  102259. if (radiusRange === void 0) { radiusRange = 1; }
  102260. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereParticleEmitter"](radius, radiusRange);
  102261. this.particleEmitterType = particleEmitter;
  102262. return particleEmitter;
  102263. };
  102264. /**
  102265. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  102266. * @param radius The radius of the sphere to emit from
  102267. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  102268. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  102269. * @returns the emitter
  102270. */
  102271. BaseParticleSystem.prototype.createDirectedSphereEmitter = function (radius, direction1, direction2) {
  102272. if (radius === void 0) { radius = 1; }
  102273. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  102274. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  102275. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereDirectedParticleEmitter"](radius, direction1, direction2);
  102276. this.particleEmitterType = particleEmitter;
  102277. return particleEmitter;
  102278. };
  102279. /**
  102280. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  102281. * @param radius The radius of the emission cylinder
  102282. * @param height The height of the emission cylinder
  102283. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  102284. * @param directionRandomizer How much to randomize the particle direction [0-1]
  102285. * @returns the emitter
  102286. */
  102287. BaseParticleSystem.prototype.createCylinderEmitter = function (radius, height, radiusRange, directionRandomizer) {
  102288. if (radius === void 0) { radius = 1; }
  102289. if (height === void 0) { height = 1; }
  102290. if (radiusRange === void 0) { radiusRange = 1; }
  102291. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  102292. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"](radius, height, radiusRange, directionRandomizer);
  102293. this.particleEmitterType = particleEmitter;
  102294. return particleEmitter;
  102295. };
  102296. /**
  102297. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  102298. * @param radius The radius of the cylinder to emit from
  102299. * @param height The height of the emission cylinder
  102300. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102301. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  102302. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  102303. * @returns the emitter
  102304. */
  102305. BaseParticleSystem.prototype.createDirectedCylinderEmitter = function (radius, height, radiusRange, direction1, direction2) {
  102306. if (radius === void 0) { radius = 1; }
  102307. if (height === void 0) { height = 1; }
  102308. if (radiusRange === void 0) { radiusRange = 1; }
  102309. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  102310. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  102311. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"](radius, height, radiusRange, direction1, direction2);
  102312. this.particleEmitterType = particleEmitter;
  102313. return particleEmitter;
  102314. };
  102315. /**
  102316. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  102317. * @param radius The radius of the cone to emit from
  102318. * @param angle The base angle of the cone
  102319. * @returns the emitter
  102320. */
  102321. BaseParticleSystem.prototype.createConeEmitter = function (radius, angle) {
  102322. if (radius === void 0) { radius = 1; }
  102323. if (angle === void 0) { angle = Math.PI / 4; }
  102324. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["ConeParticleEmitter"](radius, angle);
  102325. this.particleEmitterType = particleEmitter;
  102326. return particleEmitter;
  102327. };
  102328. /**
  102329. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  102330. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  102331. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  102332. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  102333. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  102334. * @returns the emitter
  102335. */
  102336. BaseParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
  102337. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["BoxParticleEmitter"]();
  102338. this.particleEmitterType = particleEmitter;
  102339. this.direction1 = direction1;
  102340. this.direction2 = direction2;
  102341. this.minEmitBox = minEmitBox;
  102342. this.maxEmitBox = maxEmitBox;
  102343. return particleEmitter;
  102344. };
  102345. /**
  102346. * Source color is added to the destination color without alpha affecting the result
  102347. */
  102348. BaseParticleSystem.BLENDMODE_ONEONE = 0;
  102349. /**
  102350. * Blend current color and particle color using particle’s alpha
  102351. */
  102352. BaseParticleSystem.BLENDMODE_STANDARD = 1;
  102353. /**
  102354. * Add current color and particle color multiplied by particle’s alpha
  102355. */
  102356. BaseParticleSystem.BLENDMODE_ADD = 2;
  102357. /**
  102358. * Multiply current color with particle color
  102359. */
  102360. BaseParticleSystem.BLENDMODE_MULTIPLY = 3;
  102361. /**
  102362. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  102363. */
  102364. BaseParticleSystem.BLENDMODE_MULTIPLYADD = 4;
  102365. return BaseParticleSystem;
  102366. }());
  102367. /***/ }),
  102368. /***/ "./Particles/gpuParticleSystem.ts":
  102369. /*!****************************************!*\
  102370. !*** ./Particles/gpuParticleSystem.ts ***!
  102371. \****************************************/
  102372. /*! exports provided: GPUParticleSystem */
  102373. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102374. "use strict";
  102375. __webpack_require__.r(__webpack_exports__);
  102376. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return GPUParticleSystem; });
  102377. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  102378. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  102379. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  102380. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  102381. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102382. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  102383. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  102384. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  102385. /* harmony import */ var _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Particles/EmitterTypes/boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  102386. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  102387. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  102388. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  102389. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  102390. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  102391. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  102392. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  102393. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  102394. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102395. /* harmony import */ var _Shaders_gpuUpdateParticles_fragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.fragment */ "./Shaders/gpuUpdateParticles.fragment.ts");
  102396. /* harmony import */ var _Shaders_gpuUpdateParticles_vertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.vertex */ "./Shaders/gpuUpdateParticles.vertex.ts");
  102397. /* harmony import */ var _Shaders_gpuRenderParticles_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.fragment */ "./Shaders/gpuRenderParticles.fragment.ts");
  102398. /* harmony import */ var _Shaders_gpuRenderParticles_vertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.vertex */ "./Shaders/gpuRenderParticles.vertex.ts");
  102399. /**
  102400. * This represents a GPU particle system in Babylon
  102401. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  102402. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  102403. */
  102404. var GPUParticleSystem = /** @class */ (function (_super) {
  102405. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GPUParticleSystem, _super);
  102406. /**
  102407. * Instantiates a GPU particle system.
  102408. * 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.
  102409. * @param name The name of the particle system
  102410. * @param options The options used to create the system
  102411. * @param scene The scene the particle system belongs to
  102412. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  102413. */
  102414. function GPUParticleSystem(name, options, scene, isAnimationSheetEnabled) {
  102415. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  102416. var _this = _super.call(this, name) || this;
  102417. /**
  102418. * The layer mask we are rendering the particles through.
  102419. */
  102420. _this.layerMask = 0x0FFFFFFF;
  102421. _this._accumulatedCount = 0;
  102422. _this._targetIndex = 0;
  102423. _this._currentRenderId = -1;
  102424. _this._started = false;
  102425. _this._stopped = false;
  102426. _this._timeDelta = 0;
  102427. _this._actualFrame = 0;
  102428. _this._rawTextureWidth = 256;
  102429. /**
  102430. * An event triggered when the system is disposed.
  102431. */
  102432. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  102433. /**
  102434. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  102435. * to override the particles.
  102436. */
  102437. _this.forceDepthWrite = false;
  102438. _this._preWarmDone = false;
  102439. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  102440. // Setup the default processing configuration to the scene.
  102441. _this._attachImageProcessingConfiguration(null);
  102442. _this._engine = _this._scene.getEngine();
  102443. if (!options.randomTextureSize) {
  102444. delete options.randomTextureSize;
  102445. }
  102446. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ capacity: 50000, randomTextureSize: _this._engine.getCaps().maxTextureSize }, options);
  102447. var optionsAsNumber = options;
  102448. if (isFinite(optionsAsNumber)) {
  102449. fullOptions.capacity = optionsAsNumber;
  102450. }
  102451. _this._capacity = fullOptions.capacity;
  102452. _this._activeCount = fullOptions.capacity;
  102453. _this._currentActiveCount = 0;
  102454. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  102455. _this._scene.particleSystems.push(_this);
  102456. _this._updateEffectOptions = {
  102457. attributes: ["position", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
  102458. uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower",
  102459. "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
  102460. "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
  102461. uniformBuffersNames: [],
  102462. samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"],
  102463. defines: "",
  102464. fallbacks: null,
  102465. onCompiled: null,
  102466. onError: null,
  102467. indexParameters: null,
  102468. maxSimultaneousLights: 0,
  102469. transformFeedbackVaryings: []
  102470. };
  102471. _this.particleEmitterType = new _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__["BoxParticleEmitter"]();
  102472. // Random data
  102473. var maxTextureSize = Math.min(_this._engine.getCaps().maxTextureSize, fullOptions.randomTextureSize);
  102474. var d = [];
  102475. for (var i = 0; i < maxTextureSize; ++i) {
  102476. d.push(Math.random());
  102477. d.push(Math.random());
  102478. d.push(Math.random());
  102479. d.push(Math.random());
  102480. }
  102481. _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);
  102482. _this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  102483. _this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  102484. d = [];
  102485. for (var i = 0; i < maxTextureSize; ++i) {
  102486. d.push(Math.random());
  102487. d.push(Math.random());
  102488. d.push(Math.random());
  102489. d.push(Math.random());
  102490. }
  102491. _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);
  102492. _this._randomTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  102493. _this._randomTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  102494. _this._randomTextureSize = maxTextureSize;
  102495. return _this;
  102496. }
  102497. Object.defineProperty(GPUParticleSystem, "IsSupported", {
  102498. /**
  102499. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  102500. */
  102501. get: function () {
  102502. if (!_Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine) {
  102503. return false;
  102504. }
  102505. return _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine.webGLVersion > 1;
  102506. },
  102507. enumerable: true,
  102508. configurable: true
  102509. });
  102510. /**
  102511. * Gets the maximum number of particles active at the same time.
  102512. * @returns The max number of active particles.
  102513. */
  102514. GPUParticleSystem.prototype.getCapacity = function () {
  102515. return this._capacity;
  102516. };
  102517. Object.defineProperty(GPUParticleSystem.prototype, "activeParticleCount", {
  102518. /**
  102519. * Gets or set the number of active particles
  102520. */
  102521. get: function () {
  102522. return this._activeCount;
  102523. },
  102524. set: function (value) {
  102525. this._activeCount = Math.min(value, this._capacity);
  102526. },
  102527. enumerable: true,
  102528. configurable: true
  102529. });
  102530. /**
  102531. * Is this system ready to be used/rendered
  102532. * @return true if the system is ready
  102533. */
  102534. GPUParticleSystem.prototype.isReady = function () {
  102535. if (!this._updateEffect) {
  102536. this._recreateUpdateEffect();
  102537. this._recreateRenderEffect();
  102538. return false;
  102539. }
  102540. if (!this.emitter || !this._updateEffect.isReady() || !this._imageProcessingConfiguration.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  102541. return false;
  102542. }
  102543. return true;
  102544. };
  102545. /**
  102546. * Gets if the system has been started. (Note: this will still be true after stop is called)
  102547. * @returns True if it has been started, otherwise false.
  102548. */
  102549. GPUParticleSystem.prototype.isStarted = function () {
  102550. return this._started;
  102551. };
  102552. /**
  102553. * Starts the particle system and begins to emit
  102554. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  102555. */
  102556. GPUParticleSystem.prototype.start = function (delay) {
  102557. var _this = this;
  102558. if (delay === void 0) { delay = this.startDelay; }
  102559. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  102560. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  102561. }
  102562. if (delay) {
  102563. setTimeout(function () {
  102564. _this.start(0);
  102565. }, delay);
  102566. return;
  102567. }
  102568. this._started = true;
  102569. this._stopped = false;
  102570. this._preWarmDone = false;
  102571. // Animations
  102572. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  102573. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  102574. }
  102575. };
  102576. /**
  102577. * Stops the particle system.
  102578. */
  102579. GPUParticleSystem.prototype.stop = function () {
  102580. this._stopped = true;
  102581. };
  102582. /**
  102583. * Remove all active particles
  102584. */
  102585. GPUParticleSystem.prototype.reset = function () {
  102586. this._releaseBuffers();
  102587. this._releaseVAOs();
  102588. this._currentActiveCount = 0;
  102589. this._targetIndex = 0;
  102590. };
  102591. /**
  102592. * Returns the string "GPUParticleSystem"
  102593. * @returns a string containing the class name
  102594. */
  102595. GPUParticleSystem.prototype.getClassName = function () {
  102596. return "GPUParticleSystem";
  102597. };
  102598. GPUParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  102599. _super.prototype._removeGradientAndTexture.call(this, gradient, gradients, texture);
  102600. this._releaseBuffers();
  102601. return this;
  102602. };
  102603. /**
  102604. * Adds a new color gradient
  102605. * @param gradient defines the gradient to use (between 0 and 1)
  102606. * @param color1 defines the color to affect to the specified gradient
  102607. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  102608. * @returns the current particle system
  102609. */
  102610. GPUParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  102611. if (!this._colorGradients) {
  102612. this._colorGradients = [];
  102613. }
  102614. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  102615. colorGradient.gradient = gradient;
  102616. colorGradient.color1 = color1;
  102617. this._colorGradients.push(colorGradient);
  102618. this._colorGradients.sort(function (a, b) {
  102619. if (a.gradient < b.gradient) {
  102620. return -1;
  102621. }
  102622. else if (a.gradient > b.gradient) {
  102623. return 1;
  102624. }
  102625. return 0;
  102626. });
  102627. if (this._colorGradientsTexture) {
  102628. this._colorGradientsTexture.dispose();
  102629. this._colorGradientsTexture = null;
  102630. }
  102631. this._releaseBuffers();
  102632. return this;
  102633. };
  102634. /**
  102635. * Remove a specific color gradient
  102636. * @param gradient defines the gradient to remove
  102637. * @returns the current particle system
  102638. */
  102639. GPUParticleSystem.prototype.removeColorGradient = function (gradient) {
  102640. this._removeGradientAndTexture(gradient, this._colorGradients, this._colorGradientsTexture);
  102641. this._colorGradientsTexture = null;
  102642. return this;
  102643. };
  102644. GPUParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor) {
  102645. var valueGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  102646. valueGradient.gradient = gradient;
  102647. valueGradient.factor1 = factor;
  102648. factorGradients.push(valueGradient);
  102649. factorGradients.sort(function (a, b) {
  102650. if (a.gradient < b.gradient) {
  102651. return -1;
  102652. }
  102653. else if (a.gradient > b.gradient) {
  102654. return 1;
  102655. }
  102656. return 0;
  102657. });
  102658. this._releaseBuffers();
  102659. };
  102660. /**
  102661. * Adds a new size gradient
  102662. * @param gradient defines the gradient to use (between 0 and 1)
  102663. * @param factor defines the size factor to affect to the specified gradient
  102664. * @returns the current particle system
  102665. */
  102666. GPUParticleSystem.prototype.addSizeGradient = function (gradient, factor) {
  102667. if (!this._sizeGradients) {
  102668. this._sizeGradients = [];
  102669. }
  102670. this._addFactorGradient(this._sizeGradients, gradient, factor);
  102671. if (this._sizeGradientsTexture) {
  102672. this._sizeGradientsTexture.dispose();
  102673. this._sizeGradientsTexture = null;
  102674. }
  102675. this._releaseBuffers();
  102676. return this;
  102677. };
  102678. /**
  102679. * Remove a specific size gradient
  102680. * @param gradient defines the gradient to remove
  102681. * @returns the current particle system
  102682. */
  102683. GPUParticleSystem.prototype.removeSizeGradient = function (gradient) {
  102684. this._removeGradientAndTexture(gradient, this._sizeGradients, this._sizeGradientsTexture);
  102685. this._sizeGradientsTexture = null;
  102686. return this;
  102687. };
  102688. /**
  102689. * Adds a new angular speed gradient
  102690. * @param gradient defines the gradient to use (between 0 and 1)
  102691. * @param factor defines the angular speed to affect to the specified gradient
  102692. * @returns the current particle system
  102693. */
  102694. GPUParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor) {
  102695. if (!this._angularSpeedGradients) {
  102696. this._angularSpeedGradients = [];
  102697. }
  102698. this._addFactorGradient(this._angularSpeedGradients, gradient, factor);
  102699. if (this._angularSpeedGradientsTexture) {
  102700. this._angularSpeedGradientsTexture.dispose();
  102701. this._angularSpeedGradientsTexture = null;
  102702. }
  102703. this._releaseBuffers();
  102704. return this;
  102705. };
  102706. /**
  102707. * Remove a specific angular speed gradient
  102708. * @param gradient defines the gradient to remove
  102709. * @returns the current particle system
  102710. */
  102711. GPUParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  102712. this._removeGradientAndTexture(gradient, this._angularSpeedGradients, this._angularSpeedGradientsTexture);
  102713. this._angularSpeedGradientsTexture = null;
  102714. return this;
  102715. };
  102716. /**
  102717. * Adds a new velocity gradient
  102718. * @param gradient defines the gradient to use (between 0 and 1)
  102719. * @param factor defines the velocity to affect to the specified gradient
  102720. * @returns the current particle system
  102721. */
  102722. GPUParticleSystem.prototype.addVelocityGradient = function (gradient, factor) {
  102723. if (!this._velocityGradients) {
  102724. this._velocityGradients = [];
  102725. }
  102726. this._addFactorGradient(this._velocityGradients, gradient, factor);
  102727. if (this._velocityGradientsTexture) {
  102728. this._velocityGradientsTexture.dispose();
  102729. this._velocityGradientsTexture = null;
  102730. }
  102731. this._releaseBuffers();
  102732. return this;
  102733. };
  102734. /**
  102735. * Remove a specific velocity gradient
  102736. * @param gradient defines the gradient to remove
  102737. * @returns the current particle system
  102738. */
  102739. GPUParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  102740. this._removeGradientAndTexture(gradient, this._velocityGradients, this._velocityGradientsTexture);
  102741. this._velocityGradientsTexture = null;
  102742. return this;
  102743. };
  102744. /**
  102745. * Adds a new limit velocity gradient
  102746. * @param gradient defines the gradient to use (between 0 and 1)
  102747. * @param factor defines the limit velocity value to affect to the specified gradient
  102748. * @returns the current particle system
  102749. */
  102750. GPUParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor) {
  102751. if (!this._limitVelocityGradients) {
  102752. this._limitVelocityGradients = [];
  102753. }
  102754. this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
  102755. if (this._limitVelocityGradientsTexture) {
  102756. this._limitVelocityGradientsTexture.dispose();
  102757. this._limitVelocityGradientsTexture = null;
  102758. }
  102759. this._releaseBuffers();
  102760. return this;
  102761. };
  102762. /**
  102763. * Remove a specific limit velocity gradient
  102764. * @param gradient defines the gradient to remove
  102765. * @returns the current particle system
  102766. */
  102767. GPUParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  102768. this._removeGradientAndTexture(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
  102769. this._limitVelocityGradientsTexture = null;
  102770. return this;
  102771. };
  102772. /**
  102773. * Adds a new drag gradient
  102774. * @param gradient defines the gradient to use (between 0 and 1)
  102775. * @param factor defines the drag value to affect to the specified gradient
  102776. * @returns the current particle system
  102777. */
  102778. GPUParticleSystem.prototype.addDragGradient = function (gradient, factor) {
  102779. if (!this._dragGradients) {
  102780. this._dragGradients = [];
  102781. }
  102782. this._addFactorGradient(this._dragGradients, gradient, factor);
  102783. if (this._dragGradientsTexture) {
  102784. this._dragGradientsTexture.dispose();
  102785. this._dragGradientsTexture = null;
  102786. }
  102787. this._releaseBuffers();
  102788. return this;
  102789. };
  102790. /**
  102791. * Remove a specific drag gradient
  102792. * @param gradient defines the gradient to remove
  102793. * @returns the current particle system
  102794. */
  102795. GPUParticleSystem.prototype.removeDragGradient = function (gradient) {
  102796. this._removeGradientAndTexture(gradient, this._dragGradients, this._dragGradientsTexture);
  102797. this._dragGradientsTexture = null;
  102798. return this;
  102799. };
  102800. /**
  102801. * Not supported by GPUParticleSystem
  102802. * @param gradient defines the gradient to use (between 0 and 1)
  102803. * @param factor defines the emit rate value to affect to the specified gradient
  102804. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102805. * @returns the current particle system
  102806. */
  102807. GPUParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  102808. // Do nothing as emit rate is not supported by GPUParticleSystem
  102809. return this;
  102810. };
  102811. /**
  102812. * Not supported by GPUParticleSystem
  102813. * @param gradient defines the gradient to remove
  102814. * @returns the current particle system
  102815. */
  102816. GPUParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  102817. // Do nothing as emit rate is not supported by GPUParticleSystem
  102818. return this;
  102819. };
  102820. /**
  102821. * Not supported by GPUParticleSystem
  102822. * @param gradient defines the gradient to use (between 0 and 1)
  102823. * @param factor defines the start size value to affect to the specified gradient
  102824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102825. * @returns the current particle system
  102826. */
  102827. GPUParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  102828. // Do nothing as start size is not supported by GPUParticleSystem
  102829. return this;
  102830. };
  102831. /**
  102832. * Not supported by GPUParticleSystem
  102833. * @param gradient defines the gradient to remove
  102834. * @returns the current particle system
  102835. */
  102836. GPUParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  102837. // Do nothing as start size is not supported by GPUParticleSystem
  102838. return this;
  102839. };
  102840. /**
  102841. * Not supported by GPUParticleSystem
  102842. * @param gradient defines the gradient to use (between 0 and 1)
  102843. * @param min defines the color remap minimal range
  102844. * @param max defines the color remap maximal range
  102845. * @returns the current particle system
  102846. */
  102847. GPUParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  102848. // Do nothing as start size is not supported by GPUParticleSystem
  102849. return this;
  102850. };
  102851. /**
  102852. * Not supported by GPUParticleSystem
  102853. * @param gradient defines the gradient to remove
  102854. * @returns the current particle system
  102855. */
  102856. GPUParticleSystem.prototype.removeColorRemapGradient = function () {
  102857. // Do nothing as start size is not supported by GPUParticleSystem
  102858. return this;
  102859. };
  102860. /**
  102861. * Not supported by GPUParticleSystem
  102862. * @param gradient defines the gradient to use (between 0 and 1)
  102863. * @param min defines the alpha remap minimal range
  102864. * @param max defines the alpha remap maximal range
  102865. * @returns the current particle system
  102866. */
  102867. GPUParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  102868. // Do nothing as start size is not supported by GPUParticleSystem
  102869. return this;
  102870. };
  102871. /**
  102872. * Not supported by GPUParticleSystem
  102873. * @param gradient defines the gradient to remove
  102874. * @returns the current particle system
  102875. */
  102876. GPUParticleSystem.prototype.removeAlphaRemapGradient = function () {
  102877. // Do nothing as start size is not supported by GPUParticleSystem
  102878. return this;
  102879. };
  102880. /**
  102881. * Not supported by GPUParticleSystem
  102882. * @param gradient defines the gradient to use (between 0 and 1)
  102883. * @param color defines the color to affect to the specified gradient
  102884. * @returns the current particle system
  102885. */
  102886. GPUParticleSystem.prototype.addRampGradient = function (gradient, color) {
  102887. //Not supported by GPUParticleSystem
  102888. return this;
  102889. };
  102890. /**
  102891. * Not supported by GPUParticleSystem
  102892. * @param gradient defines the gradient to remove
  102893. * @returns the current particle system
  102894. */
  102895. GPUParticleSystem.prototype.removeRampGradient = function () {
  102896. //Not supported by GPUParticleSystem
  102897. return this;
  102898. };
  102899. /**
  102900. * Not supported by GPUParticleSystem
  102901. * @returns the list of ramp gradients
  102902. */
  102903. GPUParticleSystem.prototype.getRampGradients = function () {
  102904. return null;
  102905. };
  102906. Object.defineProperty(GPUParticleSystem.prototype, "useRampGradients", {
  102907. /**
  102908. * Not supported by GPUParticleSystem
  102909. * Gets or sets a boolean indicating that ramp gradients must be used
  102910. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  102911. */
  102912. get: function () {
  102913. //Not supported by GPUParticleSystem
  102914. return false;
  102915. },
  102916. set: function (value) {
  102917. //Not supported by GPUParticleSystem
  102918. },
  102919. enumerable: true,
  102920. configurable: true
  102921. });
  102922. /**
  102923. * Not supported by GPUParticleSystem
  102924. * @param gradient defines the gradient to use (between 0 and 1)
  102925. * @param factor defines the life time factor to affect to the specified gradient
  102926. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  102927. * @returns the current particle system
  102928. */
  102929. GPUParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  102930. //Not supported by GPUParticleSystem
  102931. return this;
  102932. };
  102933. /**
  102934. * Not supported by GPUParticleSystem
  102935. * @param gradient defines the gradient to remove
  102936. * @returns the current particle system
  102937. */
  102938. GPUParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  102939. //Not supported by GPUParticleSystem
  102940. return this;
  102941. };
  102942. GPUParticleSystem.prototype._reset = function () {
  102943. this._releaseBuffers();
  102944. };
  102945. GPUParticleSystem.prototype._createUpdateVAO = function (source) {
  102946. var updateVertexBuffers = {};
  102947. updateVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3);
  102948. updateVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1);
  102949. updateVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1);
  102950. updateVertexBuffers["seed"] = source.createVertexBuffer("seed", 5, 4);
  102951. updateVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3);
  102952. var offset = 12;
  102953. if (!this._colorGradientsTexture) {
  102954. updateVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4);
  102955. offset += 4;
  102956. }
  102957. updateVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3);
  102958. offset += 3;
  102959. if (!this._isBillboardBased) {
  102960. updateVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3);
  102961. offset += 3;
  102962. }
  102963. if (this._angularSpeedGradientsTexture) {
  102964. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1);
  102965. offset += 1;
  102966. }
  102967. else {
  102968. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 2);
  102969. offset += 2;
  102970. }
  102971. if (this._isAnimationSheetEnabled) {
  102972. updateVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1);
  102973. offset += 1;
  102974. if (this.spriteRandomStartCell) {
  102975. updateVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1);
  102976. offset += 1;
  102977. }
  102978. }
  102979. if (this.noiseTexture) {
  102980. updateVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3);
  102981. offset += 3;
  102982. updateVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3);
  102983. offset += 3;
  102984. }
  102985. var vao = this._engine.recordVertexArrayObject(updateVertexBuffers, null, this._updateEffect);
  102986. this._engine.bindArrayBuffer(null);
  102987. return vao;
  102988. };
  102989. GPUParticleSystem.prototype._createRenderVAO = function (source, spriteSource) {
  102990. var renderVertexBuffers = {};
  102991. renderVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3, this._attributesStrideSize, true);
  102992. renderVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1, this._attributesStrideSize, true);
  102993. renderVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1, this._attributesStrideSize, true);
  102994. renderVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3, this._attributesStrideSize, true);
  102995. var offset = 12;
  102996. if (!this._colorGradientsTexture) {
  102997. renderVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4, this._attributesStrideSize, true);
  102998. offset += 4;
  102999. }
  103000. if (this.billboardMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED) {
  103001. renderVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3, this._attributesStrideSize, true);
  103002. }
  103003. offset += 3; // Direction
  103004. if (!this._isBillboardBased) {
  103005. renderVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3, this._attributesStrideSize, true);
  103006. offset += 3;
  103007. }
  103008. renderVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1, this._attributesStrideSize, true);
  103009. if (this._angularSpeedGradientsTexture) {
  103010. offset++;
  103011. }
  103012. else {
  103013. offset += 2;
  103014. }
  103015. if (this._isAnimationSheetEnabled) {
  103016. renderVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1, this._attributesStrideSize, true);
  103017. offset += 1;
  103018. if (this.spriteRandomStartCell) {
  103019. renderVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1, this._attributesStrideSize, true);
  103020. offset += 1;
  103021. }
  103022. }
  103023. if (this.noiseTexture) {
  103024. renderVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3, this._attributesStrideSize, true);
  103025. offset += 3;
  103026. renderVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3, this._attributesStrideSize, true);
  103027. offset += 3;
  103028. }
  103029. renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
  103030. renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
  103031. var vao = this._engine.recordVertexArrayObject(renderVertexBuffers, null, this._renderEffect);
  103032. this._engine.bindArrayBuffer(null);
  103033. return vao;
  103034. };
  103035. GPUParticleSystem.prototype._initialize = function (force) {
  103036. if (force === void 0) { force = false; }
  103037. if (this._buffer0 && !force) {
  103038. return;
  103039. }
  103040. var engine = this._scene.getEngine();
  103041. var data = new Array();
  103042. this._attributesStrideSize = 21;
  103043. this._targetIndex = 0;
  103044. if (!this.isBillboardBased) {
  103045. this._attributesStrideSize += 3;
  103046. }
  103047. if (this._colorGradientsTexture) {
  103048. this._attributesStrideSize -= 4;
  103049. }
  103050. if (this._angularSpeedGradientsTexture) {
  103051. this._attributesStrideSize -= 1;
  103052. }
  103053. if (this._isAnimationSheetEnabled) {
  103054. this._attributesStrideSize += 1;
  103055. if (this.spriteRandomStartCell) {
  103056. this._attributesStrideSize += 1;
  103057. }
  103058. }
  103059. if (this.noiseTexture) {
  103060. this._attributesStrideSize += 6;
  103061. }
  103062. for (var particleIndex = 0; particleIndex < this._capacity; particleIndex++) {
  103063. // position
  103064. data.push(0.0);
  103065. data.push(0.0);
  103066. data.push(0.0);
  103067. // Age and life
  103068. data.push(0.0); // create the particle as a dead one to create a new one at start
  103069. data.push(0.0);
  103070. // Seed
  103071. data.push(Math.random());
  103072. data.push(Math.random());
  103073. data.push(Math.random());
  103074. data.push(Math.random());
  103075. // Size
  103076. data.push(0.0);
  103077. data.push(0.0);
  103078. data.push(0.0);
  103079. if (!this._colorGradientsTexture) {
  103080. // color
  103081. data.push(0.0);
  103082. data.push(0.0);
  103083. data.push(0.0);
  103084. data.push(0.0);
  103085. }
  103086. // direction
  103087. data.push(0.0);
  103088. data.push(0.0);
  103089. data.push(0.0);
  103090. if (!this.isBillboardBased) {
  103091. // initialDirection
  103092. data.push(0.0);
  103093. data.push(0.0);
  103094. data.push(0.0);
  103095. }
  103096. // angle
  103097. data.push(0.0);
  103098. if (!this._angularSpeedGradientsTexture) {
  103099. data.push(0.0);
  103100. }
  103101. if (this._isAnimationSheetEnabled) {
  103102. data.push(0.0);
  103103. if (this.spriteRandomStartCell) {
  103104. data.push(0.0);
  103105. }
  103106. }
  103107. if (this.noiseTexture) { // Random coordinates for reading into noise texture
  103108. data.push(Math.random());
  103109. data.push(Math.random());
  103110. data.push(Math.random());
  103111. data.push(Math.random());
  103112. data.push(Math.random());
  103113. data.push(Math.random());
  103114. }
  103115. }
  103116. // Sprite data
  103117. var spriteData = new Float32Array([0.5, 0.5, 1, 1,
  103118. -0.5, 0.5, 0, 1,
  103119. -0.5, -0.5, 0, 0,
  103120. 0.5, -0.5, 1, 0]);
  103121. // Buffers
  103122. this._buffer0 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  103123. this._buffer1 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  103124. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 4);
  103125. // Update VAO
  103126. this._updateVAO = [];
  103127. this._updateVAO.push(this._createUpdateVAO(this._buffer0));
  103128. this._updateVAO.push(this._createUpdateVAO(this._buffer1));
  103129. // Render VAO
  103130. this._renderVAO = [];
  103131. this._renderVAO.push(this._createRenderVAO(this._buffer1, this._spriteBuffer));
  103132. this._renderVAO.push(this._createRenderVAO(this._buffer0, this._spriteBuffer));
  103133. // Links
  103134. this._sourceBuffer = this._buffer0;
  103135. this._targetBuffer = this._buffer1;
  103136. };
  103137. /** @hidden */
  103138. GPUParticleSystem.prototype._recreateUpdateEffect = function () {
  103139. var defines = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
  103140. if (this._isBillboardBased) {
  103141. defines += "\n#define BILLBOARD";
  103142. }
  103143. if (this._colorGradientsTexture) {
  103144. defines += "\n#define COLORGRADIENTS";
  103145. }
  103146. if (this._sizeGradientsTexture) {
  103147. defines += "\n#define SIZEGRADIENTS";
  103148. }
  103149. if (this._angularSpeedGradientsTexture) {
  103150. defines += "\n#define ANGULARSPEEDGRADIENTS";
  103151. }
  103152. if (this._velocityGradientsTexture) {
  103153. defines += "\n#define VELOCITYGRADIENTS";
  103154. }
  103155. if (this._limitVelocityGradientsTexture) {
  103156. defines += "\n#define LIMITVELOCITYGRADIENTS";
  103157. }
  103158. if (this._dragGradientsTexture) {
  103159. defines += "\n#define DRAGGRADIENTS";
  103160. }
  103161. if (this.isAnimationSheetEnabled) {
  103162. defines += "\n#define ANIMATESHEET";
  103163. if (this.spriteRandomStartCell) {
  103164. defines += "\n#define ANIMATESHEETRANDOMSTART";
  103165. }
  103166. }
  103167. if (this.noiseTexture) {
  103168. defines += "\n#define NOISE";
  103169. }
  103170. if (this._updateEffect && this._updateEffectOptions.defines === defines) {
  103171. return;
  103172. }
  103173. this._updateEffectOptions.transformFeedbackVaryings = ["outPosition", "outAge", "outLife", "outSeed", "outSize"];
  103174. if (!this._colorGradientsTexture) {
  103175. this._updateEffectOptions.transformFeedbackVaryings.push("outColor");
  103176. }
  103177. this._updateEffectOptions.transformFeedbackVaryings.push("outDirection");
  103178. if (!this._isBillboardBased) {
  103179. this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection");
  103180. }
  103181. this._updateEffectOptions.transformFeedbackVaryings.push("outAngle");
  103182. if (this.isAnimationSheetEnabled) {
  103183. this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex");
  103184. if (this.spriteRandomStartCell) {
  103185. this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset");
  103186. }
  103187. }
  103188. if (this.noiseTexture) {
  103189. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1");
  103190. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2");
  103191. }
  103192. this._updateEffectOptions.defines = defines;
  103193. this._updateEffect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["Effect"]("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());
  103194. };
  103195. /** @hidden */
  103196. GPUParticleSystem.prototype._recreateRenderEffect = function () {
  103197. var defines = "";
  103198. if (this._scene.clipPlane) {
  103199. defines = "\n#define CLIPPLANE";
  103200. }
  103201. if (this._scene.clipPlane2) {
  103202. defines = "\n#define CLIPPLANE2";
  103203. }
  103204. if (this._scene.clipPlane3) {
  103205. defines = "\n#define CLIPPLANE3";
  103206. }
  103207. if (this._scene.clipPlane4) {
  103208. defines = "\n#define CLIPPLANE4";
  103209. }
  103210. if (this.blendMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY) {
  103211. defines = "\n#define BLENDMULTIPLYMODE";
  103212. }
  103213. if (this._isBillboardBased) {
  103214. defines += "\n#define BILLBOARD";
  103215. switch (this.billboardMode) {
  103216. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_Y:
  103217. defines += "\n#define BILLBOARDY";
  103218. break;
  103219. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED:
  103220. defines += "\n#define BILLBOARDSTRETCHED";
  103221. break;
  103222. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_ALL:
  103223. default:
  103224. break;
  103225. }
  103226. }
  103227. if (this._colorGradientsTexture) {
  103228. defines += "\n#define COLORGRADIENTS";
  103229. }
  103230. if (this.isAnimationSheetEnabled) {
  103231. defines += "\n#define ANIMATESHEET";
  103232. }
  103233. if (this._imageProcessingConfiguration) {
  103234. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  103235. defines += "\n" + this._imageProcessingConfigurationDefines.toString();
  103236. }
  103237. if (this._renderEffect && this._renderEffect.defines === defines) {
  103238. return;
  103239. }
  103240. var uniforms = ["view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "sheetInfos", "translationPivot", "eyePosition"];
  103241. var samplers = ["textureSampler", "colorGradientSampler"];
  103242. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  103243. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._imageProcessingConfigurationDefines);
  103244. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  103245. }
  103246. 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);
  103247. };
  103248. /**
  103249. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  103250. * @param preWarm defines if we are in the pre-warmimg phase
  103251. */
  103252. GPUParticleSystem.prototype.animate = function (preWarm) {
  103253. if (preWarm === void 0) { preWarm = false; }
  103254. this._timeDelta = this.updateSpeed * (preWarm ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  103255. this._actualFrame += this._timeDelta;
  103256. if (!this._stopped) {
  103257. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  103258. this.stop();
  103259. }
  103260. }
  103261. };
  103262. GPUParticleSystem.prototype._createFactorGradientTexture = function (factorGradients, textureName) {
  103263. var texture = this[textureName];
  103264. if (!factorGradients || !factorGradients.length || texture) {
  103265. return;
  103266. }
  103267. var data = new Float32Array(this._rawTextureWidth);
  103268. for (var x = 0; x < this._rawTextureWidth; x++) {
  103269. var ratio = x / this._rawTextureWidth;
  103270. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, factorGradients, function (currentGradient, nextGradient, scale) {
  103271. data[x] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  103272. });
  103273. }
  103274. 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);
  103275. };
  103276. GPUParticleSystem.prototype._createSizeGradientTexture = function () {
  103277. this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture");
  103278. };
  103279. GPUParticleSystem.prototype._createAngularSpeedGradientTexture = function () {
  103280. this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture");
  103281. };
  103282. GPUParticleSystem.prototype._createVelocityGradientTexture = function () {
  103283. this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture");
  103284. };
  103285. GPUParticleSystem.prototype._createLimitVelocityGradientTexture = function () {
  103286. this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture");
  103287. };
  103288. GPUParticleSystem.prototype._createDragGradientTexture = function () {
  103289. this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture");
  103290. };
  103291. GPUParticleSystem.prototype._createColorGradientTexture = function () {
  103292. if (!this._colorGradients || !this._colorGradients.length || this._colorGradientsTexture) {
  103293. return;
  103294. }
  103295. var data = new Uint8Array(this._rawTextureWidth * 4);
  103296. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color4[0];
  103297. for (var x = 0; x < this._rawTextureWidth; x++) {
  103298. var ratio = x / this._rawTextureWidth;
  103299. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._colorGradients, function (currentGradient, nextGradient, scale) {
  103300. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(currentGradient.color1, nextGradient.color1, scale, tmpColor);
  103301. data[x * 4] = tmpColor.r * 255;
  103302. data[x * 4 + 1] = tmpColor.g * 255;
  103303. data[x * 4 + 2] = tmpColor.b * 255;
  103304. data[x * 4 + 3] = tmpColor.a * 255;
  103305. });
  103306. }
  103307. 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);
  103308. };
  103309. /**
  103310. * Renders the particle system in its current state
  103311. * @param preWarm defines if the system should only update the particles but not render them
  103312. * @returns the current number of particles
  103313. */
  103314. GPUParticleSystem.prototype.render = function (preWarm) {
  103315. if (preWarm === void 0) { preWarm = false; }
  103316. if (!this._started) {
  103317. return 0;
  103318. }
  103319. this._createColorGradientTexture();
  103320. this._createSizeGradientTexture();
  103321. this._createAngularSpeedGradientTexture();
  103322. this._createVelocityGradientTexture();
  103323. this._createLimitVelocityGradientTexture();
  103324. this._createDragGradientTexture();
  103325. this._recreateUpdateEffect();
  103326. this._recreateRenderEffect();
  103327. if (!this.isReady()) {
  103328. return 0;
  103329. }
  103330. if (!preWarm) {
  103331. if (!this._preWarmDone && this.preWarmCycles) {
  103332. for (var index = 0; index < this.preWarmCycles; index++) {
  103333. this.animate(true);
  103334. this.render(true);
  103335. }
  103336. this._preWarmDone = true;
  103337. }
  103338. if (this._currentRenderId === this._scene.getFrameId()) {
  103339. return 0;
  103340. }
  103341. this._currentRenderId = this._scene.getFrameId();
  103342. }
  103343. // Get everything ready to render
  103344. this._initialize();
  103345. this._accumulatedCount += this.emitRate * this._timeDelta;
  103346. if (this._accumulatedCount > 1) {
  103347. var intPart = this._accumulatedCount | 0;
  103348. this._accumulatedCount -= intPart;
  103349. this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + intPart);
  103350. }
  103351. if (!this._currentActiveCount) {
  103352. return 0;
  103353. }
  103354. // Enable update effect
  103355. this._engine.enableEffect(this._updateEffect);
  103356. this._engine.setState(false);
  103357. this._updateEffect.setFloat("currentCount", this._currentActiveCount);
  103358. this._updateEffect.setFloat("timeDelta", this._timeDelta);
  103359. this._updateEffect.setFloat("stopFactor", this._stopped ? 0 : 1);
  103360. this._updateEffect.setTexture("randomSampler", this._randomTexture);
  103361. this._updateEffect.setTexture("randomSampler2", this._randomTexture2);
  103362. this._updateEffect.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
  103363. this._updateEffect.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
  103364. if (!this._colorGradientsTexture) {
  103365. this._updateEffect.setDirectColor4("color1", this.color1);
  103366. this._updateEffect.setDirectColor4("color2", this.color2);
  103367. }
  103368. this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize);
  103369. this._updateEffect.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
  103370. this._updateEffect.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
  103371. this._updateEffect.setVector3("gravity", this.gravity);
  103372. if (this._sizeGradientsTexture) {
  103373. this._updateEffect.setTexture("sizeGradientSampler", this._sizeGradientsTexture);
  103374. }
  103375. if (this._angularSpeedGradientsTexture) {
  103376. this._updateEffect.setTexture("angularSpeedGradientSampler", this._angularSpeedGradientsTexture);
  103377. }
  103378. if (this._velocityGradientsTexture) {
  103379. this._updateEffect.setTexture("velocityGradientSampler", this._velocityGradientsTexture);
  103380. }
  103381. if (this._limitVelocityGradientsTexture) {
  103382. this._updateEffect.setTexture("limitVelocityGradientSampler", this._limitVelocityGradientsTexture);
  103383. this._updateEffect.setFloat("limitVelocityDamping", this.limitVelocityDamping);
  103384. }
  103385. if (this._dragGradientsTexture) {
  103386. this._updateEffect.setTexture("dragGradientSampler", this._dragGradientsTexture);
  103387. }
  103388. if (this.particleEmitterType) {
  103389. this.particleEmitterType.applyToShader(this._updateEffect);
  103390. }
  103391. if (this._isAnimationSheetEnabled) {
  103392. this._updateEffect.setFloat3("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed);
  103393. }
  103394. if (this.noiseTexture) {
  103395. this._updateEffect.setTexture("noiseSampler", this.noiseTexture);
  103396. this._updateEffect.setVector3("noiseStrength", this.noiseStrength);
  103397. }
  103398. var emitterWM;
  103399. if (this.emitter.position) {
  103400. var emitterMesh = this.emitter;
  103401. emitterWM = emitterMesh.getWorldMatrix();
  103402. }
  103403. else {
  103404. var emitterPosition = this.emitter;
  103405. emitterWM = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  103406. }
  103407. this._updateEffect.setMatrix("emitterWM", emitterWM);
  103408. // Bind source VAO
  103409. this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex], null);
  103410. // Update
  103411. this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer());
  103412. this._engine.setRasterizerState(false);
  103413. this._engine.beginTransformFeedback(true);
  103414. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].PointListDrawMode, 0, this._currentActiveCount);
  103415. this._engine.endTransformFeedback();
  103416. this._engine.setRasterizerState(true);
  103417. this._engine.bindTransformFeedbackBuffer(null);
  103418. if (!preWarm) {
  103419. // Enable render effect
  103420. this._engine.enableEffect(this._renderEffect);
  103421. var viewMatrix = this._scene.getViewMatrix();
  103422. this._renderEffect.setMatrix("view", viewMatrix);
  103423. this._renderEffect.setMatrix("projection", this._scene.getProjectionMatrix());
  103424. this._renderEffect.setTexture("textureSampler", this.particleTexture);
  103425. this._renderEffect.setVector2("translationPivot", this.translationPivot);
  103426. if (this._colorGradientsTexture) {
  103427. this._renderEffect.setTexture("colorGradientSampler", this._colorGradientsTexture);
  103428. }
  103429. else {
  103430. this._renderEffect.setDirectColor4("colorDead", this.colorDead);
  103431. }
  103432. if (this._isAnimationSheetEnabled && this.particleTexture) {
  103433. var baseSize = this.particleTexture.getBaseSize();
  103434. this._renderEffect.setFloat3("sheetInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  103435. }
  103436. if (this._isBillboardBased) {
  103437. var camera = this._scene.activeCamera;
  103438. this._renderEffect.setVector3("eyePosition", camera.globalPosition);
  103439. }
  103440. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  103441. var invView = viewMatrix.clone();
  103442. invView.invert();
  103443. this._renderEffect.setMatrix("invView", invView);
  103444. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindClipPlane(this._renderEffect, this._scene);
  103445. }
  103446. // image processing
  103447. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  103448. this._imageProcessingConfiguration.bind(this._renderEffect);
  103449. }
  103450. // Draw order
  103451. switch (this.blendMode) {
  103452. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ADD:
  103453. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ADD);
  103454. break;
  103455. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ONEONE:
  103456. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ONEONE);
  103457. break;
  103458. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_STANDARD:
  103459. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_COMBINE);
  103460. break;
  103461. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY:
  103462. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_MULTIPLY);
  103463. break;
  103464. }
  103465. if (this.forceDepthWrite) {
  103466. this._engine.setDepthWrite(true);
  103467. }
  103468. // Bind source VAO
  103469. this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex], null);
  103470. // Render
  103471. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].TriangleFanDrawMode, 0, 4, this._currentActiveCount);
  103472. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_DISABLE);
  103473. }
  103474. // Switch VAOs
  103475. this._targetIndex++;
  103476. if (this._targetIndex === 2) {
  103477. this._targetIndex = 0;
  103478. }
  103479. // Switch buffers
  103480. var tmpBuffer = this._sourceBuffer;
  103481. this._sourceBuffer = this._targetBuffer;
  103482. this._targetBuffer = tmpBuffer;
  103483. return this._currentActiveCount;
  103484. };
  103485. /**
  103486. * Rebuilds the particle system
  103487. */
  103488. GPUParticleSystem.prototype.rebuild = function () {
  103489. this._initialize(true);
  103490. };
  103491. GPUParticleSystem.prototype._releaseBuffers = function () {
  103492. if (this._buffer0) {
  103493. this._buffer0.dispose();
  103494. this._buffer0 = null;
  103495. }
  103496. if (this._buffer1) {
  103497. this._buffer1.dispose();
  103498. this._buffer1 = null;
  103499. }
  103500. if (this._spriteBuffer) {
  103501. this._spriteBuffer.dispose();
  103502. this._spriteBuffer = null;
  103503. }
  103504. };
  103505. GPUParticleSystem.prototype._releaseVAOs = function () {
  103506. if (!this._updateVAO) {
  103507. return;
  103508. }
  103509. for (var index = 0; index < this._updateVAO.length; index++) {
  103510. this._engine.releaseVertexArrayObject(this._updateVAO[index]);
  103511. }
  103512. this._updateVAO = [];
  103513. for (var index = 0; index < this._renderVAO.length; index++) {
  103514. this._engine.releaseVertexArrayObject(this._renderVAO[index]);
  103515. }
  103516. this._renderVAO = [];
  103517. };
  103518. /**
  103519. * Disposes the particle system and free the associated resources
  103520. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  103521. */
  103522. GPUParticleSystem.prototype.dispose = function (disposeTexture) {
  103523. if (disposeTexture === void 0) { disposeTexture = true; }
  103524. var index = this._scene.particleSystems.indexOf(this);
  103525. if (index > -1) {
  103526. this._scene.particleSystems.splice(index, 1);
  103527. }
  103528. this._releaseBuffers();
  103529. this._releaseVAOs();
  103530. if (this._colorGradientsTexture) {
  103531. this._colorGradientsTexture.dispose();
  103532. this._colorGradientsTexture = null;
  103533. }
  103534. if (this._sizeGradientsTexture) {
  103535. this._sizeGradientsTexture.dispose();
  103536. this._sizeGradientsTexture = null;
  103537. }
  103538. if (this._angularSpeedGradientsTexture) {
  103539. this._angularSpeedGradientsTexture.dispose();
  103540. this._angularSpeedGradientsTexture = null;
  103541. }
  103542. if (this._velocityGradientsTexture) {
  103543. this._velocityGradientsTexture.dispose();
  103544. this._velocityGradientsTexture = null;
  103545. }
  103546. if (this._limitVelocityGradientsTexture) {
  103547. this._limitVelocityGradientsTexture.dispose();
  103548. this._limitVelocityGradientsTexture = null;
  103549. }
  103550. if (this._dragGradientsTexture) {
  103551. this._dragGradientsTexture.dispose();
  103552. this._dragGradientsTexture = null;
  103553. }
  103554. if (this._randomTexture) {
  103555. this._randomTexture.dispose();
  103556. this._randomTexture = null;
  103557. }
  103558. if (this._randomTexture2) {
  103559. this._randomTexture2.dispose();
  103560. this._randomTexture2 = null;
  103561. }
  103562. if (disposeTexture && this.particleTexture) {
  103563. this.particleTexture.dispose();
  103564. this.particleTexture = null;
  103565. }
  103566. if (disposeTexture && this.noiseTexture) {
  103567. this.noiseTexture.dispose();
  103568. this.noiseTexture = null;
  103569. }
  103570. // Callback
  103571. this.onDisposeObservable.notifyObservers(this);
  103572. this.onDisposeObservable.clear();
  103573. };
  103574. /**
  103575. * Clones the particle system.
  103576. * @param name The name of the cloned object
  103577. * @param newEmitter The new emitter to use
  103578. * @returns the cloned particle system
  103579. */
  103580. GPUParticleSystem.prototype.clone = function (name, newEmitter) {
  103581. var result = new GPUParticleSystem(name, { capacity: this._capacity, randomTextureSize: this._randomTextureSize }, this._scene);
  103582. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__["DeepCopier"].DeepCopy(this, result);
  103583. if (newEmitter === undefined) {
  103584. newEmitter = this.emitter;
  103585. }
  103586. result.emitter = newEmitter;
  103587. if (this.particleTexture) {
  103588. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"](this.particleTexture.url, this._scene);
  103589. }
  103590. return result;
  103591. };
  103592. /**
  103593. * Serializes the particle system to a JSON object.
  103594. * @returns the JSON object
  103595. */
  103596. GPUParticleSystem.prototype.serialize = function () {
  103597. var serializationObject = {};
  103598. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Serialize(serializationObject, this);
  103599. serializationObject.activeParticleCount = this.activeParticleCount;
  103600. return serializationObject;
  103601. };
  103602. /**
  103603. * Parses a JSON object to create a GPU particle system.
  103604. * @param parsedParticleSystem The JSON object to parse
  103605. * @param scene The scene to create the particle system in
  103606. * @param rootUrl The root url to use to load external dependencies like texture
  103607. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  103608. * @returns the parsed GPU particle system
  103609. */
  103610. GPUParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  103611. if (doNotStart === void 0) { doNotStart = false; }
  103612. var name = parsedParticleSystem.name;
  103613. var particleSystem = new GPUParticleSystem(name, { capacity: parsedParticleSystem.capacity, randomTextureSize: parsedParticleSystem.randomTextureSize }, scene);
  103614. if (parsedParticleSystem.activeParticleCount) {
  103615. particleSystem.activeParticleCount = parsedParticleSystem.activeParticleCount;
  103616. }
  103617. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  103618. // Auto start
  103619. if (parsedParticleSystem.preventAutoStart) {
  103620. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  103621. }
  103622. if (!doNotStart && !particleSystem.preventAutoStart) {
  103623. particleSystem.start();
  103624. }
  103625. return particleSystem;
  103626. };
  103627. return GPUParticleSystem;
  103628. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__["BaseParticleSystem"]));
  103629. /***/ }),
  103630. /***/ "./Particles/index.ts":
  103631. /*!****************************!*\
  103632. !*** ./Particles/index.ts ***!
  103633. \****************************/
  103634. /*! exports provided: BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  103635. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103636. "use strict";
  103637. __webpack_require__.r(__webpack_exports__);
  103638. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  103639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  103640. /* harmony import */ var _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  103641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["BoxParticleEmitter"]; });
  103642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  103643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderParticleEmitter"]; });
  103644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderDirectedParticleEmitter"]; });
  103645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["HemisphericParticleEmitter"]; });
  103646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["PointParticleEmitter"]; });
  103647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereParticleEmitter"]; });
  103648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereDirectedParticleEmitter"]; });
  103649. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  103650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__["GPUParticleSystem"]; });
  103651. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  103652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _particle__WEBPACK_IMPORTED_MODULE_3__["Particle"]; });
  103653. /* harmony import */ var _particleHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleHelper */ "./Particles/particleHelper.ts");
  103654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _particleHelper__WEBPACK_IMPORTED_MODULE_4__["ParticleHelper"]; });
  103655. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  103656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _particleSystem__WEBPACK_IMPORTED_MODULE_5__["ParticleSystem"]; });
  103657. /* harmony import */ var _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystemComponent */ "./Particles/particleSystemComponent.ts");
  103658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__["_IDoNeedToBeInTheBuild"]; });
  103659. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  103660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__["ParticleSystemSet"]; });
  103661. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  103662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["SolidParticle"]; });
  103663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["ModelShape"]; });
  103664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["DepthSortedParticle"]; });
  103665. /* harmony import */ var _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./solidParticleSystem */ "./Particles/solidParticleSystem.ts");
  103666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__["SolidParticleSystem"]; });
  103667. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  103668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitterType"]; });
  103669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitter"]; });
  103670. /***/ }),
  103671. /***/ "./Particles/particle.ts":
  103672. /*!*******************************!*\
  103673. !*** ./Particles/particle.ts ***!
  103674. \*******************************/
  103675. /*! exports provided: Particle */
  103676. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103677. "use strict";
  103678. __webpack_require__.r(__webpack_exports__);
  103679. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return Particle; });
  103680. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  103681. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  103682. /**
  103683. * A particle represents one of the element emitted by a particle system.
  103684. * This is mainly define by its coordinates, direction, velocity and age.
  103685. */
  103686. var Particle = /** @class */ (function () {
  103687. /**
  103688. * Creates a new instance Particle
  103689. * @param particleSystem the particle system the particle belongs to
  103690. */
  103691. function Particle(
  103692. /**
  103693. * The particle system the particle belongs to.
  103694. */
  103695. particleSystem) {
  103696. this.particleSystem = particleSystem;
  103697. /**
  103698. * The world position of the particle in the scene.
  103699. */
  103700. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103701. /**
  103702. * The world direction of the particle in the scene.
  103703. */
  103704. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103705. /**
  103706. * The color of the particle.
  103707. */
  103708. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  103709. /**
  103710. * The color change of the particle per step.
  103711. */
  103712. this.colorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  103713. /**
  103714. * Defines how long will the life of the particle be.
  103715. */
  103716. this.lifeTime = 1.0;
  103717. /**
  103718. * The current age of the particle.
  103719. */
  103720. this.age = 0;
  103721. /**
  103722. * The current size of the particle.
  103723. */
  103724. this.size = 0;
  103725. /**
  103726. * The current scale of the particle.
  103727. */
  103728. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](1, 1);
  103729. /**
  103730. * The current angle of the particle.
  103731. */
  103732. this.angle = 0;
  103733. /**
  103734. * Defines how fast is the angle changing.
  103735. */
  103736. this.angularSpeed = 0;
  103737. /**
  103738. * Defines the cell index used by the particle to be rendered from a sprite.
  103739. */
  103740. this.cellIndex = 0;
  103741. /** @hidden */
  103742. this._attachedSubEmitters = null;
  103743. /** @hidden */
  103744. this._currentColor1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  103745. /** @hidden */
  103746. this._currentColor2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  103747. /** @hidden */
  103748. this._currentSize1 = 0;
  103749. /** @hidden */
  103750. this._currentSize2 = 0;
  103751. /** @hidden */
  103752. this._currentAngularSpeed1 = 0;
  103753. /** @hidden */
  103754. this._currentAngularSpeed2 = 0;
  103755. /** @hidden */
  103756. this._currentVelocity1 = 0;
  103757. /** @hidden */
  103758. this._currentVelocity2 = 0;
  103759. /** @hidden */
  103760. this._currentLimitVelocity1 = 0;
  103761. /** @hidden */
  103762. this._currentLimitVelocity2 = 0;
  103763. /** @hidden */
  103764. this._currentDrag1 = 0;
  103765. /** @hidden */
  103766. this._currentDrag2 = 0;
  103767. this.id = Particle._Count++;
  103768. if (!this.particleSystem.isAnimationSheetEnabled) {
  103769. return;
  103770. }
  103771. this.updateCellInfoFromSystem();
  103772. }
  103773. Particle.prototype.updateCellInfoFromSystem = function () {
  103774. this.cellIndex = this.particleSystem.startSpriteCellID;
  103775. };
  103776. /**
  103777. * Defines how the sprite cell index is updated for the particle
  103778. */
  103779. Particle.prototype.updateCellIndex = function () {
  103780. var offsetAge = this.age;
  103781. var changeSpeed = this.particleSystem.spriteCellChangeSpeed;
  103782. if (this.particleSystem.spriteRandomStartCell) {
  103783. if (this._randomCellOffset === undefined) {
  103784. this._randomCellOffset = Math.random() * this.lifeTime;
  103785. }
  103786. if (changeSpeed === 0) { // Special case when speed = 0 meaning we want to stay on initial cell
  103787. changeSpeed = 1;
  103788. offsetAge = this._randomCellOffset;
  103789. }
  103790. else {
  103791. offsetAge += this._randomCellOffset;
  103792. }
  103793. }
  103794. var dist = (this._initialEndSpriteCellID - this._initialStartSpriteCellID);
  103795. var ratio = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(((offsetAge * changeSpeed) % this.lifeTime) / this.lifeTime);
  103796. this.cellIndex = this._initialStartSpriteCellID + (ratio * dist) | 0;
  103797. };
  103798. /** @hidden */
  103799. Particle.prototype._inheritParticleInfoToSubEmitter = function (subEmitter) {
  103800. if (subEmitter.particleSystem.emitter.position) {
  103801. var emitterMesh = subEmitter.particleSystem.emitter;
  103802. emitterMesh.position.copyFrom(this.position);
  103803. if (subEmitter.inheritDirection) {
  103804. emitterMesh.position.subtractToRef(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  103805. // Look at using Y as forward
  103806. emitterMesh.lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0], 0, Math.PI / 2);
  103807. }
  103808. }
  103809. else {
  103810. var emitterPosition = subEmitter.particleSystem.emitter;
  103811. emitterPosition.copyFrom(this.position);
  103812. }
  103813. // Set inheritedVelocityOffset to be used when new particles are created
  103814. this.direction.scaleToRef(subEmitter.inheritedVelocityAmount / 2, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  103815. subEmitter.particleSystem._inheritedVelocityOffset.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  103816. };
  103817. /** @hidden */
  103818. Particle.prototype._inheritParticleInfoToSubEmitters = function () {
  103819. var _this = this;
  103820. if (this._attachedSubEmitters && this._attachedSubEmitters.length > 0) {
  103821. this._attachedSubEmitters.forEach(function (subEmitter) {
  103822. _this._inheritParticleInfoToSubEmitter(subEmitter);
  103823. });
  103824. }
  103825. };
  103826. /** @hidden */
  103827. Particle.prototype._reset = function () {
  103828. this.age = 0;
  103829. this._currentColorGradient = null;
  103830. this._currentSizeGradient = null;
  103831. this._currentAngularSpeedGradient = null;
  103832. this._currentVelocityGradient = null;
  103833. this._currentLimitVelocityGradient = null;
  103834. this._currentDragGradient = null;
  103835. this.cellIndex = this.particleSystem.startSpriteCellID;
  103836. this._randomCellOffset = undefined;
  103837. };
  103838. /**
  103839. * Copy the properties of particle to another one.
  103840. * @param other the particle to copy the information to.
  103841. */
  103842. Particle.prototype.copyTo = function (other) {
  103843. other.position.copyFrom(this.position);
  103844. if (this._initialDirection) {
  103845. if (other._initialDirection) {
  103846. other._initialDirection.copyFrom(this._initialDirection);
  103847. }
  103848. else {
  103849. other._initialDirection = this._initialDirection.clone();
  103850. }
  103851. }
  103852. else {
  103853. other._initialDirection = null;
  103854. }
  103855. other.direction.copyFrom(this.direction);
  103856. other.color.copyFrom(this.color);
  103857. other.colorStep.copyFrom(this.colorStep);
  103858. other.lifeTime = this.lifeTime;
  103859. other.age = this.age;
  103860. other._randomCellOffset = this._randomCellOffset;
  103861. other.size = this.size;
  103862. other.scale.copyFrom(this.scale);
  103863. other.angle = this.angle;
  103864. other.angularSpeed = this.angularSpeed;
  103865. other.particleSystem = this.particleSystem;
  103866. other.cellIndex = this.cellIndex;
  103867. other.id = this.id;
  103868. other._attachedSubEmitters = this._attachedSubEmitters;
  103869. if (this._currentColorGradient) {
  103870. other._currentColorGradient = this._currentColorGradient;
  103871. other._currentColor1.copyFrom(this._currentColor1);
  103872. other._currentColor2.copyFrom(this._currentColor2);
  103873. }
  103874. if (this._currentSizeGradient) {
  103875. other._currentSizeGradient = this._currentSizeGradient;
  103876. other._currentSize1 = this._currentSize1;
  103877. other._currentSize2 = this._currentSize2;
  103878. }
  103879. if (this._currentAngularSpeedGradient) {
  103880. other._currentAngularSpeedGradient = this._currentAngularSpeedGradient;
  103881. other._currentAngularSpeed1 = this._currentAngularSpeed1;
  103882. other._currentAngularSpeed2 = this._currentAngularSpeed2;
  103883. }
  103884. if (this._currentVelocityGradient) {
  103885. other._currentVelocityGradient = this._currentVelocityGradient;
  103886. other._currentVelocity1 = this._currentVelocity1;
  103887. other._currentVelocity2 = this._currentVelocity2;
  103888. }
  103889. if (this._currentLimitVelocityGradient) {
  103890. other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
  103891. other._currentLimitVelocity1 = this._currentLimitVelocity1;
  103892. other._currentLimitVelocity2 = this._currentLimitVelocity2;
  103893. }
  103894. if (this._currentDragGradient) {
  103895. other._currentDragGradient = this._currentDragGradient;
  103896. other._currentDrag1 = this._currentDrag1;
  103897. other._currentDrag2 = this._currentDrag2;
  103898. }
  103899. if (this.particleSystem.isAnimationSheetEnabled) {
  103900. other._initialStartSpriteCellID = this._initialStartSpriteCellID;
  103901. other._initialEndSpriteCellID = this._initialEndSpriteCellID;
  103902. }
  103903. if (this.particleSystem.useRampGradients) {
  103904. other.remapData.copyFrom(this.remapData);
  103905. }
  103906. if (this._randomNoiseCoordinates1) {
  103907. if (other._randomNoiseCoordinates1) {
  103908. other._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1);
  103909. other._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2);
  103910. }
  103911. else {
  103912. other._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone();
  103913. other._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone();
  103914. }
  103915. }
  103916. };
  103917. Particle._Count = 0;
  103918. return Particle;
  103919. }());
  103920. /***/ }),
  103921. /***/ "./Particles/particleHelper.ts":
  103922. /*!*************************************!*\
  103923. !*** ./Particles/particleHelper.ts ***!
  103924. \*************************************/
  103925. /*! exports provided: ParticleHelper */
  103926. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103927. "use strict";
  103928. __webpack_require__.r(__webpack_exports__);
  103929. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return ParticleHelper; });
  103930. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  103931. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  103932. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  103933. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  103934. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  103935. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  103936. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  103937. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  103938. /**
  103939. * This class is made for on one-liner static method to help creating particle system set.
  103940. */
  103941. var ParticleHelper = /** @class */ (function () {
  103942. function ParticleHelper() {
  103943. }
  103944. /**
  103945. * Create a default particle system that you can tweak
  103946. * @param emitter defines the emitter to use
  103947. * @param capacity defines the system capacity (default is 500 particles)
  103948. * @param scene defines the hosting scene
  103949. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  103950. * @returns the new Particle system
  103951. */
  103952. ParticleHelper.CreateDefault = function (emitter, capacity, scene, useGPU) {
  103953. if (capacity === void 0) { capacity = 500; }
  103954. if (useGPU === void 0) { useGPU = false; }
  103955. var system;
  103956. if (useGPU) {
  103957. system = new _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"]("default system", { capacity: capacity }, scene);
  103958. }
  103959. else {
  103960. system = new _particleSystem__WEBPACK_IMPORTED_MODULE_6__["ParticleSystem"]("default system", capacity, scene);
  103961. }
  103962. system.emitter = emitter;
  103963. system.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]("https://www.babylonjs.com/assets/Flare.png", system.getScene());
  103964. system.createConeEmitter(0.1, Math.PI / 4);
  103965. // Particle color
  103966. system.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  103967. system.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  103968. system.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 0.0);
  103969. // Particle Size
  103970. system.minSize = 0.1;
  103971. system.maxSize = 0.1;
  103972. // Emission speed
  103973. system.minEmitPower = 2;
  103974. system.maxEmitPower = 2;
  103975. // Update speed
  103976. system.updateSpeed = 1 / 60;
  103977. system.emitRate = 30;
  103978. return system;
  103979. };
  103980. /**
  103981. * This is the main static method (one-liner) of this helper to create different particle systems
  103982. * @param type This string represents the type to the particle system to create
  103983. * @param scene The scene where the particle system should live
  103984. * @param gpu If the system will use gpu
  103985. * @returns the ParticleSystemSet created
  103986. */
  103987. ParticleHelper.CreateAsync = function (type, scene, gpu) {
  103988. if (gpu === void 0) { gpu = false; }
  103989. if (!scene) {
  103990. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  103991. }
  103992. var token = {};
  103993. scene._addPendingData(token);
  103994. return new Promise(function (resolve, reject) {
  103995. if (gpu && !_gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"].IsSupported) {
  103996. scene._removePendingData(token);
  103997. return reject("Particle system with GPU is not supported.");
  103998. }
  103999. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(ParticleHelper.BaseAssetsUrl + "/systems/" + type + ".json", function (data) {
  104000. scene._removePendingData(token);
  104001. var newData = JSON.parse(data.toString());
  104002. return resolve(_particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"].Parse(newData, scene, gpu));
  104003. }, undefined, undefined, undefined, function () {
  104004. scene._removePendingData(token);
  104005. return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
  104006. });
  104007. });
  104008. };
  104009. /**
  104010. * Static function used to export a particle system to a ParticleSystemSet variable.
  104011. * Please note that the emitter shape is not exported
  104012. * @param systems defines the particle systems to export
  104013. * @returns the created particle system set
  104014. */
  104015. ParticleHelper.ExportSet = function (systems) {
  104016. var set = new _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"]();
  104017. for (var _i = 0, systems_1 = systems; _i < systems_1.length; _i++) {
  104018. var system = systems_1[_i];
  104019. set.systems.push(system);
  104020. }
  104021. return set;
  104022. };
  104023. /**
  104024. * Gets or sets base Assets URL
  104025. */
  104026. ParticleHelper.BaseAssetsUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].PARTICLES_BaseAssetsUrl;
  104027. return ParticleHelper;
  104028. }());
  104029. /***/ }),
  104030. /***/ "./Particles/particleSystem.ts":
  104031. /*!*************************************!*\
  104032. !*** ./Particles/particleSystem.ts ***!
  104033. \*************************************/
  104034. /*! exports provided: ParticleSystem */
  104035. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104036. "use strict";
  104037. __webpack_require__.r(__webpack_exports__);
  104038. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return ParticleSystem; });
  104039. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  104040. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  104041. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  104042. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  104043. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  104044. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  104045. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  104046. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  104047. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  104048. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  104049. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  104050. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  104051. /* harmony import */ var _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/Textures/Procedurals/proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  104052. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  104053. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  104054. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  104055. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  104056. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  104057. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  104058. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  104059. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  104060. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  104061. /* harmony import */ var _Shaders_particles_fragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Shaders/particles.fragment */ "./Shaders/particles.fragment.ts");
  104062. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  104063. /**
  104064. * This represents a particle system in Babylon.
  104065. * 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.
  104066. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  104067. * @example https://doc.babylonjs.com/babylon101/particles
  104068. */
  104069. var ParticleSystem = /** @class */ (function (_super) {
  104070. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticleSystem, _super);
  104071. /**
  104072. * Instantiates a particle system.
  104073. * 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.
  104074. * @param name The name of the particle system
  104075. * @param capacity The max number of particles alive at the same time
  104076. * @param scene The scene the particle system belongs to
  104077. * @param customEffect a custom effect used to change the way particles are rendered by default
  104078. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  104079. * @param epsilon Offset used to render the particles
  104080. */
  104081. function ParticleSystem(name, capacity, scene, customEffect, isAnimationSheetEnabled, epsilon) {
  104082. if (customEffect === void 0) { customEffect = null; }
  104083. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  104084. if (epsilon === void 0) { epsilon = 0.01; }
  104085. var _this = _super.call(this, name) || this;
  104086. /**
  104087. * @hidden
  104088. */
  104089. _this._inheritedVelocityOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  104090. /**
  104091. * An event triggered when the system is disposed
  104092. */
  104093. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  104094. _this._particles = new Array();
  104095. _this._stockParticles = new Array();
  104096. _this._newPartsExcess = 0;
  104097. _this._vertexBuffers = {};
  104098. _this._scaledColorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  104099. _this._colorDiff = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  104100. _this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  104101. _this._scaledGravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  104102. _this._currentRenderId = -1;
  104103. _this._useInstancing = false;
  104104. _this._started = false;
  104105. _this._stopped = false;
  104106. _this._actualFrame = 0;
  104107. /** @hidden */
  104108. _this._currentEmitRate1 = 0;
  104109. /** @hidden */
  104110. _this._currentEmitRate2 = 0;
  104111. /** @hidden */
  104112. _this._currentStartSize1 = 0;
  104113. /** @hidden */
  104114. _this._currentStartSize2 = 0;
  104115. _this._rawTextureWidth = 256;
  104116. _this._useRampGradients = false;
  104117. /**
  104118. * @hidden
  104119. * If the particle systems emitter should be disposed when the particle system is disposed
  104120. */
  104121. _this._disposeEmitterOnDispose = false;
  104122. // start of sub system methods
  104123. /**
  104124. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  104125. * Its lifetime will start back at 0.
  104126. */
  104127. _this.recycleParticle = function (particle) {
  104128. // move particle from activeParticle list to stock particles
  104129. var lastParticle = _this._particles.pop();
  104130. if (lastParticle !== particle) {
  104131. lastParticle.copyTo(particle);
  104132. }
  104133. _this._stockParticles.push(lastParticle);
  104134. };
  104135. _this._createParticle = function () {
  104136. var particle;
  104137. if (_this._stockParticles.length !== 0) {
  104138. particle = _this._stockParticles.pop();
  104139. particle._reset();
  104140. }
  104141. else {
  104142. particle = new _particle__WEBPACK_IMPORTED_MODULE_17__["Particle"](_this);
  104143. }
  104144. // Attach emitters
  104145. if (_this._subEmitters && _this._subEmitters.length > 0) {
  104146. var subEmitters = _this._subEmitters[Math.floor(Math.random() * _this._subEmitters.length)];
  104147. particle._attachedSubEmitters = [];
  104148. subEmitters.forEach(function (subEmitter) {
  104149. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_18__["SubEmitterType"].ATTACHED) {
  104150. var newEmitter = subEmitter.clone();
  104151. particle._attachedSubEmitters.push(newEmitter);
  104152. newEmitter.particleSystem.start();
  104153. }
  104154. });
  104155. }
  104156. return particle;
  104157. };
  104158. _this._emitFromParticle = function (particle) {
  104159. if (!_this._subEmitters || _this._subEmitters.length === 0) {
  104160. return;
  104161. }
  104162. var templateIndex = Math.floor(Math.random() * _this._subEmitters.length);
  104163. _this._subEmitters[templateIndex].forEach(function (subEmitter) {
  104164. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_18__["SubEmitterType"].END) {
  104165. var subSystem = subEmitter.clone();
  104166. particle._inheritParticleInfoToSubEmitter(subSystem);
  104167. subSystem.particleSystem._rootParticleSystem = _this;
  104168. _this.activeSubSystems.push(subSystem.particleSystem);
  104169. subSystem.particleSystem.start();
  104170. }
  104171. });
  104172. };
  104173. _this._capacity = capacity;
  104174. _this._epsilon = epsilon;
  104175. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  104176. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__["EngineStore"].LastCreatedScene;
  104177. // Setup the default processing configuration to the scene.
  104178. _this._attachImageProcessingConfiguration(null);
  104179. _this._customEffect = customEffect;
  104180. _this._scene.particleSystems.push(_this);
  104181. _this._useInstancing = _this._scene.getEngine().getCaps().instancedArrays;
  104182. _this._createIndexBuffer();
  104183. _this._createVertexBuffers();
  104184. // Default emitter type
  104185. _this.particleEmitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["BoxParticleEmitter"]();
  104186. // Update
  104187. _this.updateFunction = function (particles) {
  104188. var noiseTextureSize = null;
  104189. var noiseTextureData = null;
  104190. if (_this.noiseTexture) { // We need to get texture data back to CPU
  104191. noiseTextureSize = _this.noiseTexture.getSize();
  104192. noiseTextureData = (_this.noiseTexture.getContent());
  104193. }
  104194. var _loop_1 = function () {
  104195. particle = particles[index];
  104196. var scaledUpdateSpeed = _this._scaledUpdateSpeed;
  104197. var previousAge = particle.age;
  104198. particle.age += scaledUpdateSpeed;
  104199. // Evaluate step to death
  104200. if (particle.age > particle.lifeTime) {
  104201. var diff = particle.age - previousAge;
  104202. var oldDiff = particle.lifeTime - previousAge;
  104203. scaledUpdateSpeed = (oldDiff * scaledUpdateSpeed) / diff;
  104204. particle.age = particle.lifeTime;
  104205. }
  104206. var ratio = particle.age / particle.lifeTime;
  104207. // Color
  104208. if (_this._colorGradients && _this._colorGradients.length > 0) {
  104209. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorGradients, function (currentGradient, nextGradient, scale) {
  104210. if (currentGradient !== particle._currentColorGradient) {
  104211. particle._currentColor1.copyFrom(particle._currentColor2);
  104212. nextGradient.getColorToRef(particle._currentColor2);
  104213. particle._currentColorGradient = currentGradient;
  104214. }
  104215. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(particle._currentColor1, particle._currentColor2, scale, particle.color);
  104216. });
  104217. }
  104218. else {
  104219. particle.colorStep.scaleToRef(scaledUpdateSpeed, _this._scaledColorStep);
  104220. particle.color.addInPlace(_this._scaledColorStep);
  104221. if (particle.color.a < 0) {
  104222. particle.color.a = 0;
  104223. }
  104224. }
  104225. // Angular speed
  104226. if (_this._angularSpeedGradients && _this._angularSpeedGradients.length > 0) {
  104227. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._angularSpeedGradients, function (currentGradient, nextGradient, scale) {
  104228. if (currentGradient !== particle._currentAngularSpeedGradient) {
  104229. particle._currentAngularSpeed1 = particle._currentAngularSpeed2;
  104230. particle._currentAngularSpeed2 = nextGradient.getFactor();
  104231. particle._currentAngularSpeedGradient = currentGradient;
  104232. }
  104233. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentAngularSpeed1, particle._currentAngularSpeed2, scale);
  104234. });
  104235. }
  104236. particle.angle += particle.angularSpeed * scaledUpdateSpeed;
  104237. // Direction
  104238. var directionScale = scaledUpdateSpeed;
  104239. /// Velocity
  104240. if (_this._velocityGradients && _this._velocityGradients.length > 0) {
  104241. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._velocityGradients, function (currentGradient, nextGradient, scale) {
  104242. if (currentGradient !== particle._currentVelocityGradient) {
  104243. particle._currentVelocity1 = particle._currentVelocity2;
  104244. particle._currentVelocity2 = nextGradient.getFactor();
  104245. particle._currentVelocityGradient = currentGradient;
  104246. }
  104247. directionScale *= _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
  104248. });
  104249. }
  104250. particle.direction.scaleToRef(directionScale, _this._scaledDirection);
  104251. /// Limit velocity
  104252. if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
  104253. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
  104254. if (currentGradient !== particle._currentLimitVelocityGradient) {
  104255. particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
  104256. particle._currentLimitVelocity2 = nextGradient.getFactor();
  104257. particle._currentLimitVelocityGradient = currentGradient;
  104258. }
  104259. var limitVelocity = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
  104260. var currentVelocity = particle.direction.length();
  104261. if (currentVelocity > limitVelocity) {
  104262. particle.direction.scaleInPlace(_this.limitVelocityDamping);
  104263. }
  104264. });
  104265. }
  104266. /// Drag
  104267. if (_this._dragGradients && _this._dragGradients.length > 0) {
  104268. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._dragGradients, function (currentGradient, nextGradient, scale) {
  104269. if (currentGradient !== particle._currentDragGradient) {
  104270. particle._currentDrag1 = particle._currentDrag2;
  104271. particle._currentDrag2 = nextGradient.getFactor();
  104272. particle._currentDragGradient = currentGradient;
  104273. }
  104274. var drag = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentDrag1, particle._currentDrag2, scale);
  104275. _this._scaledDirection.scaleInPlace(1.0 - drag);
  104276. });
  104277. }
  104278. particle.position.addInPlace(_this._scaledDirection);
  104279. // Noise
  104280. if (noiseTextureData && noiseTextureSize && particle._randomNoiseCoordinates1) {
  104281. var fetchedColorR = _this._fetchR(particle._randomNoiseCoordinates1.x, particle._randomNoiseCoordinates1.y, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  104282. var fetchedColorG = _this._fetchR(particle._randomNoiseCoordinates1.z, particle._randomNoiseCoordinates2.x, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  104283. var fetchedColorB = _this._fetchR(particle._randomNoiseCoordinates2.y, particle._randomNoiseCoordinates2.z, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  104284. var force = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  104285. var scaledForce = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  104286. force.copyFromFloats((2 * fetchedColorR - 1) * _this.noiseStrength.x, (2 * fetchedColorG - 1) * _this.noiseStrength.y, (2 * fetchedColorB - 1) * _this.noiseStrength.z);
  104287. force.scaleToRef(scaledUpdateSpeed, scaledForce);
  104288. particle.direction.addInPlace(scaledForce);
  104289. }
  104290. // Gravity
  104291. _this.gravity.scaleToRef(scaledUpdateSpeed, _this._scaledGravity);
  104292. particle.direction.addInPlace(_this._scaledGravity);
  104293. // Size
  104294. if (_this._sizeGradients && _this._sizeGradients.length > 0) {
  104295. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._sizeGradients, function (currentGradient, nextGradient, scale) {
  104296. if (currentGradient !== particle._currentSizeGradient) {
  104297. particle._currentSize1 = particle._currentSize2;
  104298. particle._currentSize2 = nextGradient.getFactor();
  104299. particle._currentSizeGradient = currentGradient;
  104300. }
  104301. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentSize1, particle._currentSize2, scale);
  104302. });
  104303. }
  104304. // Remap data
  104305. if (_this._useRampGradients) {
  104306. if (_this._colorRemapGradients && _this._colorRemapGradients.length > 0) {
  104307. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorRemapGradients, function (currentGradient, nextGradient, scale) {
  104308. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  104309. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  104310. particle.remapData.x = min;
  104311. particle.remapData.y = max - min;
  104312. });
  104313. }
  104314. if (_this._alphaRemapGradients && _this._alphaRemapGradients.length > 0) {
  104315. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._alphaRemapGradients, function (currentGradient, nextGradient, scale) {
  104316. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  104317. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  104318. particle.remapData.z = min;
  104319. particle.remapData.w = max - min;
  104320. });
  104321. }
  104322. }
  104323. if (_this._isAnimationSheetEnabled) {
  104324. particle.updateCellIndex();
  104325. }
  104326. // Update the position of the attached sub-emitters to match their attached particle
  104327. particle._inheritParticleInfoToSubEmitters();
  104328. if (particle.age >= particle.lifeTime) { // Recycle by swapping with last particle
  104329. _this._emitFromParticle(particle);
  104330. if (particle._attachedSubEmitters) {
  104331. particle._attachedSubEmitters.forEach(function (subEmitter) {
  104332. subEmitter.particleSystem.disposeOnStop = true;
  104333. subEmitter.particleSystem.stop();
  104334. });
  104335. particle._attachedSubEmitters = null;
  104336. }
  104337. _this.recycleParticle(particle);
  104338. index--;
  104339. return "continue";
  104340. }
  104341. };
  104342. var particle;
  104343. for (var index = 0; index < particles.length; index++) {
  104344. _loop_1();
  104345. }
  104346. };
  104347. return _this;
  104348. }
  104349. Object.defineProperty(ParticleSystem.prototype, "onDispose", {
  104350. /**
  104351. * Sets a callback that will be triggered when the system is disposed
  104352. */
  104353. set: function (callback) {
  104354. if (this._onDisposeObserver) {
  104355. this.onDisposeObservable.remove(this._onDisposeObserver);
  104356. }
  104357. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  104358. },
  104359. enumerable: true,
  104360. configurable: true
  104361. });
  104362. Object.defineProperty(ParticleSystem.prototype, "useRampGradients", {
  104363. /** Gets or sets a boolean indicating that ramp gradients must be used
  104364. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  104365. */
  104366. get: function () {
  104367. return this._useRampGradients;
  104368. },
  104369. set: function (value) {
  104370. if (this._useRampGradients === value) {
  104371. return;
  104372. }
  104373. this._useRampGradients = value;
  104374. this._resetEffect();
  104375. },
  104376. enumerable: true,
  104377. configurable: true
  104378. });
  104379. Object.defineProperty(ParticleSystem.prototype, "particles", {
  104380. //end of Sub-emitter
  104381. /**
  104382. * Gets the current list of active particles
  104383. */
  104384. get: function () {
  104385. return this._particles;
  104386. },
  104387. enumerable: true,
  104388. configurable: true
  104389. });
  104390. /**
  104391. * Returns the string "ParticleSystem"
  104392. * @returns a string containing the class name
  104393. */
  104394. ParticleSystem.prototype.getClassName = function () {
  104395. return "ParticleSystem";
  104396. };
  104397. ParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor, factor2) {
  104398. var newGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  104399. newGradient.gradient = gradient;
  104400. newGradient.factor1 = factor;
  104401. newGradient.factor2 = factor2;
  104402. factorGradients.push(newGradient);
  104403. factorGradients.sort(function (a, b) {
  104404. if (a.gradient < b.gradient) {
  104405. return -1;
  104406. }
  104407. else if (a.gradient > b.gradient) {
  104408. return 1;
  104409. }
  104410. return 0;
  104411. });
  104412. };
  104413. ParticleSystem.prototype._removeFactorGradient = function (factorGradients, gradient) {
  104414. if (!factorGradients) {
  104415. return;
  104416. }
  104417. var index = 0;
  104418. for (var _i = 0, factorGradients_1 = factorGradients; _i < factorGradients_1.length; _i++) {
  104419. var factorGradient = factorGradients_1[_i];
  104420. if (factorGradient.gradient === gradient) {
  104421. factorGradients.splice(index, 1);
  104422. break;
  104423. }
  104424. index++;
  104425. }
  104426. };
  104427. /**
  104428. * Adds a new life time gradient
  104429. * @param gradient defines the gradient to use (between 0 and 1)
  104430. * @param factor defines the life time factor to affect to the specified gradient
  104431. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104432. * @returns the current particle system
  104433. */
  104434. ParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  104435. if (!this._lifeTimeGradients) {
  104436. this._lifeTimeGradients = [];
  104437. }
  104438. this._addFactorGradient(this._lifeTimeGradients, gradient, factor, factor2);
  104439. return this;
  104440. };
  104441. /**
  104442. * Remove a specific life time gradient
  104443. * @param gradient defines the gradient to remove
  104444. * @returns the current particle system
  104445. */
  104446. ParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  104447. this._removeFactorGradient(this._lifeTimeGradients, gradient);
  104448. return this;
  104449. };
  104450. /**
  104451. * Adds a new size gradient
  104452. * @param gradient defines the gradient to use (between 0 and 1)
  104453. * @param factor defines the size factor to affect to the specified gradient
  104454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104455. * @returns the current particle system
  104456. */
  104457. ParticleSystem.prototype.addSizeGradient = function (gradient, factor, factor2) {
  104458. if (!this._sizeGradients) {
  104459. this._sizeGradients = [];
  104460. }
  104461. this._addFactorGradient(this._sizeGradients, gradient, factor, factor2);
  104462. return this;
  104463. };
  104464. /**
  104465. * Remove a specific size gradient
  104466. * @param gradient defines the gradient to remove
  104467. * @returns the current particle system
  104468. */
  104469. ParticleSystem.prototype.removeSizeGradient = function (gradient) {
  104470. this._removeFactorGradient(this._sizeGradients, gradient);
  104471. return this;
  104472. };
  104473. /**
  104474. * Adds a new color remap gradient
  104475. * @param gradient defines the gradient to use (between 0 and 1)
  104476. * @param min defines the color remap minimal range
  104477. * @param max defines the color remap maximal range
  104478. * @returns the current particle system
  104479. */
  104480. ParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  104481. if (!this._colorRemapGradients) {
  104482. this._colorRemapGradients = [];
  104483. }
  104484. this._addFactorGradient(this._colorRemapGradients, gradient, min, max);
  104485. return this;
  104486. };
  104487. /**
  104488. * Remove a specific color remap gradient
  104489. * @param gradient defines the gradient to remove
  104490. * @returns the current particle system
  104491. */
  104492. ParticleSystem.prototype.removeColorRemapGradient = function (gradient) {
  104493. this._removeFactorGradient(this._colorRemapGradients, gradient);
  104494. return this;
  104495. };
  104496. /**
  104497. * Adds a new alpha remap gradient
  104498. * @param gradient defines the gradient to use (between 0 and 1)
  104499. * @param min defines the alpha remap minimal range
  104500. * @param max defines the alpha remap maximal range
  104501. * @returns the current particle system
  104502. */
  104503. ParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  104504. if (!this._alphaRemapGradients) {
  104505. this._alphaRemapGradients = [];
  104506. }
  104507. this._addFactorGradient(this._alphaRemapGradients, gradient, min, max);
  104508. return this;
  104509. };
  104510. /**
  104511. * Remove a specific alpha remap gradient
  104512. * @param gradient defines the gradient to remove
  104513. * @returns the current particle system
  104514. */
  104515. ParticleSystem.prototype.removeAlphaRemapGradient = function (gradient) {
  104516. this._removeFactorGradient(this._alphaRemapGradients, gradient);
  104517. return this;
  104518. };
  104519. /**
  104520. * Adds a new angular speed gradient
  104521. * @param gradient defines the gradient to use (between 0 and 1)
  104522. * @param factor defines the angular speed to affect to the specified gradient
  104523. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104524. * @returns the current particle system
  104525. */
  104526. ParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor, factor2) {
  104527. if (!this._angularSpeedGradients) {
  104528. this._angularSpeedGradients = [];
  104529. }
  104530. this._addFactorGradient(this._angularSpeedGradients, gradient, factor, factor2);
  104531. return this;
  104532. };
  104533. /**
  104534. * Remove a specific angular speed gradient
  104535. * @param gradient defines the gradient to remove
  104536. * @returns the current particle system
  104537. */
  104538. ParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  104539. this._removeFactorGradient(this._angularSpeedGradients, gradient);
  104540. return this;
  104541. };
  104542. /**
  104543. * Adds a new velocity gradient
  104544. * @param gradient defines the gradient to use (between 0 and 1)
  104545. * @param factor defines the velocity to affect to the specified gradient
  104546. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104547. * @returns the current particle system
  104548. */
  104549. ParticleSystem.prototype.addVelocityGradient = function (gradient, factor, factor2) {
  104550. if (!this._velocityGradients) {
  104551. this._velocityGradients = [];
  104552. }
  104553. this._addFactorGradient(this._velocityGradients, gradient, factor, factor2);
  104554. return this;
  104555. };
  104556. /**
  104557. * Remove a specific velocity gradient
  104558. * @param gradient defines the gradient to remove
  104559. * @returns the current particle system
  104560. */
  104561. ParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  104562. this._removeFactorGradient(this._velocityGradients, gradient);
  104563. return this;
  104564. };
  104565. /**
  104566. * Adds a new limit velocity gradient
  104567. * @param gradient defines the gradient to use (between 0 and 1)
  104568. * @param factor defines the limit velocity value to affect to the specified gradient
  104569. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104570. * @returns the current particle system
  104571. */
  104572. ParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor, factor2) {
  104573. if (!this._limitVelocityGradients) {
  104574. this._limitVelocityGradients = [];
  104575. }
  104576. this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
  104577. return this;
  104578. };
  104579. /**
  104580. * Remove a specific limit velocity gradient
  104581. * @param gradient defines the gradient to remove
  104582. * @returns the current particle system
  104583. */
  104584. ParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  104585. this._removeFactorGradient(this._limitVelocityGradients, gradient);
  104586. return this;
  104587. };
  104588. /**
  104589. * Adds a new drag gradient
  104590. * @param gradient defines the gradient to use (between 0 and 1)
  104591. * @param factor defines the drag value to affect to the specified gradient
  104592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104593. * @returns the current particle system
  104594. */
  104595. ParticleSystem.prototype.addDragGradient = function (gradient, factor, factor2) {
  104596. if (!this._dragGradients) {
  104597. this._dragGradients = [];
  104598. }
  104599. this._addFactorGradient(this._dragGradients, gradient, factor, factor2);
  104600. return this;
  104601. };
  104602. /**
  104603. * Remove a specific drag gradient
  104604. * @param gradient defines the gradient to remove
  104605. * @returns the current particle system
  104606. */
  104607. ParticleSystem.prototype.removeDragGradient = function (gradient) {
  104608. this._removeFactorGradient(this._dragGradients, gradient);
  104609. return this;
  104610. };
  104611. /**
  104612. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  104613. * @param gradient defines the gradient to use (between 0 and 1)
  104614. * @param factor defines the emit rate value to affect to the specified gradient
  104615. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104616. * @returns the current particle system
  104617. */
  104618. ParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  104619. if (!this._emitRateGradients) {
  104620. this._emitRateGradients = [];
  104621. }
  104622. this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
  104623. return this;
  104624. };
  104625. /**
  104626. * Remove a specific emit rate gradient
  104627. * @param gradient defines the gradient to remove
  104628. * @returns the current particle system
  104629. */
  104630. ParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  104631. this._removeFactorGradient(this._emitRateGradients, gradient);
  104632. return this;
  104633. };
  104634. /**
  104635. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  104636. * @param gradient defines the gradient to use (between 0 and 1)
  104637. * @param factor defines the start size value to affect to the specified gradient
  104638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104639. * @returns the current particle system
  104640. */
  104641. ParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  104642. if (!this._startSizeGradients) {
  104643. this._startSizeGradients = [];
  104644. }
  104645. this._addFactorGradient(this._startSizeGradients, gradient, factor, factor2);
  104646. return this;
  104647. };
  104648. /**
  104649. * Remove a specific start size gradient
  104650. * @param gradient defines the gradient to remove
  104651. * @returns the current particle system
  104652. */
  104653. ParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  104654. this._removeFactorGradient(this._emitRateGradients, gradient);
  104655. return this;
  104656. };
  104657. ParticleSystem.prototype._createRampGradientTexture = function () {
  104658. if (!this._rampGradients || !this._rampGradients.length || this._rampGradientsTexture) {
  104659. return;
  104660. }
  104661. var data = new Uint8Array(this._rawTextureWidth * 4);
  104662. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color3[0];
  104663. for (var x = 0; x < this._rawTextureWidth; x++) {
  104664. var ratio = x / this._rawTextureWidth;
  104665. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._rampGradients, function (currentGradient, nextGradient, scale) {
  104666. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].LerpToRef(currentGradient.color, nextGradient.color, scale, tmpColor);
  104667. data[x * 4] = tmpColor.r * 255;
  104668. data[x * 4 + 1] = tmpColor.g * 255;
  104669. data[x * 4 + 2] = tmpColor.b * 255;
  104670. data[x * 4 + 3] = 255;
  104671. });
  104672. }
  104673. 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);
  104674. };
  104675. /**
  104676. * Gets the current list of ramp gradients.
  104677. * You must use addRampGradient and removeRampGradient to udpate this list
  104678. * @returns the list of ramp gradients
  104679. */
  104680. ParticleSystem.prototype.getRampGradients = function () {
  104681. return this._rampGradients;
  104682. };
  104683. /**
  104684. * Adds a new ramp gradient used to remap particle colors
  104685. * @param gradient defines the gradient to use (between 0 and 1)
  104686. * @param color defines the color to affect to the specified gradient
  104687. * @returns the current particle system
  104688. */
  104689. ParticleSystem.prototype.addRampGradient = function (gradient, color) {
  104690. if (!this._rampGradients) {
  104691. this._rampGradients = [];
  104692. }
  104693. var rampGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Color3Gradient"]();
  104694. rampGradient.gradient = gradient;
  104695. rampGradient.color = color;
  104696. this._rampGradients.push(rampGradient);
  104697. this._rampGradients.sort(function (a, b) {
  104698. if (a.gradient < b.gradient) {
  104699. return -1;
  104700. }
  104701. else if (a.gradient > b.gradient) {
  104702. return 1;
  104703. }
  104704. return 0;
  104705. });
  104706. if (this._rampGradientsTexture) {
  104707. this._rampGradientsTexture.dispose();
  104708. this._rampGradientsTexture = null;
  104709. }
  104710. this._createRampGradientTexture();
  104711. return this;
  104712. };
  104713. /**
  104714. * Remove a specific ramp gradient
  104715. * @param gradient defines the gradient to remove
  104716. * @returns the current particle system
  104717. */
  104718. ParticleSystem.prototype.removeRampGradient = function (gradient) {
  104719. this._removeGradientAndTexture(gradient, this._rampGradients, this._rampGradientsTexture);
  104720. this._rampGradientsTexture = null;
  104721. if (this._rampGradients && this._rampGradients.length > 0) {
  104722. this._createRampGradientTexture();
  104723. }
  104724. return this;
  104725. };
  104726. /**
  104727. * Adds a new color gradient
  104728. * @param gradient defines the gradient to use (between 0 and 1)
  104729. * @param color1 defines the color to affect to the specified gradient
  104730. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  104731. * @returns this particle system
  104732. */
  104733. ParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  104734. if (!this._colorGradients) {
  104735. this._colorGradients = [];
  104736. }
  104737. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  104738. colorGradient.gradient = gradient;
  104739. colorGradient.color1 = color1;
  104740. colorGradient.color2 = color2;
  104741. this._colorGradients.push(colorGradient);
  104742. this._colorGradients.sort(function (a, b) {
  104743. if (a.gradient < b.gradient) {
  104744. return -1;
  104745. }
  104746. else if (a.gradient > b.gradient) {
  104747. return 1;
  104748. }
  104749. return 0;
  104750. });
  104751. return this;
  104752. };
  104753. /**
  104754. * Remove a specific color gradient
  104755. * @param gradient defines the gradient to remove
  104756. * @returns this particle system
  104757. */
  104758. ParticleSystem.prototype.removeColorGradient = function (gradient) {
  104759. if (!this._colorGradients) {
  104760. return this;
  104761. }
  104762. var index = 0;
  104763. for (var _i = 0, _a = this._colorGradients; _i < _a.length; _i++) {
  104764. var colorGradient = _a[_i];
  104765. if (colorGradient.gradient === gradient) {
  104766. this._colorGradients.splice(index, 1);
  104767. break;
  104768. }
  104769. index++;
  104770. }
  104771. return this;
  104772. };
  104773. ParticleSystem.prototype._fetchR = function (u, v, width, height, pixels) {
  104774. u = Math.abs(u) * 0.5 + 0.5;
  104775. v = Math.abs(v) * 0.5 + 0.5;
  104776. var wrappedU = ((u * width) % width) | 0;
  104777. var wrappedV = ((v * height) % height) | 0;
  104778. var position = (wrappedU + wrappedV * width) * 4;
  104779. return pixels[position] / 255;
  104780. };
  104781. ParticleSystem.prototype._reset = function () {
  104782. this._resetEffect();
  104783. };
  104784. ParticleSystem.prototype._resetEffect = function () {
  104785. if (this._vertexBuffer) {
  104786. this._vertexBuffer.dispose();
  104787. this._vertexBuffer = null;
  104788. }
  104789. if (this._spriteBuffer) {
  104790. this._spriteBuffer.dispose();
  104791. this._spriteBuffer = null;
  104792. }
  104793. this._createVertexBuffers();
  104794. };
  104795. ParticleSystem.prototype._createVertexBuffers = function () {
  104796. this._vertexBufferSize = this._useInstancing ? 10 : 12;
  104797. if (this._isAnimationSheetEnabled) {
  104798. this._vertexBufferSize += 1;
  104799. }
  104800. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  104801. this._vertexBufferSize += 3;
  104802. }
  104803. if (this._useRampGradients) {
  104804. this._vertexBufferSize += 4;
  104805. }
  104806. var engine = this._scene.getEngine();
  104807. this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4));
  104808. this._vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, this._vertexData, true, this._vertexBufferSize);
  104809. var dataOffset = 0;
  104810. var positions = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  104811. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind] = positions;
  104812. dataOffset += 3;
  104813. var colors = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  104814. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind] = colors;
  104815. dataOffset += 4;
  104816. var options = this._vertexBuffer.createVertexBuffer("angle", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  104817. this._vertexBuffers["angle"] = options;
  104818. dataOffset += 1;
  104819. var size = this._vertexBuffer.createVertexBuffer("size", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  104820. this._vertexBuffers["size"] = size;
  104821. dataOffset += 2;
  104822. if (this._isAnimationSheetEnabled) {
  104823. var cellIndexBuffer = this._vertexBuffer.createVertexBuffer("cellIndex", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  104824. this._vertexBuffers["cellIndex"] = cellIndexBuffer;
  104825. dataOffset += 1;
  104826. }
  104827. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  104828. var directionBuffer = this._vertexBuffer.createVertexBuffer("direction", dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  104829. this._vertexBuffers["direction"] = directionBuffer;
  104830. dataOffset += 3;
  104831. }
  104832. if (this._useRampGradients) {
  104833. var rampDataBuffer = this._vertexBuffer.createVertexBuffer("remapData", dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  104834. this._vertexBuffers["remapData"] = rampDataBuffer;
  104835. dataOffset += 4;
  104836. }
  104837. var offsets;
  104838. if (this._useInstancing) {
  104839. var spriteData = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
  104840. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 2);
  104841. offsets = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
  104842. }
  104843. else {
  104844. offsets = this._vertexBuffer.createVertexBuffer("offset", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  104845. dataOffset += 2;
  104846. }
  104847. this._vertexBuffers["offset"] = offsets;
  104848. };
  104849. ParticleSystem.prototype._createIndexBuffer = function () {
  104850. if (this._useInstancing) {
  104851. return;
  104852. }
  104853. var indices = [];
  104854. var index = 0;
  104855. for (var count = 0; count < this._capacity; count++) {
  104856. indices.push(index);
  104857. indices.push(index + 1);
  104858. indices.push(index + 2);
  104859. indices.push(index);
  104860. indices.push(index + 2);
  104861. indices.push(index + 3);
  104862. index += 4;
  104863. }
  104864. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  104865. };
  104866. /**
  104867. * Gets the maximum number of particles active at the same time.
  104868. * @returns The max number of active particles.
  104869. */
  104870. ParticleSystem.prototype.getCapacity = function () {
  104871. return this._capacity;
  104872. };
  104873. /**
  104874. * Gets whether there are still active particles in the system.
  104875. * @returns True if it is alive, otherwise false.
  104876. */
  104877. ParticleSystem.prototype.isAlive = function () {
  104878. return this._alive;
  104879. };
  104880. /**
  104881. * Gets if the system has been started. (Note: this will still be true after stop is called)
  104882. * @returns True if it has been started, otherwise false.
  104883. */
  104884. ParticleSystem.prototype.isStarted = function () {
  104885. return this._started;
  104886. };
  104887. ParticleSystem.prototype._prepareSubEmitterInternalArray = function () {
  104888. var _this = this;
  104889. this._subEmitters = new Array();
  104890. if (this.subEmitters) {
  104891. this.subEmitters.forEach(function (subEmitter) {
  104892. if (subEmitter instanceof ParticleSystem) {
  104893. _this._subEmitters.push([new _subEmitter__WEBPACK_IMPORTED_MODULE_18__["SubEmitter"](subEmitter)]);
  104894. }
  104895. else if (subEmitter instanceof _subEmitter__WEBPACK_IMPORTED_MODULE_18__["SubEmitter"]) {
  104896. _this._subEmitters.push([subEmitter]);
  104897. }
  104898. else if (subEmitter instanceof Array) {
  104899. _this._subEmitters.push(subEmitter);
  104900. }
  104901. });
  104902. }
  104903. };
  104904. /**
  104905. * Starts the particle system and begins to emit
  104906. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  104907. */
  104908. ParticleSystem.prototype.start = function (delay) {
  104909. var _this = this;
  104910. if (delay === void 0) { delay = this.startDelay; }
  104911. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  104912. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  104913. }
  104914. if (delay) {
  104915. setTimeout(function () {
  104916. _this.start(0);
  104917. }, delay);
  104918. return;
  104919. }
  104920. // Convert the subEmitters field to the constant type field _subEmitters
  104921. this._prepareSubEmitterInternalArray();
  104922. this._started = true;
  104923. this._stopped = false;
  104924. this._actualFrame = 0;
  104925. if (this._subEmitters && this._subEmitters.length != 0) {
  104926. this.activeSubSystems = new Array();
  104927. }
  104928. // Reset emit gradient so it acts the same on every start
  104929. if (this._emitRateGradients) {
  104930. if (this._emitRateGradients.length > 0) {
  104931. this._currentEmitRateGradient = this._emitRateGradients[0];
  104932. this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
  104933. this._currentEmitRate2 = this._currentEmitRate1;
  104934. }
  104935. if (this._emitRateGradients.length > 1) {
  104936. this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
  104937. }
  104938. }
  104939. // Reset start size gradient so it acts the same on every start
  104940. if (this._startSizeGradients) {
  104941. if (this._startSizeGradients.length > 0) {
  104942. this._currentStartSizeGradient = this._startSizeGradients[0];
  104943. this._currentStartSize1 = this._currentStartSizeGradient.getFactor();
  104944. this._currentStartSize2 = this._currentStartSize1;
  104945. }
  104946. if (this._startSizeGradients.length > 1) {
  104947. this._currentStartSize2 = this._startSizeGradients[1].getFactor();
  104948. }
  104949. }
  104950. if (this.preWarmCycles) {
  104951. if (this.emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__["AbstractMesh"]) {
  104952. this.emitter.computeWorldMatrix(true);
  104953. }
  104954. var noiseTextureAsProcedural_1 = this.noiseTexture;
  104955. if (noiseTextureAsProcedural_1 && noiseTextureAsProcedural_1.onGeneratedObservable) {
  104956. noiseTextureAsProcedural_1.onGeneratedObservable.addOnce(function () {
  104957. setTimeout(function () {
  104958. for (var index = 0; index < _this.preWarmCycles; index++) {
  104959. _this.animate(true);
  104960. noiseTextureAsProcedural_1.render();
  104961. }
  104962. });
  104963. });
  104964. }
  104965. else {
  104966. for (var index = 0; index < this.preWarmCycles; index++) {
  104967. this.animate(true);
  104968. }
  104969. }
  104970. }
  104971. // Animations
  104972. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  104973. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  104974. }
  104975. };
  104976. /**
  104977. * Stops the particle system.
  104978. * @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.
  104979. */
  104980. ParticleSystem.prototype.stop = function (stopSubEmitters) {
  104981. if (stopSubEmitters === void 0) { stopSubEmitters = true; }
  104982. this._stopped = true;
  104983. if (stopSubEmitters) {
  104984. this._stopSubEmitters();
  104985. }
  104986. };
  104987. // animation sheet
  104988. /**
  104989. * Remove all active particles
  104990. */
  104991. ParticleSystem.prototype.reset = function () {
  104992. this._stockParticles = [];
  104993. this._particles = [];
  104994. };
  104995. /**
  104996. * @hidden (for internal use only)
  104997. */
  104998. ParticleSystem.prototype._appendParticleVertex = function (index, particle, offsetX, offsetY) {
  104999. var offset = index * this._vertexBufferSize;
  105000. this._vertexData[offset++] = particle.position.x;
  105001. this._vertexData[offset++] = particle.position.y;
  105002. this._vertexData[offset++] = particle.position.z;
  105003. this._vertexData[offset++] = particle.color.r;
  105004. this._vertexData[offset++] = particle.color.g;
  105005. this._vertexData[offset++] = particle.color.b;
  105006. this._vertexData[offset++] = particle.color.a;
  105007. this._vertexData[offset++] = particle.angle;
  105008. this._vertexData[offset++] = particle.scale.x * particle.size;
  105009. this._vertexData[offset++] = particle.scale.y * particle.size;
  105010. if (this._isAnimationSheetEnabled) {
  105011. this._vertexData[offset++] = particle.cellIndex;
  105012. }
  105013. if (!this._isBillboardBased) {
  105014. if (particle._initialDirection) {
  105015. this._vertexData[offset++] = particle._initialDirection.x;
  105016. this._vertexData[offset++] = particle._initialDirection.y;
  105017. this._vertexData[offset++] = particle._initialDirection.z;
  105018. }
  105019. else {
  105020. this._vertexData[offset++] = particle.direction.x;
  105021. this._vertexData[offset++] = particle.direction.y;
  105022. this._vertexData[offset++] = particle.direction.z;
  105023. }
  105024. }
  105025. else if (this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  105026. this._vertexData[offset++] = particle.direction.x;
  105027. this._vertexData[offset++] = particle.direction.y;
  105028. this._vertexData[offset++] = particle.direction.z;
  105029. }
  105030. if (this._useRampGradients) {
  105031. this._vertexData[offset++] = particle.remapData.x;
  105032. this._vertexData[offset++] = particle.remapData.y;
  105033. this._vertexData[offset++] = particle.remapData.z;
  105034. this._vertexData[offset++] = particle.remapData.w;
  105035. }
  105036. if (!this._useInstancing) {
  105037. if (this._isAnimationSheetEnabled) {
  105038. if (offsetX === 0) {
  105039. offsetX = this._epsilon;
  105040. }
  105041. else if (offsetX === 1) {
  105042. offsetX = 1 - this._epsilon;
  105043. }
  105044. if (offsetY === 0) {
  105045. offsetY = this._epsilon;
  105046. }
  105047. else if (offsetY === 1) {
  105048. offsetY = 1 - this._epsilon;
  105049. }
  105050. }
  105051. this._vertexData[offset++] = offsetX;
  105052. this._vertexData[offset++] = offsetY;
  105053. }
  105054. };
  105055. ParticleSystem.prototype._stopSubEmitters = function () {
  105056. if (!this.activeSubSystems) {
  105057. return;
  105058. }
  105059. this.activeSubSystems.forEach(function (subSystem) {
  105060. subSystem.stop(true);
  105061. });
  105062. this.activeSubSystems = new Array();
  105063. };
  105064. ParticleSystem.prototype._removeFromRoot = function () {
  105065. if (!this._rootParticleSystem) {
  105066. return;
  105067. }
  105068. var index = this._rootParticleSystem.activeSubSystems.indexOf(this);
  105069. if (index !== -1) {
  105070. this._rootParticleSystem.activeSubSystems.splice(index, 1);
  105071. }
  105072. this._rootParticleSystem = null;
  105073. };
  105074. // End of sub system methods
  105075. ParticleSystem.prototype._update = function (newParticles) {
  105076. var _this = this;
  105077. // Update current
  105078. this._alive = this._particles.length > 0;
  105079. if (this.emitter.position) {
  105080. var emitterMesh = this.emitter;
  105081. this._emitterWorldMatrix = emitterMesh.getWorldMatrix();
  105082. }
  105083. else {
  105084. var emitterPosition = this.emitter;
  105085. this._emitterWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  105086. }
  105087. this.updateFunction(this._particles);
  105088. // Add new ones
  105089. var particle;
  105090. var _loop_2 = function () {
  105091. if (this_1._particles.length === this_1._capacity) {
  105092. return "break";
  105093. }
  105094. particle = this_1._createParticle();
  105095. this_1._particles.push(particle);
  105096. // Emitter
  105097. var emitPower = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minEmitPower, this_1.maxEmitPower);
  105098. if (this_1.startPositionFunction) {
  105099. this_1.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  105100. }
  105101. else {
  105102. this_1.particleEmitterType.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  105103. }
  105104. if (this_1.startDirectionFunction) {
  105105. this_1.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  105106. }
  105107. else {
  105108. this_1.particleEmitterType.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  105109. }
  105110. if (emitPower === 0) {
  105111. if (!particle._initialDirection) {
  105112. particle._initialDirection = particle.direction.clone();
  105113. }
  105114. else {
  105115. particle._initialDirection.copyFrom(particle.direction);
  105116. }
  105117. }
  105118. else {
  105119. particle._initialDirection = null;
  105120. }
  105121. particle.direction.scaleInPlace(emitPower);
  105122. // Life time
  105123. if (this_1.targetStopDuration && this_1._lifeTimeGradients && this_1._lifeTimeGradients.length > 0) {
  105124. var ratio_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(this_1._actualFrame / this_1.targetStopDuration);
  105125. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio_1, this_1._lifeTimeGradients, function (currentGradient, nextGradient) {
  105126. var factorGradient1 = currentGradient;
  105127. var factorGradient2 = nextGradient;
  105128. var lifeTime1 = factorGradient1.getFactor();
  105129. var lifeTime2 = factorGradient2.getFactor();
  105130. var gradient = (ratio_1 - factorGradient1.gradient) / (factorGradient2.gradient - factorGradient1.gradient);
  105131. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(lifeTime1, lifeTime2, gradient);
  105132. });
  105133. }
  105134. else {
  105135. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minLifeTime, this_1.maxLifeTime);
  105136. }
  105137. // Size
  105138. if (!this_1._sizeGradients || this_1._sizeGradients.length === 0) {
  105139. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minSize, this_1.maxSize);
  105140. }
  105141. else {
  105142. particle._currentSizeGradient = this_1._sizeGradients[0];
  105143. particle._currentSize1 = particle._currentSizeGradient.getFactor();
  105144. particle.size = particle._currentSize1;
  105145. if (this_1._sizeGradients.length > 1) {
  105146. particle._currentSize2 = this_1._sizeGradients[1].getFactor();
  105147. }
  105148. else {
  105149. particle._currentSize2 = particle._currentSize1;
  105150. }
  105151. }
  105152. // Size and scale
  105153. 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));
  105154. // Adjust scale by start size
  105155. if (this_1._startSizeGradients && this_1._startSizeGradients[0] && this_1.targetStopDuration) {
  105156. var ratio = this_1._actualFrame / this_1.targetStopDuration;
  105157. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this_1._startSizeGradients, function (currentGradient, nextGradient, scale) {
  105158. if (currentGradient !== _this._currentStartSizeGradient) {
  105159. _this._currentStartSize1 = _this._currentStartSize2;
  105160. _this._currentStartSize2 = nextGradient.getFactor();
  105161. _this._currentStartSizeGradient = currentGradient;
  105162. }
  105163. var value = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentStartSize1, _this._currentStartSize2, scale);
  105164. particle.scale.scaleInPlace(value);
  105165. });
  105166. }
  105167. // Angle
  105168. if (!this_1._angularSpeedGradients || this_1._angularSpeedGradients.length === 0) {
  105169. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minAngularSpeed, this_1.maxAngularSpeed);
  105170. }
  105171. else {
  105172. particle._currentAngularSpeedGradient = this_1._angularSpeedGradients[0];
  105173. particle.angularSpeed = particle._currentAngularSpeedGradient.getFactor();
  105174. particle._currentAngularSpeed1 = particle.angularSpeed;
  105175. if (this_1._angularSpeedGradients.length > 1) {
  105176. particle._currentAngularSpeed2 = this_1._angularSpeedGradients[1].getFactor();
  105177. }
  105178. else {
  105179. particle._currentAngularSpeed2 = particle._currentAngularSpeed1;
  105180. }
  105181. }
  105182. particle.angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minInitialRotation, this_1.maxInitialRotation);
  105183. // Velocity
  105184. if (this_1._velocityGradients && this_1._velocityGradients.length > 0) {
  105185. particle._currentVelocityGradient = this_1._velocityGradients[0];
  105186. particle._currentVelocity1 = particle._currentVelocityGradient.getFactor();
  105187. if (this_1._velocityGradients.length > 1) {
  105188. particle._currentVelocity2 = this_1._velocityGradients[1].getFactor();
  105189. }
  105190. else {
  105191. particle._currentVelocity2 = particle._currentVelocity1;
  105192. }
  105193. }
  105194. // Limit velocity
  105195. if (this_1._limitVelocityGradients && this_1._limitVelocityGradients.length > 0) {
  105196. particle._currentLimitVelocityGradient = this_1._limitVelocityGradients[0];
  105197. particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
  105198. if (this_1._limitVelocityGradients.length > 1) {
  105199. particle._currentLimitVelocity2 = this_1._limitVelocityGradients[1].getFactor();
  105200. }
  105201. else {
  105202. particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
  105203. }
  105204. }
  105205. // Drag
  105206. if (this_1._dragGradients && this_1._dragGradients.length > 0) {
  105207. particle._currentDragGradient = this_1._dragGradients[0];
  105208. particle._currentDrag1 = particle._currentDragGradient.getFactor();
  105209. if (this_1._dragGradients.length > 1) {
  105210. particle._currentDrag2 = this_1._dragGradients[1].getFactor();
  105211. }
  105212. else {
  105213. particle._currentDrag2 = particle._currentDrag1;
  105214. }
  105215. }
  105216. // Color
  105217. if (!this_1._colorGradients || this_1._colorGradients.length === 0) {
  105218. step = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(0, 1.0);
  105219. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(this_1.color1, this_1.color2, step, particle.color);
  105220. this_1.colorDead.subtractToRef(particle.color, this_1._colorDiff);
  105221. this_1._colorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
  105222. }
  105223. else {
  105224. particle._currentColorGradient = this_1._colorGradients[0];
  105225. particle._currentColorGradient.getColorToRef(particle.color);
  105226. particle._currentColor1.copyFrom(particle.color);
  105227. if (this_1._colorGradients.length > 1) {
  105228. this_1._colorGradients[1].getColorToRef(particle._currentColor2);
  105229. }
  105230. else {
  105231. particle._currentColor2.copyFrom(particle.color);
  105232. }
  105233. }
  105234. // Sheet
  105235. if (this_1._isAnimationSheetEnabled) {
  105236. particle._initialStartSpriteCellID = this_1.startSpriteCellID;
  105237. particle._initialEndSpriteCellID = this_1.endSpriteCellID;
  105238. }
  105239. // Inherited Velocity
  105240. particle.direction.addInPlace(this_1._inheritedVelocityOffset);
  105241. // Ramp
  105242. if (this_1._useRampGradients) {
  105243. particle.remapData = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector4"](0, 1, 0, 1);
  105244. }
  105245. // Noise texture coordinates
  105246. if (this_1.noiseTexture) {
  105247. if (particle._randomNoiseCoordinates1) {
  105248. particle._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random());
  105249. particle._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random());
  105250. }
  105251. else {
  105252. particle._randomNoiseCoordinates1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  105253. particle._randomNoiseCoordinates2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  105254. }
  105255. }
  105256. // Update the position of the attached sub-emitters to match their attached particle
  105257. particle._inheritParticleInfoToSubEmitters();
  105258. };
  105259. var this_1 = this, step;
  105260. for (var index = 0; index < newParticles; index++) {
  105261. var state_1 = _loop_2();
  105262. if (state_1 === "break")
  105263. break;
  105264. }
  105265. };
  105266. /** @hidden */
  105267. ParticleSystem._GetAttributeNamesOrOptions = function (isAnimationSheetEnabled, isBillboardBased, useRampGradients) {
  105268. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  105269. if (isBillboardBased === void 0) { isBillboardBased = false; }
  105270. if (useRampGradients === void 0) { useRampGradients = false; }
  105271. var attributeNamesOrOptions = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, "angle", "offset", "size"];
  105272. if (isAnimationSheetEnabled) {
  105273. attributeNamesOrOptions.push("cellIndex");
  105274. }
  105275. if (!isBillboardBased) {
  105276. attributeNamesOrOptions.push("direction");
  105277. }
  105278. if (useRampGradients) {
  105279. attributeNamesOrOptions.push("remapData");
  105280. }
  105281. return attributeNamesOrOptions;
  105282. };
  105283. /** @hidden */
  105284. ParticleSystem._GetEffectCreationOptions = function (isAnimationSheetEnabled) {
  105285. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  105286. var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMask", "translationPivot", "eyePosition"];
  105287. if (isAnimationSheetEnabled) {
  105288. effectCreationOption.push("particlesInfos");
  105289. }
  105290. return effectCreationOption;
  105291. };
  105292. /** @hidden */
  105293. ParticleSystem.prototype._getEffect = function (blendMode) {
  105294. if (this._customEffect) {
  105295. return this._customEffect;
  105296. }
  105297. var defines = [];
  105298. if (this._scene.clipPlane) {
  105299. defines.push("#define CLIPPLANE");
  105300. }
  105301. if (this._scene.clipPlane2) {
  105302. defines.push("#define CLIPPLANE2");
  105303. }
  105304. if (this._scene.clipPlane3) {
  105305. defines.push("#define CLIPPLANE3");
  105306. }
  105307. if (this._scene.clipPlane4) {
  105308. defines.push("#define CLIPPLANE4");
  105309. }
  105310. if (this._isAnimationSheetEnabled) {
  105311. defines.push("#define ANIMATESHEET");
  105312. }
  105313. if (blendMode === ParticleSystem.BLENDMODE_MULTIPLY) {
  105314. defines.push("#define BLENDMULTIPLYMODE");
  105315. }
  105316. if (this._useRampGradients) {
  105317. defines.push("#define RAMPGRADIENT");
  105318. }
  105319. if (this._isBillboardBased) {
  105320. defines.push("#define BILLBOARD");
  105321. switch (this.billboardMode) {
  105322. case ParticleSystem.BILLBOARDMODE_Y:
  105323. defines.push("#define BILLBOARDY");
  105324. break;
  105325. case ParticleSystem.BILLBOARDMODE_STRETCHED:
  105326. defines.push("#define BILLBOARDSTRETCHED");
  105327. break;
  105328. case ParticleSystem.BILLBOARDMODE_ALL:
  105329. default:
  105330. break;
  105331. }
  105332. }
  105333. if (this._imageProcessingConfiguration) {
  105334. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  105335. defines.push(this._imageProcessingConfigurationDefines.toString());
  105336. }
  105337. // Effect
  105338. var join = defines.join("\n");
  105339. if (this._cachedDefines !== join) {
  105340. this._cachedDefines = join;
  105341. var attributesNamesOrOptions = ParticleSystem._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== ParticleSystem.BILLBOARDMODE_STRETCHED, this._useRampGradients);
  105342. var effectCreationOption = ParticleSystem._GetEffectCreationOptions(this._isAnimationSheetEnabled);
  105343. var samplers = ["diffuseSampler", "rampSampler"];
  105344. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"]) {
  105345. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareUniforms(effectCreationOption, this._imageProcessingConfigurationDefines);
  105346. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  105347. }
  105348. this._effect = this._scene.getEngine().createEffect("particles", attributesNamesOrOptions, effectCreationOption, samplers, join);
  105349. }
  105350. return this._effect;
  105351. };
  105352. /**
  105353. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  105354. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  105355. */
  105356. ParticleSystem.prototype.animate = function (preWarmOnly) {
  105357. var _this = this;
  105358. if (preWarmOnly === void 0) { preWarmOnly = false; }
  105359. if (!this._started) {
  105360. return;
  105361. }
  105362. if (!preWarmOnly) {
  105363. // Check
  105364. if (!this.isReady()) {
  105365. return;
  105366. }
  105367. if (this._currentRenderId === this._scene.getFrameId()) {
  105368. return;
  105369. }
  105370. this._currentRenderId = this._scene.getFrameId();
  105371. }
  105372. this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  105373. // Determine the number of particles we need to create
  105374. var newParticles;
  105375. if (this.manualEmitCount > -1) {
  105376. newParticles = this.manualEmitCount;
  105377. this._newPartsExcess = 0;
  105378. this.manualEmitCount = 0;
  105379. }
  105380. else {
  105381. var rate_1 = this.emitRate;
  105382. if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
  105383. var ratio = this._actualFrame / this.targetStopDuration;
  105384. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._emitRateGradients, function (currentGradient, nextGradient, scale) {
  105385. if (currentGradient !== _this._currentEmitRateGradient) {
  105386. _this._currentEmitRate1 = _this._currentEmitRate2;
  105387. _this._currentEmitRate2 = nextGradient.getFactor();
  105388. _this._currentEmitRateGradient = currentGradient;
  105389. }
  105390. rate_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentEmitRate1, _this._currentEmitRate2, scale);
  105391. });
  105392. }
  105393. newParticles = ((rate_1 * this._scaledUpdateSpeed) >> 0);
  105394. this._newPartsExcess += rate_1 * this._scaledUpdateSpeed - newParticles;
  105395. }
  105396. if (this._newPartsExcess > 1.0) {
  105397. newParticles += this._newPartsExcess >> 0;
  105398. this._newPartsExcess -= this._newPartsExcess >> 0;
  105399. }
  105400. this._alive = false;
  105401. if (!this._stopped) {
  105402. this._actualFrame += this._scaledUpdateSpeed;
  105403. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  105404. this.stop();
  105405. }
  105406. }
  105407. else {
  105408. newParticles = 0;
  105409. }
  105410. this._update(newParticles);
  105411. // Stopped?
  105412. if (this._stopped) {
  105413. if (!this._alive) {
  105414. this._started = false;
  105415. if (this.onAnimationEnd) {
  105416. this.onAnimationEnd();
  105417. }
  105418. if (this.disposeOnStop) {
  105419. this._scene._toBeDisposed.push(this);
  105420. }
  105421. }
  105422. }
  105423. if (!preWarmOnly) {
  105424. // Update VBO
  105425. var offset = 0;
  105426. for (var index = 0; index < this._particles.length; index++) {
  105427. var particle = this._particles[index];
  105428. this._appendParticleVertices(offset, particle);
  105429. offset += this._useInstancing ? 1 : 4;
  105430. }
  105431. if (this._vertexBuffer) {
  105432. this._vertexBuffer.update(this._vertexData);
  105433. }
  105434. }
  105435. if (this.manualEmitCount === 0 && this.disposeOnStop) {
  105436. this.stop();
  105437. }
  105438. };
  105439. ParticleSystem.prototype._appendParticleVertices = function (offset, particle) {
  105440. this._appendParticleVertex(offset++, particle, 0, 0);
  105441. if (!this._useInstancing) {
  105442. this._appendParticleVertex(offset++, particle, 1, 0);
  105443. this._appendParticleVertex(offset++, particle, 1, 1);
  105444. this._appendParticleVertex(offset++, particle, 0, 1);
  105445. }
  105446. };
  105447. /**
  105448. * Rebuilds the particle system.
  105449. */
  105450. ParticleSystem.prototype.rebuild = function () {
  105451. this._createIndexBuffer();
  105452. if (this._vertexBuffer) {
  105453. this._vertexBuffer._rebuild();
  105454. }
  105455. };
  105456. /**
  105457. * Is this system ready to be used/rendered
  105458. * @return true if the system is ready
  105459. */
  105460. ParticleSystem.prototype.isReady = function () {
  105461. if (!this.emitter || !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  105462. return false;
  105463. }
  105464. if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
  105465. if (!this._getEffect(this.blendMode).isReady()) {
  105466. return false;
  105467. }
  105468. }
  105469. else {
  105470. if (!this._getEffect(ParticleSystem.BLENDMODE_MULTIPLY).isReady()) {
  105471. return false;
  105472. }
  105473. if (!this._getEffect(ParticleSystem.BLENDMODE_ADD).isReady()) {
  105474. return false;
  105475. }
  105476. }
  105477. return true;
  105478. };
  105479. ParticleSystem.prototype._render = function (blendMode) {
  105480. var effect = this._getEffect(blendMode);
  105481. var engine = this._scene.getEngine();
  105482. // Render
  105483. engine.enableEffect(effect);
  105484. var viewMatrix = this._scene.getViewMatrix();
  105485. effect.setTexture("diffuseSampler", this.particleTexture);
  105486. effect.setMatrix("view", viewMatrix);
  105487. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  105488. if (this._isAnimationSheetEnabled && this.particleTexture) {
  105489. var baseSize = this.particleTexture.getBaseSize();
  105490. effect.setFloat3("particlesInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  105491. }
  105492. effect.setVector2("translationPivot", this.translationPivot);
  105493. effect.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
  105494. if (this._isBillboardBased) {
  105495. var camera = this._scene.activeCamera;
  105496. effect.setVector3("eyePosition", camera.globalPosition);
  105497. }
  105498. if (this._rampGradientsTexture) {
  105499. effect.setTexture("rampSampler", this._rampGradientsTexture);
  105500. }
  105501. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  105502. var invView = viewMatrix.clone();
  105503. invView.invert();
  105504. effect.setMatrix("invView", invView);
  105505. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__["MaterialHelper"].BindClipPlane(effect, this._scene);
  105506. }
  105507. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  105508. // image processing
  105509. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  105510. this._imageProcessingConfiguration.bind(effect);
  105511. }
  105512. // Draw order
  105513. switch (blendMode) {
  105514. case ParticleSystem.BLENDMODE_ADD:
  105515. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].ALPHA_ADD);
  105516. break;
  105517. case ParticleSystem.BLENDMODE_ONEONE:
  105518. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].ALPHA_ONEONE);
  105519. break;
  105520. case ParticleSystem.BLENDMODE_STANDARD:
  105521. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].ALPHA_COMBINE);
  105522. break;
  105523. case ParticleSystem.BLENDMODE_MULTIPLY:
  105524. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].ALPHA_MULTIPLY);
  105525. break;
  105526. }
  105527. if (this._useInstancing) {
  105528. engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFanDrawMode, 0, 4, this._particles.length);
  105529. }
  105530. else {
  105531. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, this._particles.length * 6);
  105532. }
  105533. return this._particles.length;
  105534. };
  105535. /**
  105536. * Renders the particle system in its current state.
  105537. * @returns the current number of particles
  105538. */
  105539. ParticleSystem.prototype.render = function () {
  105540. // Check
  105541. if (!this.isReady() || !this._particles.length) {
  105542. return 0;
  105543. }
  105544. var engine = this._scene.getEngine();
  105545. engine.setState(false);
  105546. if (this.forceDepthWrite) {
  105547. engine.setDepthWrite(true);
  105548. }
  105549. var outparticles = 0;
  105550. if (this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD) {
  105551. outparticles = this._render(ParticleSystem.BLENDMODE_MULTIPLY) + this._render(ParticleSystem.BLENDMODE_ADD);
  105552. }
  105553. outparticles = this._render(this.blendMode);
  105554. engine.unbindInstanceAttributes();
  105555. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].ALPHA_DISABLE);
  105556. return outparticles;
  105557. };
  105558. /**
  105559. * Disposes the particle system and free the associated resources
  105560. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  105561. */
  105562. ParticleSystem.prototype.dispose = function (disposeTexture) {
  105563. if (disposeTexture === void 0) { disposeTexture = true; }
  105564. if (this._vertexBuffer) {
  105565. this._vertexBuffer.dispose();
  105566. this._vertexBuffer = null;
  105567. }
  105568. if (this._spriteBuffer) {
  105569. this._spriteBuffer.dispose();
  105570. this._spriteBuffer = null;
  105571. }
  105572. if (this._indexBuffer) {
  105573. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  105574. this._indexBuffer = null;
  105575. }
  105576. if (disposeTexture && this.particleTexture) {
  105577. this.particleTexture.dispose();
  105578. this.particleTexture = null;
  105579. }
  105580. if (disposeTexture && this.noiseTexture) {
  105581. this.noiseTexture.dispose();
  105582. this.noiseTexture = null;
  105583. }
  105584. if (this._rampGradientsTexture) {
  105585. this._rampGradientsTexture.dispose();
  105586. this._rampGradientsTexture = null;
  105587. }
  105588. this._removeFromRoot();
  105589. if (this._subEmitters && this._subEmitters.length) {
  105590. for (var index = 0; index < this._subEmitters.length; index++) {
  105591. for (var _i = 0, _a = this._subEmitters[index]; _i < _a.length; _i++) {
  105592. var subEmitter = _a[_i];
  105593. subEmitter.dispose();
  105594. }
  105595. }
  105596. this._subEmitters = [];
  105597. this.subEmitters = [];
  105598. }
  105599. if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose) {
  105600. this.emitter.dispose(true);
  105601. }
  105602. // Remove from scene
  105603. var index = this._scene.particleSystems.indexOf(this);
  105604. if (index > -1) {
  105605. this._scene.particleSystems.splice(index, 1);
  105606. }
  105607. this._scene._activeParticleSystems.dispose();
  105608. // Callback
  105609. this.onDisposeObservable.notifyObservers(this);
  105610. this.onDisposeObservable.clear();
  105611. this.reset();
  105612. };
  105613. // Clone
  105614. /**
  105615. * Clones the particle system.
  105616. * @param name The name of the cloned object
  105617. * @param newEmitter The new emitter to use
  105618. * @returns the cloned particle system
  105619. */
  105620. ParticleSystem.prototype.clone = function (name, newEmitter) {
  105621. var custom = null;
  105622. var program = null;
  105623. if (this.customShader != null) {
  105624. program = this.customShader;
  105625. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  105626. custom = this._scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  105627. }
  105628. else if (this._customEffect) {
  105629. custom = this._customEffect;
  105630. }
  105631. var result = new ParticleSystem(name, this._capacity, this._scene, custom);
  105632. result.customShader = program;
  105633. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_21__["DeepCopier"].DeepCopy(this, result, ["particles", "customShader", "noiseTexture"]);
  105634. if (newEmitter === undefined) {
  105635. newEmitter = this.emitter;
  105636. }
  105637. result.noiseTexture = this.noiseTexture;
  105638. result.emitter = newEmitter;
  105639. if (this.particleTexture) {
  105640. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](this.particleTexture.url, this._scene);
  105641. }
  105642. // Clone gradients
  105643. if (this._colorGradients) {
  105644. this._colorGradients.forEach(function (v) {
  105645. result.addColorGradient(v.gradient, v.color1, v.color2);
  105646. });
  105647. }
  105648. if (this._dragGradients) {
  105649. this._dragGradients.forEach(function (v) {
  105650. result.addDragGradient(v.gradient, v.factor1, v.factor2);
  105651. });
  105652. }
  105653. if (this._angularSpeedGradients) {
  105654. this._angularSpeedGradients.forEach(function (v) {
  105655. result.addAngularSpeedGradient(v.gradient, v.factor1, v.factor2);
  105656. });
  105657. }
  105658. if (this._emitRateGradients) {
  105659. this._emitRateGradients.forEach(function (v) {
  105660. result.addEmitRateGradient(v.gradient, v.factor1, v.factor2);
  105661. });
  105662. }
  105663. if (this._lifeTimeGradients) {
  105664. this._lifeTimeGradients.forEach(function (v) {
  105665. result.addLifeTimeGradient(v.gradient, v.factor1, v.factor2);
  105666. });
  105667. }
  105668. if (this._limitVelocityGradients) {
  105669. this._limitVelocityGradients.forEach(function (v) {
  105670. result.addLimitVelocityGradient(v.gradient, v.factor1, v.factor2);
  105671. });
  105672. }
  105673. if (this._sizeGradients) {
  105674. this._sizeGradients.forEach(function (v) {
  105675. result.addSizeGradient(v.gradient, v.factor1, v.factor2);
  105676. });
  105677. }
  105678. if (this._startSizeGradients) {
  105679. this._startSizeGradients.forEach(function (v) {
  105680. result.addStartSizeGradient(v.gradient, v.factor1, v.factor2);
  105681. });
  105682. }
  105683. if (this._velocityGradients) {
  105684. this._velocityGradients.forEach(function (v) {
  105685. result.addVelocityGradient(v.gradient, v.factor1, v.factor2);
  105686. });
  105687. }
  105688. if (this._rampGradients) {
  105689. this._rampGradients.forEach(function (v) {
  105690. result.addRampGradient(v.gradient, v.color);
  105691. });
  105692. }
  105693. if (this._colorRemapGradients) {
  105694. this._colorRemapGradients.forEach(function (v) {
  105695. result.addColorRemapGradient(v.gradient, v.factor1, v.factor2);
  105696. });
  105697. }
  105698. if (this._alphaRemapGradients) {
  105699. this._alphaRemapGradients.forEach(function (v) {
  105700. result.addAlphaRemapGradient(v.gradient, v.factor1, v.factor2);
  105701. });
  105702. }
  105703. if (!this.preventAutoStart) {
  105704. result.start();
  105705. }
  105706. return result;
  105707. };
  105708. /**
  105709. * Serializes the particle system to a JSON object.
  105710. * @returns the JSON object
  105711. */
  105712. ParticleSystem.prototype.serialize = function () {
  105713. var serializationObject = {};
  105714. ParticleSystem._Serialize(serializationObject, this);
  105715. serializationObject.textureMask = this.textureMask.asArray();
  105716. serializationObject.customShader = this.customShader;
  105717. serializationObject.preventAutoStart = this.preventAutoStart;
  105718. // SubEmitters
  105719. if (this.subEmitters) {
  105720. serializationObject.subEmitters = [];
  105721. if (!this._subEmitters) {
  105722. this._prepareSubEmitterInternalArray();
  105723. }
  105724. for (var _i = 0, _a = this._subEmitters; _i < _a.length; _i++) {
  105725. var subs = _a[_i];
  105726. var cell = [];
  105727. for (var _b = 0, subs_1 = subs; _b < subs_1.length; _b++) {
  105728. var sub = subs_1[_b];
  105729. cell.push(sub.serialize());
  105730. }
  105731. serializationObject.subEmitters.push(cell);
  105732. }
  105733. }
  105734. return serializationObject;
  105735. };
  105736. /** @hidden */
  105737. ParticleSystem._Serialize = function (serializationObject, particleSystem) {
  105738. serializationObject.name = particleSystem.name;
  105739. serializationObject.id = particleSystem.id;
  105740. serializationObject.capacity = particleSystem.getCapacity();
  105741. // Emitter
  105742. if (particleSystem.emitter.position) {
  105743. var emitterMesh = particleSystem.emitter;
  105744. serializationObject.emitterId = emitterMesh.id;
  105745. }
  105746. else {
  105747. var emitterPosition = particleSystem.emitter;
  105748. serializationObject.emitter = emitterPosition.asArray();
  105749. }
  105750. // Emitter
  105751. if (particleSystem.particleEmitterType) {
  105752. serializationObject.particleEmitterType = particleSystem.particleEmitterType.serialize();
  105753. }
  105754. if (particleSystem.particleTexture) {
  105755. serializationObject.textureName = particleSystem.particleTexture.name;
  105756. serializationObject.invertY = particleSystem.particleTexture._invertY;
  105757. }
  105758. // Animations
  105759. _Misc_decorators__WEBPACK_IMPORTED_MODULE_20__["SerializationHelper"].AppendSerializedAnimations(particleSystem, serializationObject);
  105760. serializationObject.beginAnimationOnStart = particleSystem.beginAnimationOnStart;
  105761. serializationObject.beginAnimationFrom = particleSystem.beginAnimationFrom;
  105762. serializationObject.beginAnimationTo = particleSystem.beginAnimationTo;
  105763. serializationObject.beginAnimationLoop = particleSystem.beginAnimationLoop;
  105764. // Particle system
  105765. serializationObject.startDelay = particleSystem.startDelay;
  105766. serializationObject.renderingGroupId = particleSystem.renderingGroupId;
  105767. serializationObject.isBillboardBased = particleSystem.isBillboardBased;
  105768. serializationObject.billboardMode = particleSystem.billboardMode;
  105769. serializationObject.minAngularSpeed = particleSystem.minAngularSpeed;
  105770. serializationObject.maxAngularSpeed = particleSystem.maxAngularSpeed;
  105771. serializationObject.minSize = particleSystem.minSize;
  105772. serializationObject.maxSize = particleSystem.maxSize;
  105773. serializationObject.minScaleX = particleSystem.minScaleX;
  105774. serializationObject.maxScaleX = particleSystem.maxScaleX;
  105775. serializationObject.minScaleY = particleSystem.minScaleY;
  105776. serializationObject.maxScaleY = particleSystem.maxScaleY;
  105777. serializationObject.minEmitPower = particleSystem.minEmitPower;
  105778. serializationObject.maxEmitPower = particleSystem.maxEmitPower;
  105779. serializationObject.minLifeTime = particleSystem.minLifeTime;
  105780. serializationObject.maxLifeTime = particleSystem.maxLifeTime;
  105781. serializationObject.emitRate = particleSystem.emitRate;
  105782. serializationObject.gravity = particleSystem.gravity.asArray();
  105783. serializationObject.noiseStrength = particleSystem.noiseStrength.asArray();
  105784. serializationObject.color1 = particleSystem.color1.asArray();
  105785. serializationObject.color2 = particleSystem.color2.asArray();
  105786. serializationObject.colorDead = particleSystem.colorDead.asArray();
  105787. serializationObject.updateSpeed = particleSystem.updateSpeed;
  105788. serializationObject.targetStopDuration = particleSystem.targetStopDuration;
  105789. serializationObject.blendMode = particleSystem.blendMode;
  105790. serializationObject.preWarmCycles = particleSystem.preWarmCycles;
  105791. serializationObject.preWarmStepOffset = particleSystem.preWarmStepOffset;
  105792. serializationObject.minInitialRotation = particleSystem.minInitialRotation;
  105793. serializationObject.maxInitialRotation = particleSystem.maxInitialRotation;
  105794. serializationObject.startSpriteCellID = particleSystem.startSpriteCellID;
  105795. serializationObject.endSpriteCellID = particleSystem.endSpriteCellID;
  105796. serializationObject.spriteCellChangeSpeed = particleSystem.spriteCellChangeSpeed;
  105797. serializationObject.spriteCellWidth = particleSystem.spriteCellWidth;
  105798. serializationObject.spriteCellHeight = particleSystem.spriteCellHeight;
  105799. serializationObject.spriteRandomStartCell = particleSystem.spriteRandomStartCell;
  105800. serializationObject.isAnimationSheetEnabled = particleSystem.isAnimationSheetEnabled;
  105801. var colorGradients = particleSystem.getColorGradients();
  105802. if (colorGradients) {
  105803. serializationObject.colorGradients = [];
  105804. for (var _i = 0, colorGradients_1 = colorGradients; _i < colorGradients_1.length; _i++) {
  105805. var colorGradient = colorGradients_1[_i];
  105806. var serializedGradient = {
  105807. gradient: colorGradient.gradient,
  105808. color1: colorGradient.color1.asArray()
  105809. };
  105810. if (colorGradient.color2) {
  105811. serializedGradient.color2 = colorGradient.color2.asArray();
  105812. }
  105813. serializationObject.colorGradients.push(serializedGradient);
  105814. }
  105815. }
  105816. var rampGradients = particleSystem.getRampGradients();
  105817. if (rampGradients) {
  105818. serializationObject.rampGradients = [];
  105819. for (var _a = 0, rampGradients_1 = rampGradients; _a < rampGradients_1.length; _a++) {
  105820. var rampGradient = rampGradients_1[_a];
  105821. var serializedGradient = {
  105822. gradient: rampGradient.gradient,
  105823. color: rampGradient.color.asArray()
  105824. };
  105825. serializationObject.rampGradients.push(serializedGradient);
  105826. }
  105827. serializationObject.useRampGradients = particleSystem.useRampGradients;
  105828. }
  105829. var colorRemapGradients = particleSystem.getColorRemapGradients();
  105830. if (colorRemapGradients) {
  105831. serializationObject.colorRemapGradients = [];
  105832. for (var _b = 0, colorRemapGradients_1 = colorRemapGradients; _b < colorRemapGradients_1.length; _b++) {
  105833. var colorRemapGradient = colorRemapGradients_1[_b];
  105834. var serializedGradient = {
  105835. gradient: colorRemapGradient.gradient,
  105836. factor1: colorRemapGradient.factor1
  105837. };
  105838. if (colorRemapGradient.factor2 !== undefined) {
  105839. serializedGradient.factor2 = colorRemapGradient.factor2;
  105840. }
  105841. serializationObject.colorRemapGradients.push(serializedGradient);
  105842. }
  105843. }
  105844. var alphaRemapGradients = particleSystem.getAlphaRemapGradients();
  105845. if (alphaRemapGradients) {
  105846. serializationObject.alphaRemapGradients = [];
  105847. for (var _c = 0, alphaRemapGradients_1 = alphaRemapGradients; _c < alphaRemapGradients_1.length; _c++) {
  105848. var alphaRemapGradient = alphaRemapGradients_1[_c];
  105849. var serializedGradient = {
  105850. gradient: alphaRemapGradient.gradient,
  105851. factor1: alphaRemapGradient.factor1
  105852. };
  105853. if (alphaRemapGradient.factor2 !== undefined) {
  105854. serializedGradient.factor2 = alphaRemapGradient.factor2;
  105855. }
  105856. serializationObject.alphaRemapGradients.push(serializedGradient);
  105857. }
  105858. }
  105859. var sizeGradients = particleSystem.getSizeGradients();
  105860. if (sizeGradients) {
  105861. serializationObject.sizeGradients = [];
  105862. for (var _d = 0, sizeGradients_1 = sizeGradients; _d < sizeGradients_1.length; _d++) {
  105863. var sizeGradient = sizeGradients_1[_d];
  105864. var serializedGradient = {
  105865. gradient: sizeGradient.gradient,
  105866. factor1: sizeGradient.factor1
  105867. };
  105868. if (sizeGradient.factor2 !== undefined) {
  105869. serializedGradient.factor2 = sizeGradient.factor2;
  105870. }
  105871. serializationObject.sizeGradients.push(serializedGradient);
  105872. }
  105873. }
  105874. var angularSpeedGradients = particleSystem.getAngularSpeedGradients();
  105875. if (angularSpeedGradients) {
  105876. serializationObject.angularSpeedGradients = [];
  105877. for (var _e = 0, angularSpeedGradients_1 = angularSpeedGradients; _e < angularSpeedGradients_1.length; _e++) {
  105878. var angularSpeedGradient = angularSpeedGradients_1[_e];
  105879. var serializedGradient = {
  105880. gradient: angularSpeedGradient.gradient,
  105881. factor1: angularSpeedGradient.factor1
  105882. };
  105883. if (angularSpeedGradient.factor2 !== undefined) {
  105884. serializedGradient.factor2 = angularSpeedGradient.factor2;
  105885. }
  105886. serializationObject.angularSpeedGradients.push(serializedGradient);
  105887. }
  105888. }
  105889. var velocityGradients = particleSystem.getVelocityGradients();
  105890. if (velocityGradients) {
  105891. serializationObject.velocityGradients = [];
  105892. for (var _f = 0, velocityGradients_1 = velocityGradients; _f < velocityGradients_1.length; _f++) {
  105893. var velocityGradient = velocityGradients_1[_f];
  105894. var serializedGradient = {
  105895. gradient: velocityGradient.gradient,
  105896. factor1: velocityGradient.factor1
  105897. };
  105898. if (velocityGradient.factor2 !== undefined) {
  105899. serializedGradient.factor2 = velocityGradient.factor2;
  105900. }
  105901. serializationObject.velocityGradients.push(serializedGradient);
  105902. }
  105903. }
  105904. var dragGradients = particleSystem.getDragGradients();
  105905. if (dragGradients) {
  105906. serializationObject.dragyGradients = [];
  105907. for (var _g = 0, dragGradients_1 = dragGradients; _g < dragGradients_1.length; _g++) {
  105908. var dragGradient = dragGradients_1[_g];
  105909. var serializedGradient = {
  105910. gradient: dragGradient.gradient,
  105911. factor1: dragGradient.factor1
  105912. };
  105913. if (dragGradient.factor2 !== undefined) {
  105914. serializedGradient.factor2 = dragGradient.factor2;
  105915. }
  105916. serializationObject.dragGradients.push(serializedGradient);
  105917. }
  105918. }
  105919. var emitRateGradients = particleSystem.getEmitRateGradients();
  105920. if (emitRateGradients) {
  105921. serializationObject.emitRateGradients = [];
  105922. for (var _h = 0, emitRateGradients_1 = emitRateGradients; _h < emitRateGradients_1.length; _h++) {
  105923. var emitRateGradient = emitRateGradients_1[_h];
  105924. var serializedGradient = {
  105925. gradient: emitRateGradient.gradient,
  105926. factor1: emitRateGradient.factor1
  105927. };
  105928. if (emitRateGradient.factor2 !== undefined) {
  105929. serializedGradient.factor2 = emitRateGradient.factor2;
  105930. }
  105931. serializationObject.emitRateGradients.push(serializedGradient);
  105932. }
  105933. }
  105934. var startSizeGradients = particleSystem.getStartSizeGradients();
  105935. if (startSizeGradients) {
  105936. serializationObject.startSizeGradients = [];
  105937. for (var _j = 0, startSizeGradients_1 = startSizeGradients; _j < startSizeGradients_1.length; _j++) {
  105938. var startSizeGradient = startSizeGradients_1[_j];
  105939. var serializedGradient = {
  105940. gradient: startSizeGradient.gradient,
  105941. factor1: startSizeGradient.factor1
  105942. };
  105943. if (startSizeGradient.factor2 !== undefined) {
  105944. serializedGradient.factor2 = startSizeGradient.factor2;
  105945. }
  105946. serializationObject.startSizeGradients.push(serializedGradient);
  105947. }
  105948. }
  105949. var lifeTimeGradients = particleSystem.getLifeTimeGradients();
  105950. if (lifeTimeGradients) {
  105951. serializationObject.lifeTimeGradients = [];
  105952. for (var _k = 0, lifeTimeGradients_1 = lifeTimeGradients; _k < lifeTimeGradients_1.length; _k++) {
  105953. var lifeTimeGradient = lifeTimeGradients_1[_k];
  105954. var serializedGradient = {
  105955. gradient: lifeTimeGradient.gradient,
  105956. factor1: lifeTimeGradient.factor1
  105957. };
  105958. if (lifeTimeGradient.factor2 !== undefined) {
  105959. serializedGradient.factor2 = lifeTimeGradient.factor2;
  105960. }
  105961. serializationObject.lifeTimeGradients.push(serializedGradient);
  105962. }
  105963. }
  105964. var limitVelocityGradients = particleSystem.getLimitVelocityGradients();
  105965. if (limitVelocityGradients) {
  105966. serializationObject.limitVelocityGradients = [];
  105967. for (var _l = 0, limitVelocityGradients_1 = limitVelocityGradients; _l < limitVelocityGradients_1.length; _l++) {
  105968. var limitVelocityGradient = limitVelocityGradients_1[_l];
  105969. var serializedGradient = {
  105970. gradient: limitVelocityGradient.gradient,
  105971. factor1: limitVelocityGradient.factor1
  105972. };
  105973. if (limitVelocityGradient.factor2 !== undefined) {
  105974. serializedGradient.factor2 = limitVelocityGradient.factor2;
  105975. }
  105976. serializationObject.limitVelocityGradients.push(serializedGradient);
  105977. }
  105978. serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
  105979. }
  105980. if (particleSystem.noiseTexture) {
  105981. serializationObject.noiseTexture = particleSystem.noiseTexture.serialize();
  105982. }
  105983. };
  105984. /** @hidden */
  105985. ParticleSystem._Parse = function (parsedParticleSystem, particleSystem, scene, rootUrl) {
  105986. // Texture
  105987. if (parsedParticleSystem.textureName) {
  105988. particleSystem.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](rootUrl + parsedParticleSystem.textureName, scene, false, parsedParticleSystem.invertY !== undefined ? parsedParticleSystem.invertY : true);
  105989. particleSystem.particleTexture.name = parsedParticleSystem.textureName;
  105990. }
  105991. // Emitter
  105992. if (!parsedParticleSystem.emitterId && parsedParticleSystem.emitterId !== 0 && parsedParticleSystem.emitter === undefined) {
  105993. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  105994. }
  105995. else if (parsedParticleSystem.emitterId) {
  105996. particleSystem.emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
  105997. }
  105998. else {
  105999. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.emitter);
  106000. }
  106001. // Misc.
  106002. if (parsedParticleSystem.renderingGroupId !== undefined) {
  106003. particleSystem.renderingGroupId = parsedParticleSystem.renderingGroupId;
  106004. }
  106005. if (parsedParticleSystem.isBillboardBased !== undefined) {
  106006. particleSystem.isBillboardBased = parsedParticleSystem.isBillboardBased;
  106007. }
  106008. if (parsedParticleSystem.billboardMode !== undefined) {
  106009. particleSystem.billboardMode = parsedParticleSystem.billboardMode;
  106010. }
  106011. // Animations
  106012. if (parsedParticleSystem.animations) {
  106013. for (var animationIndex = 0; animationIndex < parsedParticleSystem.animations.length; animationIndex++) {
  106014. var parsedAnimation = parsedParticleSystem.animations[animationIndex];
  106015. particleSystem.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_14__["Animation"].Parse(parsedAnimation));
  106016. }
  106017. particleSystem.beginAnimationOnStart = parsedParticleSystem.beginAnimationOnStart;
  106018. particleSystem.beginAnimationFrom = parsedParticleSystem.beginAnimationFrom;
  106019. particleSystem.beginAnimationTo = parsedParticleSystem.beginAnimationTo;
  106020. particleSystem.beginAnimationLoop = parsedParticleSystem.beginAnimationLoop;
  106021. }
  106022. if (parsedParticleSystem.autoAnimate) {
  106023. scene.beginAnimation(particleSystem, parsedParticleSystem.autoAnimateFrom, parsedParticleSystem.autoAnimateTo, parsedParticleSystem.autoAnimateLoop, parsedParticleSystem.autoAnimateSpeed || 1.0);
  106024. }
  106025. // Particle system
  106026. particleSystem.startDelay = parsedParticleSystem.startDelay | 0;
  106027. particleSystem.minAngularSpeed = parsedParticleSystem.minAngularSpeed;
  106028. particleSystem.maxAngularSpeed = parsedParticleSystem.maxAngularSpeed;
  106029. particleSystem.minSize = parsedParticleSystem.minSize;
  106030. particleSystem.maxSize = parsedParticleSystem.maxSize;
  106031. if (parsedParticleSystem.minScaleX) {
  106032. particleSystem.minScaleX = parsedParticleSystem.minScaleX;
  106033. particleSystem.maxScaleX = parsedParticleSystem.maxScaleX;
  106034. particleSystem.minScaleY = parsedParticleSystem.minScaleY;
  106035. particleSystem.maxScaleY = parsedParticleSystem.maxScaleY;
  106036. }
  106037. if (parsedParticleSystem.preWarmCycles !== undefined) {
  106038. particleSystem.preWarmCycles = parsedParticleSystem.preWarmCycles;
  106039. particleSystem.preWarmStepOffset = parsedParticleSystem.preWarmStepOffset;
  106040. }
  106041. if (parsedParticleSystem.minInitialRotation !== undefined) {
  106042. particleSystem.minInitialRotation = parsedParticleSystem.minInitialRotation;
  106043. particleSystem.maxInitialRotation = parsedParticleSystem.maxInitialRotation;
  106044. }
  106045. particleSystem.minLifeTime = parsedParticleSystem.minLifeTime;
  106046. particleSystem.maxLifeTime = parsedParticleSystem.maxLifeTime;
  106047. particleSystem.minEmitPower = parsedParticleSystem.minEmitPower;
  106048. particleSystem.maxEmitPower = parsedParticleSystem.maxEmitPower;
  106049. particleSystem.emitRate = parsedParticleSystem.emitRate;
  106050. particleSystem.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.gravity);
  106051. if (parsedParticleSystem.noiseStrength) {
  106052. particleSystem.noiseStrength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.noiseStrength);
  106053. }
  106054. particleSystem.color1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color1);
  106055. particleSystem.color2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color2);
  106056. particleSystem.colorDead = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.colorDead);
  106057. particleSystem.updateSpeed = parsedParticleSystem.updateSpeed;
  106058. particleSystem.targetStopDuration = parsedParticleSystem.targetStopDuration;
  106059. particleSystem.blendMode = parsedParticleSystem.blendMode;
  106060. if (parsedParticleSystem.colorGradients) {
  106061. for (var _i = 0, _a = parsedParticleSystem.colorGradients; _i < _a.length; _i++) {
  106062. var colorGradient = _a[_i];
  106063. 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);
  106064. }
  106065. }
  106066. if (parsedParticleSystem.rampGradients) {
  106067. for (var _b = 0, _c = parsedParticleSystem.rampGradients; _b < _c.length; _b++) {
  106068. var rampGradient = _c[_b];
  106069. particleSystem.addRampGradient(rampGradient.gradient, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].FromArray(rampGradient.color));
  106070. }
  106071. particleSystem.useRampGradients = parsedParticleSystem.useRampGradients;
  106072. }
  106073. if (parsedParticleSystem.colorRemapGradients) {
  106074. for (var _d = 0, _e = parsedParticleSystem.colorRemapGradients; _d < _e.length; _d++) {
  106075. var colorRemapGradient = _e[_d];
  106076. particleSystem.addColorRemapGradient(colorRemapGradient.gradient, colorRemapGradient.factor1 !== undefined ? colorRemapGradient.factor1 : colorRemapGradient.factor, colorRemapGradient.factor2);
  106077. }
  106078. }
  106079. if (parsedParticleSystem.alphaRemapGradients) {
  106080. for (var _f = 0, _g = parsedParticleSystem.alphaRemapGradients; _f < _g.length; _f++) {
  106081. var alphaRemapGradient = _g[_f];
  106082. particleSystem.addAlphaRemapGradient(alphaRemapGradient.gradient, alphaRemapGradient.factor1 !== undefined ? alphaRemapGradient.factor1 : alphaRemapGradient.factor, alphaRemapGradient.factor2);
  106083. }
  106084. }
  106085. if (parsedParticleSystem.sizeGradients) {
  106086. for (var _h = 0, _j = parsedParticleSystem.sizeGradients; _h < _j.length; _h++) {
  106087. var sizeGradient = _j[_h];
  106088. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  106089. }
  106090. }
  106091. if (parsedParticleSystem.sizeGradients) {
  106092. for (var _k = 0, _l = parsedParticleSystem.sizeGradients; _k < _l.length; _k++) {
  106093. var sizeGradient = _l[_k];
  106094. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  106095. }
  106096. }
  106097. if (parsedParticleSystem.angularSpeedGradients) {
  106098. for (var _m = 0, _o = parsedParticleSystem.angularSpeedGradients; _m < _o.length; _m++) {
  106099. var angularSpeedGradient = _o[_m];
  106100. particleSystem.addAngularSpeedGradient(angularSpeedGradient.gradient, angularSpeedGradient.factor1 !== undefined ? angularSpeedGradient.factor1 : angularSpeedGradient.factor, angularSpeedGradient.factor2);
  106101. }
  106102. }
  106103. if (parsedParticleSystem.velocityGradients) {
  106104. for (var _p = 0, _q = parsedParticleSystem.velocityGradients; _p < _q.length; _p++) {
  106105. var velocityGradient = _q[_p];
  106106. particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
  106107. }
  106108. }
  106109. if (parsedParticleSystem.dragGradients) {
  106110. for (var _r = 0, _s = parsedParticleSystem.dragGradients; _r < _s.length; _r++) {
  106111. var dragGradient = _s[_r];
  106112. particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ? dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
  106113. }
  106114. }
  106115. if (parsedParticleSystem.emitRateGradients) {
  106116. for (var _t = 0, _u = parsedParticleSystem.emitRateGradients; _t < _u.length; _t++) {
  106117. var emitRateGradient = _u[_t];
  106118. particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ? emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
  106119. }
  106120. }
  106121. if (parsedParticleSystem.startSizeGradients) {
  106122. for (var _v = 0, _w = parsedParticleSystem.startSizeGradients; _v < _w.length; _v++) {
  106123. var startSizeGradient = _w[_v];
  106124. particleSystem.addStartSizeGradient(startSizeGradient.gradient, startSizeGradient.factor1 !== undefined ? startSizeGradient.factor1 : startSizeGradient.factor, startSizeGradient.factor2);
  106125. }
  106126. }
  106127. if (parsedParticleSystem.lifeTimeGradients) {
  106128. for (var _x = 0, _y = parsedParticleSystem.lifeTimeGradients; _x < _y.length; _x++) {
  106129. var lifeTimeGradient = _y[_x];
  106130. particleSystem.addLifeTimeGradient(lifeTimeGradient.gradient, lifeTimeGradient.factor1 !== undefined ? lifeTimeGradient.factor1 : lifeTimeGradient.factor, lifeTimeGradient.factor2);
  106131. }
  106132. }
  106133. if (parsedParticleSystem.limitVelocityGradients) {
  106134. for (var _z = 0, _0 = parsedParticleSystem.limitVelocityGradients; _z < _0.length; _z++) {
  106135. var limitVelocityGradient = _0[_z];
  106136. particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
  106137. }
  106138. particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
  106139. }
  106140. if (parsedParticleSystem.noiseTexture) {
  106141. particleSystem.noiseTexture = _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__["ProceduralTexture"].Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);
  106142. }
  106143. // Emitter
  106144. var emitterType;
  106145. if (parsedParticleSystem.particleEmitterType) {
  106146. switch (parsedParticleSystem.particleEmitterType.type) {
  106147. case "SphereParticleEmitter":
  106148. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["SphereParticleEmitter"]();
  106149. break;
  106150. case "SphereDirectedParticleEmitter":
  106151. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["SphereDirectedParticleEmitter"]();
  106152. break;
  106153. case "ConeEmitter":
  106154. case "ConeParticleEmitter":
  106155. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["ConeParticleEmitter"]();
  106156. break;
  106157. case "CylinderParticleEmitter":
  106158. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["CylinderParticleEmitter"]();
  106159. break;
  106160. case "HemisphericParticleEmitter":
  106161. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["HemisphericParticleEmitter"]();
  106162. break;
  106163. case "BoxEmitter":
  106164. case "BoxParticleEmitter":
  106165. default:
  106166. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["BoxParticleEmitter"]();
  106167. break;
  106168. }
  106169. emitterType.parse(parsedParticleSystem.particleEmitterType);
  106170. }
  106171. else {
  106172. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_15__["BoxParticleEmitter"]();
  106173. emitterType.parse(parsedParticleSystem);
  106174. }
  106175. particleSystem.particleEmitterType = emitterType;
  106176. // Animation sheet
  106177. particleSystem.startSpriteCellID = parsedParticleSystem.startSpriteCellID;
  106178. particleSystem.endSpriteCellID = parsedParticleSystem.endSpriteCellID;
  106179. particleSystem.spriteCellWidth = parsedParticleSystem.spriteCellWidth;
  106180. particleSystem.spriteCellHeight = parsedParticleSystem.spriteCellHeight;
  106181. particleSystem.spriteCellChangeSpeed = parsedParticleSystem.spriteCellChangeSpeed;
  106182. particleSystem.spriteRandomStartCell = parsedParticleSystem.spriteRandomStartCell;
  106183. };
  106184. /**
  106185. * Parses a JSON object to create a particle system.
  106186. * @param parsedParticleSystem The JSON object to parse
  106187. * @param scene The scene to create the particle system in
  106188. * @param rootUrl The root url to use to load external dependencies like texture
  106189. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  106190. * @returns the Parsed particle system
  106191. */
  106192. ParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  106193. if (doNotStart === void 0) { doNotStart = false; }
  106194. var name = parsedParticleSystem.name;
  106195. var custom = null;
  106196. var program = null;
  106197. if (parsedParticleSystem.customShader) {
  106198. program = parsedParticleSystem.customShader;
  106199. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  106200. custom = scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  106201. }
  106202. var particleSystem = new ParticleSystem(name, parsedParticleSystem.capacity, scene, custom, parsedParticleSystem.isAnimationSheetEnabled);
  106203. particleSystem.customShader = program;
  106204. if (parsedParticleSystem.id) {
  106205. particleSystem.id = parsedParticleSystem.id;
  106206. }
  106207. // SubEmitters
  106208. if (parsedParticleSystem.subEmitters) {
  106209. particleSystem.subEmitters = [];
  106210. for (var _i = 0, _a = parsedParticleSystem.subEmitters; _i < _a.length; _i++) {
  106211. var cell = _a[_i];
  106212. var cellArray = [];
  106213. for (var _b = 0, cell_1 = cell; _b < cell_1.length; _b++) {
  106214. var sub = cell_1[_b];
  106215. cellArray.push(_subEmitter__WEBPACK_IMPORTED_MODULE_18__["SubEmitter"].Parse(sub, scene, rootUrl));
  106216. }
  106217. particleSystem.subEmitters.push(cellArray);
  106218. }
  106219. }
  106220. ParticleSystem._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  106221. particleSystem.textureMask = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.textureMask);
  106222. // Auto start
  106223. if (parsedParticleSystem.preventAutoStart) {
  106224. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  106225. }
  106226. if (!doNotStart && !particleSystem.preventAutoStart) {
  106227. particleSystem.start();
  106228. }
  106229. return particleSystem;
  106230. };
  106231. /**
  106232. * Billboard mode will only apply to Y axis
  106233. */
  106234. ParticleSystem.BILLBOARDMODE_Y = _Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].PARTICLES_BILLBOARDMODE_Y;
  106235. /**
  106236. * Billboard mode will apply to all axes
  106237. */
  106238. ParticleSystem.BILLBOARDMODE_ALL = _Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  106239. /**
  106240. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  106241. */
  106242. ParticleSystem.BILLBOARDMODE_STRETCHED = _Engines_constants__WEBPACK_IMPORTED_MODULE_19__["Constants"].PARTICLES_BILLBOARDMODE_STRETCHED;
  106243. return ParticleSystem;
  106244. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_16__["BaseParticleSystem"]));
  106245. _subEmitter__WEBPACK_IMPORTED_MODULE_18__["SubEmitter"]._ParseParticleSystem = ParticleSystem.Parse;
  106246. /***/ }),
  106247. /***/ "./Particles/particleSystemComponent.ts":
  106248. /*!**********************************************!*\
  106249. !*** ./Particles/particleSystemComponent.ts ***!
  106250. \**********************************************/
  106251. /*! exports provided: _IDoNeedToBeInTheBuild */
  106252. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106253. "use strict";
  106254. __webpack_require__.r(__webpack_exports__);
  106255. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _IDoNeedToBeInTheBuild; });
  106256. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  106257. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  106258. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  106259. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  106260. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  106261. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  106262. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  106263. // Adds the parsers to the scene parsers.
  106264. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedData, scene, container, rootUrl) {
  106265. var individualParser = _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  106266. if (!individualParser) {
  106267. return;
  106268. }
  106269. // Particles Systems
  106270. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  106271. for (var index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  106272. var parsedParticleSystem = parsedData.particleSystems[index];
  106273. container.particleSystems.push(individualParser(parsedParticleSystem, scene, rootUrl));
  106274. }
  106275. }
  106276. });
  106277. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedParticleSystem, scene, rootUrl) {
  106278. if (parsedParticleSystem.activeParticleCount) {
  106279. var ps = _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__["GPUParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  106280. return ps;
  106281. }
  106282. else {
  106283. var ps = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  106284. return ps;
  106285. }
  106286. });
  106287. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createEffectForParticles = function (fragmentName, uniformsNames, samplers, defines, fallbacks, onCompiled, onError) {
  106288. if (uniformsNames === void 0) { uniformsNames = []; }
  106289. if (samplers === void 0) { samplers = []; }
  106290. if (defines === void 0) { defines = ""; }
  106291. var attributesNamesOrOptions = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetAttributeNamesOrOptions();
  106292. var effectCreationOption = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetEffectCreationOptions();
  106293. if (defines.indexOf(" BILLBOARD") === -1) {
  106294. defines += "\n#define BILLBOARD\n";
  106295. }
  106296. if (samplers.indexOf("diffuseSampler") === -1) {
  106297. samplers.push("diffuseSampler");
  106298. }
  106299. return this.createEffect({
  106300. vertex: "particles",
  106301. fragmentElement: fragmentName
  106302. }, attributesNamesOrOptions, effectCreationOption.concat(uniformsNames), samplers, defines, fallbacks, onCompiled, onError);
  106303. };
  106304. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getEmittedParticleSystems = function () {
  106305. var results = new Array();
  106306. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  106307. var particleSystem = this.getScene().particleSystems[index];
  106308. if (particleSystem.emitter === this) {
  106309. results.push(particleSystem);
  106310. }
  106311. }
  106312. return results;
  106313. };
  106314. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getHierarchyEmittedParticleSystems = function () {
  106315. var results = new Array();
  106316. var descendants = this.getDescendants();
  106317. descendants.push(this);
  106318. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  106319. var particleSystem = this.getScene().particleSystems[index];
  106320. var emitter = particleSystem.emitter;
  106321. if (emitter.position && descendants.indexOf(emitter) !== -1) {
  106322. results.push(particleSystem);
  106323. }
  106324. }
  106325. return results;
  106326. };
  106327. /**
  106328. * @hidden
  106329. */
  106330. var _IDoNeedToBeInTheBuild = 42;
  106331. /***/ }),
  106332. /***/ "./Particles/particleSystemSet.ts":
  106333. /*!****************************************!*\
  106334. !*** ./Particles/particleSystemSet.ts ***!
  106335. \****************************************/
  106336. /*! exports provided: ParticleSystemSet */
  106337. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106338. "use strict";
  106339. __webpack_require__.r(__webpack_exports__);
  106340. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return ParticleSystemSet; });
  106341. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  106342. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  106343. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  106344. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  106345. /* harmony import */ var _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Particles/particleSystem */ "./Particles/particleSystem.ts");
  106346. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  106347. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  106348. /** Internal class used to store shapes for emitters */
  106349. var ParticleSystemSetEmitterCreationOptions = /** @class */ (function () {
  106350. function ParticleSystemSetEmitterCreationOptions() {
  106351. }
  106352. return ParticleSystemSetEmitterCreationOptions;
  106353. }());
  106354. /**
  106355. * Represents a set of particle systems working together to create a specific effect
  106356. */
  106357. var ParticleSystemSet = /** @class */ (function () {
  106358. function ParticleSystemSet() {
  106359. /**
  106360. * Gets the particle system list
  106361. */
  106362. this.systems = new Array();
  106363. }
  106364. Object.defineProperty(ParticleSystemSet.prototype, "emitterNode", {
  106365. /**
  106366. * Gets the emitter node used with this set
  106367. */
  106368. get: function () {
  106369. return this._emitterNode;
  106370. },
  106371. enumerable: true,
  106372. configurable: true
  106373. });
  106374. /**
  106375. * Creates a new emitter mesh as a sphere
  106376. * @param options defines the options used to create the sphere
  106377. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  106378. * @param scene defines the hosting scene
  106379. */
  106380. ParticleSystemSet.prototype.setEmitterAsSphere = function (options, renderingGroupId, scene) {
  106381. if (this._emitterNode) {
  106382. this._emitterNode.dispose();
  106383. }
  106384. this._emitterCreationOptions = {
  106385. kind: "Sphere",
  106386. options: options,
  106387. renderingGroupId: renderingGroupId
  106388. };
  106389. var emitterMesh = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_1__["MeshBuilder"].CreateSphere("emitterSphere", { diameter: options.diameter, segments: options.segments }, scene);
  106390. emitterMesh.renderingGroupId = renderingGroupId;
  106391. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("emitterSphereMaterial", scene);
  106392. material.emissiveColor = options.color;
  106393. emitterMesh.material = material;
  106394. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  106395. var system = _a[_i];
  106396. system.emitter = emitterMesh;
  106397. }
  106398. this._emitterNode = emitterMesh;
  106399. };
  106400. /**
  106401. * Starts all particle systems of the set
  106402. * @param emitter defines an optional mesh to use as emitter for the particle systems
  106403. */
  106404. ParticleSystemSet.prototype.start = function (emitter) {
  106405. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  106406. var system = _a[_i];
  106407. if (emitter) {
  106408. system.emitter = emitter;
  106409. }
  106410. system.start();
  106411. }
  106412. };
  106413. /**
  106414. * Release all associated resources
  106415. */
  106416. ParticleSystemSet.prototype.dispose = function () {
  106417. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  106418. var system = _a[_i];
  106419. system.dispose();
  106420. }
  106421. this.systems = [];
  106422. if (this._emitterNode) {
  106423. this._emitterNode.dispose();
  106424. this._emitterNode = null;
  106425. }
  106426. };
  106427. /**
  106428. * Serialize the set into a JSON compatible object
  106429. * @returns a JSON compatible representation of the set
  106430. */
  106431. ParticleSystemSet.prototype.serialize = function () {
  106432. var result = {};
  106433. result.systems = [];
  106434. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  106435. var system = _a[_i];
  106436. result.systems.push(system.serialize());
  106437. }
  106438. if (this._emitterNode) {
  106439. result.emitter = this._emitterCreationOptions;
  106440. }
  106441. return result;
  106442. };
  106443. /**
  106444. * Parse a new ParticleSystemSet from a serialized source
  106445. * @param data defines a JSON compatible representation of the set
  106446. * @param scene defines the hosting scene
  106447. * @param gpu defines if we want GPU particles or CPU particles
  106448. * @returns a new ParticleSystemSet
  106449. */
  106450. ParticleSystemSet.Parse = function (data, scene, gpu) {
  106451. if (gpu === void 0) { gpu = false; }
  106452. var result = new ParticleSystemSet();
  106453. var rootUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].PARTICLES_BaseAssetsUrl + "/textures/";
  106454. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  106455. for (var _i = 0, _a = data.systems; _i < _a.length; _i++) {
  106456. var system = _a[_i];
  106457. 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));
  106458. }
  106459. if (data.emitter) {
  106460. var options = data.emitter.options;
  106461. switch (data.emitter.kind) {
  106462. case "Sphere":
  106463. result.setEmitterAsSphere({
  106464. diameter: options.diameter,
  106465. segments: options.segments,
  106466. color: _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(options.color)
  106467. }, data.emitter.renderingGroupId, scene);
  106468. break;
  106469. }
  106470. }
  106471. return result;
  106472. };
  106473. return ParticleSystemSet;
  106474. }());
  106475. /***/ }),
  106476. /***/ "./Particles/solidParticle.ts":
  106477. /*!************************************!*\
  106478. !*** ./Particles/solidParticle.ts ***!
  106479. \************************************/
  106480. /*! exports provided: SolidParticle, ModelShape, DepthSortedParticle */
  106481. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106482. "use strict";
  106483. __webpack_require__.r(__webpack_exports__);
  106484. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return SolidParticle; });
  106485. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return ModelShape; });
  106486. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return DepthSortedParticle; });
  106487. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  106488. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  106489. /* harmony import */ var _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/boundingSphere */ "./Culling/boundingSphere.ts");
  106490. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  106491. /**
  106492. * Represents one particle of a solid particle system.
  106493. */
  106494. var SolidParticle = /** @class */ (function () {
  106495. /**
  106496. * Creates a Solid Particle object.
  106497. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  106498. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  106499. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  106500. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  106501. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  106502. * @param shapeId (integer) is the model shape identifier in the SPS.
  106503. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  106504. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  106505. */
  106506. function SolidParticle(particleIndex, positionIndex, indiceIndex, model, shapeId, idxInShape, sps, modelBoundingInfo) {
  106507. if (modelBoundingInfo === void 0) { modelBoundingInfo = null; }
  106508. /**
  106509. * particle global index
  106510. */
  106511. this.idx = 0;
  106512. /**
  106513. * The color of the particle
  106514. */
  106515. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  106516. /**
  106517. * The world space position of the particle.
  106518. */
  106519. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106520. /**
  106521. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  106522. */
  106523. this.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106524. /**
  106525. * The scaling of the particle.
  106526. */
  106527. this.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  106528. /**
  106529. * The uvs of the particle.
  106530. */
  106531. this.uvs = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  106532. /**
  106533. * The current speed of the particle.
  106534. */
  106535. this.velocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106536. /**
  106537. * The pivot point in the particle local space.
  106538. */
  106539. this.pivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106540. /**
  106541. * Must the particle be translated from its pivot point in its local space ?
  106542. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  106543. * Default : false
  106544. */
  106545. this.translateFromPivot = false;
  106546. /**
  106547. * Is the particle active or not ?
  106548. */
  106549. this.alive = true;
  106550. /**
  106551. * Is the particle visible or not ?
  106552. */
  106553. this.isVisible = true;
  106554. /**
  106555. * Index of this particle in the global "positions" array (Internal use)
  106556. * @hidden
  106557. */
  106558. this._pos = 0;
  106559. /**
  106560. * @hidden Index of this particle in the global "indices" array (Internal use)
  106561. */
  106562. this._ind = 0;
  106563. /**
  106564. * ModelShape id of this particle
  106565. */
  106566. this.shapeId = 0;
  106567. /**
  106568. * Index of the particle in its shape id (Internal use)
  106569. */
  106570. this.idxInShape = 0;
  106571. /**
  106572. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  106573. */
  106574. this._stillInvisible = false;
  106575. /**
  106576. * @hidden Last computed particle rotation matrix
  106577. */
  106578. this._rotationMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];
  106579. /**
  106580. * Parent particle Id, if any.
  106581. * Default null.
  106582. */
  106583. this.parentId = null;
  106584. /**
  106585. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  106586. * The possible values are :
  106587. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  106588. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  106589. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  106590. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  106591. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  106592. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  106593. * */
  106594. this.cullingStrategy = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"].CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  106595. /**
  106596. * @hidden Internal global position in the SPS.
  106597. */
  106598. this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106599. this.idx = particleIndex;
  106600. this._pos = positionIndex;
  106601. this._ind = indiceIndex;
  106602. this._model = model;
  106603. this.shapeId = shapeId;
  106604. this.idxInShape = idxInShape;
  106605. this._sps = sps;
  106606. if (modelBoundingInfo) {
  106607. this._modelBoundingInfo = modelBoundingInfo;
  106608. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"](modelBoundingInfo.minimum, modelBoundingInfo.maximum);
  106609. }
  106610. }
  106611. Object.defineProperty(SolidParticle.prototype, "scale", {
  106612. /**
  106613. * Legacy support, changed scale to scaling
  106614. */
  106615. get: function () {
  106616. return this.scaling;
  106617. },
  106618. /**
  106619. * Legacy support, changed scale to scaling
  106620. */
  106621. set: function (scale) {
  106622. this.scaling = scale;
  106623. },
  106624. enumerable: true,
  106625. configurable: true
  106626. });
  106627. Object.defineProperty(SolidParticle.prototype, "quaternion", {
  106628. /**
  106629. * Legacy support, changed quaternion to rotationQuaternion
  106630. */
  106631. get: function () {
  106632. return this.rotationQuaternion;
  106633. },
  106634. /**
  106635. * Legacy support, changed quaternion to rotationQuaternion
  106636. */
  106637. set: function (q) {
  106638. this.rotationQuaternion = q;
  106639. },
  106640. enumerable: true,
  106641. configurable: true
  106642. });
  106643. /**
  106644. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  106645. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  106646. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  106647. * @returns true if it intersects
  106648. */
  106649. SolidParticle.prototype.intersectsMesh = function (target) {
  106650. if (!this._boundingInfo || !target._boundingInfo) {
  106651. return false;
  106652. }
  106653. if (this._sps._bSphereOnly) {
  106654. return _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"].Intersects(this._boundingInfo.boundingSphere, target._boundingInfo.boundingSphere);
  106655. }
  106656. return this._boundingInfo.intersects(target._boundingInfo, false);
  106657. };
  106658. /**
  106659. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  106660. * A particle is in the frustum if its bounding box intersects the frustum
  106661. * @param frustumPlanes defines the frustum to test
  106662. * @returns true if the particle is in the frustum planes
  106663. */
  106664. SolidParticle.prototype.isInFrustum = function (frustumPlanes) {
  106665. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  106666. };
  106667. /**
  106668. * get the rotation matrix of the particle
  106669. * @hidden
  106670. */
  106671. SolidParticle.prototype.getRotationMatrix = function (m) {
  106672. var quaternion;
  106673. if (this.rotationQuaternion) {
  106674. quaternion = this.rotationQuaternion;
  106675. }
  106676. else {
  106677. quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  106678. var rotation = this.rotation;
  106679. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  106680. }
  106681. quaternion.toRotationMatrix(m);
  106682. };
  106683. return SolidParticle;
  106684. }());
  106685. /**
  106686. * Represents the shape of the model used by one particle of a solid particle system.
  106687. * SPS internal tool, don't use it manually.
  106688. */
  106689. var ModelShape = /** @class */ (function () {
  106690. /**
  106691. * 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.
  106692. * SPS internal tool, don't use it manually.
  106693. * @hidden
  106694. */
  106695. function ModelShape(id, shape, indicesLength, shapeUV, posFunction, vtxFunction) {
  106696. /**
  106697. * length of the shape in the model indices array (internal use)
  106698. * @hidden
  106699. */
  106700. this._indicesLength = 0;
  106701. this.shapeID = id;
  106702. this._shape = shape;
  106703. this._indicesLength = indicesLength;
  106704. this._shapeUV = shapeUV;
  106705. this._positionFunction = posFunction;
  106706. this._vertexFunction = vtxFunction;
  106707. }
  106708. return ModelShape;
  106709. }());
  106710. /**
  106711. * Represents a Depth Sorted Particle in the solid particle system.
  106712. */
  106713. var DepthSortedParticle = /** @class */ (function () {
  106714. function DepthSortedParticle() {
  106715. /**
  106716. * Index of the particle in the "indices" array
  106717. */
  106718. this.ind = 0;
  106719. /**
  106720. * Length of the particle shape in the "indices" array
  106721. */
  106722. this.indicesLength = 0;
  106723. /**
  106724. * Squared distance from the particle to the camera
  106725. */
  106726. this.sqDistance = 0.0;
  106727. }
  106728. return DepthSortedParticle;
  106729. }());
  106730. /***/ }),
  106731. /***/ "./Particles/solidParticleSystem.ts":
  106732. /*!******************************************!*\
  106733. !*** ./Particles/solidParticleSystem.ts ***!
  106734. \******************************************/
  106735. /*! exports provided: SolidParticleSystem */
  106736. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106737. "use strict";
  106738. __webpack_require__.r(__webpack_exports__);
  106739. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return SolidParticleSystem; });
  106740. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  106741. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  106742. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  106743. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  106744. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  106745. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  106746. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  106747. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  106748. var depthSortFunction = function (p1, p2) { return p2.sqDistance - p1.sqDistance; };
  106749. /**
  106750. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  106751. *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.
  106752. * The SPS is also a particle system. It provides some methods to manage the particles.
  106753. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  106754. *
  106755. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  106756. */
  106757. var SolidParticleSystem = /** @class */ (function () {
  106758. /**
  106759. * Creates a SPS (Solid Particle System) object.
  106760. * @param name (String) is the SPS name, this will be the underlying mesh name.
  106761. * @param scene (Scene) is the scene in which the SPS is added.
  106762. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  106763. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  106764. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  106765. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  106766. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  106767. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  106768. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  106769. */
  106770. function SolidParticleSystem(name, scene, options) {
  106771. /**
  106772. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  106773. * Example : var p = SPS.particles[i];
  106774. */
  106775. this.particles = new Array();
  106776. /**
  106777. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  106778. */
  106779. this.nbParticles = 0;
  106780. /**
  106781. * If the particles must ever face the camera (default false). Useful for planar particles.
  106782. */
  106783. this.billboard = false;
  106784. /**
  106785. * Recompute normals when adding a shape
  106786. */
  106787. this.recomputeNormals = true;
  106788. /**
  106789. * This a counter ofr your own usage. It's not set by any SPS functions.
  106790. */
  106791. this.counter = 0;
  106792. /**
  106793. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  106794. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  106795. */
  106796. this.vars = {};
  106797. /**
  106798. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  106799. * @hidden
  106800. */
  106801. this._bSphereOnly = false;
  106802. /**
  106803. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  106804. * @hidden
  106805. */
  106806. this._bSphereRadiusFactor = 1.0;
  106807. this._positions = new Array();
  106808. this._indices = new Array();
  106809. this._normals = new Array();
  106810. this._colors = new Array();
  106811. this._uvs = new Array();
  106812. this._index = 0; // indices index
  106813. this._updatable = true;
  106814. this._pickable = false;
  106815. this._isVisibilityBoxLocked = false;
  106816. this._alwaysVisible = false;
  106817. this._depthSort = false;
  106818. this._shapeCounter = 0;
  106819. this._copy = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](0, 0, 0, null, 0, 0, this);
  106820. this._color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  106821. this._computeParticleColor = true;
  106822. this._computeParticleTexture = true;
  106823. this._computeParticleRotation = true;
  106824. this._computeParticleVertex = false;
  106825. this._computeBoundingBox = false;
  106826. this._depthSortParticles = true;
  106827. this._mustUnrotateFixedNormals = false;
  106828. this._particlesIntersect = false;
  106829. this._needs32Bits = false;
  106830. this.name = name;
  106831. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  106832. this._camera = scene.activeCamera;
  106833. this._pickable = options ? options.isPickable : false;
  106834. this._depthSort = options ? options.enableDepthSort : false;
  106835. this._particlesIntersect = options ? options.particleIntersection : false;
  106836. this._bSphereOnly = options ? options.boundingSphereOnly : false;
  106837. this._bSphereRadiusFactor = (options && options.bSphereRadiusFactor) ? options.bSphereRadiusFactor : 1.0;
  106838. if (options && options.updatable !== undefined) {
  106839. this._updatable = options.updatable;
  106840. }
  106841. else {
  106842. this._updatable = true;
  106843. }
  106844. if (this._pickable) {
  106845. this.pickedParticles = [];
  106846. }
  106847. if (this._depthSort) {
  106848. this.depthSortedParticles = [];
  106849. }
  106850. }
  106851. /**
  106852. * Builds the SPS underlying mesh. Returns a standard Mesh.
  106853. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  106854. * @returns the created mesh
  106855. */
  106856. SolidParticleSystem.prototype.buildMesh = function () {
  106857. if (this.nbParticles === 0) {
  106858. var triangle = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_4__["MeshBuilder"].CreateDisc("", { radius: 1, tessellation: 3 }, this._scene);
  106859. this.addShape(triangle, 1);
  106860. triangle.dispose();
  106861. }
  106862. this._indices32 = (this._needs32Bits) ? new Uint32Array(this._indices) : new Uint16Array(this._indices);
  106863. this._positions32 = new Float32Array(this._positions);
  106864. this._uvs32 = new Float32Array(this._uvs);
  106865. this._colors32 = new Float32Array(this._colors);
  106866. if (this.recomputeNormals) {
  106867. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(this._positions32, this._indices32, this._normals);
  106868. }
  106869. this._normals32 = new Float32Array(this._normals);
  106870. this._fixedNormal32 = new Float32Array(this._normals);
  106871. if (this._mustUnrotateFixedNormals) { // the particles could be created already rotated in the mesh with a positionFunction
  106872. this._unrotateFixedNormals();
  106873. }
  106874. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  106875. vertexData.indices = (this._depthSort) ? this._indices : this._indices32;
  106876. vertexData.set(this._positions32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  106877. vertexData.set(this._normals32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  106878. if (this._uvs32.length > 0) {
  106879. vertexData.set(this._uvs32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  106880. }
  106881. if (this._colors32.length > 0) {
  106882. vertexData.set(this._colors32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  106883. }
  106884. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this.name, this._scene);
  106885. vertexData.applyToMesh(mesh, this._updatable);
  106886. this.mesh = mesh;
  106887. this.mesh.isPickable = this._pickable;
  106888. // free memory
  106889. if (!this._depthSort) {
  106890. this._indices = null;
  106891. }
  106892. this._positions = null;
  106893. this._normals = null;
  106894. this._uvs = null;
  106895. this._colors = null;
  106896. if (!this._updatable) {
  106897. this.particles.length = 0;
  106898. }
  106899. return mesh;
  106900. };
  106901. /**
  106902. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  106903. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  106904. * Thus the particles generated from `digest()` have their property `position` set yet.
  106905. * @param mesh ( Mesh ) is the mesh to be digested
  106906. * @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
  106907. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  106908. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  106909. * @returns the current SPS
  106910. */
  106911. SolidParticleSystem.prototype.digest = function (mesh, options) {
  106912. var size = (options && options.facetNb) || 1;
  106913. var number = (options && options.number) || 0;
  106914. var delta = (options && options.delta) || 0;
  106915. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  106916. var meshInd = mesh.getIndices();
  106917. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  106918. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  106919. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  106920. var f = 0; // facet counter
  106921. var totalFacets = meshInd.length / 3; // a facet is a triangle, so 3 indices
  106922. // compute size from number
  106923. if (number) {
  106924. number = (number > totalFacets) ? totalFacets : number;
  106925. size = Math.round(totalFacets / number);
  106926. delta = 0;
  106927. }
  106928. else {
  106929. size = (size > totalFacets) ? totalFacets : size;
  106930. }
  106931. var facetPos = []; // submesh positions
  106932. var facetInd = []; // submesh indices
  106933. var facetUV = []; // submesh UV
  106934. var facetCol = []; // submesh colors
  106935. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  106936. var sizeO = size;
  106937. while (f < totalFacets) {
  106938. size = sizeO + Math.floor((1 + delta) * Math.random());
  106939. if (f > totalFacets - size) {
  106940. size = totalFacets - f;
  106941. }
  106942. // reset temp arrays
  106943. facetPos.length = 0;
  106944. facetInd.length = 0;
  106945. facetUV.length = 0;
  106946. facetCol.length = 0;
  106947. // iterate over "size" facets
  106948. var fi = 0;
  106949. for (var j = f * 3; j < (f + size) * 3; j++) {
  106950. facetInd.push(fi);
  106951. var i = meshInd[j];
  106952. facetPos.push(meshPos[i * 3], meshPos[i * 3 + 1], meshPos[i * 3 + 2]);
  106953. if (meshUV) {
  106954. facetUV.push(meshUV[i * 2], meshUV[i * 2 + 1]);
  106955. }
  106956. if (meshCol) {
  106957. facetCol.push(meshCol[i * 4], meshCol[i * 4 + 1], meshCol[i * 4 + 2], meshCol[i * 4 + 3]);
  106958. }
  106959. fi++;
  106960. }
  106961. // create a model shape for each single particle
  106962. var idx = this.nbParticles;
  106963. var shape = this._posToShape(facetPos);
  106964. var shapeUV = this._uvsToShapeUV(facetUV);
  106965. // compute the barycenter of the shape
  106966. var v;
  106967. for (v = 0; v < shape.length; v++) {
  106968. barycenter.addInPlace(shape[v]);
  106969. }
  106970. barycenter.scaleInPlace(1 / shape.length);
  106971. // shift the shape from its barycenter to the origin
  106972. for (v = 0; v < shape.length; v++) {
  106973. shape[v].subtractInPlace(barycenter);
  106974. }
  106975. var bInfo;
  106976. if (this._particlesIntersect) {
  106977. bInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](barycenter, barycenter);
  106978. }
  106979. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, size * 3, shapeUV, null, null);
  106980. // add the particle in the SPS
  106981. var currentPos = this._positions.length;
  106982. var currentInd = this._indices.length;
  106983. this._meshBuilder(this._index, shape, this._positions, facetInd, this._indices, facetUV, this._uvs, facetCol, this._colors, meshNor, this._normals, idx, 0, null);
  106984. this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, 0, bInfo);
  106985. // initialize the particle position
  106986. this.particles[this.nbParticles].position.addInPlace(barycenter);
  106987. this._index += shape.length;
  106988. idx++;
  106989. this.nbParticles++;
  106990. this._shapeCounter++;
  106991. f += size;
  106992. }
  106993. return this;
  106994. };
  106995. // unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  106996. SolidParticleSystem.prototype._unrotateFixedNormals = function () {
  106997. var index = 0;
  106998. var idx = 0;
  106999. var tmpNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  107000. var quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  107001. var invertedRotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  107002. for (var p = 0; p < this.particles.length; p++) {
  107003. var particle = this.particles[p];
  107004. var shape = particle._model._shape;
  107005. // computing the inverse of the rotation matrix from the quaternion
  107006. // is equivalent to computing the matrix of the inverse quaternion, i.e of the conjugate quaternion
  107007. if (particle.rotationQuaternion) {
  107008. particle.rotationQuaternion.conjugateToRef(quaternion);
  107009. }
  107010. else {
  107011. var rotation = particle.rotation;
  107012. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  107013. quaternion.conjugateInPlace();
  107014. }
  107015. quaternion.toRotationMatrix(invertedRotMatrix);
  107016. for (var pt = 0; pt < shape.length; pt++) {
  107017. idx = index + pt * 3;
  107018. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(this._normals32[idx], this._normals32[idx + 1], this._normals32[idx + 2], invertedRotMatrix, tmpNormal);
  107019. tmpNormal.toArray(this._fixedNormal32, idx);
  107020. }
  107021. index = idx + 3;
  107022. }
  107023. };
  107024. //reset copy
  107025. SolidParticleSystem.prototype._resetCopy = function () {
  107026. var copy = this._copy;
  107027. copy.position.setAll(0);
  107028. copy.rotation.setAll(0);
  107029. copy.rotationQuaternion = null;
  107030. copy.scaling.setAll(1);
  107031. copy.uvs.copyFromFloats(0.0, 0.0, 1.0, 1.0);
  107032. copy.color = null;
  107033. copy.translateFromPivot = false;
  107034. };
  107035. // _meshBuilder : inserts the shape model in the global SPS mesh
  107036. SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options) {
  107037. var i;
  107038. var u = 0;
  107039. var c = 0;
  107040. var n = 0;
  107041. this._resetCopy();
  107042. var copy = this._copy;
  107043. if (options && options.positionFunction) { // call to custom positionFunction
  107044. options.positionFunction(copy, idx, idxInShape);
  107045. this._mustUnrotateFixedNormals = true;
  107046. }
  107047. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  107048. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  107049. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  107050. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  107051. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  107052. copy.getRotationMatrix(rotMatrix);
  107053. copy.pivot.multiplyToRef(copy.scaling, scaledPivot);
  107054. if (copy.translateFromPivot) {
  107055. pivotBackTranslation.setAll(0.0);
  107056. }
  107057. else {
  107058. pivotBackTranslation.copyFrom(scaledPivot);
  107059. }
  107060. for (i = 0; i < shape.length; i++) {
  107061. tmpVertex.copyFrom(shape[i]);
  107062. if (options && options.vertexFunction) {
  107063. options.vertexFunction(copy, tmpVertex, i);
  107064. }
  107065. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  107066. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  107067. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position);
  107068. positions.push(tmpRotated.x, tmpRotated.y, tmpRotated.z);
  107069. if (meshUV) {
  107070. var copyUvs = copy.uvs;
  107071. uvs.push((copyUvs.z - copyUvs.x) * meshUV[u] + copyUvs.x, (copyUvs.w - copyUvs.y) * meshUV[u + 1] + copyUvs.y);
  107072. u += 2;
  107073. }
  107074. if (copy.color) {
  107075. this._color = copy.color;
  107076. }
  107077. else {
  107078. var color = this._color;
  107079. if (meshCol && meshCol[c] !== undefined) {
  107080. color.r = meshCol[c];
  107081. color.g = meshCol[c + 1];
  107082. color.b = meshCol[c + 2];
  107083. color.a = meshCol[c + 3];
  107084. }
  107085. else {
  107086. color.r = 1.0;
  107087. color.g = 1.0;
  107088. color.b = 1.0;
  107089. color.a = 1.0;
  107090. }
  107091. }
  107092. colors.push(this._color.r, this._color.g, this._color.b, this._color.a);
  107093. c += 4;
  107094. if (!this.recomputeNormals && meshNor) {
  107095. tmpVertex.x = meshNor[n];
  107096. tmpVertex.y = meshNor[n + 1];
  107097. tmpVertex.z = meshNor[n + 2];
  107098. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, rotMatrix, tmpVertex);
  107099. normals.push(tmpVertex.x, tmpVertex.y, tmpVertex.z);
  107100. n += 3;
  107101. }
  107102. }
  107103. for (i = 0; i < meshInd.length; i++) {
  107104. var current_ind = p + meshInd[i];
  107105. indices.push(current_ind);
  107106. if (current_ind > 65535) {
  107107. this._needs32Bits = true;
  107108. }
  107109. }
  107110. if (this._pickable) {
  107111. var nbfaces = meshInd.length / 3;
  107112. for (i = 0; i < nbfaces; i++) {
  107113. this.pickedParticles.push({ idx: idx, faceId: i });
  107114. }
  107115. }
  107116. if (this._depthSort) {
  107117. this.depthSortedParticles.push(new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["DepthSortedParticle"]());
  107118. }
  107119. return copy;
  107120. };
  107121. // returns a shape array from positions array
  107122. SolidParticleSystem.prototype._posToShape = function (positions) {
  107123. var shape = [];
  107124. for (var i = 0; i < positions.length; i += 3) {
  107125. shape.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, i));
  107126. }
  107127. return shape;
  107128. };
  107129. // returns a shapeUV array from a Vector4 uvs
  107130. SolidParticleSystem.prototype._uvsToShapeUV = function (uvs) {
  107131. var shapeUV = [];
  107132. if (uvs) {
  107133. for (var i = 0; i < uvs.length; i++) {
  107134. shapeUV.push(uvs[i]);
  107135. }
  107136. }
  107137. return shapeUV;
  107138. };
  107139. // adds a new particle object in the particles array
  107140. SolidParticleSystem.prototype._addParticle = function (idx, idxpos, idxind, model, shapeId, idxInShape, bInfo) {
  107141. if (bInfo === void 0) { bInfo = null; }
  107142. var sp = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](idx, idxpos, idxind, model, shapeId, idxInShape, this, bInfo);
  107143. this.particles.push(sp);
  107144. return sp;
  107145. };
  107146. /**
  107147. * Adds some particles to the SPS from the model shape. Returns the shape id.
  107148. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  107149. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  107150. * @param nb (positive integer) the number of particles to be created from this model
  107151. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  107152. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  107153. * @returns the number of shapes in the system
  107154. */
  107155. SolidParticleSystem.prototype.addShape = function (mesh, nb, options) {
  107156. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  107157. var meshInd = mesh.getIndices();
  107158. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  107159. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  107160. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  107161. var bbInfo;
  107162. if (this._particlesIntersect) {
  107163. bbInfo = mesh.getBoundingInfo();
  107164. }
  107165. var shape = this._posToShape(meshPos);
  107166. var shapeUV = this._uvsToShapeUV(meshUV);
  107167. var posfunc = options ? options.positionFunction : null;
  107168. var vtxfunc = options ? options.vertexFunction : null;
  107169. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, meshInd.length, shapeUV, posfunc, vtxfunc);
  107170. // particles
  107171. var sp;
  107172. var currentCopy;
  107173. var idx = this.nbParticles;
  107174. for (var i = 0; i < nb; i++) {
  107175. var currentPos = this._positions.length;
  107176. var currentInd = this._indices.length;
  107177. currentCopy = this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, meshNor, this._normals, idx, i, options);
  107178. if (this._updatable) {
  107179. sp = this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, i, bbInfo);
  107180. sp.position.copyFrom(currentCopy.position);
  107181. sp.rotation.copyFrom(currentCopy.rotation);
  107182. if (currentCopy.rotationQuaternion && sp.rotationQuaternion) {
  107183. sp.rotationQuaternion.copyFrom(currentCopy.rotationQuaternion);
  107184. }
  107185. if (currentCopy.color && sp.color) {
  107186. sp.color.copyFrom(currentCopy.color);
  107187. }
  107188. sp.scaling.copyFrom(currentCopy.scaling);
  107189. sp.uvs.copyFrom(currentCopy.uvs);
  107190. }
  107191. this._index += shape.length;
  107192. idx++;
  107193. }
  107194. this.nbParticles += nb;
  107195. this._shapeCounter++;
  107196. return this._shapeCounter - 1;
  107197. };
  107198. // rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  107199. SolidParticleSystem.prototype._rebuildParticle = function (particle) {
  107200. this._resetCopy();
  107201. var copy = this._copy;
  107202. if (particle._model._positionFunction) { // recall to stored custom positionFunction
  107203. particle._model._positionFunction(copy, particle.idx, particle.idxInShape);
  107204. }
  107205. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  107206. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  107207. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  107208. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  107209. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  107210. copy.getRotationMatrix(rotMatrix);
  107211. particle.pivot.multiplyToRef(particle.scaling, scaledPivot);
  107212. if (copy.translateFromPivot) {
  107213. pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
  107214. }
  107215. else {
  107216. pivotBackTranslation.copyFrom(scaledPivot);
  107217. }
  107218. var shape = particle._model._shape;
  107219. for (var pt = 0; pt < shape.length; pt++) {
  107220. tmpVertex.copyFrom(shape[pt]);
  107221. if (particle._model._vertexFunction) {
  107222. particle._model._vertexFunction(copy, tmpVertex, pt); // recall to stored vertexFunction
  107223. }
  107224. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  107225. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  107226. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position).toArray(this._positions32, particle._pos + pt * 3);
  107227. }
  107228. particle.position.setAll(0.0);
  107229. particle.rotation.setAll(0.0);
  107230. particle.rotationQuaternion = null;
  107231. particle.scaling.setAll(1.0);
  107232. particle.uvs.setAll(0.0);
  107233. particle.pivot.setAll(0.0);
  107234. particle.translateFromPivot = false;
  107235. particle.parentId = null;
  107236. };
  107237. /**
  107238. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  107239. * @returns the SPS.
  107240. */
  107241. SolidParticleSystem.prototype.rebuildMesh = function () {
  107242. for (var p = 0; p < this.particles.length; p++) {
  107243. this._rebuildParticle(this.particles[p]);
  107244. }
  107245. this.mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this._positions32, false, false);
  107246. return this;
  107247. };
  107248. /**
  107249. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  107250. * This method calls `updateParticle()` for each particle of the SPS.
  107251. * For an animated SPS, it is usually called within the render loop.
  107252. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  107253. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  107254. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  107255. * @returns the SPS.
  107256. */
  107257. SolidParticleSystem.prototype.setParticles = function (start, end, update) {
  107258. if (start === void 0) { start = 0; }
  107259. if (end === void 0) { end = this.nbParticles - 1; }
  107260. if (update === void 0) { update = true; }
  107261. if (!this._updatable) {
  107262. return this;
  107263. }
  107264. // custom beforeUpdate
  107265. this.beforeUpdateParticles();
  107266. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  107267. var invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  107268. var mesh = this.mesh;
  107269. var colors32 = this._colors32;
  107270. var positions32 = this._positions32;
  107271. var normals32 = this._normals32;
  107272. var uvs32 = this._uvs32;
  107273. var indices32 = this._indices32;
  107274. var indices = this._indices;
  107275. var fixedNormal32 = this._fixedNormal32;
  107276. var tempVectors = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3;
  107277. var camAxisX = tempVectors[5].copyFromFloats(1.0, 0.0, 0.0);
  107278. var camAxisY = tempVectors[6].copyFromFloats(0.0, 1.0, 0.0);
  107279. var camAxisZ = tempVectors[7].copyFromFloats(0.0, 0.0, 1.0);
  107280. var minimum = tempVectors[8].setAll(Number.MAX_VALUE);
  107281. var maximum = tempVectors[9].setAll(-Number.MAX_VALUE);
  107282. var camInvertedPosition = tempVectors[10].setAll(0);
  107283. // cases when the World Matrix is to be computed first
  107284. if (this.billboard || this._depthSort) {
  107285. this.mesh.computeWorldMatrix(true);
  107286. this.mesh._worldMatrix.invertToRef(invertedMatrix);
  107287. }
  107288. // if the particles will always face the camera
  107289. if (this.billboard) {
  107290. // compute the camera position and un-rotate it by the current mesh rotation
  107291. var tmpVertex = tempVectors[0];
  107292. this._camera.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Z, tmpVertex);
  107293. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, invertedMatrix, camAxisZ);
  107294. camAxisZ.normalize();
  107295. // same for camera up vector extracted from the cam view matrix
  107296. var view = this._camera.getViewMatrix(true);
  107297. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], invertedMatrix, camAxisY);
  107298. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(camAxisY, camAxisZ, camAxisX);
  107299. camAxisY.normalize();
  107300. camAxisX.normalize();
  107301. }
  107302. // if depthSort, compute the camera global position in the mesh local system
  107303. if (this._depthSort) {
  107304. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._camera.globalPosition, invertedMatrix, camInvertedPosition); // then un-rotate the camera
  107305. }
  107306. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(rotMatrix);
  107307. var idx = 0; // current position index in the global array positions32
  107308. var index = 0; // position start index in the global array positions32 of the current particle
  107309. var colidx = 0; // current color index in the global array colors32
  107310. var colorIndex = 0; // color start index in the global array colors32 of the current particle
  107311. var uvidx = 0; // current uv index in the global array uvs32
  107312. var uvIndex = 0; // uv start index in the global array uvs32 of the current particle
  107313. var pt = 0; // current index in the particle model shape
  107314. if (this.mesh.isFacetDataEnabled) {
  107315. this._computeBoundingBox = true;
  107316. }
  107317. end = (end >= this.nbParticles) ? this.nbParticles - 1 : end;
  107318. if (this._computeBoundingBox) {
  107319. if (start != 0 || end != this.nbParticles - 1) { // only some particles are updated, then use the current existing BBox basis. Note : it can only increase.
  107320. var boundingInfo = this.mesh._boundingInfo;
  107321. if (boundingInfo) {
  107322. minimum.copyFrom(boundingInfo.minimum);
  107323. maximum.copyFrom(boundingInfo.maximum);
  107324. }
  107325. }
  107326. }
  107327. // particle loop
  107328. index = this.particles[start]._pos;
  107329. var vpos = (index / 3) | 0;
  107330. colorIndex = vpos * 4;
  107331. uvIndex = vpos * 2;
  107332. for (var p = start; p <= end; p++) {
  107333. var particle = this.particles[p];
  107334. // call to custom user function to update the particle properties
  107335. this.updateParticle(particle);
  107336. var shape = particle._model._shape;
  107337. var shapeUV = particle._model._shapeUV;
  107338. var particleRotationMatrix = particle._rotationMatrix;
  107339. var particlePosition = particle.position;
  107340. var particleRotation = particle.rotation;
  107341. var particleScaling = particle.scaling;
  107342. var particleGlobalPosition = particle._globalPosition;
  107343. // camera-particle distance for depth sorting
  107344. if (this._depthSort && this._depthSortParticles) {
  107345. var dsp = this.depthSortedParticles[p];
  107346. dsp.ind = particle._ind;
  107347. dsp.indicesLength = particle._model._indicesLength;
  107348. dsp.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(particle.position, camInvertedPosition);
  107349. }
  107350. // skip the computations for inactive or already invisible particles
  107351. if (!particle.alive || (particle._stillInvisible && !particle.isVisible)) {
  107352. // increment indexes for the next particle
  107353. pt = shape.length;
  107354. index += pt * 3;
  107355. colorIndex += pt * 4;
  107356. uvIndex += pt * 2;
  107357. continue;
  107358. }
  107359. if (particle.isVisible) {
  107360. particle._stillInvisible = false; // un-mark permanent invisibility
  107361. var scaledPivot = tempVectors[12];
  107362. particle.pivot.multiplyToRef(particleScaling, scaledPivot);
  107363. // particle rotation matrix
  107364. if (this.billboard) {
  107365. particleRotation.x = 0.0;
  107366. particleRotation.y = 0.0;
  107367. }
  107368. if (this._computeParticleRotation || this.billboard) {
  107369. particle.getRotationMatrix(rotMatrix);
  107370. }
  107371. var particleHasParent = (particle.parentId !== null);
  107372. if (particleHasParent) {
  107373. var parent_1 = this.particles[particle.parentId];
  107374. var parentRotationMatrix = parent_1._rotationMatrix;
  107375. var parentGlobalPosition = parent_1._globalPosition;
  107376. var rotatedY = particlePosition.x * parentRotationMatrix[1] + particlePosition.y * parentRotationMatrix[4] + particlePosition.z * parentRotationMatrix[7];
  107377. var rotatedX = particlePosition.x * parentRotationMatrix[0] + particlePosition.y * parentRotationMatrix[3] + particlePosition.z * parentRotationMatrix[6];
  107378. var rotatedZ = particlePosition.x * parentRotationMatrix[2] + particlePosition.y * parentRotationMatrix[5] + particlePosition.z * parentRotationMatrix[8];
  107379. particleGlobalPosition.x = parentGlobalPosition.x + rotatedX;
  107380. particleGlobalPosition.y = parentGlobalPosition.y + rotatedY;
  107381. particleGlobalPosition.z = parentGlobalPosition.z + rotatedZ;
  107382. if (this._computeParticleRotation || this.billboard) {
  107383. var rotMatrixValues = rotMatrix.m;
  107384. particleRotationMatrix[0] = rotMatrixValues[0] * parentRotationMatrix[0] + rotMatrixValues[1] * parentRotationMatrix[3] + rotMatrixValues[2] * parentRotationMatrix[6];
  107385. particleRotationMatrix[1] = rotMatrixValues[0] * parentRotationMatrix[1] + rotMatrixValues[1] * parentRotationMatrix[4] + rotMatrixValues[2] * parentRotationMatrix[7];
  107386. particleRotationMatrix[2] = rotMatrixValues[0] * parentRotationMatrix[2] + rotMatrixValues[1] * parentRotationMatrix[5] + rotMatrixValues[2] * parentRotationMatrix[8];
  107387. particleRotationMatrix[3] = rotMatrixValues[4] * parentRotationMatrix[0] + rotMatrixValues[5] * parentRotationMatrix[3] + rotMatrixValues[6] * parentRotationMatrix[6];
  107388. particleRotationMatrix[4] = rotMatrixValues[4] * parentRotationMatrix[1] + rotMatrixValues[5] * parentRotationMatrix[4] + rotMatrixValues[6] * parentRotationMatrix[7];
  107389. particleRotationMatrix[5] = rotMatrixValues[4] * parentRotationMatrix[2] + rotMatrixValues[5] * parentRotationMatrix[5] + rotMatrixValues[6] * parentRotationMatrix[8];
  107390. particleRotationMatrix[6] = rotMatrixValues[8] * parentRotationMatrix[0] + rotMatrixValues[9] * parentRotationMatrix[3] + rotMatrixValues[10] * parentRotationMatrix[6];
  107391. particleRotationMatrix[7] = rotMatrixValues[8] * parentRotationMatrix[1] + rotMatrixValues[9] * parentRotationMatrix[4] + rotMatrixValues[10] * parentRotationMatrix[7];
  107392. particleRotationMatrix[8] = rotMatrixValues[8] * parentRotationMatrix[2] + rotMatrixValues[9] * parentRotationMatrix[5] + rotMatrixValues[10] * parentRotationMatrix[8];
  107393. }
  107394. }
  107395. else {
  107396. particleGlobalPosition.x = particlePosition.x;
  107397. particleGlobalPosition.y = particlePosition.y;
  107398. particleGlobalPosition.z = particlePosition.z;
  107399. if (this._computeParticleRotation || this.billboard) {
  107400. var rotMatrixValues = rotMatrix.m;
  107401. particleRotationMatrix[0] = rotMatrixValues[0];
  107402. particleRotationMatrix[1] = rotMatrixValues[1];
  107403. particleRotationMatrix[2] = rotMatrixValues[2];
  107404. particleRotationMatrix[3] = rotMatrixValues[4];
  107405. particleRotationMatrix[4] = rotMatrixValues[5];
  107406. particleRotationMatrix[5] = rotMatrixValues[6];
  107407. particleRotationMatrix[6] = rotMatrixValues[8];
  107408. particleRotationMatrix[7] = rotMatrixValues[9];
  107409. particleRotationMatrix[8] = rotMatrixValues[10];
  107410. }
  107411. }
  107412. var pivotBackTranslation = tempVectors[11];
  107413. if (particle.translateFromPivot) {
  107414. pivotBackTranslation.setAll(0.0);
  107415. }
  107416. else {
  107417. pivotBackTranslation.copyFrom(scaledPivot);
  107418. }
  107419. // particle vertex loop
  107420. for (pt = 0; pt < shape.length; pt++) {
  107421. idx = index + pt * 3;
  107422. colidx = colorIndex + pt * 4;
  107423. uvidx = uvIndex + pt * 2;
  107424. var tmpVertex = tempVectors[0];
  107425. tmpVertex.copyFrom(shape[pt]);
  107426. if (this._computeParticleVertex) {
  107427. this.updateParticleVertex(tmpVertex);
  107428. }
  107429. // positions
  107430. var vertexX = tmpVertex.x * particleScaling.x - scaledPivot.x;
  107431. var vertexY = tmpVertex.y * particleScaling.y - scaledPivot.y;
  107432. var vertexZ = tmpVertex.z * particleScaling.z - scaledPivot.z;
  107433. var rotatedX = vertexX * particleRotationMatrix[0] + vertexY * particleRotationMatrix[3] + vertexZ * particleRotationMatrix[6];
  107434. var rotatedY = vertexX * particleRotationMatrix[1] + vertexY * particleRotationMatrix[4] + vertexZ * particleRotationMatrix[7];
  107435. var rotatedZ = vertexX * particleRotationMatrix[2] + vertexY * particleRotationMatrix[5] + vertexZ * particleRotationMatrix[8];
  107436. rotatedX += pivotBackTranslation.x;
  107437. rotatedY += pivotBackTranslation.y;
  107438. rotatedZ += pivotBackTranslation.z;
  107439. var px = positions32[idx] = particleGlobalPosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  107440. var py = positions32[idx + 1] = particleGlobalPosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  107441. var pz = positions32[idx + 2] = particleGlobalPosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  107442. if (this._computeBoundingBox) {
  107443. minimum.minimizeInPlaceFromFloats(px, py, pz);
  107444. maximum.maximizeInPlaceFromFloats(px, py, pz);
  107445. }
  107446. // normals : if the particles can't be morphed then just rotate the normals, what is much more faster than ComputeNormals()
  107447. if (!this._computeParticleVertex) {
  107448. var normalx = fixedNormal32[idx];
  107449. var normaly = fixedNormal32[idx + 1];
  107450. var normalz = fixedNormal32[idx + 2];
  107451. var rotatedx = normalx * particleRotationMatrix[0] + normaly * particleRotationMatrix[3] + normalz * particleRotationMatrix[6];
  107452. var rotatedy = normalx * particleRotationMatrix[1] + normaly * particleRotationMatrix[4] + normalz * particleRotationMatrix[7];
  107453. var rotatedz = normalx * particleRotationMatrix[2] + normaly * particleRotationMatrix[5] + normalz * particleRotationMatrix[8];
  107454. normals32[idx] = camAxisX.x * rotatedx + camAxisY.x * rotatedy + camAxisZ.x * rotatedz;
  107455. normals32[idx + 1] = camAxisX.y * rotatedx + camAxisY.y * rotatedy + camAxisZ.y * rotatedz;
  107456. normals32[idx + 2] = camAxisX.z * rotatedx + camAxisY.z * rotatedy + camAxisZ.z * rotatedz;
  107457. }
  107458. if (this._computeParticleColor && particle.color) {
  107459. var color = particle.color;
  107460. var colors32_1 = this._colors32;
  107461. colors32_1[colidx] = color.r;
  107462. colors32_1[colidx + 1] = color.g;
  107463. colors32_1[colidx + 2] = color.b;
  107464. colors32_1[colidx + 3] = color.a;
  107465. }
  107466. if (this._computeParticleTexture) {
  107467. var uvs = particle.uvs;
  107468. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  107469. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  107470. }
  107471. }
  107472. }
  107473. // particle just set invisible : scaled to zero and positioned at the origin
  107474. else {
  107475. particle._stillInvisible = true; // mark the particle as invisible
  107476. for (pt = 0; pt < shape.length; pt++) {
  107477. idx = index + pt * 3;
  107478. colidx = colorIndex + pt * 4;
  107479. uvidx = uvIndex + pt * 2;
  107480. positions32[idx] = positions32[idx + 1] = positions32[idx + 2] = 0;
  107481. normals32[idx] = normals32[idx + 1] = normals32[idx + 2] = 0;
  107482. if (this._computeParticleColor && particle.color) {
  107483. var color = particle.color;
  107484. colors32[colidx] = color.r;
  107485. colors32[colidx + 1] = color.g;
  107486. colors32[colidx + 2] = color.b;
  107487. colors32[colidx + 3] = color.a;
  107488. }
  107489. if (this._computeParticleTexture) {
  107490. var uvs = particle.uvs;
  107491. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  107492. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  107493. }
  107494. }
  107495. }
  107496. // if the particle intersections must be computed : update the bbInfo
  107497. if (this._particlesIntersect) {
  107498. var bInfo = particle._boundingInfo;
  107499. var bBox = bInfo.boundingBox;
  107500. var bSphere = bInfo.boundingSphere;
  107501. var modelBoundingInfo = particle._modelBoundingInfo;
  107502. if (!this._bSphereOnly) {
  107503. // place, scale and rotate the particle bbox within the SPS local system, then update it
  107504. var modelBoundingInfoVectors = modelBoundingInfo.boundingBox.vectors;
  107505. var tempMin = tempVectors[1];
  107506. var tempMax = tempVectors[2];
  107507. tempMin.setAll(Number.MAX_VALUE);
  107508. tempMax.setAll(-Number.MAX_VALUE);
  107509. for (var b = 0; b < 8; b++) {
  107510. var scaledX = modelBoundingInfoVectors[b].x * particleScaling.x;
  107511. var scaledY = modelBoundingInfoVectors[b].y * particleScaling.y;
  107512. var scaledZ = modelBoundingInfoVectors[b].z * particleScaling.z;
  107513. var rotatedX = scaledX * particleRotationMatrix[0] + scaledY * particleRotationMatrix[3] + scaledZ * particleRotationMatrix[6];
  107514. var rotatedY = scaledX * particleRotationMatrix[1] + scaledY * particleRotationMatrix[4] + scaledZ * particleRotationMatrix[7];
  107515. var rotatedZ = scaledX * particleRotationMatrix[2] + scaledY * particleRotationMatrix[5] + scaledZ * particleRotationMatrix[8];
  107516. var x = particlePosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  107517. var y = particlePosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  107518. var z = particlePosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  107519. tempMin.minimizeInPlaceFromFloats(x, y, z);
  107520. tempMax.maximizeInPlaceFromFloats(x, y, z);
  107521. }
  107522. bBox.reConstruct(tempMin, tempMax, mesh._worldMatrix);
  107523. }
  107524. // place and scale the particle bouding sphere in the SPS local system, then update it
  107525. var minBbox = modelBoundingInfo.minimum.multiplyToRef(particleScaling, tempVectors[1]);
  107526. var maxBbox = modelBoundingInfo.maximum.multiplyToRef(particleScaling, tempVectors[2]);
  107527. var bSphereCenter = maxBbox.addToRef(minBbox, tempVectors[3]).scaleInPlace(0.5).addInPlace(particleGlobalPosition);
  107528. var halfDiag = maxBbox.subtractToRef(minBbox, tempVectors[4]).scaleInPlace(0.5 * this._bSphereRadiusFactor);
  107529. var bSphereMinBbox = bSphereCenter.subtractToRef(halfDiag, tempVectors[1]);
  107530. var bSphereMaxBbox = bSphereCenter.addToRef(halfDiag, tempVectors[2]);
  107531. bSphere.reConstruct(bSphereMinBbox, bSphereMaxBbox, mesh._worldMatrix);
  107532. }
  107533. // increment indexes for the next particle
  107534. index = idx + 3;
  107535. colorIndex = colidx + 4;
  107536. uvIndex = uvidx + 2;
  107537. }
  107538. // if the VBO must be updated
  107539. if (update) {
  107540. if (this._computeParticleColor) {
  107541. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, colors32, false, false);
  107542. }
  107543. if (this._computeParticleTexture) {
  107544. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs32, false, false);
  107545. }
  107546. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, positions32, false, false);
  107547. if (!mesh.areNormalsFrozen || mesh.isFacetDataEnabled) {
  107548. if (this._computeParticleVertex || mesh.isFacetDataEnabled) {
  107549. // recompute the normals only if the particles can be morphed, update then also the normal reference array _fixedNormal32[]
  107550. var params = mesh.isFacetDataEnabled ? mesh.getFacetDataParameters() : null;
  107551. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions32, indices32, normals32, params);
  107552. for (var i = 0; i < normals32.length; i++) {
  107553. fixedNormal32[i] = normals32[i];
  107554. }
  107555. }
  107556. if (!mesh.areNormalsFrozen) {
  107557. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals32, false, false);
  107558. }
  107559. }
  107560. if (this._depthSort && this._depthSortParticles) {
  107561. var depthSortedParticles = this.depthSortedParticles;
  107562. depthSortedParticles.sort(depthSortFunction);
  107563. var dspl = depthSortedParticles.length;
  107564. var sid = 0;
  107565. for (var sorted = 0; sorted < dspl; sorted++) {
  107566. var lind = depthSortedParticles[sorted].indicesLength;
  107567. var sind = depthSortedParticles[sorted].ind;
  107568. for (var i = 0; i < lind; i++) {
  107569. indices32[sid] = indices[sind + i];
  107570. sid++;
  107571. }
  107572. }
  107573. mesh.updateIndices(indices32);
  107574. }
  107575. }
  107576. if (this._computeBoundingBox) {
  107577. if (mesh._boundingInfo) {
  107578. mesh._boundingInfo.reConstruct(minimum, maximum, mesh._worldMatrix);
  107579. }
  107580. else {
  107581. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](minimum, maximum, mesh._worldMatrix);
  107582. }
  107583. }
  107584. this.afterUpdateParticles();
  107585. return this;
  107586. };
  107587. /**
  107588. * Disposes the SPS.
  107589. */
  107590. SolidParticleSystem.prototype.dispose = function () {
  107591. this.mesh.dispose();
  107592. this.vars = null;
  107593. // drop references to internal big arrays for the GC
  107594. this._positions = null;
  107595. this._indices = null;
  107596. this._normals = null;
  107597. this._uvs = null;
  107598. this._colors = null;
  107599. this._indices32 = null;
  107600. this._positions32 = null;
  107601. this._normals32 = null;
  107602. this._fixedNormal32 = null;
  107603. this._uvs32 = null;
  107604. this._colors32 = null;
  107605. this.pickedParticles = null;
  107606. };
  107607. /**
  107608. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  107609. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  107610. * @returns the SPS.
  107611. */
  107612. SolidParticleSystem.prototype.refreshVisibleSize = function () {
  107613. if (!this._isVisibilityBoxLocked) {
  107614. this.mesh.refreshBoundingInfo();
  107615. }
  107616. return this;
  107617. };
  107618. /**
  107619. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  107620. * @param size the size (float) of the visibility box
  107621. * note : this doesn't lock the SPS mesh bounding box.
  107622. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  107623. */
  107624. SolidParticleSystem.prototype.setVisibilityBox = function (size) {
  107625. var vis = size / 2;
  107626. 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));
  107627. };
  107628. Object.defineProperty(SolidParticleSystem.prototype, "isAlwaysVisible", {
  107629. /**
  107630. * Gets whether the SPS as always visible or not
  107631. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  107632. */
  107633. get: function () {
  107634. return this._alwaysVisible;
  107635. },
  107636. /**
  107637. * Sets the SPS as always visible or not
  107638. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  107639. */
  107640. set: function (val) {
  107641. this._alwaysVisible = val;
  107642. this.mesh.alwaysSelectAsActiveMesh = val;
  107643. },
  107644. enumerable: true,
  107645. configurable: true
  107646. });
  107647. Object.defineProperty(SolidParticleSystem.prototype, "isVisibilityBoxLocked", {
  107648. /**
  107649. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  107650. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  107651. */
  107652. get: function () {
  107653. return this._isVisibilityBoxLocked;
  107654. },
  107655. /**
  107656. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  107657. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  107658. */
  107659. set: function (val) {
  107660. this._isVisibilityBoxLocked = val;
  107661. var boundingInfo = this.mesh.getBoundingInfo();
  107662. boundingInfo.isLocked = val;
  107663. },
  107664. enumerable: true,
  107665. configurable: true
  107666. });
  107667. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleRotation", {
  107668. /**
  107669. * Gets if `setParticles()` computes the particle rotations or not.
  107670. * Default value : true. The SPS is faster when it's set to false.
  107671. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  107672. */
  107673. get: function () {
  107674. return this._computeParticleRotation;
  107675. },
  107676. /**
  107677. * Tells to `setParticles()` to compute the particle rotations or not.
  107678. * Default value : true. The SPS is faster when it's set to false.
  107679. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  107680. */
  107681. set: function (val) {
  107682. this._computeParticleRotation = val;
  107683. },
  107684. enumerable: true,
  107685. configurable: true
  107686. });
  107687. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleColor", {
  107688. /**
  107689. * Gets if `setParticles()` computes the particle colors or not.
  107690. * Default value : true. The SPS is faster when it's set to false.
  107691. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  107692. */
  107693. get: function () {
  107694. return this._computeParticleColor;
  107695. },
  107696. /**
  107697. * Tells to `setParticles()` to compute the particle colors or not.
  107698. * Default value : true. The SPS is faster when it's set to false.
  107699. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  107700. */
  107701. set: function (val) {
  107702. this._computeParticleColor = val;
  107703. },
  107704. enumerable: true,
  107705. configurable: true
  107706. });
  107707. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleTexture", {
  107708. /**
  107709. * Gets if `setParticles()` computes the particle textures or not.
  107710. * Default value : true. The SPS is faster when it's set to false.
  107711. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  107712. */
  107713. get: function () {
  107714. return this._computeParticleTexture;
  107715. },
  107716. set: function (val) {
  107717. this._computeParticleTexture = val;
  107718. },
  107719. enumerable: true,
  107720. configurable: true
  107721. });
  107722. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleVertex", {
  107723. /**
  107724. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  107725. * Default value : false. The SPS is faster when it's set to false.
  107726. * Note : the particle custom vertex positions aren't stored values.
  107727. */
  107728. get: function () {
  107729. return this._computeParticleVertex;
  107730. },
  107731. /**
  107732. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  107733. * Default value : false. The SPS is faster when it's set to false.
  107734. * Note : the particle custom vertex positions aren't stored values.
  107735. */
  107736. set: function (val) {
  107737. this._computeParticleVertex = val;
  107738. },
  107739. enumerable: true,
  107740. configurable: true
  107741. });
  107742. Object.defineProperty(SolidParticleSystem.prototype, "computeBoundingBox", {
  107743. /**
  107744. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  107745. */
  107746. get: function () {
  107747. return this._computeBoundingBox;
  107748. },
  107749. /**
  107750. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  107751. */
  107752. set: function (val) {
  107753. this._computeBoundingBox = val;
  107754. },
  107755. enumerable: true,
  107756. configurable: true
  107757. });
  107758. Object.defineProperty(SolidParticleSystem.prototype, "depthSortParticles", {
  107759. /**
  107760. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  107761. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  107762. * Default : `true`
  107763. */
  107764. get: function () {
  107765. return this._depthSortParticles;
  107766. },
  107767. /**
  107768. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  107769. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  107770. * Default : `true`
  107771. */
  107772. set: function (val) {
  107773. this._depthSortParticles = val;
  107774. },
  107775. enumerable: true,
  107776. configurable: true
  107777. });
  107778. // =======================================================================
  107779. // Particle behavior logic
  107780. // these following methods may be overwritten by the user to fit his needs
  107781. /**
  107782. * This function does nothing. It may be overwritten to set all the particle first values.
  107783. * The SPS doesn't call this function, you may have to call it by your own.
  107784. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  107785. */
  107786. SolidParticleSystem.prototype.initParticles = function () {
  107787. };
  107788. /**
  107789. * This function does nothing. It may be overwritten to recycle a particle.
  107790. * The SPS doesn't call this function, you may have to call it by your own.
  107791. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  107792. * @param particle The particle to recycle
  107793. * @returns the recycled particle
  107794. */
  107795. SolidParticleSystem.prototype.recycleParticle = function (particle) {
  107796. return particle;
  107797. };
  107798. /**
  107799. * Updates a particle : this function should be overwritten by the user.
  107800. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  107801. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  107802. * @example : just set a particle position or velocity and recycle conditions
  107803. * @param particle The particle to update
  107804. * @returns the updated particle
  107805. */
  107806. SolidParticleSystem.prototype.updateParticle = function (particle) {
  107807. return particle;
  107808. };
  107809. /**
  107810. * Updates a vertex of a particle : it can be overwritten by the user.
  107811. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  107812. * @param particle the current particle
  107813. * @param vertex the current index of the current particle
  107814. * @param pt the index of the current vertex in the particle shape
  107815. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  107816. * @example : just set a vertex particle position
  107817. * @returns the updated vertex
  107818. */
  107819. SolidParticleSystem.prototype.updateParticleVertex = function (vertex) {
  107820. return vertex;
  107821. };
  107822. /**
  107823. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  107824. * This does nothing and may be overwritten by the user.
  107825. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107826. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107827. * @param update the boolean update value actually passed to setParticles()
  107828. */
  107829. SolidParticleSystem.prototype.beforeUpdateParticles = function () {
  107830. };
  107831. /**
  107832. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  107833. * This will be passed three parameters.
  107834. * This does nothing and may be overwritten by the user.
  107835. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107836. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  107837. * @param update the boolean update value actually passed to setParticles()
  107838. */
  107839. SolidParticleSystem.prototype.afterUpdateParticles = function () {
  107840. };
  107841. return SolidParticleSystem;
  107842. }());
  107843. /***/ }),
  107844. /***/ "./Particles/subEmitter.ts":
  107845. /*!*********************************!*\
  107846. !*** ./Particles/subEmitter.ts ***!
  107847. \*********************************/
  107848. /*! exports provided: SubEmitterType, SubEmitter */
  107849. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107850. "use strict";
  107851. __webpack_require__.r(__webpack_exports__);
  107852. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return SubEmitterType; });
  107853. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return SubEmitter; });
  107854. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107855. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  107856. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  107857. /**
  107858. * Type of sub emitter
  107859. */
  107860. var SubEmitterType;
  107861. (function (SubEmitterType) {
  107862. /**
  107863. * Attached to the particle over it's lifetime
  107864. */
  107865. SubEmitterType[SubEmitterType["ATTACHED"] = 0] = "ATTACHED";
  107866. /**
  107867. * Created when the particle dies
  107868. */
  107869. SubEmitterType[SubEmitterType["END"] = 1] = "END";
  107870. })(SubEmitterType || (SubEmitterType = {}));
  107871. /**
  107872. * Sub emitter class used to emit particles from an existing particle
  107873. */
  107874. var SubEmitter = /** @class */ (function () {
  107875. /**
  107876. * Creates a sub emitter
  107877. * @param particleSystem the particle system to be used by the sub emitter
  107878. */
  107879. function SubEmitter(
  107880. /**
  107881. * the particle system to be used by the sub emitter
  107882. */
  107883. particleSystem) {
  107884. this.particleSystem = particleSystem;
  107885. /**
  107886. * Type of the submitter (Default: END)
  107887. */
  107888. this.type = SubEmitterType.END;
  107889. /**
  107890. * 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)
  107891. * Note: This only is supported when using an emitter of type Mesh
  107892. */
  107893. this.inheritDirection = false;
  107894. /**
  107895. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  107896. */
  107897. this.inheritedVelocityAmount = 0;
  107898. // Create mesh as emitter to support rotation
  107899. if (!particleSystem.emitter || !particleSystem.emitter.dispose) {
  107900. particleSystem.emitter = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("SubemitterSystemEmitter", particleSystem.getScene());
  107901. }
  107902. // Automatically dispose of subemitter when system is disposed
  107903. particleSystem.onDisposeObservable.add(function () {
  107904. if (particleSystem.emitter && particleSystem.emitter.dispose) {
  107905. particleSystem.emitter.dispose();
  107906. }
  107907. });
  107908. }
  107909. /**
  107910. * Clones the sub emitter
  107911. * @returns the cloned sub emitter
  107912. */
  107913. SubEmitter.prototype.clone = function () {
  107914. // Clone particle system
  107915. var emitter = this.particleSystem.emitter;
  107916. if (!emitter) {
  107917. emitter = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  107918. }
  107919. else if (emitter instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  107920. emitter = emitter.clone();
  107921. }
  107922. else if (emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  107923. emitter = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", emitter.getScene());
  107924. emitter.isVisible = false;
  107925. }
  107926. var clone = new SubEmitter(this.particleSystem.clone("", emitter));
  107927. // Clone properties
  107928. clone.type = this.type;
  107929. clone.inheritDirection = this.inheritDirection;
  107930. clone.inheritedVelocityAmount = this.inheritedVelocityAmount;
  107931. clone.particleSystem._disposeEmitterOnDispose = true;
  107932. clone.particleSystem.disposeOnStop = true;
  107933. return clone;
  107934. };
  107935. /**
  107936. * Serialize current object to a JSON object
  107937. * @returns the serialized object
  107938. */
  107939. SubEmitter.prototype.serialize = function () {
  107940. var serializationObject = {};
  107941. serializationObject.type = this.type;
  107942. serializationObject.inheritDirection = this.inheritDirection;
  107943. serializationObject.inheritedVelocityAmount = this.inheritedVelocityAmount;
  107944. serializationObject.particleSystem = this.particleSystem.serialize();
  107945. return serializationObject;
  107946. };
  107947. /** @hidden */
  107948. SubEmitter._ParseParticleSystem = function (system, scene, rootUrl) {
  107949. throw "Import ParseParticle before parsing SubEmitter.";
  107950. };
  107951. /**
  107952. * Creates a new SubEmitter from a serialized JSON version
  107953. * @param serializationObject defines the JSON object to read from
  107954. * @param scene defines the hosting scene
  107955. * @param rootUrl defines the rootUrl for data loading
  107956. * @returns a new SubEmitter
  107957. */
  107958. SubEmitter.Parse = function (serializationObject, scene, rootUrl) {
  107959. var system = serializationObject.particleSystem;
  107960. var subEmitter = new SubEmitter(SubEmitter._ParseParticleSystem(system, scene, rootUrl));
  107961. subEmitter.type = serializationObject.type;
  107962. subEmitter.inheritDirection = serializationObject.inheritDirection;
  107963. subEmitter.inheritedVelocityAmount = serializationObject.inheritedVelocityAmount;
  107964. subEmitter.particleSystem._isSubEmitter = true;
  107965. return subEmitter;
  107966. };
  107967. /** Release associated resources */
  107968. SubEmitter.prototype.dispose = function () {
  107969. this.particleSystem.dispose();
  107970. };
  107971. return SubEmitter;
  107972. }());
  107973. /***/ }),
  107974. /***/ "./Physics/Plugins/ammoJSPlugin.ts":
  107975. /*!*****************************************!*\
  107976. !*** ./Physics/Plugins/ammoJSPlugin.ts ***!
  107977. \*****************************************/
  107978. /*! exports provided: AmmoJSPlugin */
  107979. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107980. "use strict";
  107981. __webpack_require__.r(__webpack_exports__);
  107982. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return AmmoJSPlugin; });
  107983. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  107984. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  107985. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  107986. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  107987. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  107988. /**
  107989. * AmmoJS Physics plugin
  107990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107991. * @see https://github.com/kripken/ammo.js/
  107992. */
  107993. var AmmoJSPlugin = /** @class */ (function () {
  107994. /**
  107995. * Initializes the ammoJS plugin
  107996. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107997. * @param ammoInjection can be used to inject your own ammo reference
  107998. */
  107999. function AmmoJSPlugin(_useDeltaForWorldStep, ammoInjection) {
  108000. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  108001. if (ammoInjection === void 0) { ammoInjection = Ammo; }
  108002. var _this = this;
  108003. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  108004. /**
  108005. * Reference to the Ammo library
  108006. */
  108007. this.bjsAMMO = {};
  108008. /**
  108009. * Name of the plugin
  108010. */
  108011. this.name = "AmmoJSPlugin";
  108012. this._timeStep = 1 / 60;
  108013. this._fixedTimeStep = 1 / 60;
  108014. this._maxSteps = 5;
  108015. this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  108016. this._tmpContactCallbackResult = false;
  108017. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  108018. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  108019. if (typeof ammoInjection === "function") {
  108020. ammoInjection(this.bjsAMMO);
  108021. }
  108022. else {
  108023. this.bjsAMMO = ammoInjection;
  108024. }
  108025. if (!this.isSupported()) {
  108026. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("AmmoJS is not available. Please make sure you included the js file.");
  108027. return;
  108028. }
  108029. // Initialize the physics world
  108030. this._collisionConfiguration = new this.bjsAMMO.btDefaultCollisionConfiguration();
  108031. this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration);
  108032. this._overlappingPairCache = new this.bjsAMMO.btDbvtBroadphase();
  108033. this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver();
  108034. this.world = new this.bjsAMMO.btDiscreteDynamicsWorld(this._dispatcher, this._overlappingPairCache, this._solver, this._collisionConfiguration);
  108035. this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback();
  108036. this._tmpAmmoConcreteContactResultCallback.addSingleResult = function () { _this._tmpContactCallbackResult = true; };
  108037. // Create temp ammo variables
  108038. this._tmpAmmoTransform = new this.bjsAMMO.btTransform();
  108039. this._tmpAmmoTransform.setIdentity();
  108040. this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0, 0, 0, 1);
  108041. this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0, 0, 0);
  108042. this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0, 0, 0);
  108043. this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0, 0, 0);
  108044. }
  108045. /**
  108046. * Sets the gravity of the physics world (m/(s^2))
  108047. * @param gravity Gravity to set
  108048. */
  108049. AmmoJSPlugin.prototype.setGravity = function (gravity) {
  108050. this._tmpAmmoVectorA.setValue(gravity.x, gravity.y, gravity.z);
  108051. this.world.setGravity(this._tmpAmmoVectorA);
  108052. };
  108053. /**
  108054. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  108055. * @param timeStep timestep to use in seconds
  108056. */
  108057. AmmoJSPlugin.prototype.setTimeStep = function (timeStep) {
  108058. this._timeStep = timeStep;
  108059. };
  108060. /**
  108061. * 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)
  108062. * @param fixedTimeStep fixedTimeStep to use in seconds
  108063. */
  108064. AmmoJSPlugin.prototype.setFixedTimeStep = function (fixedTimeStep) {
  108065. this._fixedTimeStep = fixedTimeStep;
  108066. };
  108067. /**
  108068. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  108069. * @param maxSteps the maximum number of steps by the physics engine per frame
  108070. */
  108071. AmmoJSPlugin.prototype.setMaxSteps = function (maxSteps) {
  108072. this._maxSteps = maxSteps;
  108073. };
  108074. /**
  108075. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  108076. * @returns the current timestep in seconds
  108077. */
  108078. AmmoJSPlugin.prototype.getTimeStep = function () {
  108079. return this._timeStep;
  108080. };
  108081. // Ammo's contactTest and contactPairTest take a callback that runs synchronously, wrap them so that they are easier to consume
  108082. AmmoJSPlugin.prototype._isImpostorInContact = function (impostor) {
  108083. this._tmpContactCallbackResult = false;
  108084. this.world.contactTest(impostor.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  108085. return this._tmpContactCallbackResult;
  108086. };
  108087. // Ammo's collision events have some weird quirks
  108088. // contactPairTest fires too many events as it fires events even when objects are close together but contactTest does not
  108089. // so only fire event if both contactTest and contactPairTest have a hit
  108090. AmmoJSPlugin.prototype._isImpostorPairInContact = function (impostorA, impostorB) {
  108091. this._tmpContactCallbackResult = false;
  108092. this.world.contactPairTest(impostorA.physicsBody, impostorB.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  108093. return this._tmpContactCallbackResult;
  108094. };
  108095. // Ammo's behavior when maxSteps > 0 does not behave as described in docs
  108096. // @see http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_The_World
  108097. //
  108098. // When maxSteps is 0 do the entire simulation in one step
  108099. // 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)
  108100. // Note: To get deterministic physics, timeStep would always need to be divisible by fixedTimeStep
  108101. AmmoJSPlugin.prototype._stepSimulation = function (timeStep, maxSteps, fixedTimeStep) {
  108102. if (timeStep === void 0) { timeStep = 1 / 60; }
  108103. if (maxSteps === void 0) { maxSteps = 10; }
  108104. if (fixedTimeStep === void 0) { fixedTimeStep = 1 / 60; }
  108105. if (maxSteps == 0) {
  108106. this.world.stepSimulation(timeStep, 0);
  108107. }
  108108. else {
  108109. while (maxSteps > 0 && timeStep > 0) {
  108110. if (timeStep - fixedTimeStep < fixedTimeStep) {
  108111. this.world.stepSimulation(timeStep, 0);
  108112. timeStep = 0;
  108113. }
  108114. else {
  108115. timeStep -= fixedTimeStep;
  108116. this.world.stepSimulation(fixedTimeStep, 0);
  108117. }
  108118. maxSteps--;
  108119. }
  108120. }
  108121. };
  108122. /**
  108123. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  108124. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  108125. * After the step the babylon meshes are set to the position of the physics imposters
  108126. * @param delta amount of time to step forward
  108127. * @param impostors array of imposters to update before/after the step
  108128. */
  108129. AmmoJSPlugin.prototype.executeStep = function (delta, impostors) {
  108130. for (var _i = 0, impostors_1 = impostors; _i < impostors_1.length; _i++) {
  108131. var impostor = impostors_1[_i];
  108132. // Update physics world objects to match babylon world
  108133. impostor.beforeStep();
  108134. }
  108135. this._stepSimulation(this._useDeltaForWorldStep ? delta : this._timeStep, this._maxSteps, this._fixedTimeStep);
  108136. for (var _a = 0, impostors_2 = impostors; _a < impostors_2.length; _a++) {
  108137. var mainImpostor = impostors_2[_a];
  108138. // After physics update make babylon world objects match physics world objects
  108139. mainImpostor.afterStep();
  108140. // Handle collision event
  108141. if (mainImpostor._onPhysicsCollideCallbacks.length > 0) {
  108142. if (this._isImpostorInContact(mainImpostor)) {
  108143. for (var _b = 0, _c = mainImpostor._onPhysicsCollideCallbacks; _b < _c.length; _b++) {
  108144. var collideCallback = _c[_b];
  108145. for (var _d = 0, _e = collideCallback.otherImpostors; _d < _e.length; _d++) {
  108146. var otherImpostor = _e[_d];
  108147. if (mainImpostor.physicsBody.isActive() || otherImpostor.physicsBody.isActive()) {
  108148. if (this._isImpostorPairInContact(mainImpostor, otherImpostor)) {
  108149. mainImpostor.onCollide({ body: otherImpostor.physicsBody });
  108150. otherImpostor.onCollide({ body: mainImpostor.physicsBody });
  108151. }
  108152. }
  108153. }
  108154. }
  108155. }
  108156. }
  108157. }
  108158. };
  108159. /**
  108160. * Applies an implulse on the imposter
  108161. * @param impostor imposter to apply impulse
  108162. * @param force amount of force to be applied to the imposter
  108163. * @param contactPoint the location to apply the impulse on the imposter
  108164. */
  108165. AmmoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  108166. var worldPoint = this._tmpAmmoVectorA;
  108167. var impulse = this._tmpAmmoVectorB;
  108168. // Convert contactPoint into world space
  108169. if (impostor.object && impostor.object.getWorldMatrix) {
  108170. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  108171. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  108172. contactPoint = this._tmpVector;
  108173. }
  108174. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  108175. impulse.setValue(force.x, force.y, force.z);
  108176. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  108177. };
  108178. /**
  108179. * Applies a force on the imposter
  108180. * @param impostor imposter to apply force
  108181. * @param force amount of force to be applied to the imposter
  108182. * @param contactPoint the location to apply the force on the imposter
  108183. */
  108184. AmmoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  108185. var worldPoint = this._tmpAmmoVectorA;
  108186. var impulse = this._tmpAmmoVectorB;
  108187. // Convert contactPoint into world space
  108188. if (impostor.object && impostor.object.getWorldMatrix) {
  108189. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  108190. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  108191. contactPoint = this._tmpVector;
  108192. }
  108193. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  108194. impulse.setValue(force.x, force.y, force.z);
  108195. impostor.physicsBody.applyForce(impulse, worldPoint);
  108196. };
  108197. /**
  108198. * Creates a physics body using the plugin
  108199. * @param impostor the imposter to create the physics body on
  108200. */
  108201. AmmoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  108202. impostor._pluginData = { toDispose: [] };
  108203. //parent-child relationship
  108204. if (impostor.parent) {
  108205. if (impostor.physicsBody) {
  108206. this.removePhysicsBody(impostor);
  108207. impostor.forceUpdate();
  108208. }
  108209. return;
  108210. }
  108211. if (impostor.isBodyInitRequired()) {
  108212. var colShape = this._createShape(impostor);
  108213. var mass = impostor.getParam("mass");
  108214. impostor._pluginData.mass = mass;
  108215. var localInertia = new Ammo.btVector3(0, 0, 0);
  108216. var startTransform = new Ammo.btTransform();
  108217. startTransform.setIdentity();
  108218. if (mass !== 0) {
  108219. colShape.calculateLocalInertia(mass, localInertia);
  108220. }
  108221. this._tmpAmmoVectorA.setValue(impostor.object.position.x, impostor.object.position.y, impostor.object.position.z);
  108222. this._tmpAmmoQuaternion.setValue(impostor.object.rotationQuaternion.x, impostor.object.rotationQuaternion.y, impostor.object.rotationQuaternion.z, impostor.object.rotationQuaternion.w);
  108223. startTransform.setOrigin(this._tmpAmmoVectorA);
  108224. startTransform.setRotation(this._tmpAmmoQuaternion);
  108225. var myMotionState = new Ammo.btDefaultMotionState(startTransform);
  108226. var rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
  108227. var body = new Ammo.btRigidBody(rbInfo);
  108228. // Make objects kinematic if it's mass is 0
  108229. if (mass === 0) {
  108230. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
  108231. body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  108232. }
  108233. // Disable collision if NoImpostor, but keep collision if shape is btCompoundShape
  108234. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor && !colShape.getChildShape) {
  108235. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
  108236. }
  108237. this.world.addRigidBody(body);
  108238. impostor.physicsBody = body;
  108239. this.setBodyRestitution(impostor, impostor.getParam("restitution"));
  108240. this.setBodyFriction(impostor, impostor.getParam("friction"));
  108241. impostor._pluginData.toDispose.concat([body, rbInfo, myMotionState, startTransform, localInertia, colShape]);
  108242. }
  108243. };
  108244. /**
  108245. * Removes the physics body from the imposter and disposes of the body's memory
  108246. * @param impostor imposter to remove the physics body from
  108247. */
  108248. AmmoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  108249. var _this = this;
  108250. if (this.world) {
  108251. this.world.removeRigidBody(impostor.physicsBody);
  108252. impostor._pluginData.toDispose.forEach(function (d) {
  108253. _this.bjsAMMO.destroy(d);
  108254. });
  108255. }
  108256. };
  108257. /**
  108258. * Generates a joint
  108259. * @param impostorJoint the imposter joint to create the joint with
  108260. */
  108261. AmmoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  108262. var mainBody = impostorJoint.mainImpostor.physicsBody;
  108263. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  108264. if (!mainBody || !connectedBody) {
  108265. return;
  108266. }
  108267. var jointData = impostorJoint.joint.jointData;
  108268. if (!jointData.mainPivot) {
  108269. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  108270. }
  108271. if (!jointData.connectedPivot) {
  108272. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  108273. }
  108274. var joint;
  108275. switch (impostorJoint.joint.type) {
  108276. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].DistanceJoint:
  108277. var distance = jointData.maxDistance;
  108278. if (distance) {
  108279. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -distance / 2, 0);
  108280. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, distance / 2, 0);
  108281. }
  108282. 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));
  108283. break;
  108284. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].HingeJoint:
  108285. if (!jointData.mainAxis) {
  108286. jointData.mainAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  108287. }
  108288. if (!jointData.connectedAxis) {
  108289. jointData.connectedAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  108290. }
  108291. var mainAxis = new Ammo.btVector3(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z);
  108292. var connectedAxis = new Ammo.btVector3(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z);
  108293. 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);
  108294. break;
  108295. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].BallAndSocketJoint:
  108296. 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));
  108297. break;
  108298. default:
  108299. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint");
  108300. 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));
  108301. break;
  108302. }
  108303. this.world.addConstraint(joint, !impostorJoint.joint.jointData.collision);
  108304. impostorJoint.joint.physicsJoint = joint;
  108305. };
  108306. /**
  108307. * Removes a joint
  108308. * @param impostorJoint the imposter joint to remove the joint from
  108309. */
  108310. AmmoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  108311. if (this.world) {
  108312. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  108313. }
  108314. };
  108315. // adds all verticies (including child verticies) to the triangle mesh
  108316. AmmoJSPlugin.prototype._addMeshVerts = function (btTriangleMesh, topLevelObject, object) {
  108317. var _this = this;
  108318. var triangleCount = 0;
  108319. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  108320. var indices = object.getIndices();
  108321. if (!indices) {
  108322. indices = [];
  108323. }
  108324. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  108325. if (!vertexPositions) {
  108326. vertexPositions = [];
  108327. }
  108328. object.computeWorldMatrix(false);
  108329. var faceCount = indices.length / 3;
  108330. for (var i = 0; i < faceCount; i++) {
  108331. var triPoints = [];
  108332. for (var point = 0; point < 3; point++) {
  108333. 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]);
  108334. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, object.getWorldMatrix());
  108335. v.subtractInPlace(topLevelObject.position);
  108336. var vec;
  108337. if (point == 0) {
  108338. vec = this._tmpAmmoVectorA;
  108339. }
  108340. else if (point == 1) {
  108341. vec = this._tmpAmmoVectorB;
  108342. }
  108343. else {
  108344. vec = this._tmpAmmoVectorC;
  108345. }
  108346. vec.setValue(v.x, v.y, v.z);
  108347. triPoints.push(vec);
  108348. }
  108349. btTriangleMesh.addTriangle(triPoints[0], triPoints[1], triPoints[2]);
  108350. triangleCount++;
  108351. }
  108352. object.getChildMeshes().forEach(function (m) {
  108353. triangleCount += _this._addMeshVerts(btTriangleMesh, topLevelObject, m);
  108354. });
  108355. }
  108356. return triangleCount;
  108357. };
  108358. AmmoJSPlugin.prototype._createShape = function (impostor, ignoreChildren) {
  108359. var _this = this;
  108360. if (ignoreChildren === void 0) { ignoreChildren = false; }
  108361. var object = impostor.object;
  108362. var returnValue;
  108363. var extendSize = impostor.getObjectExtendSize();
  108364. if (!ignoreChildren) {
  108365. var meshChildren = impostor.object.getChildMeshes ? impostor.object.getChildMeshes(true) : [];
  108366. returnValue = new Ammo.btCompoundShape();
  108367. // Add shape of all children to the compound shape
  108368. var childrenAdded = 0;
  108369. meshChildren.forEach(function (childMesh) {
  108370. var childImpostor = childMesh.getPhysicsImpostor();
  108371. if (childImpostor) {
  108372. var shape = _this._createShape(childImpostor);
  108373. // Position needs to be scaled based on parent's scaling
  108374. var parentMat = childMesh.parent.getWorldMatrix().clone();
  108375. var s = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  108376. parentMat.decompose(s);
  108377. _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
  108378. _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
  108379. _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
  108380. returnValue.addChildShape(_this._tmpAmmoTransform, shape);
  108381. childImpostor.dispose();
  108382. childrenAdded++;
  108383. }
  108384. });
  108385. if (childrenAdded > 0) {
  108386. // Add parents shape as a child if present
  108387. if (impostor.type != _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor) {
  108388. var shape = this._createShape(impostor, true);
  108389. if (shape) {
  108390. this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
  108391. this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
  108392. this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
  108393. returnValue.addChildShape(this._tmpAmmoTransform, shape);
  108394. }
  108395. }
  108396. return returnValue;
  108397. }
  108398. else {
  108399. // If no children with impostors create the actual shape below instead
  108400. Ammo.destroy(returnValue);
  108401. returnValue = null;
  108402. }
  108403. }
  108404. switch (impostor.type) {
  108405. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SphereImpostor:
  108406. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  108407. break;
  108408. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].CylinderImpostor:
  108409. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  108410. returnValue = new Ammo.btCylinderShape(this._tmpAmmoVectorA);
  108411. break;
  108412. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].PlaneImpostor:
  108413. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].BoxImpostor:
  108414. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  108415. returnValue = new Ammo.btBoxShape(this._tmpAmmoVectorA);
  108416. break;
  108417. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor:
  108418. var tetraMesh = new Ammo.btTriangleMesh();
  108419. impostor._pluginData.toDispose.concat([tetraMesh]);
  108420. var triangeCount = this._addMeshVerts(tetraMesh, object, object);
  108421. if (triangeCount == 0) {
  108422. returnValue = new Ammo.btCompoundShape();
  108423. }
  108424. else {
  108425. returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
  108426. }
  108427. break;
  108428. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor:
  108429. // Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
  108430. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  108431. break;
  108432. default:
  108433. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The impostor type is not currently supported by the ammo plugin.");
  108434. break;
  108435. }
  108436. return returnValue;
  108437. };
  108438. /**
  108439. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  108440. * @param impostor imposter containing the physics body and babylon object
  108441. */
  108442. AmmoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  108443. impostor.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  108444. impostor.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z());
  108445. if (!impostor.object.rotationQuaternion) {
  108446. if (impostor.object.rotation) {
  108447. this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  108448. this._tmpQuaternion.toEulerAnglesToRef(impostor.object.rotation);
  108449. }
  108450. }
  108451. else {
  108452. impostor.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  108453. }
  108454. };
  108455. /**
  108456. * Sets the babylon object's position/rotation from the physics body's position/rotation
  108457. * @param impostor imposter containing the physics body and babylon object
  108458. * @param newPosition new position
  108459. * @param newRotation new rotation
  108460. */
  108461. AmmoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  108462. var trans = impostor.physicsBody.getWorldTransform();
  108463. // If rotation/position has changed update and activate riged body
  108464. if (trans.getOrigin().x() != newPosition.x ||
  108465. trans.getOrigin().y() != newPosition.y ||
  108466. trans.getOrigin().z() != newPosition.z ||
  108467. trans.getRotation().x() != newRotation.x ||
  108468. trans.getRotation().y() != newRotation.y ||
  108469. trans.getRotation().z() != newRotation.z ||
  108470. trans.getRotation().w() != newRotation.w) {
  108471. this._tmpAmmoVectorA.setValue(newPosition.x, newPosition.y, newPosition.z);
  108472. trans.setOrigin(this._tmpAmmoVectorA);
  108473. this._tmpAmmoQuaternion.setValue(newRotation.x, newRotation.y, newRotation.z, newRotation.w);
  108474. trans.setRotation(this._tmpAmmoQuaternion);
  108475. impostor.physicsBody.setWorldTransform(trans);
  108476. if (impostor.mass == 0) {
  108477. // Kinematic objects must be updated using motion state
  108478. var motionState = impostor.physicsBody.getMotionState();
  108479. if (motionState) {
  108480. motionState.setWorldTransform(trans);
  108481. }
  108482. }
  108483. else {
  108484. impostor.physicsBody.activate();
  108485. }
  108486. }
  108487. };
  108488. /**
  108489. * If this plugin is supported
  108490. * @returns true if its supported
  108491. */
  108492. AmmoJSPlugin.prototype.isSupported = function () {
  108493. return this.bjsAMMO !== undefined;
  108494. };
  108495. /**
  108496. * Sets the linear velocity of the physics body
  108497. * @param impostor imposter to set the velocity on
  108498. * @param velocity velocity to set
  108499. */
  108500. AmmoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  108501. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  108502. impostor.physicsBody.setLinearVelocity(this._tmpAmmoVectorA);
  108503. };
  108504. /**
  108505. * Sets the angular velocity of the physics body
  108506. * @param impostor imposter to set the velocity on
  108507. * @param velocity velocity to set
  108508. */
  108509. AmmoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  108510. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  108511. impostor.physicsBody.setAngularVelocity(this._tmpAmmoVectorA);
  108512. };
  108513. /**
  108514. * gets the linear velocity
  108515. * @param impostor imposter to get linear velocity from
  108516. * @returns linear velocity
  108517. */
  108518. AmmoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  108519. var v = impostor.physicsBody.getLinearVelocity();
  108520. if (!v) {
  108521. return null;
  108522. }
  108523. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  108524. };
  108525. /**
  108526. * gets the angular velocity
  108527. * @param impostor imposter to get angular velocity from
  108528. * @returns angular velocity
  108529. */
  108530. AmmoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  108531. var v = impostor.physicsBody.getAngularVelocity();
  108532. if (!v) {
  108533. return null;
  108534. }
  108535. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  108536. };
  108537. /**
  108538. * Sets the mass of physics body
  108539. * @param impostor imposter to set the mass on
  108540. * @param mass mass to set
  108541. */
  108542. AmmoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  108543. impostor.physicsBody.setMassProps(mass);
  108544. impostor._pluginData.mass = mass;
  108545. };
  108546. /**
  108547. * Gets the mass of the physics body
  108548. * @param impostor imposter to get the mass from
  108549. * @returns mass
  108550. */
  108551. AmmoJSPlugin.prototype.getBodyMass = function (impostor) {
  108552. return impostor._pluginData.mass;
  108553. };
  108554. /**
  108555. * Gets friction of the impostor
  108556. * @param impostor impostor to get friction from
  108557. * @returns friction value
  108558. */
  108559. AmmoJSPlugin.prototype.getBodyFriction = function (impostor) {
  108560. return impostor._pluginData.friction;
  108561. };
  108562. /**
  108563. * Sets friction of the impostor
  108564. * @param impostor impostor to set friction on
  108565. * @param friction friction value
  108566. */
  108567. AmmoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  108568. impostor.physicsBody.setFriction(friction);
  108569. impostor._pluginData.friction = friction;
  108570. };
  108571. /**
  108572. * Gets restitution of the impostor
  108573. * @param impostor impostor to get restitution from
  108574. * @returns restitution value
  108575. */
  108576. AmmoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  108577. return impostor._pluginData.restitution;
  108578. };
  108579. /**
  108580. * Sets resitution of the impostor
  108581. * @param impostor impostor to set resitution on
  108582. * @param restitution resitution value
  108583. */
  108584. AmmoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  108585. impostor.physicsBody.setRestitution(restitution);
  108586. impostor._pluginData.restitution = restitution;
  108587. };
  108588. /**
  108589. * Sleeps the physics body and stops it from being active
  108590. * @param impostor impostor to sleep
  108591. */
  108592. AmmoJSPlugin.prototype.sleepBody = function (impostor) {
  108593. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("sleepBody is not currently supported by the Ammo physics plugin");
  108594. };
  108595. /**
  108596. * Activates the physics body
  108597. * @param impostor impostor to activate
  108598. */
  108599. AmmoJSPlugin.prototype.wakeUpBody = function (impostor) {
  108600. impostor.physicsBody.activate();
  108601. };
  108602. /**
  108603. * Updates the distance parameters of the joint
  108604. * @param joint joint to update
  108605. * @param maxDistance maximum distance of the joint
  108606. * @param minDistance minimum distance of the joint
  108607. */
  108608. AmmoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  108609. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin");
  108610. };
  108611. /**
  108612. * Sets a motor on the joint
  108613. * @param joint joint to set motor on
  108614. * @param speed speed of the motor
  108615. * @param maxForce maximum force of the motor
  108616. * @param motorIndex index of the motor
  108617. */
  108618. AmmoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  108619. joint.physicsJoint.enableAngularMotor(true, speed, maxForce);
  108620. };
  108621. /**
  108622. * Sets the motors limit
  108623. * @param joint joint to set limit on
  108624. * @param upperLimit upper limit
  108625. * @param lowerLimit lower limit
  108626. */
  108627. AmmoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  108628. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("setLimit is not currently supported by the Ammo physics plugin");
  108629. };
  108630. /**
  108631. * Syncs the position and rotation of a mesh with the impostor
  108632. * @param mesh mesh to sync
  108633. * @param impostor impostor to update the mesh with
  108634. */
  108635. AmmoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  108636. var body = impostor.physicsBody;
  108637. body.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  108638. mesh.position.x = this._tmpAmmoTransform.getOrigin().x();
  108639. mesh.position.y = this._tmpAmmoTransform.getOrigin().y();
  108640. mesh.position.z = this._tmpAmmoTransform.getOrigin().z();
  108641. if (mesh.rotationQuaternion) {
  108642. mesh.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x();
  108643. mesh.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y();
  108644. mesh.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z();
  108645. mesh.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w();
  108646. }
  108647. };
  108648. /**
  108649. * Gets the radius of the impostor
  108650. * @param impostor impostor to get radius from
  108651. * @returns the radius
  108652. */
  108653. AmmoJSPlugin.prototype.getRadius = function (impostor) {
  108654. var exntend = impostor.getObjectExtendSize();
  108655. return exntend.x / 2;
  108656. };
  108657. /**
  108658. * Gets the box size of the impostor
  108659. * @param impostor impostor to get box size from
  108660. * @param result the resulting box size
  108661. */
  108662. AmmoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  108663. var exntend = impostor.getObjectExtendSize();
  108664. result.x = exntend.x;
  108665. result.y = exntend.y;
  108666. result.z = exntend.z;
  108667. };
  108668. /**
  108669. * Disposes of the impostor
  108670. */
  108671. AmmoJSPlugin.prototype.dispose = function () {
  108672. // Dispose of world
  108673. Ammo.destroy(this.world);
  108674. Ammo.destroy(this._solver);
  108675. Ammo.destroy(this._overlappingPairCache);
  108676. Ammo.destroy(this._dispatcher);
  108677. Ammo.destroy(this._collisionConfiguration);
  108678. // Dispose of tmp variables
  108679. Ammo.destroy(this._tmpAmmoVectorA);
  108680. Ammo.destroy(this._tmpAmmoVectorB);
  108681. Ammo.destroy(this._tmpAmmoVectorC);
  108682. Ammo.destroy(this._tmpAmmoTransform);
  108683. Ammo.destroy(this._tmpAmmoQuaternion);
  108684. Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
  108685. this.world = null;
  108686. };
  108687. AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
  108688. AmmoJSPlugin.KINEMATIC_FLAG = 2;
  108689. AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
  108690. return AmmoJSPlugin;
  108691. }());
  108692. /***/ }),
  108693. /***/ "./Physics/Plugins/cannonJSPlugin.ts":
  108694. /*!*******************************************!*\
  108695. !*** ./Physics/Plugins/cannonJSPlugin.ts ***!
  108696. \*******************************************/
  108697. /*! exports provided: CannonJSPlugin */
  108698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108699. "use strict";
  108700. __webpack_require__.r(__webpack_exports__);
  108701. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return CannonJSPlugin; });
  108702. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  108703. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  108704. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  108705. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  108706. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  108707. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  108708. /** @hidden */
  108709. var CannonJSPlugin = /** @class */ (function () {
  108710. function CannonJSPlugin(_useDeltaForWorldStep, iterations, cannonInjection) {
  108711. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  108712. if (iterations === void 0) { iterations = 10; }
  108713. if (cannonInjection === void 0) { cannonInjection = CANNON; }
  108714. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  108715. this.name = "CannonJSPlugin";
  108716. this._physicsMaterials = new Array();
  108717. this._fixedTimeStep = 1 / 60;
  108718. this._minus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-0.7071067811865475, 0, 0, 0.7071067811865475);
  108719. this._plus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](0.7071067811865475, 0, 0, 0.7071067811865475);
  108720. this._tmpPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  108721. this._tmpDeltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  108722. this._tmpUnityRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  108723. this.BJSCANNON = cannonInjection;
  108724. if (!this.isSupported()) {
  108725. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("CannonJS is not available. Please make sure you included the js file.");
  108726. return;
  108727. }
  108728. this._extendNamespace();
  108729. this.world = new this.BJSCANNON.World();
  108730. this.world.broadphase = new this.BJSCANNON.NaiveBroadphase();
  108731. this.world.solver.iterations = iterations;
  108732. }
  108733. CannonJSPlugin.prototype.setGravity = function (gravity) {
  108734. this.world.gravity.copy(gravity);
  108735. };
  108736. CannonJSPlugin.prototype.setTimeStep = function (timeStep) {
  108737. this._fixedTimeStep = timeStep;
  108738. };
  108739. CannonJSPlugin.prototype.getTimeStep = function () {
  108740. return this._fixedTimeStep;
  108741. };
  108742. CannonJSPlugin.prototype.executeStep = function (delta) {
  108743. this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta : 0, 3);
  108744. };
  108745. CannonJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  108746. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  108747. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  108748. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  108749. };
  108750. CannonJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  108751. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  108752. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  108753. impostor.physicsBody.applyForce(impulse, worldPoint);
  108754. };
  108755. CannonJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  108756. //parent-child relationship. Does this impostor has a parent impostor?
  108757. if (impostor.parent) {
  108758. if (impostor.physicsBody) {
  108759. this.removePhysicsBody(impostor);
  108760. //TODO is that needed?
  108761. impostor.forceUpdate();
  108762. }
  108763. return;
  108764. }
  108765. //should a new body be created for this impostor?
  108766. if (impostor.isBodyInitRequired()) {
  108767. var shape = this._createShape(impostor);
  108768. //unregister events, if body is being changed
  108769. var oldBody = impostor.physicsBody;
  108770. if (oldBody) {
  108771. this.removePhysicsBody(impostor);
  108772. }
  108773. //create the body and material
  108774. var material = this._addMaterial("mat-" + impostor.uniqueId, impostor.getParam("friction"), impostor.getParam("restitution"));
  108775. var bodyCreationObject = {
  108776. mass: impostor.getParam("mass"),
  108777. material: material
  108778. };
  108779. // A simple extend, in case native options were used.
  108780. var nativeOptions = impostor.getParam("nativeOptions");
  108781. for (var key in nativeOptions) {
  108782. if (nativeOptions.hasOwnProperty(key)) {
  108783. bodyCreationObject[key] = nativeOptions[key];
  108784. }
  108785. }
  108786. impostor.physicsBody = new this.BJSCANNON.Body(bodyCreationObject);
  108787. impostor.physicsBody.addEventListener("collide", impostor.onCollide);
  108788. this.world.addEventListener("preStep", impostor.beforeStep);
  108789. this.world.addEventListener("postStep", impostor.afterStep);
  108790. impostor.physicsBody.addShape(shape);
  108791. this.world.add(impostor.physicsBody);
  108792. //try to keep the body moving in the right direction by taking old properties.
  108793. //Should be tested!
  108794. if (oldBody) {
  108795. ['force', 'torque', 'velocity', 'angularVelocity'].forEach(function (param) {
  108796. impostor.physicsBody[param].copy(oldBody[param]);
  108797. });
  108798. }
  108799. this._processChildMeshes(impostor);
  108800. }
  108801. //now update the body's transformation
  108802. this._updatePhysicsBodyTransformation(impostor);
  108803. };
  108804. CannonJSPlugin.prototype._processChildMeshes = function (mainImpostor) {
  108805. var _this = this;
  108806. var meshChildren = mainImpostor.object.getChildMeshes ? mainImpostor.object.getChildMeshes(true) : [];
  108807. var currentRotation = mainImpostor.object.rotationQuaternion;
  108808. if (meshChildren.length) {
  108809. var processMesh = function (localPosition, mesh) {
  108810. if (!currentRotation || !mesh.rotationQuaternion) {
  108811. return;
  108812. }
  108813. var childImpostor = mesh.getPhysicsImpostor();
  108814. if (childImpostor) {
  108815. var parent = childImpostor.parent;
  108816. if (parent !== mainImpostor) {
  108817. var pPosition = mesh.getAbsolutePosition().subtract(mainImpostor.object.getAbsolutePosition());
  108818. var localRotation = mesh.rotationQuaternion.multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Inverse(currentRotation));
  108819. if (childImpostor.physicsBody) {
  108820. _this.removePhysicsBody(childImpostor);
  108821. childImpostor.physicsBody = null;
  108822. }
  108823. childImpostor.parent = mainImpostor;
  108824. childImpostor.resetUpdateFlags();
  108825. 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));
  108826. //Add the mass of the children.
  108827. mainImpostor.physicsBody.mass += childImpostor.getParam("mass");
  108828. }
  108829. }
  108830. currentRotation.multiplyInPlace(mesh.rotationQuaternion);
  108831. mesh.getChildMeshes(true).filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(_this, mesh.getAbsolutePosition()));
  108832. };
  108833. meshChildren.filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(this, mainImpostor.object.getAbsolutePosition()));
  108834. }
  108835. };
  108836. CannonJSPlugin.prototype.removePhysicsBody = function (impostor) {
  108837. impostor.physicsBody.removeEventListener("collide", impostor.onCollide);
  108838. this.world.removeEventListener("preStep", impostor.beforeStep);
  108839. this.world.removeEventListener("postStep", impostor.afterStep);
  108840. this.world.remove(impostor.physicsBody);
  108841. };
  108842. CannonJSPlugin.prototype.generateJoint = function (impostorJoint) {
  108843. var mainBody = impostorJoint.mainImpostor.physicsBody;
  108844. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  108845. if (!mainBody || !connectedBody) {
  108846. return;
  108847. }
  108848. var constraint;
  108849. var jointData = impostorJoint.joint.jointData;
  108850. //TODO - https://github.com/schteppe/this.BJSCANNON.js/blob/gh-pages/demos/collisionFilter.html
  108851. var constraintData = {
  108852. pivotA: jointData.mainPivot ? new this.BJSCANNON.Vec3().copy(jointData.mainPivot) : null,
  108853. pivotB: jointData.connectedPivot ? new this.BJSCANNON.Vec3().copy(jointData.connectedPivot) : null,
  108854. axisA: jointData.mainAxis ? new this.BJSCANNON.Vec3().copy(jointData.mainAxis) : null,
  108855. axisB: jointData.connectedAxis ? new this.BJSCANNON.Vec3().copy(jointData.connectedAxis) : null,
  108856. maxForce: jointData.nativeParams.maxForce,
  108857. collideConnected: !!jointData.collision
  108858. };
  108859. switch (impostorJoint.joint.type) {
  108860. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].HingeJoint:
  108861. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].Hinge2Joint:
  108862. constraint = new this.BJSCANNON.HingeConstraint(mainBody, connectedBody, constraintData);
  108863. break;
  108864. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].DistanceJoint:
  108865. constraint = new this.BJSCANNON.DistanceConstraint(mainBody, connectedBody, jointData.maxDistance || 2);
  108866. break;
  108867. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint:
  108868. var springData = jointData;
  108869. constraint = new this.BJSCANNON.Spring(mainBody, connectedBody, {
  108870. restLength: springData.length,
  108871. stiffness: springData.stiffness,
  108872. damping: springData.damping,
  108873. localAnchorA: constraintData.pivotA,
  108874. localAnchorB: constraintData.pivotB
  108875. });
  108876. break;
  108877. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].LockJoint:
  108878. constraint = new this.BJSCANNON.LockConstraint(mainBody, connectedBody, constraintData);
  108879. break;
  108880. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].PointToPointJoint:
  108881. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].BallAndSocketJoint:
  108882. default:
  108883. constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotB, constraintData.maxForce);
  108884. break;
  108885. }
  108886. //set the collideConnected flag after the creation, since DistanceJoint ignores it.
  108887. constraint.collideConnected = !!jointData.collision;
  108888. impostorJoint.joint.physicsJoint = constraint;
  108889. //don't add spring as constraint, as it is not one.
  108890. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  108891. this.world.addConstraint(constraint);
  108892. }
  108893. else {
  108894. impostorJoint.joint.jointData.forceApplicationCallback = impostorJoint.joint.jointData.forceApplicationCallback || function () {
  108895. constraint.applyForce();
  108896. };
  108897. impostorJoint.mainImpostor.registerAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  108898. }
  108899. };
  108900. CannonJSPlugin.prototype.removeJoint = function (impostorJoint) {
  108901. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  108902. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  108903. }
  108904. else {
  108905. impostorJoint.mainImpostor.unregisterAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  108906. }
  108907. };
  108908. CannonJSPlugin.prototype._addMaterial = function (name, friction, restitution) {
  108909. var index;
  108910. var mat;
  108911. for (index = 0; index < this._physicsMaterials.length; index++) {
  108912. mat = this._physicsMaterials[index];
  108913. if (mat.friction === friction && mat.restitution === restitution) {
  108914. return mat;
  108915. }
  108916. }
  108917. var currentMat = new this.BJSCANNON.Material(name);
  108918. currentMat.friction = friction;
  108919. currentMat.restitution = restitution;
  108920. this._physicsMaterials.push(currentMat);
  108921. return currentMat;
  108922. };
  108923. CannonJSPlugin.prototype._checkWithEpsilon = function (value) {
  108924. return value < _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon ? _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon : value;
  108925. };
  108926. CannonJSPlugin.prototype._createShape = function (impostor) {
  108927. var object = impostor.object;
  108928. var returnValue;
  108929. var extendSize = impostor.getObjectExtendSize();
  108930. switch (impostor.type) {
  108931. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].SphereImpostor:
  108932. var radiusX = extendSize.x;
  108933. var radiusY = extendSize.y;
  108934. var radiusZ = extendSize.z;
  108935. returnValue = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);
  108936. break;
  108937. //TMP also for cylinder - TODO Cannon supports cylinder natively.
  108938. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].CylinderImpostor:
  108939. var nativeParams = impostor.getParam("nativeOptions");
  108940. var radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(extendSize.x) / 2;
  108941. var radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(extendSize.x) / 2;
  108942. var height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(extendSize.y) / 2;
  108943. var numSegments = nativeParams.numSegments !== undefined ? nativeParams.numSegments : 16;
  108944. returnValue = new this.BJSCANNON.Cylinder(radiusTop, radiusBottom, height, numSegments);
  108945. break;
  108946. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].BoxImpostor:
  108947. var box = extendSize.scale(0.5);
  108948. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
  108949. break;
  108950. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor:
  108951. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead");
  108952. returnValue = new this.BJSCANNON.Plane();
  108953. break;
  108954. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor:
  108955. // should transform the vertex data to world coordinates!!
  108956. var rawVerts = object.getVerticesData ? object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) : [];
  108957. var rawFaces = object.getIndices ? object.getIndices() : [];
  108958. if (!rawVerts) {
  108959. return;
  108960. }
  108961. // get only scale! so the object could transform correctly.
  108962. var oldPosition = object.position.clone();
  108963. var oldRotation = object.rotation && object.rotation.clone();
  108964. var oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();
  108965. object.position.copyFromFloats(0, 0, 0);
  108966. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  108967. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  108968. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  108969. var transform = object.computeWorldMatrix(true);
  108970. // convert rawVerts to object space
  108971. var temp = new Array();
  108972. var index;
  108973. for (index = 0; index < rawVerts.length; index += 3) {
  108974. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(rawVerts, index), transform).toArray(temp, index);
  108975. }
  108976. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("MeshImpostor only collides against spheres.");
  108977. returnValue = new this.BJSCANNON.Trimesh(temp, rawFaces);
  108978. //now set back the transformation!
  108979. object.position.copyFrom(oldPosition);
  108980. oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);
  108981. oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);
  108982. break;
  108983. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor:
  108984. var oldPosition2 = object.position.clone();
  108985. var oldRotation2 = object.rotation && object.rotation.clone();
  108986. var oldQuaternion2 = object.rotationQuaternion && object.rotationQuaternion.clone();
  108987. object.position.copyFromFloats(0, 0, 0);
  108988. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  108989. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  108990. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  108991. object.rotationQuaternion && object.rotationQuaternion.multiplyInPlace(this._minus90X);
  108992. returnValue = this._createHeightmap(object);
  108993. object.position.copyFrom(oldPosition2);
  108994. oldRotation2 && object.rotation && object.rotation.copyFrom(oldRotation2);
  108995. oldQuaternion2 && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion2);
  108996. object.computeWorldMatrix(true);
  108997. break;
  108998. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].ParticleImpostor:
  108999. returnValue = new this.BJSCANNON.Particle();
  109000. break;
  109001. }
  109002. return returnValue;
  109003. };
  109004. CannonJSPlugin.prototype._createHeightmap = function (object, pointDepth) {
  109005. var pos = (object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  109006. var transform = object.computeWorldMatrix(true);
  109007. // convert rawVerts to object space
  109008. var temp = new Array();
  109009. var index;
  109010. for (index = 0; index < pos.length; index += 3) {
  109011. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(pos, index), transform).toArray(temp, index);
  109012. }
  109013. pos = temp;
  109014. var matrix = new Array();
  109015. //For now pointDepth will not be used and will be automatically calculated.
  109016. //Future reference - try and find the best place to add a reference to the pointDepth variable.
  109017. var arraySize = pointDepth || ~~(Math.sqrt(pos.length / 3) - 1);
  109018. var boundingInfo = object.getBoundingInfo();
  109019. var dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.y);
  109020. var minY = boundingInfo.boundingBox.extendSizeWorld.z;
  109021. var elementSize = dim * 2 / arraySize;
  109022. for (var i = 0; i < pos.length; i = i + 3) {
  109023. var x = Math.round((pos[i + 0]) / elementSize + arraySize / 2);
  109024. var z = Math.round(((pos[i + 1]) / elementSize - arraySize / 2) * -1);
  109025. var y = -pos[i + 2] + minY;
  109026. if (!matrix[x]) {
  109027. matrix[x] = [];
  109028. }
  109029. if (!matrix[x][z]) {
  109030. matrix[x][z] = y;
  109031. }
  109032. matrix[x][z] = Math.max(y, matrix[x][z]);
  109033. }
  109034. for (var x = 0; x <= arraySize; ++x) {
  109035. if (!matrix[x]) {
  109036. var loc = 1;
  109037. while (!matrix[(x + loc) % arraySize]) {
  109038. loc++;
  109039. }
  109040. matrix[x] = matrix[(x + loc) % arraySize].slice();
  109041. //console.log("missing x", x);
  109042. }
  109043. for (var z = 0; z <= arraySize; ++z) {
  109044. if (!matrix[x][z]) {
  109045. var loc = 1;
  109046. var newValue;
  109047. while (newValue === undefined) {
  109048. newValue = matrix[x][(z + loc++) % arraySize];
  109049. }
  109050. matrix[x][z] = newValue;
  109051. }
  109052. }
  109053. }
  109054. var shape = new this.BJSCANNON.Heightfield(matrix, {
  109055. elementSize: elementSize
  109056. });
  109057. //For future reference, needed for body transformation
  109058. shape.minY = minY;
  109059. return shape;
  109060. };
  109061. CannonJSPlugin.prototype._updatePhysicsBodyTransformation = function (impostor) {
  109062. var object = impostor.object;
  109063. //make sure it is updated...
  109064. object.computeWorldMatrix && object.computeWorldMatrix(true);
  109065. // The delta between the mesh position and the mesh bounding box center
  109066. var bInfo = object.getBoundingInfo();
  109067. if (!bInfo) {
  109068. return;
  109069. }
  109070. var center = impostor.getObjectCenter();
  109071. //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
  109072. this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
  109073. this._tmpDeltaPosition.divideInPlace(impostor.object.scaling);
  109074. this._tmpPosition.copyFrom(center);
  109075. var quaternion = object.rotationQuaternion;
  109076. if (!quaternion) {
  109077. return;
  109078. }
  109079. //is shape is a plane or a heightmap, it must be rotated 90 degs in the X axis.
  109080. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor || impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor || impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].CylinderImpostor) {
  109081. //-90 DEG in X, precalculated
  109082. quaternion = quaternion.multiply(this._minus90X);
  109083. //Invert! (Precalculated, 90 deg in X)
  109084. //No need to clone. this will never change.
  109085. impostor.setDeltaRotation(this._plus90X);
  109086. }
  109087. //If it is a heightfield, if should be centered.
  109088. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  109089. var mesh = object;
  109090. var boundingInfo = mesh.getBoundingInfo();
  109091. //calculate the correct body position:
  109092. var rotationQuaternion = mesh.rotationQuaternion;
  109093. mesh.rotationQuaternion = this._tmpUnityRotation;
  109094. mesh.computeWorldMatrix(true);
  109095. //get original center with no rotation
  109096. var c = center.clone();
  109097. var oldPivot = mesh.getPivotMatrix();
  109098. if (oldPivot) {
  109099. // create a copy the pivot Matrix as it is modified in place
  109100. oldPivot = oldPivot.clone();
  109101. }
  109102. else {
  109103. oldPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  109104. }
  109105. //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)
  109106. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);
  109107. mesh.setPreTransformMatrix(p);
  109108. mesh.computeWorldMatrix(true);
  109109. //calculate the translation
  109110. var translation = boundingInfo.boundingBox.centerWorld.subtract(center).subtract(mesh.position).negate();
  109111. this._tmpPosition.copyFromFloats(translation.x, translation.y - boundingInfo.boundingBox.extendSizeWorld.y, translation.z);
  109112. //add it inverted to the delta
  109113. this._tmpDeltaPosition.copyFrom(boundingInfo.boundingBox.centerWorld.subtract(c));
  109114. this._tmpDeltaPosition.y += boundingInfo.boundingBox.extendSizeWorld.y;
  109115. //rotation is back
  109116. mesh.rotationQuaternion = rotationQuaternion;
  109117. mesh.setPreTransformMatrix(oldPivot);
  109118. mesh.computeWorldMatrix(true);
  109119. }
  109120. else if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor) {
  109121. this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
  109122. //this._tmpPosition.copyFrom(object.position);
  109123. }
  109124. impostor.setDeltaPosition(this._tmpDeltaPosition);
  109125. //Now update the impostor object
  109126. impostor.physicsBody.position.copy(this._tmpPosition);
  109127. impostor.physicsBody.quaternion.copy(quaternion);
  109128. };
  109129. CannonJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  109130. impostor.object.position.copyFrom(impostor.physicsBody.position);
  109131. if (impostor.object.rotationQuaternion) {
  109132. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
  109133. }
  109134. };
  109135. CannonJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  109136. impostor.physicsBody.position.copy(newPosition);
  109137. impostor.physicsBody.quaternion.copy(newRotation);
  109138. };
  109139. CannonJSPlugin.prototype.isSupported = function () {
  109140. return this.BJSCANNON !== undefined;
  109141. };
  109142. CannonJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  109143. impostor.physicsBody.velocity.copy(velocity);
  109144. };
  109145. CannonJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  109146. impostor.physicsBody.angularVelocity.copy(velocity);
  109147. };
  109148. CannonJSPlugin.prototype.getLinearVelocity = function (impostor) {
  109149. var v = impostor.physicsBody.velocity;
  109150. if (!v) {
  109151. return null;
  109152. }
  109153. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  109154. };
  109155. CannonJSPlugin.prototype.getAngularVelocity = function (impostor) {
  109156. var v = impostor.physicsBody.angularVelocity;
  109157. if (!v) {
  109158. return null;
  109159. }
  109160. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  109161. };
  109162. CannonJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  109163. impostor.physicsBody.mass = mass;
  109164. impostor.physicsBody.updateMassProperties();
  109165. };
  109166. CannonJSPlugin.prototype.getBodyMass = function (impostor) {
  109167. return impostor.physicsBody.mass;
  109168. };
  109169. CannonJSPlugin.prototype.getBodyFriction = function (impostor) {
  109170. return impostor.physicsBody.material.friction;
  109171. };
  109172. CannonJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  109173. impostor.physicsBody.material.friction = friction;
  109174. };
  109175. CannonJSPlugin.prototype.getBodyRestitution = function (impostor) {
  109176. return impostor.physicsBody.material.restitution;
  109177. };
  109178. CannonJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  109179. impostor.physicsBody.material.restitution = restitution;
  109180. };
  109181. CannonJSPlugin.prototype.sleepBody = function (impostor) {
  109182. impostor.physicsBody.sleep();
  109183. };
  109184. CannonJSPlugin.prototype.wakeUpBody = function (impostor) {
  109185. impostor.physicsBody.wakeUp();
  109186. };
  109187. CannonJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance) {
  109188. joint.physicsJoint.distance = maxDistance;
  109189. };
  109190. // private enableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  109191. // if (!motorIndex) {
  109192. // joint.physicsJoint.enableMotor();
  109193. // }
  109194. // }
  109195. // private disableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  109196. // if (!motorIndex) {
  109197. // joint.physicsJoint.disableMotor();
  109198. // }
  109199. // }
  109200. CannonJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  109201. if (!motorIndex) {
  109202. joint.physicsJoint.enableMotor();
  109203. joint.physicsJoint.setMotorSpeed(speed);
  109204. if (maxForce) {
  109205. this.setLimit(joint, maxForce);
  109206. }
  109207. }
  109208. };
  109209. CannonJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  109210. joint.physicsJoint.motorEquation.maxForce = upperLimit;
  109211. joint.physicsJoint.motorEquation.minForce = lowerLimit === void 0 ? -upperLimit : lowerLimit;
  109212. };
  109213. CannonJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  109214. var body = impostor.physicsBody;
  109215. mesh.position.x = body.position.x;
  109216. mesh.position.y = body.position.y;
  109217. mesh.position.z = body.position.z;
  109218. if (mesh.rotationQuaternion) {
  109219. mesh.rotationQuaternion.x = body.quaternion.x;
  109220. mesh.rotationQuaternion.y = body.quaternion.y;
  109221. mesh.rotationQuaternion.z = body.quaternion.z;
  109222. mesh.rotationQuaternion.w = body.quaternion.w;
  109223. }
  109224. };
  109225. CannonJSPlugin.prototype.getRadius = function (impostor) {
  109226. var shape = impostor.physicsBody.shapes[0];
  109227. return shape.boundingSphereRadius;
  109228. };
  109229. CannonJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  109230. var shape = impostor.physicsBody.shapes[0];
  109231. result.x = shape.halfExtents.x * 2;
  109232. result.y = shape.halfExtents.y * 2;
  109233. result.z = shape.halfExtents.z * 2;
  109234. };
  109235. CannonJSPlugin.prototype.dispose = function () {
  109236. };
  109237. CannonJSPlugin.prototype._extendNamespace = function () {
  109238. //this will force cannon to execute at least one step when using interpolation
  109239. var step_tmp1 = new this.BJSCANNON.Vec3();
  109240. var Engine = this.BJSCANNON;
  109241. this.BJSCANNON.World.prototype.step = function (dt, timeSinceLastCalled, maxSubSteps) {
  109242. maxSubSteps = maxSubSteps || 10;
  109243. timeSinceLastCalled = timeSinceLastCalled || 0;
  109244. if (timeSinceLastCalled === 0) {
  109245. this.internalStep(dt);
  109246. this.time += dt;
  109247. }
  109248. else {
  109249. var internalSteps = Math.floor((this.time + timeSinceLastCalled) / dt) - Math.floor(this.time / dt);
  109250. internalSteps = Math.min(internalSteps, maxSubSteps) || 1;
  109251. var t0 = performance.now();
  109252. for (var i = 0; i !== internalSteps; i++) {
  109253. this.internalStep(dt);
  109254. if (performance.now() - t0 > dt * 1000) {
  109255. break;
  109256. }
  109257. }
  109258. this.time += timeSinceLastCalled;
  109259. var h = this.time % dt;
  109260. var h_div_dt = h / dt;
  109261. var interpvelo = step_tmp1;
  109262. var bodies = this.bodies;
  109263. for (var j = 0; j !== bodies.length; j++) {
  109264. var b = bodies[j];
  109265. if (b.type !== Engine.Body.STATIC && b.sleepState !== Engine.Body.SLEEPING) {
  109266. b.position.vsub(b.previousPosition, interpvelo);
  109267. interpvelo.scale(h_div_dt, interpvelo);
  109268. b.position.vadd(interpvelo, b.interpolatedPosition);
  109269. }
  109270. else {
  109271. b.interpolatedPosition.copy(b.position);
  109272. b.interpolatedQuaternion.copy(b.quaternion);
  109273. }
  109274. }
  109275. }
  109276. };
  109277. };
  109278. return CannonJSPlugin;
  109279. }());
  109280. _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].DefaultPluginFactory = function () { return new CannonJSPlugin(); };
  109281. /***/ }),
  109282. /***/ "./Physics/Plugins/index.ts":
  109283. /*!**********************************!*\
  109284. !*** ./Physics/Plugins/index.ts ***!
  109285. \**********************************/
  109286. /*! exports provided: CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  109287. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109288. "use strict";
  109289. __webpack_require__.r(__webpack_exports__);
  109290. /* harmony import */ var _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  109291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  109292. /* harmony import */ var _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  109293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__["AmmoJSPlugin"]; });
  109294. /* harmony import */ var _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  109295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__["OimoJSPlugin"]; });
  109296. /***/ }),
  109297. /***/ "./Physics/Plugins/oimoJSPlugin.ts":
  109298. /*!*****************************************!*\
  109299. !*** ./Physics/Plugins/oimoJSPlugin.ts ***!
  109300. \*****************************************/
  109301. /*! exports provided: OimoJSPlugin */
  109302. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109303. "use strict";
  109304. __webpack_require__.r(__webpack_exports__);
  109305. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return OimoJSPlugin; });
  109306. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  109307. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  109308. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  109309. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  109310. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  109311. /** @hidden */
  109312. var OimoJSPlugin = /** @class */ (function () {
  109313. function OimoJSPlugin(iterations, oimoInjection) {
  109314. if (oimoInjection === void 0) { oimoInjection = OIMO; }
  109315. this.name = "OimoJSPlugin";
  109316. this._tmpImpostorsArray = [];
  109317. this._tmpPositionVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  109318. this.BJSOIMO = oimoInjection;
  109319. this.world = new this.BJSOIMO.World({
  109320. iterations: iterations
  109321. });
  109322. this.world.clear();
  109323. }
  109324. OimoJSPlugin.prototype.setGravity = function (gravity) {
  109325. this.world.gravity.copy(gravity);
  109326. };
  109327. OimoJSPlugin.prototype.setTimeStep = function (timeStep) {
  109328. this.world.timeStep = timeStep;
  109329. };
  109330. OimoJSPlugin.prototype.getTimeStep = function () {
  109331. return this.world.timeStep;
  109332. };
  109333. OimoJSPlugin.prototype.executeStep = function (delta, impostors) {
  109334. var _this = this;
  109335. impostors.forEach(function (impostor) {
  109336. impostor.beforeStep();
  109337. });
  109338. this.world.step();
  109339. impostors.forEach(function (impostor) {
  109340. impostor.afterStep();
  109341. //update the ordered impostors array
  109342. _this._tmpImpostorsArray[impostor.uniqueId] = impostor;
  109343. });
  109344. //check for collisions
  109345. var contact = this.world.contacts;
  109346. while (contact !== null) {
  109347. if (contact.touching && !contact.body1.sleeping && !contact.body2.sleeping) {
  109348. contact = contact.next;
  109349. continue;
  109350. }
  109351. //is this body colliding with any other? get the impostor
  109352. var mainImpostor = this._tmpImpostorsArray[+contact.body1.name];
  109353. var collidingImpostor = this._tmpImpostorsArray[+contact.body2.name];
  109354. if (!mainImpostor || !collidingImpostor) {
  109355. contact = contact.next;
  109356. continue;
  109357. }
  109358. mainImpostor.onCollide({ body: collidingImpostor.physicsBody });
  109359. collidingImpostor.onCollide({ body: mainImpostor.physicsBody });
  109360. contact = contact.next;
  109361. }
  109362. };
  109363. OimoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  109364. var mass = impostor.physicsBody.mass;
  109365. impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));
  109366. };
  109367. OimoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  109368. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("Oimo doesn't support applying force. Using impule instead.");
  109369. this.applyImpulse(impostor, force, contactPoint);
  109370. };
  109371. OimoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  109372. var _this = this;
  109373. //parent-child relationship. Does this impostor has a parent impostor?
  109374. if (impostor.parent) {
  109375. if (impostor.physicsBody) {
  109376. this.removePhysicsBody(impostor);
  109377. //TODO is that needed?
  109378. impostor.forceUpdate();
  109379. }
  109380. return;
  109381. }
  109382. if (impostor.isBodyInitRequired()) {
  109383. var bodyConfig = {
  109384. name: impostor.uniqueId,
  109385. //Oimo must have mass, also for static objects.
  109386. config: [impostor.getParam("mass") || 1, impostor.getParam("friction"), impostor.getParam("restitution")],
  109387. size: [],
  109388. type: [],
  109389. pos: [],
  109390. posShape: [],
  109391. rot: [],
  109392. rotShape: [],
  109393. move: impostor.getParam("mass") !== 0,
  109394. density: impostor.getParam("mass"),
  109395. friction: impostor.getParam("friction"),
  109396. restitution: impostor.getParam("restitution"),
  109397. //Supporting older versions of Oimo
  109398. world: this.world
  109399. };
  109400. var impostors = [impostor];
  109401. var addToArray = function (parent) {
  109402. if (!parent.getChildMeshes) {
  109403. return;
  109404. }
  109405. parent.getChildMeshes().forEach(function (m) {
  109406. if (m.physicsImpostor) {
  109407. impostors.push(m.physicsImpostor);
  109408. //m.physicsImpostor._init();
  109409. }
  109410. });
  109411. };
  109412. addToArray(impostor.object);
  109413. var checkWithEpsilon_1 = function (value) {
  109414. return Math.max(value, _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__["PhysicsEngine"].Epsilon);
  109415. };
  109416. var globalQuaternion_1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  109417. impostors.forEach(function (i) {
  109418. if (!i.object.rotationQuaternion) {
  109419. return;
  109420. }
  109421. //get the correct bounding box
  109422. var oldQuaternion = i.object.rotationQuaternion;
  109423. globalQuaternion_1 = oldQuaternion.clone();
  109424. var rot = oldQuaternion.toEulerAngles();
  109425. var extendSize = i.getObjectExtendSize();
  109426. var radToDeg = 57.295779513082320876;
  109427. if (i === impostor) {
  109428. var center = impostor.getObjectCenter();
  109429. impostor.object.getAbsolutePivotPoint().subtractToRef(center, _this._tmpPositionVector);
  109430. _this._tmpPositionVector.divideInPlace(impostor.object.scaling);
  109431. //Can also use Array.prototype.push.apply
  109432. bodyConfig.pos.push(center.x);
  109433. bodyConfig.pos.push(center.y);
  109434. bodyConfig.pos.push(center.z);
  109435. bodyConfig.posShape.push(0, 0, 0);
  109436. bodyConfig.rotShape.push(0, 0, 0);
  109437. }
  109438. else {
  109439. var localPosition = i.object.getAbsolutePosition().subtract(impostor.object.getAbsolutePosition());
  109440. bodyConfig.posShape.push(localPosition.x);
  109441. bodyConfig.posShape.push(localPosition.y);
  109442. bodyConfig.posShape.push(localPosition.z);
  109443. bodyConfig.pos.push(0, 0, 0);
  109444. bodyConfig.rotShape.push(rot.x * radToDeg);
  109445. bodyConfig.rotShape.push(rot.y * radToDeg);
  109446. bodyConfig.rotShape.push(rot.z * radToDeg);
  109447. }
  109448. // register mesh
  109449. switch (i.type) {
  109450. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].ParticleImpostor:
  109451. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("No Particle support in OIMO.js. using SphereImpostor instead");
  109452. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].SphereImpostor:
  109453. var radiusX = extendSize.x;
  109454. var radiusY = extendSize.y;
  109455. var radiusZ = extendSize.z;
  109456. var size = Math.max(checkWithEpsilon_1(radiusX), checkWithEpsilon_1(radiusY), checkWithEpsilon_1(radiusZ)) / 2;
  109457. bodyConfig.type.push('sphere');
  109458. //due to the way oimo works with compounds, add 3 times
  109459. bodyConfig.size.push(size);
  109460. bodyConfig.size.push(size);
  109461. bodyConfig.size.push(size);
  109462. break;
  109463. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].CylinderImpostor:
  109464. var sizeX = checkWithEpsilon_1(extendSize.x) / 2;
  109465. var sizeY = checkWithEpsilon_1(extendSize.y);
  109466. bodyConfig.type.push('cylinder');
  109467. bodyConfig.size.push(sizeX);
  109468. bodyConfig.size.push(sizeY);
  109469. //due to the way oimo works with compounds, add one more value.
  109470. bodyConfig.size.push(sizeY);
  109471. break;
  109472. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].PlaneImpostor:
  109473. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].BoxImpostor:
  109474. default:
  109475. var sizeX = checkWithEpsilon_1(extendSize.x);
  109476. var sizeY = checkWithEpsilon_1(extendSize.y);
  109477. var sizeZ = checkWithEpsilon_1(extendSize.z);
  109478. bodyConfig.type.push('box');
  109479. //if (i === impostor) {
  109480. bodyConfig.size.push(sizeX);
  109481. bodyConfig.size.push(sizeY);
  109482. bodyConfig.size.push(sizeZ);
  109483. //} else {
  109484. // bodyConfig.size.push(0,0,0);
  109485. //}
  109486. break;
  109487. }
  109488. //actually not needed, but hey...
  109489. i.object.rotationQuaternion = oldQuaternion;
  109490. });
  109491. impostor.physicsBody = this.world.add(bodyConfig);
  109492. // set the quaternion, ignoring the previously defined (euler) rotation
  109493. impostor.physicsBody.resetQuaternion(globalQuaternion_1);
  109494. // update with delta 0, so the body will reveive the new rotation.
  109495. impostor.physicsBody.updatePosition(0);
  109496. }
  109497. else {
  109498. this._tmpPositionVector.copyFromFloats(0, 0, 0);
  109499. }
  109500. impostor.setDeltaPosition(this._tmpPositionVector);
  109501. //this._tmpPositionVector.addInPlace(impostor.mesh.getBoundingInfo().boundingBox.center);
  109502. //this.setPhysicsBodyTransformation(impostor, this._tmpPositionVector, impostor.mesh.rotationQuaternion);
  109503. };
  109504. OimoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  109505. //impostor.physicsBody.dispose();
  109506. //Same as : (older oimo versions)
  109507. this.world.removeRigidBody(impostor.physicsBody);
  109508. };
  109509. OimoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  109510. var mainBody = impostorJoint.mainImpostor.physicsBody;
  109511. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  109512. if (!mainBody || !connectedBody) {
  109513. return;
  109514. }
  109515. var jointData = impostorJoint.joint.jointData;
  109516. var options = jointData.nativeParams || {};
  109517. var type;
  109518. var nativeJointData = {
  109519. body1: mainBody,
  109520. body2: connectedBody,
  109521. axe1: options.axe1 || (jointData.mainAxis ? jointData.mainAxis.asArray() : null),
  109522. axe2: options.axe2 || (jointData.connectedAxis ? jointData.connectedAxis.asArray() : null),
  109523. pos1: options.pos1 || (jointData.mainPivot ? jointData.mainPivot.asArray() : null),
  109524. pos2: options.pos2 || (jointData.connectedPivot ? jointData.connectedPivot.asArray() : null),
  109525. min: options.min,
  109526. max: options.max,
  109527. collision: options.collision || jointData.collision,
  109528. spring: options.spring,
  109529. //supporting older version of Oimo
  109530. world: this.world
  109531. };
  109532. switch (impostorJoint.joint.type) {
  109533. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].BallAndSocketJoint:
  109534. type = "jointBall";
  109535. break;
  109536. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SpringJoint:
  109537. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
  109538. var springData = jointData;
  109539. nativeJointData.min = springData.length || nativeJointData.min;
  109540. //Max should also be set, just make sure it is at least min
  109541. nativeJointData.max = Math.max(nativeJointData.min, nativeJointData.max);
  109542. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].DistanceJoint:
  109543. type = "jointDistance";
  109544. nativeJointData.max = jointData.maxDistance;
  109545. break;
  109546. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].PrismaticJoint:
  109547. type = "jointPrisme";
  109548. break;
  109549. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SliderJoint:
  109550. type = "jointSlide";
  109551. break;
  109552. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].WheelJoint:
  109553. type = "jointWheel";
  109554. break;
  109555. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].HingeJoint:
  109556. default:
  109557. type = "jointHinge";
  109558. break;
  109559. }
  109560. nativeJointData.type = type;
  109561. impostorJoint.joint.physicsJoint = this.world.add(nativeJointData);
  109562. };
  109563. OimoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  109564. //Bug in Oimo prevents us from disposing a joint in the playground
  109565. //joint.joint.physicsJoint.dispose();
  109566. //So we will bruteforce it!
  109567. try {
  109568. this.world.removeJoint(impostorJoint.joint.physicsJoint);
  109569. }
  109570. catch (e) {
  109571. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn(e);
  109572. }
  109573. };
  109574. OimoJSPlugin.prototype.isSupported = function () {
  109575. return this.BJSOIMO !== undefined;
  109576. };
  109577. OimoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  109578. if (!impostor.physicsBody.sleeping) {
  109579. //TODO check that
  109580. /*if (impostor.physicsBody.shapes.next) {
  109581. var parentShape = this._getLastShape(impostor.physicsBody);
  109582. impostor.object.position.copyFrom(parentShape.position);
  109583. console.log(parentShape.position);
  109584. } else {*/
  109585. impostor.object.position.copyFrom(impostor.physicsBody.getPosition());
  109586. //}
  109587. if (impostor.object.rotationQuaternion) {
  109588. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.getQuaternion());
  109589. }
  109590. }
  109591. };
  109592. OimoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  109593. var body = impostor.physicsBody;
  109594. body.position.copy(newPosition);
  109595. body.orientation.copy(newRotation);
  109596. body.syncShapes();
  109597. body.awake();
  109598. };
  109599. /*private _getLastShape(body: any): any {
  109600. var lastShape = body.shapes;
  109601. while (lastShape.next) {
  109602. lastShape = lastShape.next;
  109603. }
  109604. return lastShape;
  109605. }*/
  109606. OimoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  109607. impostor.physicsBody.linearVelocity.copy(velocity);
  109608. };
  109609. OimoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  109610. impostor.physicsBody.angularVelocity.copy(velocity);
  109611. };
  109612. OimoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  109613. var v = impostor.physicsBody.linearVelocity;
  109614. if (!v) {
  109615. return null;
  109616. }
  109617. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  109618. };
  109619. OimoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  109620. var v = impostor.physicsBody.angularVelocity;
  109621. if (!v) {
  109622. return null;
  109623. }
  109624. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  109625. };
  109626. OimoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  109627. var staticBody = mass === 0;
  109628. //this will actually set the body's density and not its mass.
  109629. //But this is how oimo treats the mass variable.
  109630. impostor.physicsBody.shapes.density = staticBody ? 1 : mass;
  109631. impostor.physicsBody.setupMass(staticBody ? 0x2 : 0x1);
  109632. };
  109633. OimoJSPlugin.prototype.getBodyMass = function (impostor) {
  109634. return impostor.physicsBody.shapes.density;
  109635. };
  109636. OimoJSPlugin.prototype.getBodyFriction = function (impostor) {
  109637. return impostor.physicsBody.shapes.friction;
  109638. };
  109639. OimoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  109640. impostor.physicsBody.shapes.friction = friction;
  109641. };
  109642. OimoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  109643. return impostor.physicsBody.shapes.restitution;
  109644. };
  109645. OimoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  109646. impostor.physicsBody.shapes.restitution = restitution;
  109647. };
  109648. OimoJSPlugin.prototype.sleepBody = function (impostor) {
  109649. impostor.physicsBody.sleep();
  109650. };
  109651. OimoJSPlugin.prototype.wakeUpBody = function (impostor) {
  109652. impostor.physicsBody.awake();
  109653. };
  109654. OimoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  109655. joint.physicsJoint.limitMotor.upperLimit = maxDistance;
  109656. if (minDistance !== void 0) {
  109657. joint.physicsJoint.limitMotor.lowerLimit = minDistance;
  109658. }
  109659. };
  109660. OimoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  109661. //TODO separate rotational and transational motors.
  109662. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  109663. if (motor) {
  109664. motor.setMotor(speed, maxForce);
  109665. }
  109666. };
  109667. OimoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit, motorIndex) {
  109668. //TODO separate rotational and transational motors.
  109669. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  109670. if (motor) {
  109671. motor.setLimit(upperLimit, lowerLimit === void 0 ? -upperLimit : lowerLimit);
  109672. }
  109673. };
  109674. OimoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  109675. var body = impostor.physicsBody;
  109676. mesh.position.x = body.position.x;
  109677. mesh.position.y = body.position.y;
  109678. mesh.position.z = body.position.z;
  109679. if (mesh.rotationQuaternion) {
  109680. mesh.rotationQuaternion.x = body.orientation.x;
  109681. mesh.rotationQuaternion.y = body.orientation.y;
  109682. mesh.rotationQuaternion.z = body.orientation.z;
  109683. mesh.rotationQuaternion.w = body.orientation.s;
  109684. }
  109685. };
  109686. OimoJSPlugin.prototype.getRadius = function (impostor) {
  109687. return impostor.physicsBody.shapes.radius;
  109688. };
  109689. OimoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  109690. var shape = impostor.physicsBody.shapes;
  109691. result.x = shape.halfWidth * 2;
  109692. result.y = shape.halfHeight * 2;
  109693. result.z = shape.halfDepth * 2;
  109694. };
  109695. OimoJSPlugin.prototype.dispose = function () {
  109696. this.world.clear();
  109697. };
  109698. return OimoJSPlugin;
  109699. }());
  109700. /***/ }),
  109701. /***/ "./Physics/index.ts":
  109702. /*!**************************!*\
  109703. !*** ./Physics/index.ts ***!
  109704. \**************************/
  109705. /*! exports provided: PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  109706. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109707. "use strict";
  109708. __webpack_require__.r(__webpack_exports__);
  109709. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  109710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _physicsEngine__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  109711. /* harmony import */ var _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./physicsEngineComponent */ "./Physics/physicsEngineComponent.ts");
  109712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__["PhysicsEngineSceneComponent"]; });
  109713. /* harmony import */ var _physicsHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./physicsHelper */ "./Physics/physicsHelper.ts");
  109714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsHelper"]; });
  109715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialExplosionEvent"]; });
  109716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsGravitationalFieldEvent"]; });
  109717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftEvent"]; });
  109718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsVortexEvent"]; });
  109719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialImpulseFalloff"]; });
  109720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftMode"]; });
  109721. /* harmony import */ var _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsImpostor */ "./Physics/physicsImpostor.ts");
  109722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"]; });
  109723. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  109724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"]; });
  109725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["DistanceJoint"]; });
  109726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["MotorEnabledJoint"]; });
  109727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["HingeJoint"]; });
  109728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["Hinge2Joint"]; });
  109729. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Plugins/index */ "./Physics/Plugins/index.ts");
  109730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["CannonJSPlugin"]; });
  109731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["AmmoJSPlugin"]; });
  109732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["OimoJSPlugin"]; });
  109733. /***/ }),
  109734. /***/ "./Physics/physicsEngine.ts":
  109735. /*!**********************************!*\
  109736. !*** ./Physics/physicsEngine.ts ***!
  109737. \**********************************/
  109738. /*! exports provided: PhysicsEngine */
  109739. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109740. "use strict";
  109741. __webpack_require__.r(__webpack_exports__);
  109742. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return PhysicsEngine; });
  109743. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  109744. /**
  109745. * Class used to control physics engine
  109746. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  109747. */
  109748. var PhysicsEngine = /** @class */ (function () {
  109749. /**
  109750. * Creates a new Physics Engine
  109751. * @param gravity defines the gravity vector used by the simulation
  109752. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  109753. */
  109754. function PhysicsEngine(gravity, _physicsPlugin) {
  109755. if (_physicsPlugin === void 0) { _physicsPlugin = PhysicsEngine.DefaultPluginFactory(); }
  109756. this._physicsPlugin = _physicsPlugin;
  109757. this._impostors = [];
  109758. this._joints = [];
  109759. if (!this._physicsPlugin.isSupported()) {
  109760. throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. "
  109761. + "Please make sure it is included.");
  109762. }
  109763. gravity = gravity || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -9.807, 0);
  109764. this.setGravity(gravity);
  109765. this.setTimeStep();
  109766. }
  109767. /**
  109768. * Factory used to create the default physics plugin.
  109769. * @returns The default physics plugin
  109770. */
  109771. PhysicsEngine.DefaultPluginFactory = function () {
  109772. throw "Import CannonJSPlugin or Fill DefaultPluginFactory static property on PhysicsEngine before relying on default physics plugin.";
  109773. };
  109774. /**
  109775. * Sets the gravity vector used by the simulation
  109776. * @param gravity defines the gravity vector to use
  109777. */
  109778. PhysicsEngine.prototype.setGravity = function (gravity) {
  109779. this.gravity = gravity;
  109780. this._physicsPlugin.setGravity(this.gravity);
  109781. };
  109782. /**
  109783. * Set the time step of the physics engine.
  109784. * Default is 1/60.
  109785. * To slow it down, enter 1/600 for example.
  109786. * To speed it up, 1/30
  109787. * @param newTimeStep defines the new timestep to apply to this world.
  109788. */
  109789. PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
  109790. if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
  109791. this._physicsPlugin.setTimeStep(newTimeStep);
  109792. };
  109793. /**
  109794. * Get the time step of the physics engine.
  109795. * @returns the current time step
  109796. */
  109797. PhysicsEngine.prototype.getTimeStep = function () {
  109798. return this._physicsPlugin.getTimeStep();
  109799. };
  109800. /**
  109801. * Release all resources
  109802. */
  109803. PhysicsEngine.prototype.dispose = function () {
  109804. this._impostors.forEach(function (impostor) {
  109805. impostor.dispose();
  109806. });
  109807. this._physicsPlugin.dispose();
  109808. };
  109809. /**
  109810. * Gets the name of the current physics plugin
  109811. * @returns the name of the plugin
  109812. */
  109813. PhysicsEngine.prototype.getPhysicsPluginName = function () {
  109814. return this._physicsPlugin.name;
  109815. };
  109816. /**
  109817. * Adding a new impostor for the impostor tracking.
  109818. * This will be done by the impostor itself.
  109819. * @param impostor the impostor to add
  109820. */
  109821. PhysicsEngine.prototype.addImpostor = function (impostor) {
  109822. impostor.uniqueId = this._impostors.push(impostor);
  109823. //if no parent, generate the body
  109824. if (!impostor.parent) {
  109825. this._physicsPlugin.generatePhysicsBody(impostor);
  109826. }
  109827. };
  109828. /**
  109829. * Remove an impostor from the engine.
  109830. * This impostor and its mesh will not longer be updated by the physics engine.
  109831. * @param impostor the impostor to remove
  109832. */
  109833. PhysicsEngine.prototype.removeImpostor = function (impostor) {
  109834. var index = this._impostors.indexOf(impostor);
  109835. if (index > -1) {
  109836. var removed = this._impostors.splice(index, 1);
  109837. //Is it needed?
  109838. if (removed.length) {
  109839. //this will also remove it from the world.
  109840. removed[0].physicsBody = null;
  109841. }
  109842. }
  109843. };
  109844. /**
  109845. * Add a joint to the physics engine
  109846. * @param mainImpostor defines the main impostor to which the joint is added.
  109847. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  109848. * @param joint defines the joint that will connect both impostors.
  109849. */
  109850. PhysicsEngine.prototype.addJoint = function (mainImpostor, connectedImpostor, joint) {
  109851. var impostorJoint = {
  109852. mainImpostor: mainImpostor,
  109853. connectedImpostor: connectedImpostor,
  109854. joint: joint
  109855. };
  109856. joint.physicsPlugin = this._physicsPlugin;
  109857. this._joints.push(impostorJoint);
  109858. this._physicsPlugin.generateJoint(impostorJoint);
  109859. };
  109860. /**
  109861. * Removes a joint from the simulation
  109862. * @param mainImpostor defines the impostor used with the joint
  109863. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  109864. * @param joint defines the joint to remove
  109865. */
  109866. PhysicsEngine.prototype.removeJoint = function (mainImpostor, connectedImpostor, joint) {
  109867. var matchingJoints = this._joints.filter(function (impostorJoint) {
  109868. return (impostorJoint.connectedImpostor === connectedImpostor
  109869. && impostorJoint.joint === joint
  109870. && impostorJoint.mainImpostor === mainImpostor);
  109871. });
  109872. if (matchingJoints.length) {
  109873. this._physicsPlugin.removeJoint(matchingJoints[0]);
  109874. //TODO remove it from the list as well
  109875. }
  109876. };
  109877. /**
  109878. * Called by the scene. No need to call it.
  109879. * @param delta defines the timespam between frames
  109880. */
  109881. PhysicsEngine.prototype._step = function (delta) {
  109882. var _this = this;
  109883. //check if any mesh has no body / requires an update
  109884. this._impostors.forEach(function (impostor) {
  109885. if (impostor.isBodyInitRequired()) {
  109886. _this._physicsPlugin.generatePhysicsBody(impostor);
  109887. }
  109888. });
  109889. if (delta > 0.1) {
  109890. delta = 0.1;
  109891. }
  109892. else if (delta <= 0) {
  109893. delta = 1.0 / 60.0;
  109894. }
  109895. this._physicsPlugin.executeStep(delta, this._impostors);
  109896. };
  109897. /**
  109898. * Gets the current plugin used to run the simulation
  109899. * @returns current plugin
  109900. */
  109901. PhysicsEngine.prototype.getPhysicsPlugin = function () {
  109902. return this._physicsPlugin;
  109903. };
  109904. /**
  109905. * Gets the list of physic impostors
  109906. * @returns an array of PhysicsImpostor
  109907. */
  109908. PhysicsEngine.prototype.getImpostors = function () {
  109909. return this._impostors;
  109910. };
  109911. /**
  109912. * Gets the impostor for a physics enabled object
  109913. * @param object defines the object impersonated by the impostor
  109914. * @returns the PhysicsImpostor or null if not found
  109915. */
  109916. PhysicsEngine.prototype.getImpostorForPhysicsObject = function (object) {
  109917. for (var i = 0; i < this._impostors.length; ++i) {
  109918. if (this._impostors[i].object === object) {
  109919. return this._impostors[i];
  109920. }
  109921. }
  109922. return null;
  109923. };
  109924. /**
  109925. * Gets the impostor for a physics body object
  109926. * @param body defines physics body used by the impostor
  109927. * @returns the PhysicsImpostor or null if not found
  109928. */
  109929. PhysicsEngine.prototype.getImpostorWithPhysicsBody = function (body) {
  109930. for (var i = 0; i < this._impostors.length; ++i) {
  109931. if (this._impostors[i].physicsBody === body) {
  109932. return this._impostors[i];
  109933. }
  109934. }
  109935. return null;
  109936. };
  109937. /**
  109938. * Global value used to control the smallest number supported by the simulation
  109939. */
  109940. PhysicsEngine.Epsilon = 0.001;
  109941. return PhysicsEngine;
  109942. }());
  109943. /***/ }),
  109944. /***/ "./Physics/physicsEngineComponent.ts":
  109945. /*!*******************************************!*\
  109946. !*** ./Physics/physicsEngineComponent.ts ***!
  109947. \*******************************************/
  109948. /*! exports provided: PhysicsEngineSceneComponent */
  109949. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109950. "use strict";
  109951. __webpack_require__.r(__webpack_exports__);
  109952. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return PhysicsEngineSceneComponent; });
  109953. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  109954. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  109955. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  109956. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  109957. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  109958. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  109959. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  109960. /**
  109961. * Gets the current physics engine
  109962. * @returns a IPhysicsEngine or null if none attached
  109963. */
  109964. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.getPhysicsEngine = function () {
  109965. return this._physicsEngine;
  109966. };
  109967. /**
  109968. * Enables physics to the current scene
  109969. * @param gravity defines the scene's gravity for the physics engine
  109970. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  109971. * @return a boolean indicating if the physics engine was initialized
  109972. */
  109973. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.enablePhysics = function (gravity, plugin) {
  109974. if (gravity === void 0) { gravity = null; }
  109975. if (this._physicsEngine) {
  109976. return true;
  109977. }
  109978. // Register the component to the scene
  109979. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE);
  109980. if (!component) {
  109981. component = new PhysicsEngineSceneComponent(this);
  109982. this._addComponent(component);
  109983. }
  109984. try {
  109985. this._physicsEngine = new _physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"](gravity, plugin);
  109986. return true;
  109987. }
  109988. catch (e) {
  109989. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error(e.message);
  109990. return false;
  109991. }
  109992. };
  109993. /**
  109994. * Disables and disposes the physics engine associated with the scene
  109995. */
  109996. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.disablePhysicsEngine = function () {
  109997. if (!this._physicsEngine) {
  109998. return;
  109999. }
  110000. this._physicsEngine.dispose();
  110001. this._physicsEngine = null;
  110002. };
  110003. /**
  110004. * Gets a boolean indicating if there is an active physics engine
  110005. * @returns a boolean indicating if there is an active physics engine
  110006. */
  110007. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.isPhysicsEnabled = function () {
  110008. return this._physicsEngine !== undefined;
  110009. };
  110010. /**
  110011. * Deletes a physics compound impostor
  110012. * @param compound defines the compound to delete
  110013. */
  110014. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.deleteCompoundImpostor = function (compound) {
  110015. var mesh = compound.parts[0].mesh;
  110016. if (mesh.physicsImpostor) {
  110017. mesh.physicsImpostor.dispose( /*true*/);
  110018. mesh.physicsImpostor = null;
  110019. }
  110020. };
  110021. /** @hidden */
  110022. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._advancePhysicsEngineStep = function (step) {
  110023. if (this._physicsEngine) {
  110024. this.onBeforePhysicsObservable.notifyObservers(this);
  110025. this._physicsEngine._step(step / 1000);
  110026. this.onAfterPhysicsObservable.notifyObservers(this);
  110027. }
  110028. };
  110029. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "physicsImpostor", {
  110030. get: function () {
  110031. return this._physicsImpostor;
  110032. },
  110033. set: function (value) {
  110034. var _this = this;
  110035. if (this._physicsImpostor === value) {
  110036. return;
  110037. }
  110038. if (this._disposePhysicsObserver) {
  110039. this.onDisposeObservable.remove(this._disposePhysicsObserver);
  110040. }
  110041. this._physicsImpostor = value;
  110042. if (value) {
  110043. this._disposePhysicsObserver = this.onDisposeObservable.add(function () {
  110044. // Physics
  110045. if (_this.physicsImpostor) {
  110046. _this.physicsImpostor.dispose( /*!doNotRecurse*/);
  110047. _this.physicsImpostor = null;
  110048. }
  110049. });
  110050. }
  110051. },
  110052. enumerable: true,
  110053. configurable: true
  110054. });
  110055. /**
  110056. * Gets the current physics impostor
  110057. * @see http://doc.babylonjs.com/features/physics_engine
  110058. * @returns a physics impostor or null
  110059. */
  110060. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.getPhysicsImpostor = function () {
  110061. return this.physicsImpostor;
  110062. };
  110063. /**
  110064. * Apply a physic impulse to the mesh
  110065. * @param force defines the force to apply
  110066. * @param contactPoint defines where to apply the force
  110067. * @returns the current mesh
  110068. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  110069. */
  110070. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.applyImpulse = function (force, contactPoint) {
  110071. if (!this.physicsImpostor) {
  110072. return this;
  110073. }
  110074. this.physicsImpostor.applyImpulse(force, contactPoint);
  110075. return this;
  110076. };
  110077. /**
  110078. * Creates a physic joint between two meshes
  110079. * @param otherMesh defines the other mesh to use
  110080. * @param pivot1 defines the pivot to use on this mesh
  110081. * @param pivot2 defines the pivot to use on the other mesh
  110082. * @param options defines additional options (can be plugin dependent)
  110083. * @returns the current mesh
  110084. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  110085. */
  110086. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.setPhysicsLinkWith = function (otherMesh, pivot1, pivot2, options) {
  110087. if (!this.physicsImpostor || !otherMesh.physicsImpostor) {
  110088. return this;
  110089. }
  110090. this.physicsImpostor.createJoint(otherMesh.physicsImpostor, _physicsJoint__WEBPACK_IMPORTED_MODULE_6__["PhysicsJoint"].HingeJoint, {
  110091. mainPivot: pivot1,
  110092. connectedPivot: pivot2,
  110093. nativeParams: options
  110094. });
  110095. return this;
  110096. };
  110097. /**
  110098. * Defines the physics engine scene component responsible to manage a physics engine
  110099. */
  110100. var PhysicsEngineSceneComponent = /** @class */ (function () {
  110101. /**
  110102. * Creates a new instance of the component for the given scene
  110103. * @param scene Defines the scene to register the component in
  110104. */
  110105. function PhysicsEngineSceneComponent(scene) {
  110106. var _this = this;
  110107. /**
  110108. * The component name helpful to identify the component in the list of scene components.
  110109. */
  110110. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE;
  110111. this.scene = scene;
  110112. this.scene.onBeforePhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  110113. this.scene.onAfterPhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  110114. // Replace the function used to get the deterministic frame time
  110115. this.scene.getDeterministicFrameTime = function () {
  110116. if (_this.scene._physicsEngine) {
  110117. return _this.scene._physicsEngine.getTimeStep() * 1000;
  110118. }
  110119. return 1000.0 / 60.0;
  110120. };
  110121. }
  110122. /**
  110123. * Registers the component in a given scene
  110124. */
  110125. PhysicsEngineSceneComponent.prototype.register = function () {
  110126. };
  110127. /**
  110128. * Rebuilds the elements related to this component in case of
  110129. * context lost for instance.
  110130. */
  110131. PhysicsEngineSceneComponent.prototype.rebuild = function () {
  110132. // Nothing to do for this component
  110133. };
  110134. /**
  110135. * Disposes the component and the associated ressources
  110136. */
  110137. PhysicsEngineSceneComponent.prototype.dispose = function () {
  110138. this.scene.onBeforePhysicsObservable.clear();
  110139. this.scene.onAfterPhysicsObservable.clear();
  110140. if (this.scene._physicsEngine) {
  110141. this.scene.disablePhysicsEngine();
  110142. }
  110143. };
  110144. return PhysicsEngineSceneComponent;
  110145. }());
  110146. /***/ }),
  110147. /***/ "./Physics/physicsHelper.ts":
  110148. /*!**********************************!*\
  110149. !*** ./Physics/physicsHelper.ts ***!
  110150. \**********************************/
  110151. /*! exports provided: PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode */
  110152. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110153. "use strict";
  110154. __webpack_require__.r(__webpack_exports__);
  110155. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return PhysicsHelper; });
  110156. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return PhysicsRadialExplosionEvent; });
  110157. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return PhysicsGravitationalFieldEvent; });
  110158. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return PhysicsUpdraftEvent; });
  110159. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return PhysicsVortexEvent; });
  110160. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return PhysicsRadialImpulseFalloff; });
  110161. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return PhysicsUpdraftMode; });
  110162. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  110163. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  110164. /* harmony import */ var _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/meshBuilder */ "./Meshes/meshBuilder.ts");
  110165. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  110166. /**
  110167. * A helper for physics simulations
  110168. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110169. */
  110170. var PhysicsHelper = /** @class */ (function () {
  110171. /**
  110172. * Initializes the Physics helper
  110173. * @param scene Babylon.js scene
  110174. */
  110175. function PhysicsHelper(scene) {
  110176. this._scene = scene;
  110177. this._physicsEngine = this._scene.getPhysicsEngine();
  110178. if (!this._physicsEngine) {
  110179. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you can use the methods.');
  110180. }
  110181. }
  110182. /**
  110183. * Applies a radial explosion impulse
  110184. * @param origin the origin of the explosion
  110185. * @param radius the explosion radius
  110186. * @param strength the explosion strength
  110187. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110188. * @returns A physics radial explosion event, or null
  110189. */
  110190. PhysicsHelper.prototype.applyRadialExplosionImpulse = function (origin, radius, strength, falloff) {
  110191. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  110192. if (!this._physicsEngine) {
  110193. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call this method.');
  110194. return null;
  110195. }
  110196. var impostors = this._physicsEngine.getImpostors();
  110197. if (impostors.length === 0) {
  110198. return null;
  110199. }
  110200. var event = new PhysicsRadialExplosionEvent(this._scene);
  110201. impostors.forEach(function (impostor) {
  110202. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin, radius, strength, falloff);
  110203. if (!impostorForceAndContactPoint) {
  110204. return;
  110205. }
  110206. impostor.applyImpulse(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  110207. });
  110208. event.dispose(false);
  110209. return event;
  110210. };
  110211. /**
  110212. * Applies a radial explosion force
  110213. * @param origin the origin of the explosion
  110214. * @param radius the explosion radius
  110215. * @param strength the explosion strength
  110216. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110217. * @returns A physics radial explosion event, or null
  110218. */
  110219. PhysicsHelper.prototype.applyRadialExplosionForce = function (origin, radius, strength, falloff) {
  110220. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  110221. if (!this._physicsEngine) {
  110222. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  110223. return null;
  110224. }
  110225. var impostors = this._physicsEngine.getImpostors();
  110226. if (impostors.length === 0) {
  110227. return null;
  110228. }
  110229. var event = new PhysicsRadialExplosionEvent(this._scene);
  110230. impostors.forEach(function (impostor) {
  110231. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin, radius, strength, falloff);
  110232. if (!impostorForceAndContactPoint) {
  110233. return;
  110234. }
  110235. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  110236. });
  110237. event.dispose(false);
  110238. return event;
  110239. };
  110240. /**
  110241. * Creates a gravitational field
  110242. * @param origin the origin of the explosion
  110243. * @param radius the explosion radius
  110244. * @param strength the explosion strength
  110245. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110246. * @returns A physics gravitational field event, or null
  110247. */
  110248. PhysicsHelper.prototype.gravitationalField = function (origin, radius, strength, falloff) {
  110249. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  110250. if (!this._physicsEngine) {
  110251. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  110252. return null;
  110253. }
  110254. var impostors = this._physicsEngine.getImpostors();
  110255. if (impostors.length === 0) {
  110256. return null;
  110257. }
  110258. var event = new PhysicsGravitationalFieldEvent(this, this._scene, origin, radius, strength, falloff);
  110259. event.dispose(false);
  110260. return event;
  110261. };
  110262. /**
  110263. * Creates a physics updraft event
  110264. * @param origin the origin of the updraft
  110265. * @param radius the radius of the updraft
  110266. * @param strength the strength of the updraft
  110267. * @param height the height of the updraft
  110268. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  110269. * @returns A physics updraft event, or null
  110270. */
  110271. PhysicsHelper.prototype.updraft = function (origin, radius, strength, height, updraftMode) {
  110272. if (updraftMode === void 0) { updraftMode = PhysicsUpdraftMode.Center; }
  110273. if (!this._physicsEngine) {
  110274. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  110275. return null;
  110276. }
  110277. if (this._physicsEngine.getImpostors().length === 0) {
  110278. return null;
  110279. }
  110280. var event = new PhysicsUpdraftEvent(this._scene, origin, radius, strength, height, updraftMode);
  110281. event.dispose(false);
  110282. return event;
  110283. };
  110284. /**
  110285. * Creates a physics vortex event
  110286. * @param origin the of the vortex
  110287. * @param radius the radius of the vortex
  110288. * @param strength the strength of the vortex
  110289. * @param height the height of the vortex
  110290. * @returns a Physics vortex event, or null
  110291. * A physics vortex event or null
  110292. */
  110293. PhysicsHelper.prototype.vortex = function (origin, radius, strength, height) {
  110294. if (!this._physicsEngine) {
  110295. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  110296. return null;
  110297. }
  110298. if (this._physicsEngine.getImpostors().length === 0) {
  110299. return null;
  110300. }
  110301. var event = new PhysicsVortexEvent(this._scene, origin, radius, strength, height);
  110302. event.dispose(false);
  110303. return event;
  110304. };
  110305. return PhysicsHelper;
  110306. }());
  110307. /**
  110308. * Represents a physics radial explosion event
  110309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110310. */
  110311. var PhysicsRadialExplosionEvent = /** @class */ (function () {
  110312. /**
  110313. * Initializes a radial explosioin event
  110314. * @param scene BabylonJS scene
  110315. */
  110316. function PhysicsRadialExplosionEvent(scene) {
  110317. this._sphereOptions = { segments: 32, diameter: 1 }; // TODO: make configurable
  110318. this._rays = [];
  110319. this._dataFetched = false; // check if the data has been fetched. If not, do cleanup
  110320. this._scene = scene;
  110321. }
  110322. /**
  110323. * Returns the data related to the radial explosion event (sphere & rays).
  110324. * @returns The radial explosion event data
  110325. */
  110326. PhysicsRadialExplosionEvent.prototype.getData = function () {
  110327. this._dataFetched = true;
  110328. return {
  110329. sphere: this._sphere,
  110330. rays: this._rays,
  110331. };
  110332. };
  110333. /**
  110334. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  110335. * @param impostor A physics imposter
  110336. * @param origin the origin of the explosion
  110337. * @param radius the explosion radius
  110338. * @param strength the explosion strength
  110339. * @param falloff possible options: Constant & Linear
  110340. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  110341. */
  110342. PhysicsRadialExplosionEvent.prototype.getImpostorForceAndContactPoint = function (impostor, origin, radius, strength, falloff) {
  110343. if (impostor.mass === 0) {
  110344. return null;
  110345. }
  110346. if (!this._intersectsWithSphere(impostor, origin, radius)) {
  110347. return null;
  110348. }
  110349. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  110350. return null;
  110351. }
  110352. var impostorObjectCenter = impostor.getObjectCenter();
  110353. var direction = impostorObjectCenter.subtract(origin);
  110354. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](origin, direction, radius);
  110355. this._rays.push(ray);
  110356. var hit = ray.intersectsMesh(impostor.object);
  110357. var contactPoint = hit.pickedPoint;
  110358. if (!contactPoint) {
  110359. return null;
  110360. }
  110361. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(origin, contactPoint);
  110362. if (distanceFromOrigin > radius) {
  110363. return null;
  110364. }
  110365. var multiplier = falloff === PhysicsRadialImpulseFalloff.Constant
  110366. ? strength
  110367. : strength * (1 - (distanceFromOrigin / radius));
  110368. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  110369. return { force: force, contactPoint: contactPoint };
  110370. };
  110371. /**
  110372. * Disposes the sphere.
  110373. * @param force Specifies if the sphere should be disposed by force
  110374. */
  110375. PhysicsRadialExplosionEvent.prototype.dispose = function (force) {
  110376. var _this = this;
  110377. if (force === void 0) { force = true; }
  110378. if (force) {
  110379. this._sphere.dispose();
  110380. }
  110381. else {
  110382. setTimeout(function () {
  110383. if (!_this._dataFetched) {
  110384. _this._sphere.dispose();
  110385. }
  110386. }, 0);
  110387. }
  110388. };
  110389. /*** Helpers ***/
  110390. PhysicsRadialExplosionEvent.prototype._prepareSphere = function () {
  110391. if (!this._sphere) {
  110392. this._sphere = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreateSphere("radialExplosionEventSphere", this._sphereOptions, this._scene);
  110393. this._sphere.isVisible = false;
  110394. }
  110395. };
  110396. PhysicsRadialExplosionEvent.prototype._intersectsWithSphere = function (impostor, origin, radius) {
  110397. var impostorObject = impostor.object;
  110398. this._prepareSphere();
  110399. this._sphere.position = origin;
  110400. this._sphere.scaling = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](radius * 2, radius * 2, radius * 2);
  110401. this._sphere._updateBoundingInfo();
  110402. this._sphere.computeWorldMatrix(true);
  110403. return this._sphere.intersectsMesh(impostorObject, true);
  110404. };
  110405. return PhysicsRadialExplosionEvent;
  110406. }());
  110407. /**
  110408. * Represents a gravitational field event
  110409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110410. */
  110411. var PhysicsGravitationalFieldEvent = /** @class */ (function () {
  110412. /**
  110413. * Initializes the physics gravitational field event
  110414. * @param physicsHelper A physics helper
  110415. * @param scene BabylonJS scene
  110416. * @param origin The origin position of the gravitational field event
  110417. * @param radius The radius of the gravitational field event
  110418. * @param strength The strength of the gravitational field event
  110419. * @param falloff The falloff for the gravitational field event
  110420. */
  110421. function PhysicsGravitationalFieldEvent(physicsHelper, scene, origin, radius, strength, falloff) {
  110422. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  110423. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  110424. this._physicsHelper = physicsHelper;
  110425. this._scene = scene;
  110426. this._origin = origin;
  110427. this._radius = radius;
  110428. this._strength = strength;
  110429. this._falloff = falloff;
  110430. this._tickCallback = this._tick.bind(this);
  110431. }
  110432. /**
  110433. * Returns the data related to the gravitational field event (sphere).
  110434. * @returns A gravitational field event
  110435. */
  110436. PhysicsGravitationalFieldEvent.prototype.getData = function () {
  110437. this._dataFetched = true;
  110438. return {
  110439. sphere: this._sphere,
  110440. };
  110441. };
  110442. /**
  110443. * Enables the gravitational field.
  110444. */
  110445. PhysicsGravitationalFieldEvent.prototype.enable = function () {
  110446. this._tickCallback.call(this);
  110447. this._scene.registerBeforeRender(this._tickCallback);
  110448. };
  110449. /**
  110450. * Disables the gravitational field.
  110451. */
  110452. PhysicsGravitationalFieldEvent.prototype.disable = function () {
  110453. this._scene.unregisterBeforeRender(this._tickCallback);
  110454. };
  110455. /**
  110456. * Disposes the sphere.
  110457. * @param force The force to dispose from the gravitational field event
  110458. */
  110459. PhysicsGravitationalFieldEvent.prototype.dispose = function (force) {
  110460. var _this = this;
  110461. if (force === void 0) { force = true; }
  110462. if (force) {
  110463. this._sphere.dispose();
  110464. }
  110465. else {
  110466. setTimeout(function () {
  110467. if (!_this._dataFetched) {
  110468. _this._sphere.dispose();
  110469. }
  110470. }, 0);
  110471. }
  110472. };
  110473. PhysicsGravitationalFieldEvent.prototype._tick = function () {
  110474. // Since the params won't change, we fetch the event only once
  110475. if (this._sphere) {
  110476. this._physicsHelper.applyRadialExplosionForce(this._origin, this._radius, this._strength * -1, this._falloff);
  110477. }
  110478. else {
  110479. var radialExplosionEvent = this._physicsHelper.applyRadialExplosionForce(this._origin, this._radius, this._strength * -1, this._falloff);
  110480. if (radialExplosionEvent) {
  110481. this._sphere = radialExplosionEvent.getData().sphere.clone('radialExplosionEventSphereClone');
  110482. }
  110483. }
  110484. };
  110485. return PhysicsGravitationalFieldEvent;
  110486. }());
  110487. /**
  110488. * Represents a physics updraft event
  110489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110490. */
  110491. var PhysicsUpdraftEvent = /** @class */ (function () {
  110492. /**
  110493. * Initializes the physics updraft event
  110494. * @param _scene BabylonJS scene
  110495. * @param _origin The origin position of the updraft
  110496. * @param _radius The radius of the updraft
  110497. * @param _strength The strength of the updraft
  110498. * @param _height The height of the updraft
  110499. * @param _updraftMode The mode of the updraft
  110500. */
  110501. function PhysicsUpdraftEvent(_scene, _origin, _radius, _strength, _height, _updraftMode) {
  110502. this._scene = _scene;
  110503. this._origin = _origin;
  110504. this._radius = _radius;
  110505. this._strength = _strength;
  110506. this._height = _height;
  110507. this._updraftMode = _updraftMode;
  110508. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // the most upper part of the cylinder
  110509. this._originDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // used if the updraftMode is perpendicular
  110510. 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
  110511. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  110512. this._physicsEngine = this._scene.getPhysicsEngine();
  110513. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height / 2, 0), this._cylinderPosition);
  110514. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height, 0), this._originTop);
  110515. if (this._updraftMode === PhysicsUpdraftMode.Perpendicular) {
  110516. this._originDirection = this._origin.subtract(this._originTop).normalize();
  110517. }
  110518. this._tickCallback = this._tick.bind(this);
  110519. this._prepareCylinder();
  110520. }
  110521. /**
  110522. * Returns the data related to the updraft event (cylinder).
  110523. * @returns A physics updraft event
  110524. */
  110525. PhysicsUpdraftEvent.prototype.getData = function () {
  110526. this._dataFetched = true;
  110527. return {
  110528. cylinder: this._cylinder,
  110529. };
  110530. };
  110531. /**
  110532. * Enables the updraft.
  110533. */
  110534. PhysicsUpdraftEvent.prototype.enable = function () {
  110535. this._tickCallback.call(this);
  110536. this._scene.registerBeforeRender(this._tickCallback);
  110537. };
  110538. /**
  110539. * Disables the cortex.
  110540. */
  110541. PhysicsUpdraftEvent.prototype.disable = function () {
  110542. this._scene.unregisterBeforeRender(this._tickCallback);
  110543. };
  110544. /**
  110545. * Disposes the sphere.
  110546. * @param force Specifies if the updraft should be disposed by force
  110547. */
  110548. PhysicsUpdraftEvent.prototype.dispose = function (force) {
  110549. var _this = this;
  110550. if (force === void 0) { force = true; }
  110551. if (!this._cylinder) {
  110552. return;
  110553. }
  110554. if (force) {
  110555. this._cylinder.dispose();
  110556. }
  110557. else {
  110558. setTimeout(function () {
  110559. if (!_this._dataFetched) {
  110560. _this._cylinder.dispose();
  110561. }
  110562. }, 0);
  110563. }
  110564. };
  110565. PhysicsUpdraftEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  110566. if (impostor.mass === 0) {
  110567. return null;
  110568. }
  110569. if (!this._intersectsWithCylinder(impostor)) {
  110570. return null;
  110571. }
  110572. var impostorObjectCenter = impostor.getObjectCenter();
  110573. if (this._updraftMode === PhysicsUpdraftMode.Perpendicular) {
  110574. var direction = this._originDirection;
  110575. }
  110576. else {
  110577. var direction = impostorObjectCenter.subtract(this._originTop);
  110578. }
  110579. var multiplier = this._strength * -1;
  110580. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  110581. return { force: force, contactPoint: impostorObjectCenter };
  110582. };
  110583. PhysicsUpdraftEvent.prototype._tick = function () {
  110584. var _this = this;
  110585. this._physicsEngine.getImpostors().forEach(function (impostor) {
  110586. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  110587. if (!impostorForceAndContactPoint) {
  110588. return;
  110589. }
  110590. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  110591. });
  110592. };
  110593. /*** Helpers ***/
  110594. PhysicsUpdraftEvent.prototype._prepareCylinder = function () {
  110595. if (!this._cylinder) {
  110596. this._cylinder = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreateCylinder("updraftEventCylinder", {
  110597. height: this._height,
  110598. diameter: this._radius * 2,
  110599. }, this._scene);
  110600. this._cylinder.isVisible = false;
  110601. }
  110602. };
  110603. PhysicsUpdraftEvent.prototype._intersectsWithCylinder = function (impostor) {
  110604. var impostorObject = impostor.object;
  110605. this._cylinder.position = this._cylinderPosition;
  110606. return this._cylinder.intersectsMesh(impostorObject, true);
  110607. };
  110608. return PhysicsUpdraftEvent;
  110609. }());
  110610. /**
  110611. * Represents a physics vortex event
  110612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110613. */
  110614. var PhysicsVortexEvent = /** @class */ (function () {
  110615. /**
  110616. * Initializes the physics vortex event
  110617. * @param _scene The BabylonJS scene
  110618. * @param _origin The origin position of the vortex
  110619. * @param _radius The radius of the vortex
  110620. * @param _strength The strength of the vortex
  110621. * @param _height The height of the vortex
  110622. */
  110623. function PhysicsVortexEvent(_scene, _origin, _radius, _strength, _height) {
  110624. this._scene = _scene;
  110625. this._origin = _origin;
  110626. this._radius = _radius;
  110627. this._strength = _strength;
  110628. this._height = _height;
  110629. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // the most upper part of the cylinder
  110630. this._centripetalForceThreshold = 0.7; // at which distance, relative to the radius the centripetal forces should kick in
  110631. this._updraftMultiplier = 0.02;
  110632. 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
  110633. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  110634. this._physicsEngine = this._scene.getPhysicsEngine();
  110635. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height / 2, 0), this._cylinderPosition);
  110636. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height, 0), this._originTop);
  110637. this._tickCallback = this._tick.bind(this);
  110638. this._prepareCylinder();
  110639. }
  110640. /**
  110641. * Returns the data related to the vortex event (cylinder).
  110642. * @returns The physics vortex event data
  110643. */
  110644. PhysicsVortexEvent.prototype.getData = function () {
  110645. this._dataFetched = true;
  110646. return {
  110647. cylinder: this._cylinder,
  110648. };
  110649. };
  110650. /**
  110651. * Enables the vortex.
  110652. */
  110653. PhysicsVortexEvent.prototype.enable = function () {
  110654. this._tickCallback.call(this);
  110655. this._scene.registerBeforeRender(this._tickCallback);
  110656. };
  110657. /**
  110658. * Disables the cortex.
  110659. */
  110660. PhysicsVortexEvent.prototype.disable = function () {
  110661. this._scene.unregisterBeforeRender(this._tickCallback);
  110662. };
  110663. /**
  110664. * Disposes the sphere.
  110665. * @param force
  110666. */
  110667. PhysicsVortexEvent.prototype.dispose = function (force) {
  110668. var _this = this;
  110669. if (force === void 0) { force = true; }
  110670. if (force) {
  110671. this._cylinder.dispose();
  110672. }
  110673. else {
  110674. setTimeout(function () {
  110675. if (!_this._dataFetched) {
  110676. _this._cylinder.dispose();
  110677. }
  110678. }, 0);
  110679. }
  110680. };
  110681. PhysicsVortexEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  110682. if (impostor.mass === 0) {
  110683. return null;
  110684. }
  110685. if (!this._intersectsWithCylinder(impostor)) {
  110686. return null;
  110687. }
  110688. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  110689. return null;
  110690. }
  110691. var impostorObjectCenter = impostor.getObjectCenter();
  110692. 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)
  110693. var originToImpostorDirection = impostorObjectCenter.subtract(originOnPlane);
  110694. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](originOnPlane, originToImpostorDirection, this._radius);
  110695. var hit = ray.intersectsMesh(impostor.object);
  110696. var contactPoint = hit.pickedPoint;
  110697. if (!contactPoint) {
  110698. return null;
  110699. }
  110700. var absoluteDistanceFromOrigin = hit.distance / this._radius;
  110701. var perpendicularDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(originOnPlane, impostorObjectCenter).normalize();
  110702. var directionToOrigin = contactPoint.normalize();
  110703. if (absoluteDistanceFromOrigin > this._centripetalForceThreshold) {
  110704. directionToOrigin = directionToOrigin.negate();
  110705. }
  110706. // TODO: find a more physically based solution
  110707. if (absoluteDistanceFromOrigin > this._centripetalForceThreshold) {
  110708. var forceX = directionToOrigin.x * this._strength / 8;
  110709. var forceY = directionToOrigin.y * this._updraftMultiplier;
  110710. var forceZ = directionToOrigin.z * this._strength / 8;
  110711. }
  110712. else {
  110713. var forceX = (perpendicularDirection.x + directionToOrigin.x) / 2;
  110714. var forceY = this._originTop.y * this._updraftMultiplier;
  110715. var forceZ = (perpendicularDirection.z + directionToOrigin.z) / 2;
  110716. }
  110717. var force = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](forceX, forceY, forceZ);
  110718. force = force.multiplyByFloats(this._strength, this._strength, this._strength);
  110719. return { force: force, contactPoint: impostorObjectCenter };
  110720. };
  110721. PhysicsVortexEvent.prototype._tick = function () {
  110722. var _this = this;
  110723. this._physicsEngine.getImpostors().forEach(function (impostor) {
  110724. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  110725. if (!impostorForceAndContactPoint) {
  110726. return;
  110727. }
  110728. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  110729. });
  110730. };
  110731. /*** Helpers ***/
  110732. PhysicsVortexEvent.prototype._prepareCylinder = function () {
  110733. if (!this._cylinder) {
  110734. this._cylinder = _Meshes_meshBuilder__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreateCylinder("vortexEventCylinder", {
  110735. height: this._height,
  110736. diameter: this._radius * 2,
  110737. }, this._scene);
  110738. this._cylinder.isVisible = false;
  110739. }
  110740. };
  110741. PhysicsVortexEvent.prototype._intersectsWithCylinder = function (impostor) {
  110742. var impostorObject = impostor.object;
  110743. this._cylinder.position = this._cylinderPosition;
  110744. return this._cylinder.intersectsMesh(impostorObject, true);
  110745. };
  110746. return PhysicsVortexEvent;
  110747. }());
  110748. /**
  110749. * The strenght of the force in correspondence to the distance of the affected object
  110750. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110751. */
  110752. var PhysicsRadialImpulseFalloff;
  110753. (function (PhysicsRadialImpulseFalloff) {
  110754. /** Defines that impulse is constant in strength across it's whole radius */
  110755. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Constant"] = 0] = "Constant";
  110756. /** DEfines that impulse gets weaker if it's further from the origin */
  110757. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Linear"] = 1] = "Linear";
  110758. })(PhysicsRadialImpulseFalloff || (PhysicsRadialImpulseFalloff = {}));
  110759. /**
  110760. * The strength of the force in correspondence to the distance of the affected object
  110761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110762. */
  110763. var PhysicsUpdraftMode;
  110764. (function (PhysicsUpdraftMode) {
  110765. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  110766. PhysicsUpdraftMode[PhysicsUpdraftMode["Center"] = 0] = "Center";
  110767. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  110768. PhysicsUpdraftMode[PhysicsUpdraftMode["Perpendicular"] = 1] = "Perpendicular";
  110769. })(PhysicsUpdraftMode || (PhysicsUpdraftMode = {}));
  110770. /***/ }),
  110771. /***/ "./Physics/physicsImpostor.ts":
  110772. /*!************************************!*\
  110773. !*** ./Physics/physicsImpostor.ts ***!
  110774. \************************************/
  110775. /*! exports provided: PhysicsImpostor */
  110776. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110777. "use strict";
  110778. __webpack_require__.r(__webpack_exports__);
  110779. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return PhysicsImpostor; });
  110780. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  110781. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  110782. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  110783. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  110784. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  110785. /**
  110786. * Represents a physics imposter
  110787. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110788. */
  110789. var PhysicsImpostor = /** @class */ (function () {
  110790. /**
  110791. * Initializes the physics imposter
  110792. * @param object The physics-enabled object used as the physics imposter
  110793. * @param type The type of the physics imposter
  110794. * @param _options The options for the physics imposter
  110795. * @param _scene The Babylon scene
  110796. */
  110797. function PhysicsImpostor(
  110798. /**
  110799. * The physics-enabled object used as the physics imposter
  110800. */
  110801. object,
  110802. /**
  110803. * The type of the physics imposter
  110804. */
  110805. type, _options, _scene) {
  110806. if (_options === void 0) { _options = { mass: 0 }; }
  110807. var _this = this;
  110808. this.object = object;
  110809. this.type = type;
  110810. this._options = _options;
  110811. this._scene = _scene;
  110812. this._bodyUpdateRequired = false;
  110813. this._onBeforePhysicsStepCallbacks = new Array();
  110814. this._onAfterPhysicsStepCallbacks = new Array();
  110815. /** @hidden */
  110816. this._onPhysicsCollideCallbacks = [];
  110817. this._deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  110818. this._isDisposed = false;
  110819. //temp variables for parent rotation calculations
  110820. //private _mats: Array<Matrix> = [new Matrix(), new Matrix()];
  110821. this._tmpQuat = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  110822. this._tmpQuat2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  110823. /**
  110824. * this function is executed by the physics engine.
  110825. */
  110826. this.beforeStep = function () {
  110827. if (!_this._physicsEngine) {
  110828. return;
  110829. }
  110830. _this.object.translate(_this._deltaPosition, -1);
  110831. _this._deltaRotationConjugated && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this.object.rotationQuaternion);
  110832. _this.object.computeWorldMatrix(false);
  110833. if (_this.object.parent && _this.object.rotationQuaternion) {
  110834. _this.getParentsRotation();
  110835. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this._tmpQuat);
  110836. }
  110837. else {
  110838. _this._tmpQuat.copyFrom(_this.object.rotationQuaternion || new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]());
  110839. }
  110840. if (!_this._options.disableBidirectionalTransformation) {
  110841. _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePosition(), _this._tmpQuat);
  110842. }
  110843. _this._onBeforePhysicsStepCallbacks.forEach(function (func) {
  110844. func(_this);
  110845. });
  110846. };
  110847. /**
  110848. * this function is executed by the physics engine
  110849. */
  110850. this.afterStep = function () {
  110851. if (!_this._physicsEngine) {
  110852. return;
  110853. }
  110854. _this._onAfterPhysicsStepCallbacks.forEach(function (func) {
  110855. func(_this);
  110856. });
  110857. _this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(_this);
  110858. // object has now its world rotation. needs to be converted to local.
  110859. if (_this.object.parent && _this.object.rotationQuaternion) {
  110860. _this.getParentsRotation();
  110861. _this._tmpQuat.conjugateInPlace();
  110862. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this.object.rotationQuaternion);
  110863. }
  110864. // take the position set and make it the absolute position of this object.
  110865. _this.object.setAbsolutePosition(_this.object.position);
  110866. _this._deltaRotation && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotation, _this.object.rotationQuaternion);
  110867. _this.object.translate(_this._deltaPosition, 1);
  110868. };
  110869. /**
  110870. * Legacy collision detection event support
  110871. */
  110872. this.onCollideEvent = null;
  110873. /**
  110874. * event and body object due to cannon's event-based architecture.
  110875. */
  110876. this.onCollide = function (e) {
  110877. if (!_this._onPhysicsCollideCallbacks.length && !_this.onCollideEvent) {
  110878. return;
  110879. }
  110880. if (!_this._physicsEngine) {
  110881. return;
  110882. }
  110883. var otherImpostor = _this._physicsEngine.getImpostorWithPhysicsBody(e.body);
  110884. if (otherImpostor) {
  110885. // Legacy collision detection event support
  110886. if (_this.onCollideEvent) {
  110887. _this.onCollideEvent(_this, otherImpostor);
  110888. }
  110889. _this._onPhysicsCollideCallbacks.filter(function (obj) {
  110890. return obj.otherImpostors.indexOf(otherImpostor) !== -1;
  110891. }).forEach(function (obj) {
  110892. obj.callback(_this, otherImpostor);
  110893. });
  110894. }
  110895. };
  110896. //sanity check!
  110897. if (!this.object) {
  110898. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("No object was provided. A physics object is obligatory");
  110899. return;
  110900. }
  110901. // Legacy support for old syntax.
  110902. if (!this._scene && object.getScene) {
  110903. this._scene = object.getScene();
  110904. }
  110905. if (!this._scene) {
  110906. return;
  110907. }
  110908. this._physicsEngine = this._scene.getPhysicsEngine();
  110909. if (!this._physicsEngine) {
  110910. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.");
  110911. }
  110912. else {
  110913. //set the object's quaternion, if not set
  110914. if (!this.object.rotationQuaternion) {
  110915. if (this.object.rotation) {
  110916. this.object.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z);
  110917. }
  110918. else {
  110919. this.object.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  110920. }
  110921. }
  110922. //default options params
  110923. this._options.mass = (_options.mass === void 0) ? 0 : _options.mass;
  110924. this._options.friction = (_options.friction === void 0) ? 0.2 : _options.friction;
  110925. this._options.restitution = (_options.restitution === void 0) ? 0.2 : _options.restitution;
  110926. this._joints = [];
  110927. //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.
  110928. if (!this.object.parent || this._options.ignoreParent) {
  110929. this._init();
  110930. }
  110931. else if (this.object.parent.physicsImpostor) {
  110932. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("You must affect impostors to children before affecting impostor to parent.");
  110933. }
  110934. }
  110935. }
  110936. Object.defineProperty(PhysicsImpostor.prototype, "isDisposed", {
  110937. /**
  110938. * Specifies if the physics imposter is disposed
  110939. */
  110940. get: function () {
  110941. return this._isDisposed;
  110942. },
  110943. enumerable: true,
  110944. configurable: true
  110945. });
  110946. Object.defineProperty(PhysicsImpostor.prototype, "mass", {
  110947. /**
  110948. * Gets the mass of the physics imposter
  110949. */
  110950. get: function () {
  110951. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;
  110952. },
  110953. set: function (value) {
  110954. this.setMass(value);
  110955. },
  110956. enumerable: true,
  110957. configurable: true
  110958. });
  110959. Object.defineProperty(PhysicsImpostor.prototype, "friction", {
  110960. /**
  110961. * Gets the coefficient of friction
  110962. */
  110963. get: function () {
  110964. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;
  110965. },
  110966. /**
  110967. * Sets the coefficient of friction
  110968. */
  110969. set: function (value) {
  110970. if (!this._physicsEngine) {
  110971. return;
  110972. }
  110973. this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, value);
  110974. },
  110975. enumerable: true,
  110976. configurable: true
  110977. });
  110978. Object.defineProperty(PhysicsImpostor.prototype, "restitution", {
  110979. /**
  110980. * Gets the coefficient of restitution
  110981. */
  110982. get: function () {
  110983. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;
  110984. },
  110985. /**
  110986. * Sets the coefficient of restitution
  110987. */
  110988. set: function (value) {
  110989. if (!this._physicsEngine) {
  110990. return;
  110991. }
  110992. this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, value);
  110993. },
  110994. enumerable: true,
  110995. configurable: true
  110996. });
  110997. /**
  110998. * This function will completly initialize this impostor.
  110999. * It will create a new body - but only if this mesh has no parent.
  111000. * If it has, this impostor will not be used other than to define the impostor
  111001. * of the child mesh.
  111002. * @hidden
  111003. */
  111004. PhysicsImpostor.prototype._init = function () {
  111005. if (!this._physicsEngine) {
  111006. return;
  111007. }
  111008. this._physicsEngine.removeImpostor(this);
  111009. this.physicsBody = null;
  111010. this._parent = this._parent || this._getPhysicsParent();
  111011. if (!this._isDisposed && (!this.parent || this._options.ignoreParent)) {
  111012. this._physicsEngine.addImpostor(this);
  111013. }
  111014. };
  111015. PhysicsImpostor.prototype._getPhysicsParent = function () {
  111016. if (this.object.parent instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]) {
  111017. var parentMesh = this.object.parent;
  111018. return parentMesh.physicsImpostor;
  111019. }
  111020. return null;
  111021. };
  111022. /**
  111023. * Should a new body be generated.
  111024. * @returns boolean specifying if body initialization is required
  111025. */
  111026. PhysicsImpostor.prototype.isBodyInitRequired = function () {
  111027. return this._bodyUpdateRequired || (!this._physicsBody && !this._parent);
  111028. };
  111029. /**
  111030. * Sets the updated scaling
  111031. * @param updated Specifies if the scaling is updated
  111032. */
  111033. PhysicsImpostor.prototype.setScalingUpdated = function () {
  111034. this.forceUpdate();
  111035. };
  111036. /**
  111037. * Force a regeneration of this or the parent's impostor's body.
  111038. * Use under cautious - This will remove all joints already implemented.
  111039. */
  111040. PhysicsImpostor.prototype.forceUpdate = function () {
  111041. this._init();
  111042. if (this.parent && !this._options.ignoreParent) {
  111043. this.parent.forceUpdate();
  111044. }
  111045. };
  111046. Object.defineProperty(PhysicsImpostor.prototype, "physicsBody", {
  111047. /*public get mesh(): AbstractMesh {
  111048. return this._mesh;
  111049. }*/
  111050. /**
  111051. * Gets the body that holds this impostor. Either its own, or its parent.
  111052. */
  111053. get: function () {
  111054. return (this._parent && !this._options.ignoreParent) ? this._parent.physicsBody : this._physicsBody;
  111055. },
  111056. /**
  111057. * Set the physics body. Used mainly by the physics engine/plugin
  111058. */
  111059. set: function (physicsBody) {
  111060. if (this._physicsBody && this._physicsEngine) {
  111061. this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this);
  111062. }
  111063. this._physicsBody = physicsBody;
  111064. this.resetUpdateFlags();
  111065. },
  111066. enumerable: true,
  111067. configurable: true
  111068. });
  111069. Object.defineProperty(PhysicsImpostor.prototype, "parent", {
  111070. /**
  111071. * Get the parent of the physics imposter
  111072. * @returns Physics imposter or null
  111073. */
  111074. get: function () {
  111075. return !this._options.ignoreParent && this._parent ? this._parent : null;
  111076. },
  111077. /**
  111078. * Sets the parent of the physics imposter
  111079. */
  111080. set: function (value) {
  111081. this._parent = value;
  111082. },
  111083. enumerable: true,
  111084. configurable: true
  111085. });
  111086. /**
  111087. * Resets the update flags
  111088. */
  111089. PhysicsImpostor.prototype.resetUpdateFlags = function () {
  111090. this._bodyUpdateRequired = false;
  111091. };
  111092. /**
  111093. * Gets the object extend size
  111094. * @returns the object extend size
  111095. */
  111096. PhysicsImpostor.prototype.getObjectExtendSize = function () {
  111097. if (this.object.getBoundingInfo) {
  111098. var q = this.object.rotationQuaternion;
  111099. //reset rotation
  111100. this.object.rotationQuaternion = PhysicsImpostor.IDENTITY_QUATERNION;
  111101. //calculate the world matrix with no rotation
  111102. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  111103. var boundingInfo = this.object.getBoundingInfo();
  111104. var size = boundingInfo.boundingBox.extendSizeWorld.scale(2);
  111105. //bring back the rotation
  111106. this.object.rotationQuaternion = q;
  111107. //calculate the world matrix with the new rotation
  111108. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  111109. return size;
  111110. }
  111111. else {
  111112. return PhysicsImpostor.DEFAULT_OBJECT_SIZE;
  111113. }
  111114. };
  111115. /**
  111116. * Gets the object center
  111117. * @returns The object center
  111118. */
  111119. PhysicsImpostor.prototype.getObjectCenter = function () {
  111120. if (this.object.getBoundingInfo) {
  111121. var boundingInfo = this.object.getBoundingInfo();
  111122. return boundingInfo.boundingBox.centerWorld;
  111123. }
  111124. else {
  111125. return this.object.position;
  111126. }
  111127. };
  111128. /**
  111129. * Get a specific parametes from the options parameter
  111130. * @param paramName The object parameter name
  111131. * @returns The object parameter
  111132. */
  111133. PhysicsImpostor.prototype.getParam = function (paramName) {
  111134. return this._options[paramName];
  111135. };
  111136. /**
  111137. * Sets a specific parameter in the options given to the physics plugin
  111138. * @param paramName The parameter name
  111139. * @param value The value of the parameter
  111140. */
  111141. PhysicsImpostor.prototype.setParam = function (paramName, value) {
  111142. this._options[paramName] = value;
  111143. this._bodyUpdateRequired = true;
  111144. };
  111145. /**
  111146. * Specifically change the body's mass option. Won't recreate the physics body object
  111147. * @param mass The mass of the physics imposter
  111148. */
  111149. PhysicsImpostor.prototype.setMass = function (mass) {
  111150. if (this.getParam("mass") !== mass) {
  111151. this.setParam("mass", mass);
  111152. }
  111153. if (this._physicsEngine) {
  111154. this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);
  111155. }
  111156. };
  111157. /**
  111158. * Gets the linear velocity
  111159. * @returns linear velocity or null
  111160. */
  111161. PhysicsImpostor.prototype.getLinearVelocity = function () {
  111162. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  111163. };
  111164. /**
  111165. * Sets the linear velocity
  111166. * @param velocity linear velocity or null
  111167. */
  111168. PhysicsImpostor.prototype.setLinearVelocity = function (velocity) {
  111169. if (this._physicsEngine) {
  111170. this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);
  111171. }
  111172. };
  111173. /**
  111174. * Gets the angular velocity
  111175. * @returns angular velocity or null
  111176. */
  111177. PhysicsImpostor.prototype.getAngularVelocity = function () {
  111178. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  111179. };
  111180. /**
  111181. * Sets the angular velocity
  111182. * @param velocity The velocity or null
  111183. */
  111184. PhysicsImpostor.prototype.setAngularVelocity = function (velocity) {
  111185. if (this._physicsEngine) {
  111186. this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, velocity);
  111187. }
  111188. };
  111189. /**
  111190. * Execute a function with the physics plugin native code
  111191. * Provide a function the will have two variables - the world object and the physics body object
  111192. * @param func The function to execute with the physics plugin native code
  111193. */
  111194. PhysicsImpostor.prototype.executeNativeFunction = function (func) {
  111195. if (this._physicsEngine) {
  111196. func(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);
  111197. }
  111198. };
  111199. /**
  111200. * Register a function that will be executed before the physics world is stepping forward
  111201. * @param func The function to execute before the physics world is stepped forward
  111202. */
  111203. PhysicsImpostor.prototype.registerBeforePhysicsStep = function (func) {
  111204. this._onBeforePhysicsStepCallbacks.push(func);
  111205. };
  111206. /**
  111207. * Unregister a function that will be executed before the physics world is stepping forward
  111208. * @param func The function to execute before the physics world is stepped forward
  111209. */
  111210. PhysicsImpostor.prototype.unregisterBeforePhysicsStep = function (func) {
  111211. var index = this._onBeforePhysicsStepCallbacks.indexOf(func);
  111212. if (index > -1) {
  111213. this._onBeforePhysicsStepCallbacks.splice(index, 1);
  111214. }
  111215. else {
  111216. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  111217. }
  111218. };
  111219. /**
  111220. * Register a function that will be executed after the physics step
  111221. * @param func The function to execute after physics step
  111222. */
  111223. PhysicsImpostor.prototype.registerAfterPhysicsStep = function (func) {
  111224. this._onAfterPhysicsStepCallbacks.push(func);
  111225. };
  111226. /**
  111227. * Unregisters a function that will be executed after the physics step
  111228. * @param func The function to execute after physics step
  111229. */
  111230. PhysicsImpostor.prototype.unregisterAfterPhysicsStep = function (func) {
  111231. var index = this._onAfterPhysicsStepCallbacks.indexOf(func);
  111232. if (index > -1) {
  111233. this._onAfterPhysicsStepCallbacks.splice(index, 1);
  111234. }
  111235. else {
  111236. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  111237. }
  111238. };
  111239. /**
  111240. * register a function that will be executed when this impostor collides against a different body
  111241. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  111242. * @param func Callback that is executed on collision
  111243. */
  111244. PhysicsImpostor.prototype.registerOnPhysicsCollide = function (collideAgainst, func) {
  111245. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  111246. this._onPhysicsCollideCallbacks.push({ callback: func, otherImpostors: collidedAgainstList });
  111247. };
  111248. /**
  111249. * Unregisters the physics imposter on contact
  111250. * @param collideAgainst The physics object to collide against
  111251. * @param func Callback to execute on collision
  111252. */
  111253. PhysicsImpostor.prototype.unregisterOnPhysicsCollide = function (collideAgainst, func) {
  111254. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  111255. var index = -1;
  111256. var found = this._onPhysicsCollideCallbacks.some(function (cbDef, idx) {
  111257. if (cbDef.callback === func && cbDef.otherImpostors.length === collidedAgainstList.length) {
  111258. // chcek the arrays match
  111259. var sameList = cbDef.otherImpostors.every(function (impostor) {
  111260. return collidedAgainstList.indexOf(impostor) > -1;
  111261. });
  111262. if (sameList) {
  111263. index = idx;
  111264. }
  111265. return sameList;
  111266. }
  111267. return false;
  111268. });
  111269. if (found) {
  111270. this._onPhysicsCollideCallbacks.splice(index, 1);
  111271. }
  111272. else {
  111273. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  111274. }
  111275. };
  111276. /**
  111277. * Get the parent rotation
  111278. * @returns The parent rotation
  111279. */
  111280. PhysicsImpostor.prototype.getParentsRotation = function () {
  111281. var parent = this.object.parent;
  111282. this._tmpQuat.copyFromFloats(0, 0, 0, 1);
  111283. while (parent) {
  111284. if (parent.rotationQuaternion) {
  111285. this._tmpQuat2.copyFrom(parent.rotationQuaternion);
  111286. }
  111287. else {
  111288. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(parent.rotation.y, parent.rotation.x, parent.rotation.z, this._tmpQuat2);
  111289. }
  111290. this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat);
  111291. parent = parent.parent;
  111292. }
  111293. return this._tmpQuat;
  111294. };
  111295. /**
  111296. * Apply a force
  111297. * @param force The force to apply
  111298. * @param contactPoint The contact point for the force
  111299. * @returns The physics imposter
  111300. */
  111301. PhysicsImpostor.prototype.applyForce = function (force, contactPoint) {
  111302. if (this._physicsEngine) {
  111303. this._physicsEngine.getPhysicsPlugin().applyForce(this, force, contactPoint);
  111304. }
  111305. return this;
  111306. };
  111307. /**
  111308. * Apply an impulse
  111309. * @param force The impulse force
  111310. * @param contactPoint The contact point for the impulse force
  111311. * @returns The physics imposter
  111312. */
  111313. PhysicsImpostor.prototype.applyImpulse = function (force, contactPoint) {
  111314. if (this._physicsEngine) {
  111315. this._physicsEngine.getPhysicsPlugin().applyImpulse(this, force, contactPoint);
  111316. }
  111317. return this;
  111318. };
  111319. /**
  111320. * A help function to create a joint
  111321. * @param otherImpostor A physics imposter used to create a joint
  111322. * @param jointType The type of joint
  111323. * @param jointData The data for the joint
  111324. * @returns The physics imposter
  111325. */
  111326. PhysicsImpostor.prototype.createJoint = function (otherImpostor, jointType, jointData) {
  111327. var joint = new _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"](jointType, jointData);
  111328. this.addJoint(otherImpostor, joint);
  111329. return this;
  111330. };
  111331. /**
  111332. * Add a joint to this impostor with a different impostor
  111333. * @param otherImpostor A physics imposter used to add a joint
  111334. * @param joint The joint to add
  111335. * @returns The physics imposter
  111336. */
  111337. PhysicsImpostor.prototype.addJoint = function (otherImpostor, joint) {
  111338. this._joints.push({
  111339. otherImpostor: otherImpostor,
  111340. joint: joint
  111341. });
  111342. if (this._physicsEngine) {
  111343. this._physicsEngine.addJoint(this, otherImpostor, joint);
  111344. }
  111345. return this;
  111346. };
  111347. /**
  111348. * Will keep this body still, in a sleep mode.
  111349. * @returns the physics imposter
  111350. */
  111351. PhysicsImpostor.prototype.sleep = function () {
  111352. if (this._physicsEngine) {
  111353. this._physicsEngine.getPhysicsPlugin().sleepBody(this);
  111354. }
  111355. return this;
  111356. };
  111357. /**
  111358. * Wake the body up.
  111359. * @returns The physics imposter
  111360. */
  111361. PhysicsImpostor.prototype.wakeUp = function () {
  111362. if (this._physicsEngine) {
  111363. this._physicsEngine.getPhysicsPlugin().wakeUpBody(this);
  111364. }
  111365. return this;
  111366. };
  111367. /**
  111368. * Clones the physics imposter
  111369. * @param newObject The physics imposter clones to this physics-enabled object
  111370. * @returns A nullable physics imposter
  111371. */
  111372. PhysicsImpostor.prototype.clone = function (newObject) {
  111373. if (!newObject) {
  111374. return null;
  111375. }
  111376. return new PhysicsImpostor(newObject, this.type, this._options, this._scene);
  111377. };
  111378. /**
  111379. * Disposes the physics imposter
  111380. */
  111381. PhysicsImpostor.prototype.dispose = function ( /*disposeChildren: boolean = true*/) {
  111382. var _this = this;
  111383. //no dispose if no physics engine is available.
  111384. if (!this._physicsEngine) {
  111385. return;
  111386. }
  111387. this._joints.forEach(function (j) {
  111388. if (_this._physicsEngine) {
  111389. _this._physicsEngine.removeJoint(_this, j.otherImpostor, j.joint);
  111390. }
  111391. });
  111392. //dispose the physics body
  111393. this._physicsEngine.removeImpostor(this);
  111394. if (this.parent) {
  111395. this.parent.forceUpdate();
  111396. }
  111397. else {
  111398. /*this._object.getChildMeshes().forEach(function(mesh) {
  111399. if (mesh.physicsImpostor) {
  111400. if (disposeChildren) {
  111401. mesh.physicsImpostor.dispose();
  111402. mesh.physicsImpostor = null;
  111403. }
  111404. }
  111405. })*/
  111406. }
  111407. this._isDisposed = true;
  111408. };
  111409. /**
  111410. * Sets the delta position
  111411. * @param position The delta position amount
  111412. */
  111413. PhysicsImpostor.prototype.setDeltaPosition = function (position) {
  111414. this._deltaPosition.copyFrom(position);
  111415. };
  111416. /**
  111417. * Sets the delta rotation
  111418. * @param rotation The delta rotation amount
  111419. */
  111420. PhysicsImpostor.prototype.setDeltaRotation = function (rotation) {
  111421. if (!this._deltaRotation) {
  111422. this._deltaRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  111423. }
  111424. this._deltaRotation.copyFrom(rotation);
  111425. this._deltaRotationConjugated = this._deltaRotation.conjugate();
  111426. };
  111427. /**
  111428. * Gets the box size of the physics imposter and stores the result in the input parameter
  111429. * @param result Stores the box size
  111430. * @returns The physics imposter
  111431. */
  111432. PhysicsImpostor.prototype.getBoxSizeToRef = function (result) {
  111433. if (this._physicsEngine) {
  111434. this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, result);
  111435. }
  111436. return this;
  111437. };
  111438. /**
  111439. * Gets the radius of the physics imposter
  111440. * @returns Radius of the physics imposter
  111441. */
  111442. PhysicsImpostor.prototype.getRadius = function () {
  111443. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;
  111444. };
  111445. /**
  111446. * Sync a bone with this impostor
  111447. * @param bone The bone to sync to the impostor.
  111448. * @param boneMesh The mesh that the bone is influencing.
  111449. * @param jointPivot The pivot of the joint / bone in local space.
  111450. * @param distToJoint Optional distance from the impostor to the joint.
  111451. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  111452. */
  111453. PhysicsImpostor.prototype.syncBoneWithImpostor = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation) {
  111454. var tempVec = PhysicsImpostor._tmpVecs[0];
  111455. var mesh = this.object;
  111456. if (mesh.rotationQuaternion) {
  111457. if (adjustRotation) {
  111458. var tempQuat = PhysicsImpostor._tmpQuat;
  111459. mesh.rotationQuaternion.multiplyToRef(adjustRotation, tempQuat);
  111460. bone.setRotationQuaternion(tempQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  111461. }
  111462. else {
  111463. bone.setRotationQuaternion(mesh.rotationQuaternion, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  111464. }
  111465. }
  111466. tempVec.x = 0;
  111467. tempVec.y = 0;
  111468. tempVec.z = 0;
  111469. if (jointPivot) {
  111470. tempVec.x = jointPivot.x;
  111471. tempVec.y = jointPivot.y;
  111472. tempVec.z = jointPivot.z;
  111473. bone.getDirectionToRef(tempVec, boneMesh, tempVec);
  111474. if (distToJoint === undefined || distToJoint === null) {
  111475. distToJoint = jointPivot.length();
  111476. }
  111477. tempVec.x *= distToJoint;
  111478. tempVec.y *= distToJoint;
  111479. tempVec.z *= distToJoint;
  111480. }
  111481. if (bone.getParent()) {
  111482. tempVec.addInPlace(mesh.getAbsolutePosition());
  111483. bone.setAbsolutePosition(tempVec, boneMesh);
  111484. }
  111485. else {
  111486. boneMesh.setAbsolutePosition(mesh.getAbsolutePosition());
  111487. boneMesh.position.x -= tempVec.x;
  111488. boneMesh.position.y -= tempVec.y;
  111489. boneMesh.position.z -= tempVec.z;
  111490. }
  111491. };
  111492. /**
  111493. * Sync impostor to a bone
  111494. * @param bone The bone that the impostor will be synced to.
  111495. * @param boneMesh The mesh that the bone is influencing.
  111496. * @param jointPivot The pivot of the joint / bone in local space.
  111497. * @param distToJoint Optional distance from the impostor to the joint.
  111498. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  111499. * @param boneAxis Optional vector3 axis the bone is aligned with
  111500. */
  111501. PhysicsImpostor.prototype.syncImpostorWithBone = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation, boneAxis) {
  111502. var mesh = this.object;
  111503. if (mesh.rotationQuaternion) {
  111504. if (adjustRotation) {
  111505. var tempQuat = PhysicsImpostor._tmpQuat;
  111506. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, tempQuat);
  111507. tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);
  111508. }
  111509. else {
  111510. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, mesh.rotationQuaternion);
  111511. }
  111512. }
  111513. var pos = PhysicsImpostor._tmpVecs[0];
  111514. var boneDir = PhysicsImpostor._tmpVecs[1];
  111515. if (!boneAxis) {
  111516. boneAxis = PhysicsImpostor._tmpVecs[2];
  111517. boneAxis.x = 0;
  111518. boneAxis.y = 1;
  111519. boneAxis.z = 0;
  111520. }
  111521. bone.getDirectionToRef(boneAxis, boneMesh, boneDir);
  111522. bone.getAbsolutePositionToRef(boneMesh, pos);
  111523. if ((distToJoint === undefined || distToJoint === null) && jointPivot) {
  111524. distToJoint = jointPivot.length();
  111525. }
  111526. if (distToJoint !== undefined && distToJoint !== null) {
  111527. pos.x += boneDir.x * distToJoint;
  111528. pos.y += boneDir.y * distToJoint;
  111529. pos.z += boneDir.z * distToJoint;
  111530. }
  111531. mesh.setAbsolutePosition(pos);
  111532. };
  111533. /**
  111534. * The default object size of the imposter
  111535. */
  111536. PhysicsImpostor.DEFAULT_OBJECT_SIZE = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  111537. /**
  111538. * The identity quaternion of the imposter
  111539. */
  111540. PhysicsImpostor.IDENTITY_QUATERNION = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  111541. PhysicsImpostor._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero);
  111542. PhysicsImpostor._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  111543. //Impostor types
  111544. /**
  111545. * No-Imposter type
  111546. */
  111547. PhysicsImpostor.NoImpostor = 0;
  111548. /**
  111549. * Sphere-Imposter type
  111550. */
  111551. PhysicsImpostor.SphereImpostor = 1;
  111552. /**
  111553. * Box-Imposter type
  111554. */
  111555. PhysicsImpostor.BoxImpostor = 2;
  111556. /**
  111557. * Plane-Imposter type
  111558. */
  111559. PhysicsImpostor.PlaneImpostor = 3;
  111560. /**
  111561. * Mesh-imposter type
  111562. */
  111563. PhysicsImpostor.MeshImpostor = 4;
  111564. /**
  111565. * Cylinder-Imposter type
  111566. */
  111567. PhysicsImpostor.CylinderImpostor = 7;
  111568. /**
  111569. * Particle-Imposter type
  111570. */
  111571. PhysicsImpostor.ParticleImpostor = 8;
  111572. /**
  111573. * Heightmap-Imposter type
  111574. */
  111575. PhysicsImpostor.HeightmapImpostor = 9;
  111576. return PhysicsImpostor;
  111577. }());
  111578. /***/ }),
  111579. /***/ "./Physics/physicsJoint.ts":
  111580. /*!*********************************!*\
  111581. !*** ./Physics/physicsJoint.ts ***!
  111582. \*********************************/
  111583. /*! exports provided: PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint */
  111584. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111585. "use strict";
  111586. __webpack_require__.r(__webpack_exports__);
  111587. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return PhysicsJoint; });
  111588. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return DistanceJoint; });
  111589. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return MotorEnabledJoint; });
  111590. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return HingeJoint; });
  111591. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return Hinge2Joint; });
  111592. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  111593. /**
  111594. * This is a holder class for the physics joint created by the physics plugin
  111595. * It holds a set of functions to control the underlying joint
  111596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111597. */
  111598. var PhysicsJoint = /** @class */ (function () {
  111599. /**
  111600. * Initializes the physics joint
  111601. * @param type The type of the physics joint
  111602. * @param jointData The data for the physics joint
  111603. */
  111604. function PhysicsJoint(
  111605. /**
  111606. * The type of the physics joint
  111607. */
  111608. type,
  111609. /**
  111610. * The data for the physics joint
  111611. */
  111612. jointData) {
  111613. this.type = type;
  111614. this.jointData = jointData;
  111615. jointData.nativeParams = jointData.nativeParams || {};
  111616. }
  111617. Object.defineProperty(PhysicsJoint.prototype, "physicsJoint", {
  111618. /**
  111619. * Gets the physics joint
  111620. */
  111621. get: function () {
  111622. return this._physicsJoint;
  111623. },
  111624. /**
  111625. * Sets the physics joint
  111626. */
  111627. set: function (newJoint) {
  111628. if (this._physicsJoint) {
  111629. //remove from the wolrd
  111630. }
  111631. this._physicsJoint = newJoint;
  111632. },
  111633. enumerable: true,
  111634. configurable: true
  111635. });
  111636. Object.defineProperty(PhysicsJoint.prototype, "physicsPlugin", {
  111637. /**
  111638. * Sets the physics plugin
  111639. */
  111640. set: function (physicsPlugin) {
  111641. this._physicsPlugin = physicsPlugin;
  111642. },
  111643. enumerable: true,
  111644. configurable: true
  111645. });
  111646. /**
  111647. * Execute a function that is physics-plugin specific.
  111648. * @param {Function} func the function that will be executed.
  111649. * It accepts two parameters: the physics world and the physics joint
  111650. */
  111651. PhysicsJoint.prototype.executeNativeFunction = function (func) {
  111652. func(this._physicsPlugin.world, this._physicsJoint);
  111653. };
  111654. //TODO check if the native joints are the same
  111655. //Joint Types
  111656. /**
  111657. * Distance-Joint type
  111658. */
  111659. PhysicsJoint.DistanceJoint = 0;
  111660. /**
  111661. * Hinge-Joint type
  111662. */
  111663. PhysicsJoint.HingeJoint = 1;
  111664. /**
  111665. * Ball-and-Socket joint type
  111666. */
  111667. PhysicsJoint.BallAndSocketJoint = 2;
  111668. /**
  111669. * Wheel-Joint type
  111670. */
  111671. PhysicsJoint.WheelJoint = 3;
  111672. /**
  111673. * Slider-Joint type
  111674. */
  111675. PhysicsJoint.SliderJoint = 4;
  111676. //OIMO
  111677. /**
  111678. * Prismatic-Joint type
  111679. */
  111680. PhysicsJoint.PrismaticJoint = 5;
  111681. //
  111682. /**
  111683. * Universal-Joint type
  111684. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  111685. */
  111686. PhysicsJoint.UniversalJoint = 6;
  111687. /**
  111688. * Hinge-Joint 2 type
  111689. */
  111690. PhysicsJoint.Hinge2Joint = PhysicsJoint.WheelJoint;
  111691. //Cannon
  111692. /**
  111693. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  111694. */
  111695. PhysicsJoint.PointToPointJoint = 8;
  111696. //Cannon only at the moment
  111697. /**
  111698. * Spring-Joint type
  111699. */
  111700. PhysicsJoint.SpringJoint = 9;
  111701. /**
  111702. * Lock-Joint type
  111703. */
  111704. PhysicsJoint.LockJoint = 10;
  111705. return PhysicsJoint;
  111706. }());
  111707. /**
  111708. * A class representing a physics distance joint
  111709. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111710. */
  111711. var DistanceJoint = /** @class */ (function (_super) {
  111712. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DistanceJoint, _super);
  111713. /**
  111714. *
  111715. * @param jointData The data for the Distance-Joint
  111716. */
  111717. function DistanceJoint(jointData) {
  111718. return _super.call(this, PhysicsJoint.DistanceJoint, jointData) || this;
  111719. }
  111720. /**
  111721. * Update the predefined distance.
  111722. * @param maxDistance The maximum preferred distance
  111723. * @param minDistance The minimum preferred distance
  111724. */
  111725. DistanceJoint.prototype.updateDistance = function (maxDistance, minDistance) {
  111726. this._physicsPlugin.updateDistanceJoint(this, maxDistance, minDistance);
  111727. };
  111728. return DistanceJoint;
  111729. }(PhysicsJoint));
  111730. /**
  111731. * Represents a Motor-Enabled Joint
  111732. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111733. */
  111734. var MotorEnabledJoint = /** @class */ (function (_super) {
  111735. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotorEnabledJoint, _super);
  111736. /**
  111737. * Initializes the Motor-Enabled Joint
  111738. * @param type The type of the joint
  111739. * @param jointData The physica joint data for the joint
  111740. */
  111741. function MotorEnabledJoint(type, jointData) {
  111742. return _super.call(this, type, jointData) || this;
  111743. }
  111744. /**
  111745. * Set the motor values.
  111746. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111747. * @param force the force to apply
  111748. * @param maxForce max force for this motor.
  111749. */
  111750. MotorEnabledJoint.prototype.setMotor = function (force, maxForce) {
  111751. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  111752. };
  111753. /**
  111754. * Set the motor's limits.
  111755. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111756. * @param upperLimit The upper limit of the motor
  111757. * @param lowerLimit The lower limit of the motor
  111758. */
  111759. MotorEnabledJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  111760. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  111761. };
  111762. return MotorEnabledJoint;
  111763. }(PhysicsJoint));
  111764. /**
  111765. * This class represents a single physics Hinge-Joint
  111766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111767. */
  111768. var HingeJoint = /** @class */ (function (_super) {
  111769. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HingeJoint, _super);
  111770. /**
  111771. * Initializes the Hinge-Joint
  111772. * @param jointData The joint data for the Hinge-Joint
  111773. */
  111774. function HingeJoint(jointData) {
  111775. return _super.call(this, PhysicsJoint.HingeJoint, jointData) || this;
  111776. }
  111777. /**
  111778. * Set the motor values.
  111779. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111780. * @param {number} force the force to apply
  111781. * @param {number} maxForce max force for this motor.
  111782. */
  111783. HingeJoint.prototype.setMotor = function (force, maxForce) {
  111784. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  111785. };
  111786. /**
  111787. * Set the motor's limits.
  111788. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111789. * @param upperLimit The upper limit of the motor
  111790. * @param lowerLimit The lower limit of the motor
  111791. */
  111792. HingeJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  111793. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  111794. };
  111795. return HingeJoint;
  111796. }(MotorEnabledJoint));
  111797. /**
  111798. * This class represents a dual hinge physics joint (same as wheel joint)
  111799. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111800. */
  111801. var Hinge2Joint = /** @class */ (function (_super) {
  111802. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Hinge2Joint, _super);
  111803. /**
  111804. * Initializes the Hinge2-Joint
  111805. * @param jointData The joint data for the Hinge2-Joint
  111806. */
  111807. function Hinge2Joint(jointData) {
  111808. return _super.call(this, PhysicsJoint.Hinge2Joint, jointData) || this;
  111809. }
  111810. /**
  111811. * Set the motor values.
  111812. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111813. * @param {number} force the force to apply
  111814. * @param {number} maxForce max force for this motor.
  111815. * @param {motorIndex} the motor's index, 0 or 1.
  111816. */
  111817. Hinge2Joint.prototype.setMotor = function (force, maxForce, motorIndex) {
  111818. if (motorIndex === void 0) { motorIndex = 0; }
  111819. this._physicsPlugin.setMotor(this, force || 0, maxForce, motorIndex);
  111820. };
  111821. /**
  111822. * Set the motor limits.
  111823. * Attention, this function is plugin specific. Engines won't react 100% the same.
  111824. * @param {number} upperLimit the upper limit
  111825. * @param {number} lowerLimit lower limit
  111826. * @param {motorIndex} the motor's index, 0 or 1.
  111827. */
  111828. Hinge2Joint.prototype.setLimit = function (upperLimit, lowerLimit, motorIndex) {
  111829. if (motorIndex === void 0) { motorIndex = 0; }
  111830. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit, motorIndex);
  111831. };
  111832. return Hinge2Joint;
  111833. }(MotorEnabledJoint));
  111834. /***/ }),
  111835. /***/ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts":
  111836. /*!****************************************************************************!*\
  111837. !*** ./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts ***!
  111838. \****************************************************************************/
  111839. /*! exports provided: DefaultRenderingPipeline */
  111840. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111841. "use strict";
  111842. __webpack_require__.r(__webpack_exports__);
  111843. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return DefaultRenderingPipeline; });
  111844. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  111845. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  111846. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  111847. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  111848. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  111849. /* harmony import */ var _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Layers/glowLayer */ "./Layers/glowLayer.ts");
  111850. /* harmony import */ var _PostProcesses_sharpenPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  111851. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  111852. /* harmony import */ var _PostProcesses_chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  111853. /* harmony import */ var _PostProcesses_grainPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  111854. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  111855. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  111856. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  111857. /* harmony import */ var _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../PostProcesses/depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  111858. /* harmony import */ var _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../PostProcesses/bloomEffect */ "./PostProcesses/bloomEffect.ts");
  111859. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  111860. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  111861. /**
  111862. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  111863. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  111864. */
  111865. var DefaultRenderingPipeline = /** @class */ (function (_super) {
  111866. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DefaultRenderingPipeline, _super);
  111867. /**
  111868. * @constructor
  111869. * @param name - The rendering pipeline name (default: "")
  111870. * @param hdr - If high dynamic range textures should be used (default: true)
  111871. * @param scene - The scene linked to this pipeline (default: the last created scene)
  111872. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  111873. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  111874. */
  111875. function DefaultRenderingPipeline(name, hdr, scene, cameras, automaticBuild) {
  111876. if (name === void 0) { name = ""; }
  111877. if (hdr === void 0) { hdr = true; }
  111878. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene; }
  111879. if (automaticBuild === void 0) { automaticBuild = true; }
  111880. var _this = _super.call(this, scene.getEngine(), name) || this;
  111881. _this._camerasToBeAttached = [];
  111882. /**
  111883. * ID of the sharpen post process,
  111884. */
  111885. _this.SharpenPostProcessId = "SharpenPostProcessEffect";
  111886. /**
  111887. * @ignore
  111888. * ID of the image processing post process;
  111889. */
  111890. _this.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect";
  111891. /**
  111892. * @ignore
  111893. * ID of the Fast Approximate Anti-Aliasing post process;
  111894. */
  111895. _this.FxaaPostProcessId = "FxaaPostProcessEffect";
  111896. /**
  111897. * ID of the chromatic aberration post process,
  111898. */
  111899. _this.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect";
  111900. /**
  111901. * ID of the grain post process
  111902. */
  111903. _this.GrainPostProcessId = "GrainPostProcessEffect";
  111904. /**
  111905. * Glow post process which adds a glow to emmisive areas of the image
  111906. */
  111907. _this._glowLayer = null;
  111908. /**
  111909. * Animations which can be used to tweak settings over a period of time
  111910. */
  111911. _this.animations = [];
  111912. _this._imageProcessingConfigurationObserver = null;
  111913. // Values
  111914. _this._sharpenEnabled = false;
  111915. _this._bloomEnabled = false;
  111916. _this._depthOfFieldEnabled = false;
  111917. _this._depthOfFieldBlurLevel = _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffectBlurLevel"].Low;
  111918. _this._fxaaEnabled = false;
  111919. _this._imageProcessingEnabled = true;
  111920. _this._bloomScale = 0.5;
  111921. _this._chromaticAberrationEnabled = false;
  111922. _this._grainEnabled = false;
  111923. _this._buildAllowed = true;
  111924. _this._resizeObserver = null;
  111925. _this._hardwareScaleLevel = 1.0;
  111926. _this._bloomKernel = 64;
  111927. /**
  111928. * Specifies the weight of the bloom in the final rendering
  111929. */
  111930. _this._bloomWeight = 0.15;
  111931. /**
  111932. * Specifies the luma threshold for the area that will be blurred by the bloom
  111933. */
  111934. _this._bloomThreshold = 0.9;
  111935. _this._samples = 1;
  111936. _this._hasCleared = false;
  111937. _this._prevPostProcess = null;
  111938. _this._prevPrevPostProcess = null;
  111939. _this._depthOfFieldSceneObserver = null;
  111940. _this._cameras = cameras || scene.cameras;
  111941. _this._cameras = _this._cameras.slice();
  111942. _this._camerasToBeAttached = _this._cameras.slice();
  111943. _this._buildAllowed = automaticBuild;
  111944. // Initialize
  111945. _this._scene = scene;
  111946. var caps = _this._scene.getEngine().getCaps();
  111947. _this._hdr = hdr && (caps.textureHalfFloatRender || caps.textureFloatRender);
  111948. // Misc
  111949. if (_this._hdr) {
  111950. if (caps.textureHalfFloatRender) {
  111951. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_HALF_FLOAT;
  111952. }
  111953. else if (caps.textureFloatRender) {
  111954. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_FLOAT;
  111955. }
  111956. }
  111957. else {
  111958. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  111959. }
  111960. // Attach
  111961. scene.postProcessRenderPipelineManager.addPipeline(_this);
  111962. var engine = _this._scene.getEngine();
  111963. // Create post processes before hand so they can be modified before enabled.
  111964. // Block compilation flag is set to true to avoid compilation prior to use, these will be updated on first use in build pipeline.
  111965. _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);
  111966. _this._sharpenEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.SharpenPostProcessId, function () { return _this.sharpen; }, true);
  111967. _this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](_this._scene, null, _this._depthOfFieldBlurLevel, _this._defaultPipelineTextureType, true);
  111968. _this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](_this._scene, _this._bloomScale, _this._bloomWeight, _this.bloomKernel, _this._defaultPipelineTextureType, true);
  111969. _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);
  111970. _this._chromaticAberrationEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.ChromaticAberrationPostProcessId, function () { return _this.chromaticAberration; }, true);
  111971. _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);
  111972. _this._grainEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.GrainPostProcessId, function () { return _this.grain; }, true);
  111973. _this._resizeObserver = engine.onResizeObservable.add(function () {
  111974. _this._hardwareScaleLevel = engine.getHardwareScalingLevel();
  111975. _this.bloomKernel = _this.bloomKernel;
  111976. });
  111977. _this._imageProcessingConfigurationObserver = _this._scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  111978. _this.bloom._downscale._exposure = _this._scene.imageProcessingConfiguration.exposure;
  111979. });
  111980. _this._buildPipeline();
  111981. return _this;
  111982. }
  111983. Object.defineProperty(DefaultRenderingPipeline.prototype, "sharpenEnabled", {
  111984. get: function () {
  111985. return this._sharpenEnabled;
  111986. },
  111987. /**
  111988. * Enable or disable the sharpen process from the pipeline
  111989. */
  111990. set: function (enabled) {
  111991. if (this._sharpenEnabled === enabled) {
  111992. return;
  111993. }
  111994. this._sharpenEnabled = enabled;
  111995. this._buildPipeline();
  111996. },
  111997. enumerable: true,
  111998. configurable: true
  111999. });
  112000. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomKernel", {
  112001. /**
  112002. * Specifies the size of the bloom blur kernel, relative to the final output size
  112003. */
  112004. get: function () {
  112005. return this._bloomKernel;
  112006. },
  112007. set: function (value) {
  112008. this._bloomKernel = value;
  112009. this.bloom.kernel = value / this._hardwareScaleLevel;
  112010. },
  112011. enumerable: true,
  112012. configurable: true
  112013. });
  112014. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomWeight", {
  112015. get: function () {
  112016. return this._bloomWeight;
  112017. },
  112018. /**
  112019. * The strength of the bloom.
  112020. */
  112021. set: function (value) {
  112022. if (this._bloomWeight === value) {
  112023. return;
  112024. }
  112025. this.bloom.weight = value;
  112026. this._bloomWeight = value;
  112027. },
  112028. enumerable: true,
  112029. configurable: true
  112030. });
  112031. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomThreshold", {
  112032. get: function () {
  112033. return this._bloomThreshold;
  112034. },
  112035. /**
  112036. * The strength of the bloom.
  112037. */
  112038. set: function (value) {
  112039. if (this._bloomThreshold === value) {
  112040. return;
  112041. }
  112042. this.bloom.threshold = value;
  112043. this._bloomThreshold = value;
  112044. },
  112045. enumerable: true,
  112046. configurable: true
  112047. });
  112048. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomScale", {
  112049. get: function () {
  112050. return this._bloomScale;
  112051. },
  112052. /**
  112053. * The scale of the bloom, lower value will provide better performance.
  112054. */
  112055. set: function (value) {
  112056. if (this._bloomScale === value) {
  112057. return;
  112058. }
  112059. this._bloomScale = value;
  112060. // recreate bloom and dispose old as this setting is not dynamic
  112061. this._rebuildBloom();
  112062. this._buildPipeline();
  112063. },
  112064. enumerable: true,
  112065. configurable: true
  112066. });
  112067. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomEnabled", {
  112068. get: function () {
  112069. return this._bloomEnabled;
  112070. },
  112071. /**
  112072. * Enable or disable the bloom from the pipeline
  112073. */
  112074. set: function (enabled) {
  112075. if (this._bloomEnabled === enabled) {
  112076. return;
  112077. }
  112078. this._bloomEnabled = enabled;
  112079. this._buildPipeline();
  112080. },
  112081. enumerable: true,
  112082. configurable: true
  112083. });
  112084. DefaultRenderingPipeline.prototype._rebuildBloom = function () {
  112085. // recreate bloom and dispose old as this setting is not dynamic
  112086. var oldBloom = this.bloom;
  112087. this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](this._scene, this.bloomScale, this._bloomWeight, this.bloomKernel, this._defaultPipelineTextureType, false);
  112088. this.bloom.threshold = oldBloom.threshold;
  112089. for (var i = 0; i < this._cameras.length; i++) {
  112090. oldBloom.disposeEffects(this._cameras[i]);
  112091. }
  112092. };
  112093. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", {
  112094. /**
  112095. * If the depth of field is enabled.
  112096. */
  112097. get: function () {
  112098. return this._depthOfFieldEnabled;
  112099. },
  112100. set: function (enabled) {
  112101. if (this._depthOfFieldEnabled === enabled) {
  112102. return;
  112103. }
  112104. this._depthOfFieldEnabled = enabled;
  112105. this._buildPipeline();
  112106. },
  112107. enumerable: true,
  112108. configurable: true
  112109. });
  112110. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", {
  112111. /**
  112112. * Blur level of the depth of field effect. (Higher blur will effect performance)
  112113. */
  112114. get: function () {
  112115. return this._depthOfFieldBlurLevel;
  112116. },
  112117. set: function (value) {
  112118. if (this._depthOfFieldBlurLevel === value) {
  112119. return;
  112120. }
  112121. this._depthOfFieldBlurLevel = value;
  112122. // recreate dof and dispose old as this setting is not dynamic
  112123. var oldDof = this.depthOfField;
  112124. this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](this._scene, null, this._depthOfFieldBlurLevel, this._defaultPipelineTextureType, false);
  112125. this.depthOfField.focalLength = oldDof.focalLength;
  112126. this.depthOfField.focusDistance = oldDof.focusDistance;
  112127. this.depthOfField.fStop = oldDof.fStop;
  112128. this.depthOfField.lensSize = oldDof.lensSize;
  112129. for (var i = 0; i < this._cameras.length; i++) {
  112130. oldDof.disposeEffects(this._cameras[i]);
  112131. }
  112132. this._buildPipeline();
  112133. },
  112134. enumerable: true,
  112135. configurable: true
  112136. });
  112137. Object.defineProperty(DefaultRenderingPipeline.prototype, "fxaaEnabled", {
  112138. get: function () {
  112139. return this._fxaaEnabled;
  112140. },
  112141. /**
  112142. * If the anti aliasing is enabled.
  112143. */
  112144. set: function (enabled) {
  112145. if (this._fxaaEnabled === enabled) {
  112146. return;
  112147. }
  112148. this._fxaaEnabled = enabled;
  112149. this._buildPipeline();
  112150. },
  112151. enumerable: true,
  112152. configurable: true
  112153. });
  112154. Object.defineProperty(DefaultRenderingPipeline.prototype, "samples", {
  112155. get: function () {
  112156. return this._samples;
  112157. },
  112158. /**
  112159. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  112160. */
  112161. set: function (sampleCount) {
  112162. if (this._samples === sampleCount) {
  112163. return;
  112164. }
  112165. this._samples = sampleCount;
  112166. this._buildPipeline();
  112167. },
  112168. enumerable: true,
  112169. configurable: true
  112170. });
  112171. Object.defineProperty(DefaultRenderingPipeline.prototype, "imageProcessingEnabled", {
  112172. get: function () {
  112173. return this._imageProcessingEnabled;
  112174. },
  112175. /**
  112176. * If image processing is enabled.
  112177. */
  112178. set: function (enabled) {
  112179. if (this._imageProcessingEnabled === enabled) {
  112180. return;
  112181. }
  112182. this._imageProcessingEnabled = enabled;
  112183. this._buildPipeline();
  112184. },
  112185. enumerable: true,
  112186. configurable: true
  112187. });
  112188. Object.defineProperty(DefaultRenderingPipeline.prototype, "glowLayerEnabled", {
  112189. get: function () {
  112190. return this._glowLayer == null;
  112191. },
  112192. /**
  112193. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  112194. */
  112195. set: function (enabled) {
  112196. if (enabled && !this._glowLayer) {
  112197. this._glowLayer = new _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__["GlowLayer"]("", this._scene);
  112198. }
  112199. else if (!enabled && this._glowLayer) {
  112200. this._glowLayer.dispose();
  112201. this._glowLayer = null;
  112202. }
  112203. },
  112204. enumerable: true,
  112205. configurable: true
  112206. });
  112207. Object.defineProperty(DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", {
  112208. get: function () {
  112209. return this._chromaticAberrationEnabled;
  112210. },
  112211. /**
  112212. * Enable or disable the chromaticAberration process from the pipeline
  112213. */
  112214. set: function (enabled) {
  112215. if (this._chromaticAberrationEnabled === enabled) {
  112216. return;
  112217. }
  112218. this._chromaticAberrationEnabled = enabled;
  112219. this._buildPipeline();
  112220. },
  112221. enumerable: true,
  112222. configurable: true
  112223. });
  112224. Object.defineProperty(DefaultRenderingPipeline.prototype, "grainEnabled", {
  112225. get: function () {
  112226. return this._grainEnabled;
  112227. },
  112228. /**
  112229. * Enable or disable the grain process from the pipeline
  112230. */
  112231. set: function (enabled) {
  112232. if (this._grainEnabled === enabled) {
  112233. return;
  112234. }
  112235. this._grainEnabled = enabled;
  112236. this._buildPipeline();
  112237. },
  112238. enumerable: true,
  112239. configurable: true
  112240. });
  112241. /**
  112242. * Force the compilation of the entire pipeline.
  112243. */
  112244. DefaultRenderingPipeline.prototype.prepare = function () {
  112245. var previousState = this._buildAllowed;
  112246. this._buildAllowed = true;
  112247. this._buildPipeline();
  112248. this._buildAllowed = previousState;
  112249. };
  112250. DefaultRenderingPipeline.prototype._setAutoClearAndTextureSharing = function (postProcess, skipTextureSharing) {
  112251. if (skipTextureSharing === void 0) { skipTextureSharing = false; }
  112252. if (this._hasCleared) {
  112253. postProcess.autoClear = false;
  112254. }
  112255. else {
  112256. postProcess.autoClear = true;
  112257. this._scene.autoClear = false;
  112258. this._hasCleared = true;
  112259. }
  112260. if (!skipTextureSharing) {
  112261. if (this._prevPrevPostProcess) {
  112262. postProcess.shareOutputWith(this._prevPrevPostProcess);
  112263. }
  112264. else {
  112265. postProcess.useOwnOutput();
  112266. }
  112267. if (this._prevPostProcess) {
  112268. this._prevPrevPostProcess = this._prevPostProcess;
  112269. }
  112270. this._prevPostProcess = postProcess;
  112271. }
  112272. };
  112273. DefaultRenderingPipeline.prototype._buildPipeline = function () {
  112274. var _this = this;
  112275. if (!this._buildAllowed) {
  112276. return;
  112277. }
  112278. this._scene.autoClear = true;
  112279. var engine = this._scene.getEngine();
  112280. this._disposePostProcesses();
  112281. if (this._cameras !== null) {
  112282. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  112283. // get back cameras to be used to reattach pipeline
  112284. this._cameras = this._camerasToBeAttached.slice();
  112285. }
  112286. this._reset();
  112287. this._prevPostProcess = null;
  112288. this._prevPrevPostProcess = null;
  112289. this._hasCleared = false;
  112290. if (this.depthOfFieldEnabled) {
  112291. // Multi camera suport
  112292. if (this._cameras.length > 1) {
  112293. for (var _i = 0, _a = this._cameras; _i < _a.length; _i++) {
  112294. var camera = _a[_i];
  112295. var depthRenderer = this._scene.enableDepthRenderer(camera);
  112296. depthRenderer.useOnlyInActiveCamera = true;
  112297. }
  112298. this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function (scene) {
  112299. if (_this._cameras.indexOf(scene.activeCamera) > -1) {
  112300. _this.depthOfField.depthTexture = scene.enableDepthRenderer(scene.activeCamera).getDepthMap();
  112301. }
  112302. });
  112303. }
  112304. else {
  112305. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  112306. var depthRenderer = this._scene.enableDepthRenderer(this._cameras[0]);
  112307. this.depthOfField.depthTexture = depthRenderer.getDepthMap();
  112308. }
  112309. if (!this.depthOfField._isReady()) {
  112310. this.depthOfField._updateEffects();
  112311. }
  112312. this.addEffect(this.depthOfField);
  112313. this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], true);
  112314. }
  112315. else {
  112316. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  112317. }
  112318. if (this.bloomEnabled) {
  112319. if (!this.bloom._isReady()) {
  112320. this.bloom._updateEffects();
  112321. }
  112322. this.addEffect(this.bloom);
  112323. this._setAutoClearAndTextureSharing(this.bloom._effects[0], true);
  112324. }
  112325. if (this._imageProcessingEnabled) {
  112326. 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);
  112327. if (this._hdr) {
  112328. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.ImageProcessingPostProcessId, function () { return _this.imageProcessing; }, true));
  112329. this._setAutoClearAndTextureSharing(this.imageProcessing);
  112330. }
  112331. else {
  112332. this._scene.imageProcessingConfiguration.applyByPostProcess = false;
  112333. }
  112334. }
  112335. if (this.sharpenEnabled) {
  112336. if (!this.sharpen.isReady()) {
  112337. this.sharpen.updateEffect();
  112338. }
  112339. this.addEffect(this._sharpenEffect);
  112340. this._setAutoClearAndTextureSharing(this.sharpen);
  112341. }
  112342. if (this.grainEnabled) {
  112343. if (!this.grain.isReady()) {
  112344. this.grain.updateEffect();
  112345. }
  112346. this.addEffect(this._grainEffect);
  112347. this._setAutoClearAndTextureSharing(this.grain);
  112348. }
  112349. if (this.chromaticAberrationEnabled) {
  112350. if (!this.chromaticAberration.isReady()) {
  112351. this.chromaticAberration.updateEffect();
  112352. }
  112353. this.addEffect(this._chromaticAberrationEffect);
  112354. this._setAutoClearAndTextureSharing(this.chromaticAberration);
  112355. }
  112356. if (this.fxaaEnabled) {
  112357. 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);
  112358. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.FxaaPostProcessId, function () { return _this.fxaa; }, true));
  112359. this._setAutoClearAndTextureSharing(this.fxaa, true);
  112360. }
  112361. if (this._cameras !== null) {
  112362. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  112363. }
  112364. if (!this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1) {
  112365. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  112366. }
  112367. };
  112368. DefaultRenderingPipeline.prototype._disposePostProcesses = function (disposeNonRecreated) {
  112369. if (disposeNonRecreated === void 0) { disposeNonRecreated = false; }
  112370. for (var i = 0; i < this._cameras.length; i++) {
  112371. var camera = this._cameras[i];
  112372. if (this.imageProcessing) {
  112373. this.imageProcessing.dispose(camera);
  112374. }
  112375. if (this.fxaa) {
  112376. this.fxaa.dispose(camera);
  112377. }
  112378. // These are created in the constructor and should not be disposed on every pipeline change
  112379. if (disposeNonRecreated) {
  112380. if (this.sharpen) {
  112381. this.sharpen.dispose(camera);
  112382. }
  112383. if (this.depthOfField) {
  112384. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  112385. this.depthOfField.disposeEffects(camera);
  112386. }
  112387. if (this.bloom) {
  112388. this.bloom.disposeEffects(camera);
  112389. }
  112390. if (this.chromaticAberration) {
  112391. this.chromaticAberration.dispose(camera);
  112392. }
  112393. if (this.grain) {
  112394. this.grain.dispose(camera);
  112395. }
  112396. if (this._glowLayer) {
  112397. this._glowLayer.dispose();
  112398. }
  112399. }
  112400. }
  112401. this.imageProcessing = null;
  112402. this.fxaa = null;
  112403. if (disposeNonRecreated) {
  112404. this.sharpen = null;
  112405. this._sharpenEffect = null;
  112406. this.depthOfField = null;
  112407. this.bloom = null;
  112408. this.chromaticAberration = null;
  112409. this._chromaticAberrationEffect = null;
  112410. this.grain = null;
  112411. this._grainEffect = null;
  112412. this._glowLayer = null;
  112413. }
  112414. };
  112415. /**
  112416. * Adds a camera to the pipeline
  112417. * @param camera the camera to be added
  112418. */
  112419. DefaultRenderingPipeline.prototype.addCamera = function (camera) {
  112420. this._camerasToBeAttached.push(camera);
  112421. this._buildPipeline();
  112422. };
  112423. /**
  112424. * Removes a camera from the pipeline
  112425. * @param camera the camera to remove
  112426. */
  112427. DefaultRenderingPipeline.prototype.removeCamera = function (camera) {
  112428. var index = this._camerasToBeAttached.indexOf(camera);
  112429. this._camerasToBeAttached.splice(index, 1);
  112430. this._buildPipeline();
  112431. };
  112432. /**
  112433. * Dispose of the pipeline and stop all post processes
  112434. */
  112435. DefaultRenderingPipeline.prototype.dispose = function () {
  112436. this._disposePostProcesses(true);
  112437. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  112438. this._scene.autoClear = true;
  112439. if (this._resizeObserver) {
  112440. this._scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  112441. this._resizeObserver = null;
  112442. }
  112443. this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver);
  112444. _super.prototype.dispose.call(this);
  112445. };
  112446. /**
  112447. * Serialize the rendering pipeline (Used when exporting)
  112448. * @returns the serialized object
  112449. */
  112450. DefaultRenderingPipeline.prototype.serialize = function () {
  112451. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  112452. serializationObject.customType = "DefaultRenderingPipeline";
  112453. return serializationObject;
  112454. };
  112455. /**
  112456. * Parse the serialized pipeline
  112457. * @param source Source pipeline.
  112458. * @param scene The scene to load the pipeline to.
  112459. * @param rootUrl The URL of the serialized pipeline.
  112460. * @returns An instantiated pipeline from the serialized object.
  112461. */
  112462. DefaultRenderingPipeline.Parse = function (source, scene, rootUrl) {
  112463. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new DefaultRenderingPipeline(source._name, source._name._hdr, scene); }, source, scene, rootUrl);
  112464. };
  112465. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112466. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112467. ], DefaultRenderingPipeline.prototype, "sharpenEnabled", null);
  112468. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112469. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112470. ], DefaultRenderingPipeline.prototype, "bloomKernel", null);
  112471. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112472. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112473. ], DefaultRenderingPipeline.prototype, "_bloomWeight", void 0);
  112474. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112475. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112476. ], DefaultRenderingPipeline.prototype, "_bloomThreshold", void 0);
  112477. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112478. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112479. ], DefaultRenderingPipeline.prototype, "_hdr", void 0);
  112480. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112481. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112482. ], DefaultRenderingPipeline.prototype, "bloomWeight", null);
  112483. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112484. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112485. ], DefaultRenderingPipeline.prototype, "bloomThreshold", null);
  112486. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112487. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112488. ], DefaultRenderingPipeline.prototype, "bloomScale", null);
  112489. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112490. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112491. ], DefaultRenderingPipeline.prototype, "bloomEnabled", null);
  112492. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112493. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112494. ], DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", null);
  112495. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112496. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112497. ], DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", null);
  112498. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112499. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112500. ], DefaultRenderingPipeline.prototype, "fxaaEnabled", null);
  112501. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112502. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112503. ], DefaultRenderingPipeline.prototype, "samples", null);
  112504. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112505. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112506. ], DefaultRenderingPipeline.prototype, "imageProcessingEnabled", null);
  112507. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112508. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112509. ], DefaultRenderingPipeline.prototype, "glowLayerEnabled", null);
  112510. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112511. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112512. ], DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", null);
  112513. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  112514. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  112515. ], DefaultRenderingPipeline.prototype, "grainEnabled", null);
  112516. return DefaultRenderingPipeline;
  112517. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__["PostProcessRenderPipeline"]));
  112518. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__["_TypeStore"].RegisteredTypes["BABYLON.DefaultRenderingPipeline"] = DefaultRenderingPipeline;
  112519. /***/ }),
  112520. /***/ "./PostProcesses/RenderPipeline/Pipelines/index.ts":
  112521. /*!*********************************************************!*\
  112522. !*** ./PostProcesses/RenderPipeline/Pipelines/index.ts ***!
  112523. \*********************************************************/
  112524. /*! exports provided: DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  112525. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112526. "use strict";
  112527. __webpack_require__.r(__webpack_exports__);
  112528. /* harmony import */ var _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts");
  112529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  112530. /* harmony import */ var _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts");
  112531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__["LensRenderingPipeline"]; });
  112532. /* harmony import */ var _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ssao2RenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts");
  112533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__["SSAO2RenderingPipeline"]; });
  112534. /* harmony import */ var _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ssaoRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts");
  112535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__["SSAORenderingPipeline"]; });
  112536. /* harmony import */ var _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./standardRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts");
  112537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__["StandardRenderingPipeline"]; });
  112538. /***/ }),
  112539. /***/ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts":
  112540. /*!*************************************************************************!*\
  112541. !*** ./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts ***!
  112542. \*************************************************************************/
  112543. /*! exports provided: LensRenderingPipeline */
  112544. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112545. "use strict";
  112546. __webpack_require__.r(__webpack_exports__);
  112547. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return LensRenderingPipeline; });
  112548. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  112549. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  112550. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  112551. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  112552. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  112553. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  112554. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  112555. /* harmony import */ var _Shaders_lensHighlights_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Shaders/lensHighlights.fragment */ "./Shaders/lensHighlights.fragment.ts");
  112556. /* harmony import */ var _Shaders_depthOfField_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../Shaders/depthOfField.fragment */ "./Shaders/depthOfField.fragment.ts");
  112557. /**
  112558. * BABYLON.JS Chromatic Aberration GLSL Shader
  112559. * Author: Olivier Guyot
  112560. * Separates very slightly R, G and B colors on the edges of the screen
  112561. * Inspired by Francois Tarlier & Martins Upitis
  112562. */
  112563. var LensRenderingPipeline = /** @class */ (function (_super) {
  112564. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensRenderingPipeline, _super);
  112565. /**
  112566. * @constructor
  112567. *
  112568. * Effect parameters are as follow:
  112569. * {
  112570. * chromatic_aberration: number; // from 0 to x (1 for realism)
  112571. * edge_blur: number; // from 0 to x (1 for realism)
  112572. * distortion: number; // from 0 to x (1 for realism)
  112573. * grain_amount: number; // from 0 to 1
  112574. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  112575. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  112576. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  112577. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  112578. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  112579. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  112580. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  112581. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  112582. * }
  112583. * Note: if an effect parameter is unset, effect is disabled
  112584. *
  112585. * @param name The rendering pipeline name
  112586. * @param parameters - An object containing all parameters (see above)
  112587. * @param scene The scene linked to this pipeline
  112588. * @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)
  112589. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112590. */
  112591. function LensRenderingPipeline(name, parameters, scene, ratio, cameras) {
  112592. if (ratio === void 0) { ratio = 1.0; }
  112593. var _this = _super.call(this, scene.getEngine(), name) || this;
  112594. // Lens effects can be of the following:
  112595. // - chromatic aberration (slight shift of RGB colors)
  112596. // - blur on the edge of the lens
  112597. // - lens distortion
  112598. // - depth-of-field blur & highlights enhancing
  112599. // - depth-of-field 'bokeh' effect (shapes appearing in blurred areas)
  112600. // - grain effect (noise or custom texture)
  112601. // Two additional texture samplers are needed:
  112602. // - depth map (for depth-of-field)
  112603. // - grain texture
  112604. /**
  112605. * @ignore
  112606. * The chromatic aberration PostProcess id in the pipeline
  112607. */
  112608. _this.LensChromaticAberrationEffect = "LensChromaticAberrationEffect";
  112609. /**
  112610. * @ignore
  112611. * The highlights enhancing PostProcess id in the pipeline
  112612. */
  112613. _this.HighlightsEnhancingEffect = "HighlightsEnhancingEffect";
  112614. /**
  112615. * @ignore
  112616. * The depth-of-field PostProcess id in the pipeline
  112617. */
  112618. _this.LensDepthOfFieldEffect = "LensDepthOfFieldEffect";
  112619. _this._scene = scene;
  112620. // Fetch texture samplers
  112621. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  112622. if (parameters.grain_texture) {
  112623. _this._grainTexture = parameters.grain_texture;
  112624. }
  112625. else {
  112626. _this._createGrainTexture();
  112627. }
  112628. // save parameters
  112629. _this._edgeBlur = parameters.edge_blur ? parameters.edge_blur : 0;
  112630. _this._grainAmount = parameters.grain_amount ? parameters.grain_amount : 0;
  112631. _this._chromaticAberration = parameters.chromatic_aberration ? parameters.chromatic_aberration : 0;
  112632. _this._distortion = parameters.distortion ? parameters.distortion : 0;
  112633. _this._highlightsGain = parameters.dof_gain !== undefined ? parameters.dof_gain : -1;
  112634. _this._highlightsThreshold = parameters.dof_threshold ? parameters.dof_threshold : 1;
  112635. _this._dofDistance = parameters.dof_focus_distance !== undefined ? parameters.dof_focus_distance : -1;
  112636. _this._dofAperture = parameters.dof_aperture ? parameters.dof_aperture : 1;
  112637. _this._dofDarken = parameters.dof_darken ? parameters.dof_darken : 0;
  112638. _this._dofPentagon = parameters.dof_pentagon !== undefined ? parameters.dof_pentagon : true;
  112639. _this._blurNoise = parameters.blur_noise !== undefined ? parameters.blur_noise : true;
  112640. // Create effects
  112641. _this._createChromaticAberrationPostProcess(ratio);
  112642. _this._createHighlightsPostProcess(ratio);
  112643. _this._createDepthOfFieldPostProcess(ratio / 4);
  112644. // Set up pipeline
  112645. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensChromaticAberrationEffect, function () { return _this._chromaticAberrationPostProcess; }, true));
  112646. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.HighlightsEnhancingEffect, function () { return _this._highlightsPostProcess; }, true));
  112647. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensDepthOfFieldEffect, function () { return _this._depthOfFieldPostProcess; }, true));
  112648. if (_this._highlightsGain === -1) {
  112649. _this._disableEffect(_this.HighlightsEnhancingEffect, null);
  112650. }
  112651. // Finish
  112652. scene.postProcessRenderPipelineManager.addPipeline(_this);
  112653. if (cameras) {
  112654. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  112655. }
  112656. return _this;
  112657. }
  112658. // public methods (self explanatory)
  112659. /**
  112660. * Sets the amount of blur at the edges
  112661. * @param amount blur amount
  112662. */
  112663. LensRenderingPipeline.prototype.setEdgeBlur = function (amount) { this._edgeBlur = amount; };
  112664. /**
  112665. * Sets edge blur to 0
  112666. */
  112667. LensRenderingPipeline.prototype.disableEdgeBlur = function () { this._edgeBlur = 0; };
  112668. /**
  112669. * Sets the amout of grain
  112670. * @param amount Amount of grain
  112671. */
  112672. LensRenderingPipeline.prototype.setGrainAmount = function (amount) { this._grainAmount = amount; };
  112673. /**
  112674. * Set grain amount to 0
  112675. */
  112676. LensRenderingPipeline.prototype.disableGrain = function () { this._grainAmount = 0; };
  112677. /**
  112678. * Sets the chromatic aberration amount
  112679. * @param amount amount of chromatic aberration
  112680. */
  112681. LensRenderingPipeline.prototype.setChromaticAberration = function (amount) { this._chromaticAberration = amount; };
  112682. /**
  112683. * Sets chromatic aberration amount to 0
  112684. */
  112685. LensRenderingPipeline.prototype.disableChromaticAberration = function () { this._chromaticAberration = 0; };
  112686. /**
  112687. * Sets the EdgeDistortion amount
  112688. * @param amount amount of EdgeDistortion
  112689. */
  112690. LensRenderingPipeline.prototype.setEdgeDistortion = function (amount) { this._distortion = amount; };
  112691. /**
  112692. * Sets edge distortion to 0
  112693. */
  112694. LensRenderingPipeline.prototype.disableEdgeDistortion = function () { this._distortion = 0; };
  112695. /**
  112696. * Sets the FocusDistance amount
  112697. * @param amount amount of FocusDistance
  112698. */
  112699. LensRenderingPipeline.prototype.setFocusDistance = function (amount) { this._dofDistance = amount; };
  112700. /**
  112701. * Disables depth of field
  112702. */
  112703. LensRenderingPipeline.prototype.disableDepthOfField = function () { this._dofDistance = -1; };
  112704. /**
  112705. * Sets the Aperture amount
  112706. * @param amount amount of Aperture
  112707. */
  112708. LensRenderingPipeline.prototype.setAperture = function (amount) { this._dofAperture = amount; };
  112709. /**
  112710. * Sets the DarkenOutOfFocus amount
  112711. * @param amount amount of DarkenOutOfFocus
  112712. */
  112713. LensRenderingPipeline.prototype.setDarkenOutOfFocus = function (amount) { this._dofDarken = amount; };
  112714. /**
  112715. * Creates a pentagon bokeh effect
  112716. */
  112717. LensRenderingPipeline.prototype.enablePentagonBokeh = function () {
  112718. this._highlightsPostProcess.updateEffect("#define PENTAGON\n");
  112719. };
  112720. /**
  112721. * Disables the pentagon bokeh effect
  112722. */
  112723. LensRenderingPipeline.prototype.disablePentagonBokeh = function () {
  112724. this._highlightsPostProcess.updateEffect();
  112725. };
  112726. /**
  112727. * Enables noise blur
  112728. */
  112729. LensRenderingPipeline.prototype.enableNoiseBlur = function () { this._blurNoise = true; };
  112730. /**
  112731. * Disables noise blur
  112732. */
  112733. LensRenderingPipeline.prototype.disableNoiseBlur = function () { this._blurNoise = false; };
  112734. /**
  112735. * Sets the HighlightsGain amount
  112736. * @param amount amount of HighlightsGain
  112737. */
  112738. LensRenderingPipeline.prototype.setHighlightsGain = function (amount) {
  112739. this._highlightsGain = amount;
  112740. };
  112741. /**
  112742. * Sets the HighlightsThreshold amount
  112743. * @param amount amount of HighlightsThreshold
  112744. */
  112745. LensRenderingPipeline.prototype.setHighlightsThreshold = function (amount) {
  112746. if (this._highlightsGain === -1) {
  112747. this._highlightsGain = 1.0;
  112748. }
  112749. this._highlightsThreshold = amount;
  112750. };
  112751. /**
  112752. * Disables highlights
  112753. */
  112754. LensRenderingPipeline.prototype.disableHighlights = function () {
  112755. this._highlightsGain = -1;
  112756. };
  112757. /**
  112758. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  112759. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  112760. */
  112761. LensRenderingPipeline.prototype.dispose = function (disableDepthRender) {
  112762. if (disableDepthRender === void 0) { disableDepthRender = false; }
  112763. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  112764. this._chromaticAberrationPostProcess = null;
  112765. this._highlightsPostProcess = null;
  112766. this._depthOfFieldPostProcess = null;
  112767. this._grainTexture.dispose();
  112768. if (disableDepthRender) {
  112769. this._scene.disableDepthRenderer();
  112770. }
  112771. };
  112772. // colors shifting and distortion
  112773. LensRenderingPipeline.prototype._createChromaticAberrationPostProcess = function (ratio) {
  112774. var _this = this;
  112775. this._chromaticAberrationPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensChromaticAberration", "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], // uniforms
  112776. [], // samplers
  112777. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  112778. this._chromaticAberrationPostProcess.onApply = function (effect) {
  112779. effect.setFloat('chromatic_aberration', _this._chromaticAberration);
  112780. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  112781. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  112782. effect.setFloat('radialIntensity', 1);
  112783. effect.setFloat2('direction', 17, 17);
  112784. effect.setFloat2('centerPosition', 0.5, 0.5);
  112785. };
  112786. };
  112787. // highlights enhancing
  112788. LensRenderingPipeline.prototype._createHighlightsPostProcess = function (ratio) {
  112789. var _this = this;
  112790. this._highlightsPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensHighlights", "lensHighlights", ["gain", "threshold", "screen_width", "screen_height"], // uniforms
  112791. [], // samplers
  112792. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, this._dofPentagon ? "#define PENTAGON\n" : "");
  112793. this._highlightsPostProcess.onApply = function (effect) {
  112794. effect.setFloat('gain', _this._highlightsGain);
  112795. effect.setFloat('threshold', _this._highlightsThreshold);
  112796. effect.setTextureFromPostProcess("textureSampler", _this._chromaticAberrationPostProcess);
  112797. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  112798. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  112799. };
  112800. };
  112801. // colors shifting and distortion
  112802. LensRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (ratio) {
  112803. var _this = this;
  112804. this._depthOfFieldPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensDepthOfField", "depthOfField", [
  112805. "grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled",
  112806. "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"
  112807. ], ["depthSampler", "grainSampler", "highlightsSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  112808. this._depthOfFieldPostProcess.onApply = function (effect) {
  112809. effect.setTexture("depthSampler", _this._depthTexture);
  112810. effect.setTexture("grainSampler", _this._grainTexture);
  112811. effect.setTextureFromPostProcess("textureSampler", _this._highlightsPostProcess);
  112812. effect.setTextureFromPostProcess("highlightsSampler", _this._depthOfFieldPostProcess);
  112813. effect.setFloat('grain_amount', _this._grainAmount);
  112814. effect.setBool('blur_noise', _this._blurNoise);
  112815. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  112816. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  112817. effect.setFloat('distortion', _this._distortion);
  112818. effect.setBool('dof_enabled', (_this._dofDistance !== -1));
  112819. effect.setFloat('screen_distance', 1.0 / (0.1 - 1.0 / _this._dofDistance));
  112820. effect.setFloat('aperture', _this._dofAperture);
  112821. effect.setFloat('darken', _this._dofDarken);
  112822. effect.setFloat('edge_blur', _this._edgeBlur);
  112823. effect.setBool('highlights', (_this._highlightsGain !== -1));
  112824. if (_this._scene.activeCamera) {
  112825. effect.setFloat('near', _this._scene.activeCamera.minZ);
  112826. effect.setFloat('far', _this._scene.activeCamera.maxZ);
  112827. }
  112828. };
  112829. };
  112830. // creates a black and white random noise texture, 512x512
  112831. LensRenderingPipeline.prototype._createGrainTexture = function () {
  112832. var size = 512;
  112833. 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);
  112834. this._grainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  112835. this._grainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  112836. var context = this._grainTexture.getContext();
  112837. var rand = function (min, max) {
  112838. return Math.random() * (max - min) + min;
  112839. };
  112840. var value;
  112841. for (var x = 0; x < size; x++) {
  112842. for (var y = 0; y < size; y++) {
  112843. value = Math.floor(rand(0.42, 0.58) * 255);
  112844. context.fillStyle = 'rgb(' + value + ', ' + value + ', ' + value + ')';
  112845. context.fillRect(x, y, 1, 1);
  112846. }
  112847. }
  112848. this._grainTexture.update(false);
  112849. };
  112850. return LensRenderingPipeline;
  112851. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipeline"]));
  112852. /***/ }),
  112853. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts":
  112854. /*!**************************************************************************!*\
  112855. !*** ./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts ***!
  112856. \**************************************************************************/
  112857. /*! exports provided: SSAO2RenderingPipeline */
  112858. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112859. "use strict";
  112860. __webpack_require__.r(__webpack_exports__);
  112861. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return SSAO2RenderingPipeline; });
  112862. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  112863. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  112864. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  112865. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  112866. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  112867. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  112868. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  112869. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  112870. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  112871. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  112872. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  112873. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  112874. /* harmony import */ var _Shaders_ssao2_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssao2.fragment */ "./Shaders/ssao2.fragment.ts");
  112875. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  112876. /**
  112877. * Render pipeline to produce ssao effect
  112878. */
  112879. var SSAO2RenderingPipeline = /** @class */ (function (_super) {
  112880. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAO2RenderingPipeline, _super);
  112881. /**
  112882. * @constructor
  112883. * @param name The rendering pipeline name
  112884. * @param scene The scene linked to this pipeline
  112885. * @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 }
  112886. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112887. */
  112888. function SSAO2RenderingPipeline(name, scene, ratio, cameras) {
  112889. var _this = _super.call(this, scene.getEngine(), name) || this;
  112890. // Members
  112891. /**
  112892. * @ignore
  112893. * The PassPostProcess id in the pipeline that contains the original scene color
  112894. */
  112895. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  112896. /**
  112897. * @ignore
  112898. * The SSAO PostProcess id in the pipeline
  112899. */
  112900. _this.SSAORenderEffect = "SSAORenderEffect";
  112901. /**
  112902. * @ignore
  112903. * The horizontal blur PostProcess id in the pipeline
  112904. */
  112905. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  112906. /**
  112907. * @ignore
  112908. * The vertical blur PostProcess id in the pipeline
  112909. */
  112910. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  112911. /**
  112912. * @ignore
  112913. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  112914. */
  112915. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  112916. /**
  112917. * The output strength of the SSAO post-process. Default value is 1.0.
  112918. */
  112919. _this.totalStrength = 1.0;
  112920. /**
  112921. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  112922. */
  112923. _this.maxZ = 100.0;
  112924. /**
  112925. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  112926. */
  112927. _this.minZAspect = 0.2;
  112928. _this._samples = 8;
  112929. _this._textureSamples = 1;
  112930. _this._expensiveBlur = true;
  112931. /**
  112932. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  112933. */
  112934. _this.radius = 2.0;
  112935. /**
  112936. * The base color of the SSAO post-process
  112937. * The final result is "base + ssao" between [0, 1]
  112938. */
  112939. _this.base = 0;
  112940. _this._firstUpdate = true;
  112941. _this._bits = new Uint32Array(1);
  112942. _this._scene = scene;
  112943. _this._ratio = ratio;
  112944. if (!_this.isSupported) {
  112945. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("SSAO 2 needs WebGL 2 support.");
  112946. return _this;
  112947. }
  112948. var ssaoRatio = _this._ratio.ssaoRatio || ratio;
  112949. var blurRatio = _this._ratio.blurRatio || ratio;
  112950. // Set up assets
  112951. var geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  112952. _this._createRandomTexture();
  112953. _this._depthTexture = geometryBufferRenderer.getGBuffer().textures[0];
  112954. _this._normalTexture = geometryBufferRenderer.getGBuffer().textures[1];
  112955. _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);
  112956. _this._originalColorPostProcess.samples = _this.textureSamples;
  112957. _this._createSSAOPostProcess(1.0);
  112958. _this._createBlurPostProcess(ssaoRatio, blurRatio);
  112959. _this._createSSAOCombinePostProcess(blurRatio);
  112960. // Set up pipeline
  112961. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  112962. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  112963. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  112964. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  112965. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  112966. // Finish
  112967. scene.postProcessRenderPipelineManager.addPipeline(_this);
  112968. if (cameras) {
  112969. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  112970. }
  112971. return _this;
  112972. }
  112973. Object.defineProperty(SSAO2RenderingPipeline.prototype, "samples", {
  112974. get: function () {
  112975. return this._samples;
  112976. },
  112977. /**
  112978. * Number of samples used for the SSAO calculations. Default value is 8
  112979. */
  112980. set: function (n) {
  112981. this._ssaoPostProcess.updateEffect("#define SAMPLES " + n + "\n#define SSAO");
  112982. this._samples = n;
  112983. this._sampleSphere = this._generateHemisphere();
  112984. this._firstUpdate = true;
  112985. },
  112986. enumerable: true,
  112987. configurable: true
  112988. });
  112989. Object.defineProperty(SSAO2RenderingPipeline.prototype, "textureSamples", {
  112990. get: function () {
  112991. return this._textureSamples;
  112992. },
  112993. /**
  112994. * Number of samples to use for antialiasing
  112995. */
  112996. set: function (n) {
  112997. this._textureSamples = n;
  112998. this._originalColorPostProcess.samples = n;
  112999. this._blurHPostProcess.samples = n;
  113000. this._blurVPostProcess.samples = n;
  113001. this._ssaoPostProcess.samples = n;
  113002. this._ssaoCombinePostProcess.samples = n;
  113003. },
  113004. enumerable: true,
  113005. configurable: true
  113006. });
  113007. Object.defineProperty(SSAO2RenderingPipeline.prototype, "expensiveBlur", {
  113008. get: function () {
  113009. return this._expensiveBlur;
  113010. },
  113011. /**
  113012. * If bilateral blur should be used
  113013. */
  113014. set: function (b) {
  113015. 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"]);
  113016. this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE " + (b ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]);
  113017. this._expensiveBlur = b;
  113018. this._firstUpdate = true;
  113019. },
  113020. enumerable: true,
  113021. configurable: true
  113022. });
  113023. Object.defineProperty(SSAO2RenderingPipeline, "IsSupported", {
  113024. /**
  113025. * Support test.
  113026. */
  113027. get: function () {
  113028. var engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__["EngineStore"].LastCreatedEngine;
  113029. if (!engine) {
  113030. return false;
  113031. }
  113032. return engine.getCaps().drawBuffersExtension;
  113033. },
  113034. enumerable: true,
  113035. configurable: true
  113036. });
  113037. // Public Methods
  113038. /**
  113039. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113040. */
  113041. SSAO2RenderingPipeline.prototype.dispose = function (disableGeometryBufferRenderer) {
  113042. if (disableGeometryBufferRenderer === void 0) { disableGeometryBufferRenderer = false; }
  113043. for (var i = 0; i < this._scene.cameras.length; i++) {
  113044. var camera = this._scene.cameras[i];
  113045. this._originalColorPostProcess.dispose(camera);
  113046. this._ssaoPostProcess.dispose(camera);
  113047. this._blurHPostProcess.dispose(camera);
  113048. this._blurVPostProcess.dispose(camera);
  113049. this._ssaoCombinePostProcess.dispose(camera);
  113050. }
  113051. this._randomTexture.dispose();
  113052. if (disableGeometryBufferRenderer) {
  113053. this._scene.disableGeometryBufferRenderer();
  113054. }
  113055. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  113056. _super.prototype.dispose.call(this);
  113057. };
  113058. // Private Methods
  113059. SSAO2RenderingPipeline.prototype._createBlurPostProcess = function (ssaoRatio, blurRatio) {
  113060. var _this = this;
  113061. this._samplerOffsets = [];
  113062. var expensive = this.expensiveBlur;
  113063. for (var i = -8; i < 8; i++) {
  113064. this._samplerOffsets.push(i * 2 + 0.5);
  113065. }
  113066. 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");
  113067. this._blurHPostProcess.onApply = function (effect) {
  113068. if (!_this._scene.activeCamera) {
  113069. return;
  113070. }
  113071. effect.setFloat("outSize", _this._ssaoCombinePostProcess.width > 0 ? _this._ssaoCombinePostProcess.width : _this._originalColorPostProcess.width);
  113072. effect.setFloat("near", _this._scene.activeCamera.minZ);
  113073. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  113074. effect.setFloat("radius", _this.radius);
  113075. effect.setTexture("depthSampler", _this._depthTexture);
  113076. if (_this._firstUpdate) {
  113077. effect.setArray("samplerOffsets", _this._samplerOffsets);
  113078. }
  113079. };
  113080. 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");
  113081. this._blurVPostProcess.onApply = function (effect) {
  113082. if (!_this._scene.activeCamera) {
  113083. return;
  113084. }
  113085. effect.setFloat("outSize", _this._ssaoCombinePostProcess.height > 0 ? _this._ssaoCombinePostProcess.height : _this._originalColorPostProcess.height);
  113086. effect.setFloat("near", _this._scene.activeCamera.minZ);
  113087. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  113088. effect.setFloat("radius", _this.radius);
  113089. effect.setTexture("depthSampler", _this._depthTexture);
  113090. if (_this._firstUpdate) {
  113091. effect.setArray("samplerOffsets", _this._samplerOffsets);
  113092. _this._firstUpdate = false;
  113093. }
  113094. };
  113095. this._blurHPostProcess.samples = this.textureSamples;
  113096. this._blurVPostProcess.samples = this.textureSamples;
  113097. };
  113098. /** @hidden */
  113099. SSAO2RenderingPipeline.prototype._rebuild = function () {
  113100. this._firstUpdate = true;
  113101. _super.prototype._rebuild.call(this);
  113102. };
  113103. //Van der Corput radical inverse
  113104. SSAO2RenderingPipeline.prototype._radicalInverse_VdC = function (i) {
  113105. this._bits[0] = i;
  113106. this._bits[0] = ((this._bits[0] << 16) | (this._bits[0] >> 16)) >>> 0;
  113107. this._bits[0] = ((this._bits[0] & 0x55555555) << 1) | ((this._bits[0] & 0xAAAAAAAA) >>> 1) >>> 0;
  113108. this._bits[0] = ((this._bits[0] & 0x33333333) << 2) | ((this._bits[0] & 0xCCCCCCCC) >>> 2) >>> 0;
  113109. this._bits[0] = ((this._bits[0] & 0x0F0F0F0F) << 4) | ((this._bits[0] & 0xF0F0F0F0) >>> 4) >>> 0;
  113110. this._bits[0] = ((this._bits[0] & 0x00FF00FF) << 8) | ((this._bits[0] & 0xFF00FF00) >>> 8) >>> 0;
  113111. return this._bits[0] * 2.3283064365386963e-10; // / 0x100000000 or / 4294967296
  113112. };
  113113. SSAO2RenderingPipeline.prototype._hammersley = function (i, n) {
  113114. return [i / n, this._radicalInverse_VdC(i)];
  113115. };
  113116. SSAO2RenderingPipeline.prototype._hemisphereSample_uniform = function (u, v) {
  113117. var phi = v * 2.0 * Math.PI;
  113118. // rejecting samples that are close to tangent plane to avoid z-fighting artifacts
  113119. var cosTheta = 1.0 - (u * 0.85 + 0.15);
  113120. var sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta);
  113121. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.cos(phi) * sinTheta, Math.sin(phi) * sinTheta, cosTheta);
  113122. };
  113123. SSAO2RenderingPipeline.prototype._generateHemisphere = function () {
  113124. var numSamples = this.samples;
  113125. var result = [];
  113126. var vector;
  113127. var i = 0;
  113128. while (i < numSamples) {
  113129. if (numSamples < 16) {
  113130. vector = this._hemisphereSample_uniform(Math.random(), Math.random());
  113131. }
  113132. else {
  113133. var rand = this._hammersley(i, numSamples);
  113134. vector = this._hemisphereSample_uniform(rand[0], rand[1]);
  113135. }
  113136. result.push(vector.x, vector.y, vector.z);
  113137. i++;
  113138. }
  113139. return result;
  113140. };
  113141. SSAO2RenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  113142. var _this = this;
  113143. var numSamples = this.samples;
  113144. this._sampleSphere = this._generateHemisphere();
  113145. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("ssao2", "ssao2", [
  113146. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  113147. "base", "range", "projection", "near", "far", "texelSize",
  113148. "xViewport", "yViewport", "maxZ", "minZAspect"
  113149. ], ["randomSampler", "normalSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  113150. this._ssaoPostProcess.onApply = function (effect) {
  113151. if (_this._firstUpdate) {
  113152. effect.setArray3("sampleSphere", _this._sampleSphere);
  113153. effect.setFloat("randTextureTiles", 32.0);
  113154. }
  113155. if (!_this._scene.activeCamera) {
  113156. return;
  113157. }
  113158. effect.setFloat("samplesFactor", 1 / _this.samples);
  113159. effect.setFloat("totalStrength", _this.totalStrength);
  113160. effect.setFloat2("texelSize", 1 / _this._ssaoPostProcess.width, 1 / _this._ssaoPostProcess.height);
  113161. effect.setFloat("radius", _this.radius);
  113162. effect.setFloat("maxZ", _this.maxZ);
  113163. effect.setFloat("minZAspect", _this.minZAspect);
  113164. effect.setFloat("base", _this.base);
  113165. effect.setFloat("near", _this._scene.activeCamera.minZ);
  113166. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  113167. effect.setFloat("xViewport", Math.tan(_this._scene.activeCamera.fov / 2) * _this._scene.getEngine().getAspectRatio(_this._scene.activeCamera, true));
  113168. effect.setFloat("yViewport", Math.tan(_this._scene.activeCamera.fov / 2));
  113169. effect.setMatrix("projection", _this._scene.getProjectionMatrix());
  113170. effect.setTexture("textureSampler", _this._depthTexture);
  113171. effect.setTexture("normalSampler", _this._normalTexture);
  113172. effect.setTexture("randomSampler", _this._randomTexture);
  113173. };
  113174. this._ssaoPostProcess.samples = this.textureSamples;
  113175. };
  113176. SSAO2RenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  113177. var _this = this;
  113178. 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);
  113179. this._ssaoCombinePostProcess.onApply = function (effect) {
  113180. var viewport = _this._scene.activeCamera.viewport;
  113181. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector4[0].copyFromFloats(viewport.x, viewport.y, viewport.width, viewport.height));
  113182. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  113183. };
  113184. this._ssaoCombinePostProcess.samples = this.textureSamples;
  113185. };
  113186. SSAO2RenderingPipeline.prototype._createRandomTexture = function () {
  113187. var size = 128;
  113188. 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);
  113189. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  113190. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  113191. var context = this._randomTexture.getContext();
  113192. var rand = function (min, max) {
  113193. return Math.random() * (max - min) + min;
  113194. };
  113195. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  113196. for (var x = 0; x < size; x++) {
  113197. for (var y = 0; y < size; y++) {
  113198. randVector.x = rand(0.0, 1.0);
  113199. randVector.y = rand(0.0, 1.0);
  113200. randVector.z = 0.0;
  113201. randVector.normalize();
  113202. randVector.scaleInPlace(255);
  113203. randVector.x = Math.floor(randVector.x);
  113204. randVector.y = Math.floor(randVector.y);
  113205. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  113206. context.fillRect(x, y, 1, 1);
  113207. }
  113208. }
  113209. this._randomTexture.update(false);
  113210. };
  113211. /**
  113212. * Serialize the rendering pipeline (Used when exporting)
  113213. * @returns the serialized object
  113214. */
  113215. SSAO2RenderingPipeline.prototype.serialize = function () {
  113216. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Serialize(this);
  113217. serializationObject.customType = "SSAO2RenderingPipeline";
  113218. return serializationObject;
  113219. };
  113220. /**
  113221. * Parse the serialized pipeline
  113222. * @param source Source pipeline.
  113223. * @param scene The scene to load the pipeline to.
  113224. * @param rootUrl The URL of the serialized pipeline.
  113225. * @returns An instantiated pipeline from the serialized object.
  113226. */
  113227. SSAO2RenderingPipeline.Parse = function (source, scene, rootUrl) {
  113228. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Parse(function () { return new SSAO2RenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  113229. };
  113230. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113231. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  113232. ], SSAO2RenderingPipeline.prototype, "totalStrength", void 0);
  113233. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113234. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  113235. ], SSAO2RenderingPipeline.prototype, "maxZ", void 0);
  113236. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113237. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  113238. ], SSAO2RenderingPipeline.prototype, "minZAspect", void 0);
  113239. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113240. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("samples")
  113241. ], SSAO2RenderingPipeline.prototype, "_samples", void 0);
  113242. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113243. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("textureSamples")
  113244. ], SSAO2RenderingPipeline.prototype, "_textureSamples", void 0);
  113245. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113246. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  113247. ], SSAO2RenderingPipeline.prototype, "_ratio", void 0);
  113248. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113249. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("expensiveBlur")
  113250. ], SSAO2RenderingPipeline.prototype, "_expensiveBlur", void 0);
  113251. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113252. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  113253. ], SSAO2RenderingPipeline.prototype, "radius", void 0);
  113254. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113255. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  113256. ], SSAO2RenderingPipeline.prototype, "base", void 0);
  113257. return SSAO2RenderingPipeline;
  113258. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  113259. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__["_TypeStore"].RegisteredTypes["BABYLON.SSAO2RenderingPipeline"] = SSAO2RenderingPipeline;
  113260. /***/ }),
  113261. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts":
  113262. /*!*************************************************************************!*\
  113263. !*** ./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts ***!
  113264. \*************************************************************************/
  113265. /*! exports provided: SSAORenderingPipeline */
  113266. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113267. "use strict";
  113268. __webpack_require__.r(__webpack_exports__);
  113269. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return SSAORenderingPipeline; });
  113270. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  113271. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  113272. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  113273. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  113274. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  113275. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  113276. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  113277. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  113278. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  113279. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  113280. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  113281. /* harmony import */ var _Shaders_ssao_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Shaders/ssao.fragment */ "./Shaders/ssao.fragment.ts");
  113282. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  113283. /**
  113284. * Render pipeline to produce ssao effect
  113285. */
  113286. var SSAORenderingPipeline = /** @class */ (function (_super) {
  113287. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAORenderingPipeline, _super);
  113288. /**
  113289. * @constructor
  113290. * @param name - The rendering pipeline name
  113291. * @param scene - The scene linked to this pipeline
  113292. * @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 }
  113293. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  113294. */
  113295. function SSAORenderingPipeline(name, scene, ratio, cameras) {
  113296. var _this = _super.call(this, scene.getEngine(), name) || this;
  113297. // Members
  113298. /**
  113299. * @ignore
  113300. * The PassPostProcess id in the pipeline that contains the original scene color
  113301. */
  113302. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  113303. /**
  113304. * @ignore
  113305. * The SSAO PostProcess id in the pipeline
  113306. */
  113307. _this.SSAORenderEffect = "SSAORenderEffect";
  113308. /**
  113309. * @ignore
  113310. * The horizontal blur PostProcess id in the pipeline
  113311. */
  113312. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  113313. /**
  113314. * @ignore
  113315. * The vertical blur PostProcess id in the pipeline
  113316. */
  113317. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  113318. /**
  113319. * @ignore
  113320. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113321. */
  113322. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  113323. /**
  113324. * The output strength of the SSAO post-process. Default value is 1.0.
  113325. */
  113326. _this.totalStrength = 1.0;
  113327. /**
  113328. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  113329. */
  113330. _this.radius = 0.0001;
  113331. /**
  113332. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  113333. * Must not be equal to fallOff and superior to fallOff.
  113334. * Default value is 0.975
  113335. */
  113336. _this.area = 0.0075;
  113337. /**
  113338. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  113339. * Must not be equal to area and inferior to area.
  113340. * Default value is 0.0
  113341. */
  113342. _this.fallOff = 0.000001;
  113343. /**
  113344. * The base color of the SSAO post-process
  113345. * The final result is "base + ssao" between [0, 1]
  113346. */
  113347. _this.base = 0.5;
  113348. _this._firstUpdate = true;
  113349. _this._scene = scene;
  113350. // Set up assets
  113351. _this._createRandomTexture();
  113352. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  113353. var ssaoRatio = ratio.ssaoRatio || ratio;
  113354. var combineRatio = ratio.combineRatio || ratio;
  113355. _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);
  113356. _this._createSSAOPostProcess(ssaoRatio);
  113357. _this._createBlurPostProcess(ssaoRatio);
  113358. _this._createSSAOCombinePostProcess(combineRatio);
  113359. // Set up pipeline
  113360. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  113361. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  113362. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  113363. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  113364. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  113365. // Finish
  113366. scene.postProcessRenderPipelineManager.addPipeline(_this);
  113367. if (cameras) {
  113368. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  113369. }
  113370. return _this;
  113371. }
  113372. // Public Methods
  113373. /**
  113374. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113375. */
  113376. SSAORenderingPipeline.prototype.dispose = function (disableDepthRender) {
  113377. if (disableDepthRender === void 0) { disableDepthRender = false; }
  113378. for (var i = 0; i < this._scene.cameras.length; i++) {
  113379. var camera = this._scene.cameras[i];
  113380. this._originalColorPostProcess.dispose(camera);
  113381. this._ssaoPostProcess.dispose(camera);
  113382. this._blurHPostProcess.dispose(camera);
  113383. this._blurVPostProcess.dispose(camera);
  113384. this._ssaoCombinePostProcess.dispose(camera);
  113385. }
  113386. this._randomTexture.dispose();
  113387. if (disableDepthRender) {
  113388. this._scene.disableDepthRenderer();
  113389. }
  113390. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  113391. _super.prototype.dispose.call(this);
  113392. };
  113393. // Private Methods
  113394. SSAORenderingPipeline.prototype._createBlurPostProcess = function (ratio) {
  113395. var _this = this;
  113396. var size = 16;
  113397. 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);
  113398. 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);
  113399. this._blurHPostProcess.onActivateObservable.add(function () {
  113400. var dw = _this._blurHPostProcess.width / _this._scene.getEngine().getRenderWidth();
  113401. _this._blurHPostProcess.kernel = size * dw;
  113402. });
  113403. this._blurVPostProcess.onActivateObservable.add(function () {
  113404. var dw = _this._blurVPostProcess.height / _this._scene.getEngine().getRenderHeight();
  113405. _this._blurVPostProcess.kernel = size * dw;
  113406. });
  113407. };
  113408. /** @hidden */
  113409. SSAORenderingPipeline.prototype._rebuild = function () {
  113410. this._firstUpdate = true;
  113411. _super.prototype._rebuild.call(this);
  113412. };
  113413. SSAORenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  113414. var _this = this;
  113415. var numSamples = 16;
  113416. var sampleSphere = [
  113417. 0.5381, 0.1856, -0.4319,
  113418. 0.1379, 0.2486, 0.4430,
  113419. 0.3371, 0.5679, -0.0057,
  113420. -0.6999, -0.0451, -0.0019,
  113421. 0.0689, -0.1598, -0.8547,
  113422. 0.0560, 0.0069, -0.1843,
  113423. -0.0146, 0.1402, 0.0762,
  113424. 0.0100, -0.1924, -0.0344,
  113425. -0.3577, -0.5301, -0.4358,
  113426. -0.3169, 0.1063, 0.0158,
  113427. 0.0103, -0.5869, 0.0046,
  113428. -0.0897, -0.4940, 0.3287,
  113429. 0.7119, -0.0154, -0.0918,
  113430. -0.0533, 0.0596, -0.5411,
  113431. 0.0352, -0.0631, 0.5460,
  113432. -0.4776, 0.2847, -0.0271
  113433. ];
  113434. var samplesFactor = 1.0 / numSamples;
  113435. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__["PostProcess"]("ssao", "ssao", [
  113436. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  113437. "area", "fallOff", "base", "range", "viewport"
  113438. ], ["randomSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  113439. this._ssaoPostProcess.onApply = function (effect) {
  113440. if (_this._firstUpdate) {
  113441. effect.setArray3("sampleSphere", sampleSphere);
  113442. effect.setFloat("samplesFactor", samplesFactor);
  113443. effect.setFloat("randTextureTiles", 4.0);
  113444. }
  113445. effect.setFloat("totalStrength", _this.totalStrength);
  113446. effect.setFloat("radius", _this.radius);
  113447. effect.setFloat("area", _this.area);
  113448. effect.setFloat("fallOff", _this.fallOff);
  113449. effect.setFloat("base", _this.base);
  113450. effect.setTexture("textureSampler", _this._depthTexture);
  113451. effect.setTexture("randomSampler", _this._randomTexture);
  113452. };
  113453. };
  113454. SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  113455. var _this = this;
  113456. 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);
  113457. this._ssaoCombinePostProcess.onApply = function (effect) {
  113458. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector4[0].copyFromFloats(0, 0, 1.0, 1.0));
  113459. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  113460. };
  113461. };
  113462. SSAORenderingPipeline.prototype._createRandomTexture = function () {
  113463. var size = 512;
  113464. 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);
  113465. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  113466. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  113467. var context = this._randomTexture.getContext();
  113468. var rand = function (min, max) {
  113469. return Math.random() * (max - min) + min;
  113470. };
  113471. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  113472. for (var x = 0; x < size; x++) {
  113473. for (var y = 0; y < size; y++) {
  113474. randVector.x = Math.floor(rand(-1.0, 1.0) * 255);
  113475. randVector.y = Math.floor(rand(-1.0, 1.0) * 255);
  113476. randVector.z = Math.floor(rand(-1.0, 1.0) * 255);
  113477. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  113478. context.fillRect(x, y, 1, 1);
  113479. }
  113480. }
  113481. this._randomTexture.update(false);
  113482. };
  113483. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113484. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  113485. ], SSAORenderingPipeline.prototype, "totalStrength", void 0);
  113486. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113487. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  113488. ], SSAORenderingPipeline.prototype, "radius", void 0);
  113489. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113490. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  113491. ], SSAORenderingPipeline.prototype, "area", void 0);
  113492. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113493. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  113494. ], SSAORenderingPipeline.prototype, "fallOff", void 0);
  113495. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  113496. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  113497. ], SSAORenderingPipeline.prototype, "base", void 0);
  113498. return SSAORenderingPipeline;
  113499. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderPipeline"]));
  113500. /***/ }),
  113501. /***/ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts":
  113502. /*!*****************************************************************************!*\
  113503. !*** ./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts ***!
  113504. \*****************************************************************************/
  113505. /*! exports provided: StandardRenderingPipeline */
  113506. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113507. "use strict";
  113508. __webpack_require__.r(__webpack_exports__);
  113509. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return StandardRenderingPipeline; });
  113510. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  113511. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  113512. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  113513. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  113514. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  113515. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  113516. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  113517. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  113518. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  113519. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  113520. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  113521. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  113522. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  113523. /* harmony import */ var _Shaders_standard_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/standard.fragment */ "./Shaders/standard.fragment.ts");
  113524. /**
  113525. * Standard rendering pipeline
  113526. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113527. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  113528. */
  113529. var StandardRenderingPipeline = /** @class */ (function (_super) {
  113530. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardRenderingPipeline, _super);
  113531. /**
  113532. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113533. * @constructor
  113534. * @param name The rendering pipeline name
  113535. * @param scene The scene linked to this pipeline
  113536. * @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)
  113537. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  113538. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113539. */
  113540. function StandardRenderingPipeline(name, scene, ratio, originalPostProcess, cameras) {
  113541. if (originalPostProcess === void 0) { originalPostProcess = null; }
  113542. var _this = _super.call(this, scene.getEngine(), name) || this;
  113543. /**
  113544. * Post-process used to down scale an image x4
  113545. */
  113546. _this.downSampleX4PostProcess = null;
  113547. /**
  113548. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  113549. */
  113550. _this.brightPassPostProcess = null;
  113551. /**
  113552. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  113553. */
  113554. _this.blurHPostProcesses = [];
  113555. /**
  113556. * Post-process array storing all the vertical blur post-processes used by the pipeline
  113557. */
  113558. _this.blurVPostProcesses = [];
  113559. /**
  113560. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  113561. */
  113562. _this.textureAdderPostProcess = null;
  113563. /**
  113564. * Post-process used to create volumetric lighting effect
  113565. */
  113566. _this.volumetricLightPostProcess = null;
  113567. /**
  113568. * Post-process used to smooth the previous volumetric light post-process on the X axis
  113569. */
  113570. _this.volumetricLightSmoothXPostProcess = null;
  113571. /**
  113572. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  113573. */
  113574. _this.volumetricLightSmoothYPostProcess = null;
  113575. /**
  113576. * Post-process used to merge the volumetric light effect and the real scene color
  113577. */
  113578. _this.volumetricLightMergePostProces = null;
  113579. /**
  113580. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  113581. */
  113582. _this.volumetricLightFinalPostProcess = null;
  113583. /**
  113584. * Base post-process used to calculate the average luminance of the final image for HDR
  113585. */
  113586. _this.luminancePostProcess = null;
  113587. /**
  113588. * Post-processes used to create down sample post-processes in order to get
  113589. * the average luminance of the final image for HDR
  113590. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  113591. */
  113592. _this.luminanceDownSamplePostProcesses = [];
  113593. /**
  113594. * Post-process used to create a HDR effect (light adaptation)
  113595. */
  113596. _this.hdrPostProcess = null;
  113597. /**
  113598. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  113599. */
  113600. _this.textureAdderFinalPostProcess = null;
  113601. /**
  113602. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  113603. */
  113604. _this.lensFlareFinalPostProcess = null;
  113605. /**
  113606. * Post-process used to merge the final HDR post-process and the real scene color
  113607. */
  113608. _this.hdrFinalPostProcess = null;
  113609. /**
  113610. * Post-process used to create a lens flare effect
  113611. */
  113612. _this.lensFlarePostProcess = null;
  113613. /**
  113614. * Post-process that merges the result of the lens flare post-process and the real scene color
  113615. */
  113616. _this.lensFlareComposePostProcess = null;
  113617. /**
  113618. * Post-process used to create a motion blur effect
  113619. */
  113620. _this.motionBlurPostProcess = null;
  113621. /**
  113622. * Post-process used to create a depth of field effect
  113623. */
  113624. _this.depthOfFieldPostProcess = null;
  113625. /**
  113626. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113627. */
  113628. _this.fxaaPostProcess = null;
  113629. // Values
  113630. /**
  113631. * Represents the brightness threshold in order to configure the illuminated surfaces
  113632. */
  113633. _this.brightThreshold = 1.0;
  113634. /**
  113635. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  113636. */
  113637. _this.blurWidth = 512.0;
  113638. /**
  113639. * Sets if the blur for highlighted surfaces must be only horizontal
  113640. */
  113641. _this.horizontalBlur = false;
  113642. /**
  113643. * Sets the overall exposure used by the pipeline
  113644. */
  113645. _this.exposure = 1.0;
  113646. /**
  113647. * Texture used typically to simulate "dirty" on camera lens
  113648. */
  113649. _this.lensTexture = null;
  113650. /**
  113651. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  113652. */
  113653. _this.volumetricLightCoefficient = 0.2;
  113654. /**
  113655. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  113656. */
  113657. _this.volumetricLightPower = 4.0;
  113658. /**
  113659. * Used the set the blur intensity to smooth the volumetric lights
  113660. */
  113661. _this.volumetricLightBlurScale = 64.0;
  113662. /**
  113663. * Light (spot or directional) used to generate the volumetric lights rays
  113664. * The source light must have a shadow generate so the pipeline can get its
  113665. * depth map
  113666. */
  113667. _this.sourceLight = null;
  113668. /**
  113669. * For eye adaptation, represents the minimum luminance the eye can see
  113670. */
  113671. _this.hdrMinimumLuminance = 1.0;
  113672. /**
  113673. * For eye adaptation, represents the decrease luminance speed
  113674. */
  113675. _this.hdrDecreaseRate = 0.5;
  113676. /**
  113677. * For eye adaptation, represents the increase luminance speed
  113678. */
  113679. _this.hdrIncreaseRate = 0.5;
  113680. /**
  113681. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  113682. */
  113683. _this.lensColorTexture = null;
  113684. /**
  113685. * The overall strengh for the lens flare effect
  113686. */
  113687. _this.lensFlareStrength = 20.0;
  113688. /**
  113689. * Dispersion coefficient for lens flare ghosts
  113690. */
  113691. _this.lensFlareGhostDispersal = 1.4;
  113692. /**
  113693. * Main lens flare halo width
  113694. */
  113695. _this.lensFlareHaloWidth = 0.7;
  113696. /**
  113697. * Based on the lens distortion effect, defines how much the lens flare result
  113698. * is distorted
  113699. */
  113700. _this.lensFlareDistortionStrength = 16.0;
  113701. /**
  113702. * Lens star texture must be used to simulate rays on the flares and is available
  113703. * in the documentation
  113704. */
  113705. _this.lensStarTexture = null;
  113706. /**
  113707. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  113708. * flare effect by taking account of the dirt texture
  113709. */
  113710. _this.lensFlareDirtTexture = null;
  113711. /**
  113712. * Represents the focal length for the depth of field effect
  113713. */
  113714. _this.depthOfFieldDistance = 10.0;
  113715. /**
  113716. * Represents the blur intensity for the blurred part of the depth of field effect
  113717. */
  113718. _this.depthOfFieldBlurWidth = 64.0;
  113719. /**
  113720. * For motion blur, defines how much the image is blurred by the movement
  113721. */
  113722. _this.motionStrength = 1.0;
  113723. /**
  113724. * List of animations for the pipeline (IAnimatable implementation)
  113725. */
  113726. _this.animations = [];
  113727. _this._currentDepthOfFieldSource = null;
  113728. _this._hdrCurrentLuminance = 1.0;
  113729. // Getters and setters
  113730. _this._bloomEnabled = false;
  113731. _this._depthOfFieldEnabled = false;
  113732. _this._vlsEnabled = false;
  113733. _this._lensFlareEnabled = false;
  113734. _this._hdrEnabled = false;
  113735. _this._motionBlurEnabled = false;
  113736. _this._fxaaEnabled = false;
  113737. _this._motionBlurSamples = 64.0;
  113738. _this._volumetricLightStepsCount = 50.0;
  113739. _this._samples = 1;
  113740. _this._cameras = cameras || [];
  113741. // Initialize
  113742. _this._scene = scene;
  113743. _this._basePostProcess = originalPostProcess;
  113744. _this._ratio = ratio;
  113745. // Misc
  113746. _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;
  113747. // Finish
  113748. scene.postProcessRenderPipelineManager.addPipeline(_this);
  113749. _this._buildPipeline();
  113750. return _this;
  113751. }
  113752. Object.defineProperty(StandardRenderingPipeline.prototype, "BloomEnabled", {
  113753. /**
  113754. * @ignore
  113755. * Specifies if the bloom pipeline is enabled
  113756. */
  113757. get: function () {
  113758. return this._bloomEnabled;
  113759. },
  113760. set: function (enabled) {
  113761. if (this._bloomEnabled === enabled) {
  113762. return;
  113763. }
  113764. this._bloomEnabled = enabled;
  113765. this._buildPipeline();
  113766. },
  113767. enumerable: true,
  113768. configurable: true
  113769. });
  113770. Object.defineProperty(StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", {
  113771. /**
  113772. * @ignore
  113773. * Specifies if the depth of field pipeline is enabed
  113774. */
  113775. get: function () {
  113776. return this._depthOfFieldEnabled;
  113777. },
  113778. set: function (enabled) {
  113779. if (this._depthOfFieldEnabled === enabled) {
  113780. return;
  113781. }
  113782. this._depthOfFieldEnabled = enabled;
  113783. this._buildPipeline();
  113784. },
  113785. enumerable: true,
  113786. configurable: true
  113787. });
  113788. Object.defineProperty(StandardRenderingPipeline.prototype, "LensFlareEnabled", {
  113789. /**
  113790. * @ignore
  113791. * Specifies if the lens flare pipeline is enabed
  113792. */
  113793. get: function () {
  113794. return this._lensFlareEnabled;
  113795. },
  113796. set: function (enabled) {
  113797. if (this._lensFlareEnabled === enabled) {
  113798. return;
  113799. }
  113800. this._lensFlareEnabled = enabled;
  113801. this._buildPipeline();
  113802. },
  113803. enumerable: true,
  113804. configurable: true
  113805. });
  113806. Object.defineProperty(StandardRenderingPipeline.prototype, "HDREnabled", {
  113807. /**
  113808. * @ignore
  113809. * Specifies if the HDR pipeline is enabled
  113810. */
  113811. get: function () {
  113812. return this._hdrEnabled;
  113813. },
  113814. set: function (enabled) {
  113815. if (this._hdrEnabled === enabled) {
  113816. return;
  113817. }
  113818. this._hdrEnabled = enabled;
  113819. this._buildPipeline();
  113820. },
  113821. enumerable: true,
  113822. configurable: true
  113823. });
  113824. Object.defineProperty(StandardRenderingPipeline.prototype, "VLSEnabled", {
  113825. /**
  113826. * @ignore
  113827. * Specifies if the volumetric lights scattering effect is enabled
  113828. */
  113829. get: function () {
  113830. return this._vlsEnabled;
  113831. },
  113832. set: function (enabled) {
  113833. if (this._vlsEnabled === enabled) {
  113834. return;
  113835. }
  113836. if (enabled) {
  113837. var geometry = this._scene.enableGeometryBufferRenderer();
  113838. if (!geometry) {
  113839. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
  113840. return;
  113841. }
  113842. }
  113843. this._vlsEnabled = enabled;
  113844. this._buildPipeline();
  113845. },
  113846. enumerable: true,
  113847. configurable: true
  113848. });
  113849. Object.defineProperty(StandardRenderingPipeline.prototype, "MotionBlurEnabled", {
  113850. /**
  113851. * @ignore
  113852. * Specifies if the motion blur effect is enabled
  113853. */
  113854. get: function () {
  113855. return this._motionBlurEnabled;
  113856. },
  113857. set: function (enabled) {
  113858. if (this._motionBlurEnabled === enabled) {
  113859. return;
  113860. }
  113861. this._motionBlurEnabled = enabled;
  113862. this._buildPipeline();
  113863. },
  113864. enumerable: true,
  113865. configurable: true
  113866. });
  113867. Object.defineProperty(StandardRenderingPipeline.prototype, "fxaaEnabled", {
  113868. /**
  113869. * Specifies if anti-aliasing is enabled
  113870. */
  113871. get: function () {
  113872. return this._fxaaEnabled;
  113873. },
  113874. set: function (enabled) {
  113875. if (this._fxaaEnabled === enabled) {
  113876. return;
  113877. }
  113878. this._fxaaEnabled = enabled;
  113879. this._buildPipeline();
  113880. },
  113881. enumerable: true,
  113882. configurable: true
  113883. });
  113884. Object.defineProperty(StandardRenderingPipeline.prototype, "volumetricLightStepsCount", {
  113885. /**
  113886. * Specifies the number of steps used to calculate the volumetric lights
  113887. * Typically in interval [50, 200]
  113888. */
  113889. get: function () {
  113890. return this._volumetricLightStepsCount;
  113891. },
  113892. set: function (count) {
  113893. if (this.volumetricLightPostProcess) {
  113894. this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS " + count.toFixed(1));
  113895. }
  113896. this._volumetricLightStepsCount = count;
  113897. },
  113898. enumerable: true,
  113899. configurable: true
  113900. });
  113901. Object.defineProperty(StandardRenderingPipeline.prototype, "motionBlurSamples", {
  113902. /**
  113903. * Specifies the number of samples used for the motion blur effect
  113904. * Typically in interval [16, 64]
  113905. */
  113906. get: function () {
  113907. return this._motionBlurSamples;
  113908. },
  113909. set: function (samples) {
  113910. if (this.motionBlurPostProcess) {
  113911. this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + samples.toFixed(1));
  113912. }
  113913. this._motionBlurSamples = samples;
  113914. },
  113915. enumerable: true,
  113916. configurable: true
  113917. });
  113918. Object.defineProperty(StandardRenderingPipeline.prototype, "samples", {
  113919. /**
  113920. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113921. */
  113922. get: function () {
  113923. return this._samples;
  113924. },
  113925. set: function (sampleCount) {
  113926. if (this._samples === sampleCount) {
  113927. return;
  113928. }
  113929. this._samples = sampleCount;
  113930. this._buildPipeline();
  113931. },
  113932. enumerable: true,
  113933. configurable: true
  113934. });
  113935. StandardRenderingPipeline.prototype._buildPipeline = function () {
  113936. var _this = this;
  113937. var ratio = this._ratio;
  113938. var scene = this._scene;
  113939. this._disposePostProcesses();
  113940. this._reset();
  113941. // Create pass post-process
  113942. if (!this._basePostProcess) {
  113943. 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);
  113944. this.originalPostProcess.onApply = function () {
  113945. _this._currentDepthOfFieldSource = _this.originalPostProcess;
  113946. };
  113947. }
  113948. else {
  113949. this.originalPostProcess = this._basePostProcess;
  113950. }
  113951. if (this._bloomEnabled || this._vlsEnabled || this._lensFlareEnabled || this._depthOfFieldEnabled || this._motionBlurEnabled) {
  113952. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPassPostProcess", function () { return _this.originalPostProcess; }, true));
  113953. }
  113954. this._currentDepthOfFieldSource = this.originalPostProcess;
  113955. if (this._bloomEnabled) {
  113956. // Create down sample X4 post-process
  113957. this._createDownSampleX4PostProcess(scene, ratio / 2);
  113958. // Create bright pass post-process
  113959. this._createBrightPassPostProcess(scene, ratio / 2);
  113960. // Create gaussian blur post-processes (down sampling blurs)
  113961. this._createBlurPostProcesses(scene, ratio / 4, 1);
  113962. // Create texture adder post-process
  113963. this._createTextureAdderPostProcess(scene, ratio);
  113964. // Create depth-of-field source post-process
  113965. 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);
  113966. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBaseDepthOfFieldSource", function () { return _this.textureAdderFinalPostProcess; }, true));
  113967. }
  113968. if (this._vlsEnabled) {
  113969. // Create volumetric light
  113970. this._createVolumetricLightPostProcess(scene, ratio);
  113971. // Create volumetric light final post-process
  113972. 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);
  113973. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSFinal", function () { return _this.volumetricLightFinalPostProcess; }, true));
  113974. }
  113975. if (this._lensFlareEnabled) {
  113976. // Create lens flare post-process
  113977. this._createLensFlarePostProcess(scene, ratio);
  113978. // Create depth-of-field source post-process post lens-flare and disable it now
  113979. 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);
  113980. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostLensFlareDepthOfFieldSource", function () { return _this.lensFlareFinalPostProcess; }, true));
  113981. }
  113982. if (this._hdrEnabled) {
  113983. // Create luminance
  113984. this._createLuminancePostProcesses(scene, this._floatTextureType);
  113985. // Create HDR
  113986. this._createHdrPostProcess(scene, ratio);
  113987. // Create depth-of-field source post-process post hdr and disable it now
  113988. 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);
  113989. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostHDReDepthOfFieldSource", function () { return _this.hdrFinalPostProcess; }, true));
  113990. }
  113991. if (this._depthOfFieldEnabled) {
  113992. // Create gaussian blur used by depth-of-field
  113993. this._createBlurPostProcesses(scene, ratio / 2, 3, "depthOfFieldBlurWidth");
  113994. // Create depth-of-field post-process
  113995. this._createDepthOfFieldPostProcess(scene, ratio);
  113996. }
  113997. if (this._motionBlurEnabled) {
  113998. // Create motion blur post-process
  113999. this._createMotionBlurPostProcess(scene, ratio);
  114000. }
  114001. if (this._fxaaEnabled) {
  114002. // Create fxaa post-process
  114003. 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);
  114004. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRFxaa", function () { return _this.fxaaPostProcess; }, true));
  114005. }
  114006. if (this._cameras !== null) {
  114007. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  114008. }
  114009. if (!this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1) {
  114010. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  114011. }
  114012. };
  114013. // Down Sample X4 Post-Processs
  114014. StandardRenderingPipeline.prototype._createDownSampleX4PostProcess = function (scene, ratio) {
  114015. var _this = this;
  114016. var downSampleX4Offsets = new Array(32);
  114017. 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);
  114018. this.downSampleX4PostProcess.onApply = function (effect) {
  114019. var id = 0;
  114020. var width = _this.downSampleX4PostProcess.width;
  114021. var height = _this.downSampleX4PostProcess.height;
  114022. for (var i = -2; i < 2; i++) {
  114023. for (var j = -2; j < 2; j++) {
  114024. downSampleX4Offsets[id] = (i + 0.5) * (1.0 / width);
  114025. downSampleX4Offsets[id + 1] = (j + 0.5) * (1.0 / height);
  114026. id += 2;
  114027. }
  114028. }
  114029. effect.setArray2("dsOffsets", downSampleX4Offsets);
  114030. };
  114031. // Add to pipeline
  114032. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDownSampleX4", function () { return _this.downSampleX4PostProcess; }, true));
  114033. };
  114034. // Brightpass Post-Process
  114035. StandardRenderingPipeline.prototype._createBrightPassPostProcess = function (scene, ratio) {
  114036. var _this = this;
  114037. var brightOffsets = new Array(8);
  114038. 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);
  114039. this.brightPassPostProcess.onApply = function (effect) {
  114040. var sU = (1.0 / _this.brightPassPostProcess.width);
  114041. var sV = (1.0 / _this.brightPassPostProcess.height);
  114042. brightOffsets[0] = -0.5 * sU;
  114043. brightOffsets[1] = 0.5 * sV;
  114044. brightOffsets[2] = 0.5 * sU;
  114045. brightOffsets[3] = 0.5 * sV;
  114046. brightOffsets[4] = -0.5 * sU;
  114047. brightOffsets[5] = -0.5 * sV;
  114048. brightOffsets[6] = 0.5 * sU;
  114049. brightOffsets[7] = -0.5 * sV;
  114050. effect.setArray2("dsOffsets", brightOffsets);
  114051. effect.setFloat("brightThreshold", _this.brightThreshold);
  114052. };
  114053. // Add to pipeline
  114054. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBrightPass", function () { return _this.brightPassPostProcess; }, true));
  114055. };
  114056. // Create blur H&V post-processes
  114057. StandardRenderingPipeline.prototype._createBlurPostProcesses = function (scene, ratio, indice, blurWidthKey) {
  114058. var _this = this;
  114059. if (blurWidthKey === void 0) { blurWidthKey = "blurWidth"; }
  114060. var engine = scene.getEngine();
  114061. 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);
  114062. 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);
  114063. blurX.onActivateObservable.add(function () {
  114064. var dw = blurX.width / engine.getRenderWidth();
  114065. blurX.kernel = _this[blurWidthKey] * dw;
  114066. });
  114067. blurY.onActivateObservable.add(function () {
  114068. var dw = blurY.height / engine.getRenderHeight();
  114069. blurY.kernel = _this.horizontalBlur ? 64 * dw : _this[blurWidthKey] * dw;
  114070. });
  114071. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurH" + indice, function () { return blurX; }, true));
  114072. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurV" + indice, function () { return blurY; }, true));
  114073. this.blurHPostProcesses.push(blurX);
  114074. this.blurVPostProcesses.push(blurY);
  114075. };
  114076. // Create texture adder post-process
  114077. StandardRenderingPipeline.prototype._createTextureAdderPostProcess = function (scene, ratio) {
  114078. var _this = this;
  114079. 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);
  114080. this.textureAdderPostProcess.onApply = function (effect) {
  114081. effect.setTextureFromPostProcess("otherSampler", _this._vlsEnabled ? _this._currentDepthOfFieldSource : _this.originalPostProcess);
  114082. effect.setTexture("lensSampler", _this.lensTexture);
  114083. effect.setFloat("exposure", _this.exposure);
  114084. _this._currentDepthOfFieldSource = _this.textureAdderFinalPostProcess;
  114085. };
  114086. // Add to pipeline
  114087. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRTextureAdder", function () { return _this.textureAdderPostProcess; }, true));
  114088. };
  114089. StandardRenderingPipeline.prototype._createVolumetricLightPostProcess = function (scene, ratio) {
  114090. var _this = this;
  114091. var geometryRenderer = scene.enableGeometryBufferRenderer();
  114092. geometryRenderer.enablePosition = true;
  114093. var geometry = geometryRenderer.getGBuffer();
  114094. // Base post-process
  114095. 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));
  114096. var depthValues = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  114097. this.volumetricLightPostProcess.onApply = function (effect) {
  114098. if (_this.sourceLight && _this.sourceLight.getShadowGenerator() && _this._scene.activeCamera) {
  114099. var generator = _this.sourceLight.getShadowGenerator();
  114100. effect.setTexture("shadowMapSampler", generator.getShadowMap());
  114101. effect.setTexture("positionSampler", geometry.textures[2]);
  114102. effect.setColor3("sunColor", _this.sourceLight.diffuse);
  114103. effect.setVector3("sunDirection", _this.sourceLight.getShadowDirection());
  114104. effect.setVector3("cameraPosition", _this._scene.activeCamera.globalPosition);
  114105. effect.setMatrix("shadowViewProjection", generator.getTransformMatrix());
  114106. effect.setFloat("scatteringCoefficient", _this.volumetricLightCoefficient);
  114107. effect.setFloat("scatteringPower", _this.volumetricLightPower);
  114108. depthValues.x = _this.sourceLight.getDepthMinZ(_this._scene.activeCamera);
  114109. depthValues.y = _this.sourceLight.getDepthMaxZ(_this._scene.activeCamera);
  114110. effect.setVector2("depthValues", depthValues);
  114111. }
  114112. };
  114113. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLS", function () { return _this.volumetricLightPostProcess; }, true));
  114114. // Smooth
  114115. this._createBlurPostProcesses(scene, ratio / 4, 0, "volumetricLightBlurScale");
  114116. // Merge
  114117. 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");
  114118. this.volumetricLightMergePostProces.onApply = function (effect) {
  114119. effect.setTextureFromPostProcess("originalSampler", _this._bloomEnabled ? _this.textureAdderFinalPostProcess : _this.originalPostProcess);
  114120. _this._currentDepthOfFieldSource = _this.volumetricLightFinalPostProcess;
  114121. };
  114122. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSMerge", function () { return _this.volumetricLightMergePostProces; }, true));
  114123. };
  114124. // Create luminance
  114125. StandardRenderingPipeline.prototype._createLuminancePostProcesses = function (scene, textureType) {
  114126. var _this = this;
  114127. // Create luminance
  114128. var size = Math.pow(3, StandardRenderingPipeline.LuminanceSteps);
  114129. 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);
  114130. var offsets = [];
  114131. this.luminancePostProcess.onApply = function (effect) {
  114132. var sU = (1.0 / _this.luminancePostProcess.width);
  114133. var sV = (1.0 / _this.luminancePostProcess.height);
  114134. offsets[0] = -0.5 * sU;
  114135. offsets[1] = 0.5 * sV;
  114136. offsets[2] = 0.5 * sU;
  114137. offsets[3] = 0.5 * sV;
  114138. offsets[4] = -0.5 * sU;
  114139. offsets[5] = -0.5 * sV;
  114140. offsets[6] = 0.5 * sU;
  114141. offsets[7] = -0.5 * sV;
  114142. effect.setArray2("lumOffsets", offsets);
  114143. };
  114144. // Add to pipeline
  114145. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminance", function () { return _this.luminancePostProcess; }, true));
  114146. // Create down sample luminance
  114147. for (var i = StandardRenderingPipeline.LuminanceSteps - 1; i >= 0; i--) {
  114148. var size = Math.pow(3, i);
  114149. var defines = "#define LUMINANCE_DOWN_SAMPLE\n";
  114150. if (i === 0) {
  114151. defines += "#define FINAL_DOWN_SAMPLER";
  114152. }
  114153. 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);
  114154. this.luminanceDownSamplePostProcesses.push(postProcess);
  114155. }
  114156. // Create callbacks and add effects
  114157. var lastLuminance = this.luminancePostProcess;
  114158. this.luminanceDownSamplePostProcesses.forEach(function (pp, index) {
  114159. var downSampleOffsets = new Array(18);
  114160. pp.onApply = function (effect) {
  114161. if (!lastLuminance) {
  114162. return;
  114163. }
  114164. var id = 0;
  114165. for (var x = -1; x < 2; x++) {
  114166. for (var y = -1; y < 2; y++) {
  114167. downSampleOffsets[id] = x / lastLuminance.width;
  114168. downSampleOffsets[id + 1] = y / lastLuminance.height;
  114169. id += 2;
  114170. }
  114171. }
  114172. effect.setArray2("dsOffsets", downSampleOffsets);
  114173. effect.setFloat("halfDestPixelSize", 0.5 / lastLuminance.width);
  114174. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  114175. lastLuminance = _this.luminancePostProcess;
  114176. }
  114177. else {
  114178. lastLuminance = pp;
  114179. }
  114180. };
  114181. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  114182. pp.onAfterRender = function () {
  114183. var pixel = scene.getEngine().readPixels(0, 0, 1, 1);
  114184. 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);
  114185. _this._hdrCurrentLuminance = (pixel[0] * bit_shift.x + pixel[1] * bit_shift.y + pixel[2] * bit_shift.z + pixel[3] * bit_shift.w) / 100.0;
  114186. };
  114187. }
  114188. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminanceDownSample" + index, function () { return pp; }, true));
  114189. });
  114190. };
  114191. // Create HDR post-process
  114192. StandardRenderingPipeline.prototype._createHdrPostProcess = function (scene, ratio) {
  114193. var _this = this;
  114194. 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);
  114195. var outputLiminance = 1;
  114196. var time = 0;
  114197. var lastTime = 0;
  114198. this.hdrPostProcess.onApply = function (effect) {
  114199. effect.setTextureFromPostProcess("textureAdderSampler", _this._currentDepthOfFieldSource);
  114200. time += scene.getEngine().getDeltaTime();
  114201. if (outputLiminance < 0) {
  114202. outputLiminance = _this._hdrCurrentLuminance;
  114203. }
  114204. else {
  114205. var dt = (lastTime - time) / 1000.0;
  114206. if (_this._hdrCurrentLuminance < outputLiminance + _this.hdrDecreaseRate * dt) {
  114207. outputLiminance += _this.hdrDecreaseRate * dt;
  114208. }
  114209. else if (_this._hdrCurrentLuminance > outputLiminance - _this.hdrIncreaseRate * dt) {
  114210. outputLiminance -= _this.hdrIncreaseRate * dt;
  114211. }
  114212. else {
  114213. outputLiminance = _this._hdrCurrentLuminance;
  114214. }
  114215. }
  114216. outputLiminance = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(outputLiminance, _this.hdrMinimumLuminance, 1e20);
  114217. effect.setFloat("averageLuminance", outputLiminance);
  114218. lastTime = time;
  114219. _this._currentDepthOfFieldSource = _this.hdrFinalPostProcess;
  114220. };
  114221. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDR", function () { return _this.hdrPostProcess; }, true));
  114222. };
  114223. // Create lens flare post-process
  114224. StandardRenderingPipeline.prototype._createLensFlarePostProcess = function (scene, ratio) {
  114225. var _this = this;
  114226. 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);
  114227. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlare", function () { return _this.lensFlarePostProcess; }, true));
  114228. this._createBlurPostProcesses(scene, ratio / 4, 2);
  114229. 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);
  114230. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlareCompose", function () { return _this.lensFlareComposePostProcess; }, true));
  114231. var resolution = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  114232. // Lens flare
  114233. this.lensFlarePostProcess.onApply = function (effect) {
  114234. effect.setTextureFromPostProcess("textureSampler", _this._bloomEnabled ? _this.blurHPostProcesses[0] : _this.originalPostProcess);
  114235. effect.setTexture("lensColorSampler", _this.lensColorTexture);
  114236. effect.setFloat("strength", _this.lensFlareStrength);
  114237. effect.setFloat("ghostDispersal", _this.lensFlareGhostDispersal);
  114238. effect.setFloat("haloWidth", _this.lensFlareHaloWidth);
  114239. // Shift
  114240. resolution.x = _this.lensFlarePostProcess.width;
  114241. resolution.y = _this.lensFlarePostProcess.height;
  114242. effect.setVector2("resolution", resolution);
  114243. effect.setFloat("distortionStrength", _this.lensFlareDistortionStrength);
  114244. };
  114245. // Compose
  114246. 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);
  114247. 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);
  114248. this.lensFlareComposePostProcess.onApply = function (effect) {
  114249. if (!_this._scene.activeCamera) {
  114250. return;
  114251. }
  114252. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  114253. effect.setTexture("lensDirtSampler", _this.lensFlareDirtTexture);
  114254. effect.setTexture("lensStarSampler", _this.lensStarTexture);
  114255. // Lens start rotation matrix
  114256. var camerax = _this._scene.activeCamera.getViewMatrix().getRow(0);
  114257. var cameraz = _this._scene.activeCamera.getViewMatrix().getRow(2);
  114258. 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));
  114259. camRot *= 4.0;
  114260. 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);
  114261. var lensStarMatrix = scaleBias2.multiply(starRotation).multiply(scaleBias1);
  114262. effect.setMatrix("lensStarMatrix", lensStarMatrix);
  114263. _this._currentDepthOfFieldSource = _this.lensFlareFinalPostProcess;
  114264. };
  114265. };
  114266. // Create depth-of-field post-process
  114267. StandardRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (scene, ratio) {
  114268. var _this = this;
  114269. 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);
  114270. this.depthOfFieldPostProcess.onApply = function (effect) {
  114271. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  114272. effect.setTexture("depthSampler", _this._getDepthTexture());
  114273. effect.setFloat("distance", _this.depthOfFieldDistance);
  114274. };
  114275. // Add to pipeline
  114276. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDepthOfField", function () { return _this.depthOfFieldPostProcess; }, true));
  114277. };
  114278. // Create motion blur post-process
  114279. StandardRenderingPipeline.prototype._createMotionBlurPostProcess = function (scene, ratio) {
  114280. var _this = this;
  114281. 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);
  114282. var motionScale = 0;
  114283. var prevViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  114284. var invViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  114285. var viewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  114286. var screenSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  114287. this.motionBlurPostProcess.onApply = function (effect) {
  114288. viewProjection = scene.getProjectionMatrix().multiply(scene.getViewMatrix());
  114289. viewProjection.invertToRef(invViewProjection);
  114290. effect.setMatrix("inverseViewProjection", invViewProjection);
  114291. effect.setMatrix("prevViewProjection", prevViewProjection);
  114292. prevViewProjection = viewProjection;
  114293. screenSize.x = _this.motionBlurPostProcess.width;
  114294. screenSize.y = _this.motionBlurPostProcess.height;
  114295. effect.setVector2("screenSize", screenSize);
  114296. motionScale = scene.getEngine().getFps() / 60.0;
  114297. effect.setFloat("motionScale", motionScale);
  114298. effect.setFloat("motionStrength", _this.motionStrength);
  114299. effect.setTexture("depthSampler", _this._getDepthTexture());
  114300. };
  114301. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRMotionBlur", function () { return _this.motionBlurPostProcess; }, true));
  114302. };
  114303. StandardRenderingPipeline.prototype._getDepthTexture = function () {
  114304. if (this._scene.getEngine().getCaps().drawBuffersExtension) {
  114305. var renderer = this._scene.enableGeometryBufferRenderer();
  114306. return renderer.getGBuffer().textures[0];
  114307. }
  114308. return this._scene.enableDepthRenderer().getDepthMap();
  114309. };
  114310. StandardRenderingPipeline.prototype._disposePostProcesses = function () {
  114311. for (var i = 0; i < this._cameras.length; i++) {
  114312. var camera = this._cameras[i];
  114313. if (this.originalPostProcess) {
  114314. this.originalPostProcess.dispose(camera);
  114315. }
  114316. if (this.downSampleX4PostProcess) {
  114317. this.downSampleX4PostProcess.dispose(camera);
  114318. }
  114319. if (this.brightPassPostProcess) {
  114320. this.brightPassPostProcess.dispose(camera);
  114321. }
  114322. if (this.textureAdderPostProcess) {
  114323. this.textureAdderPostProcess.dispose(camera);
  114324. }
  114325. if (this.textureAdderFinalPostProcess) {
  114326. this.textureAdderFinalPostProcess.dispose(camera);
  114327. }
  114328. if (this.volumetricLightPostProcess) {
  114329. this.volumetricLightPostProcess.dispose(camera);
  114330. }
  114331. if (this.volumetricLightSmoothXPostProcess) {
  114332. this.volumetricLightSmoothXPostProcess.dispose(camera);
  114333. }
  114334. if (this.volumetricLightSmoothYPostProcess) {
  114335. this.volumetricLightSmoothYPostProcess.dispose(camera);
  114336. }
  114337. if (this.volumetricLightMergePostProces) {
  114338. this.volumetricLightMergePostProces.dispose(camera);
  114339. }
  114340. if (this.volumetricLightFinalPostProcess) {
  114341. this.volumetricLightFinalPostProcess.dispose(camera);
  114342. }
  114343. if (this.lensFlarePostProcess) {
  114344. this.lensFlarePostProcess.dispose(camera);
  114345. }
  114346. if (this.lensFlareComposePostProcess) {
  114347. this.lensFlareComposePostProcess.dispose(camera);
  114348. }
  114349. for (var j = 0; j < this.luminanceDownSamplePostProcesses.length; j++) {
  114350. this.luminanceDownSamplePostProcesses[j].dispose(camera);
  114351. }
  114352. if (this.luminancePostProcess) {
  114353. this.luminancePostProcess.dispose(camera);
  114354. }
  114355. if (this.hdrPostProcess) {
  114356. this.hdrPostProcess.dispose(camera);
  114357. }
  114358. if (this.hdrFinalPostProcess) {
  114359. this.hdrFinalPostProcess.dispose(camera);
  114360. }
  114361. if (this.depthOfFieldPostProcess) {
  114362. this.depthOfFieldPostProcess.dispose(camera);
  114363. }
  114364. if (this.motionBlurPostProcess) {
  114365. this.motionBlurPostProcess.dispose(camera);
  114366. }
  114367. if (this.fxaaPostProcess) {
  114368. this.fxaaPostProcess.dispose(camera);
  114369. }
  114370. for (var j = 0; j < this.blurHPostProcesses.length; j++) {
  114371. this.blurHPostProcesses[j].dispose(camera);
  114372. }
  114373. for (var j = 0; j < this.blurVPostProcesses.length; j++) {
  114374. this.blurVPostProcesses[j].dispose(camera);
  114375. }
  114376. }
  114377. this.originalPostProcess = null;
  114378. this.downSampleX4PostProcess = null;
  114379. this.brightPassPostProcess = null;
  114380. this.textureAdderPostProcess = null;
  114381. this.textureAdderFinalPostProcess = null;
  114382. this.volumetricLightPostProcess = null;
  114383. this.volumetricLightSmoothXPostProcess = null;
  114384. this.volumetricLightSmoothYPostProcess = null;
  114385. this.volumetricLightMergePostProces = null;
  114386. this.volumetricLightFinalPostProcess = null;
  114387. this.lensFlarePostProcess = null;
  114388. this.lensFlareComposePostProcess = null;
  114389. this.luminancePostProcess = null;
  114390. this.hdrPostProcess = null;
  114391. this.hdrFinalPostProcess = null;
  114392. this.depthOfFieldPostProcess = null;
  114393. this.motionBlurPostProcess = null;
  114394. this.fxaaPostProcess = null;
  114395. this.luminanceDownSamplePostProcesses = [];
  114396. this.blurHPostProcesses = [];
  114397. this.blurVPostProcesses = [];
  114398. };
  114399. /**
  114400. * Dispose of the pipeline and stop all post processes
  114401. */
  114402. StandardRenderingPipeline.prototype.dispose = function () {
  114403. this._disposePostProcesses();
  114404. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  114405. _super.prototype.dispose.call(this);
  114406. };
  114407. /**
  114408. * Serialize the rendering pipeline (Used when exporting)
  114409. * @returns the serialized object
  114410. */
  114411. StandardRenderingPipeline.prototype.serialize = function () {
  114412. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  114413. if (this.sourceLight) {
  114414. serializationObject.sourceLightId = this.sourceLight.id;
  114415. }
  114416. serializationObject.customType = "StandardRenderingPipeline";
  114417. return serializationObject;
  114418. };
  114419. /**
  114420. * Parse the serialized pipeline
  114421. * @param source Source pipeline.
  114422. * @param scene The scene to load the pipeline to.
  114423. * @param rootUrl The URL of the serialized pipeline.
  114424. * @returns An instantiated pipeline from the serialized object.
  114425. */
  114426. StandardRenderingPipeline.Parse = function (source, scene, rootUrl) {
  114427. var p = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardRenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  114428. if (source.sourceLightId) {
  114429. p.sourceLight = scene.getLightByID(source.sourceLightId);
  114430. }
  114431. return p;
  114432. };
  114433. /**
  114434. * Luminance steps
  114435. */
  114436. StandardRenderingPipeline.LuminanceSteps = 6;
  114437. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114438. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114439. ], StandardRenderingPipeline.prototype, "brightThreshold", void 0);
  114440. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114441. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114442. ], StandardRenderingPipeline.prototype, "blurWidth", void 0);
  114443. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114444. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114445. ], StandardRenderingPipeline.prototype, "horizontalBlur", void 0);
  114446. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114447. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114448. ], StandardRenderingPipeline.prototype, "exposure", void 0);
  114449. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114450. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensTexture")
  114451. ], StandardRenderingPipeline.prototype, "lensTexture", void 0);
  114452. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114453. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114454. ], StandardRenderingPipeline.prototype, "volumetricLightCoefficient", void 0);
  114455. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114456. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114457. ], StandardRenderingPipeline.prototype, "volumetricLightPower", void 0);
  114458. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114459. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114460. ], StandardRenderingPipeline.prototype, "volumetricLightBlurScale", void 0);
  114461. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114462. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114463. ], StandardRenderingPipeline.prototype, "hdrMinimumLuminance", void 0);
  114464. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114465. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114466. ], StandardRenderingPipeline.prototype, "hdrDecreaseRate", void 0);
  114467. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114468. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114469. ], StandardRenderingPipeline.prototype, "hdrIncreaseRate", void 0);
  114470. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114471. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensColorTexture")
  114472. ], StandardRenderingPipeline.prototype, "lensColorTexture", void 0);
  114473. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114474. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114475. ], StandardRenderingPipeline.prototype, "lensFlareStrength", void 0);
  114476. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114477. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114478. ], StandardRenderingPipeline.prototype, "lensFlareGhostDispersal", void 0);
  114479. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114480. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114481. ], StandardRenderingPipeline.prototype, "lensFlareHaloWidth", void 0);
  114482. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114483. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114484. ], StandardRenderingPipeline.prototype, "lensFlareDistortionStrength", void 0);
  114485. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114486. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensStarTexture")
  114487. ], StandardRenderingPipeline.prototype, "lensStarTexture", void 0);
  114488. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114489. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensFlareDirtTexture")
  114490. ], StandardRenderingPipeline.prototype, "lensFlareDirtTexture", void 0);
  114491. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114492. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114493. ], StandardRenderingPipeline.prototype, "depthOfFieldDistance", void 0);
  114494. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114495. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114496. ], StandardRenderingPipeline.prototype, "depthOfFieldBlurWidth", void 0);
  114497. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114498. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114499. ], StandardRenderingPipeline.prototype, "motionStrength", void 0);
  114500. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114501. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114502. ], StandardRenderingPipeline.prototype, "_ratio", void 0);
  114503. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114504. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114505. ], StandardRenderingPipeline.prototype, "BloomEnabled", null);
  114506. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114507. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114508. ], StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", null);
  114509. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114510. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114511. ], StandardRenderingPipeline.prototype, "LensFlareEnabled", null);
  114512. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114513. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114514. ], StandardRenderingPipeline.prototype, "HDREnabled", null);
  114515. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114516. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114517. ], StandardRenderingPipeline.prototype, "VLSEnabled", null);
  114518. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114519. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114520. ], StandardRenderingPipeline.prototype, "MotionBlurEnabled", null);
  114521. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114522. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114523. ], StandardRenderingPipeline.prototype, "fxaaEnabled", null);
  114524. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114525. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114526. ], StandardRenderingPipeline.prototype, "volumetricLightStepsCount", null);
  114527. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114528. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114529. ], StandardRenderingPipeline.prototype, "motionBlurSamples", null);
  114530. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114531. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114532. ], StandardRenderingPipeline.prototype, "samples", null);
  114533. return StandardRenderingPipeline;
  114534. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  114535. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardRenderingPipeline"] = StandardRenderingPipeline;
  114536. /***/ }),
  114537. /***/ "./PostProcesses/RenderPipeline/index.ts":
  114538. /*!***********************************************!*\
  114539. !*** ./PostProcesses/RenderPipeline/index.ts ***!
  114540. \***********************************************/
  114541. /*! exports provided: PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  114542. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114543. "use strict";
  114544. __webpack_require__.r(__webpack_exports__);
  114545. /* harmony import */ var _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Pipelines/index */ "./PostProcesses/RenderPipeline/Pipelines/index.ts");
  114546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  114547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  114548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  114549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  114550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  114551. /* harmony import */ var _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  114552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]; });
  114553. /* harmony import */ var _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  114554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__["PostProcessRenderPipeline"]; });
  114555. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  114556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderPipelineManager"]; });
  114557. /* harmony import */ var _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  114558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipelineManagerSceneComponent"]; });
  114559. /***/ }),
  114560. /***/ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts":
  114561. /*!*****************************************************************!*\
  114562. !*** ./PostProcesses/RenderPipeline/postProcessRenderEffect.ts ***!
  114563. \*****************************************************************/
  114564. /*! exports provided: PostProcessRenderEffect */
  114565. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114566. "use strict";
  114567. __webpack_require__.r(__webpack_exports__);
  114568. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return PostProcessRenderEffect; });
  114569. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  114570. /**
  114571. * This represents a set of one or more post processes in Babylon.
  114572. * A post process can be used to apply a shader to a texture after it is rendered.
  114573. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  114574. */
  114575. var PostProcessRenderEffect = /** @class */ (function () {
  114576. /**
  114577. * Instantiates a post process render effect.
  114578. * A post process can be used to apply a shader to a texture after it is rendered.
  114579. * @param engine The engine the effect is tied to
  114580. * @param name The name of the effect
  114581. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  114582. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  114583. */
  114584. function PostProcessRenderEffect(engine, name, getPostProcesses, singleInstance) {
  114585. this._name = name;
  114586. this._singleInstance = singleInstance || true;
  114587. this._getPostProcesses = getPostProcesses;
  114588. this._cameras = {};
  114589. this._indicesForCamera = {};
  114590. this._postProcesses = {};
  114591. }
  114592. Object.defineProperty(PostProcessRenderEffect.prototype, "isSupported", {
  114593. /**
  114594. * Checks if all the post processes in the effect are supported.
  114595. */
  114596. get: function () {
  114597. for (var index in this._postProcesses) {
  114598. if (this._postProcesses.hasOwnProperty(index)) {
  114599. var pps = this._postProcesses[index];
  114600. for (var ppIndex = 0; ppIndex < pps.length; ppIndex++) {
  114601. if (!pps[ppIndex].isSupported) {
  114602. return false;
  114603. }
  114604. }
  114605. }
  114606. }
  114607. return true;
  114608. },
  114609. enumerable: true,
  114610. configurable: true
  114611. });
  114612. /**
  114613. * Updates the current state of the effect
  114614. * @hidden
  114615. */
  114616. PostProcessRenderEffect.prototype._update = function () {
  114617. };
  114618. /**
  114619. * Attaches the effect on cameras
  114620. * @param cameras The camera to attach to.
  114621. * @hidden
  114622. */
  114623. PostProcessRenderEffect.prototype._attachCameras = function (cameras) {
  114624. var _this = this;
  114625. var cameraKey;
  114626. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  114627. if (!cams) {
  114628. return;
  114629. }
  114630. for (var i = 0; i < cams.length; i++) {
  114631. var camera = cams[i];
  114632. var cameraName = camera.name;
  114633. if (this._singleInstance) {
  114634. cameraKey = 0;
  114635. }
  114636. else {
  114637. cameraKey = cameraName;
  114638. }
  114639. if (!this._postProcesses[cameraKey]) {
  114640. var postProcess = this._getPostProcesses();
  114641. if (postProcess) {
  114642. this._postProcesses[cameraKey] = Array.isArray(postProcess) ? postProcess : [postProcess];
  114643. }
  114644. }
  114645. if (!this._indicesForCamera[cameraName]) {
  114646. this._indicesForCamera[cameraName] = [];
  114647. }
  114648. this._postProcesses[cameraKey].forEach(function (postProcess) {
  114649. var index = camera.attachPostProcess(postProcess);
  114650. _this._indicesForCamera[cameraName].push(index);
  114651. });
  114652. if (!this._cameras[cameraName]) {
  114653. this._cameras[cameraName] = camera;
  114654. }
  114655. }
  114656. };
  114657. /**
  114658. * Detatches the effect on cameras
  114659. * @param cameras The camera to detatch from.
  114660. * @hidden
  114661. */
  114662. PostProcessRenderEffect.prototype._detachCameras = function (cameras) {
  114663. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  114664. if (!cams) {
  114665. return;
  114666. }
  114667. for (var i = 0; i < cams.length; i++) {
  114668. var camera = cams[i];
  114669. var cameraName = camera.name;
  114670. var postProcesses = this._postProcesses[this._singleInstance ? 0 : cameraName];
  114671. if (postProcesses) {
  114672. postProcesses.forEach(function (postProcess) {
  114673. camera.detachPostProcess(postProcess);
  114674. });
  114675. }
  114676. if (this._cameras[cameraName]) {
  114677. this._cameras[cameraName] = null;
  114678. }
  114679. }
  114680. };
  114681. /**
  114682. * Enables the effect on given cameras
  114683. * @param cameras The camera to enable.
  114684. * @hidden
  114685. */
  114686. PostProcessRenderEffect.prototype._enable = function (cameras) {
  114687. var _this = this;
  114688. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  114689. if (!cams) {
  114690. return;
  114691. }
  114692. for (var i = 0; i < cams.length; i++) {
  114693. var camera = cams[i];
  114694. var cameraName = camera.name;
  114695. for (var j = 0; j < this._indicesForCamera[cameraName].length; j++) {
  114696. if (camera._postProcesses[this._indicesForCamera[cameraName][j]] === undefined || camera._postProcesses[this._indicesForCamera[cameraName][j]] === null) {
  114697. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  114698. cams[i].attachPostProcess(postProcess, _this._indicesForCamera[cameraName][j]);
  114699. });
  114700. }
  114701. }
  114702. }
  114703. };
  114704. /**
  114705. * Disables the effect on the given cameras
  114706. * @param cameras The camera to disable.
  114707. * @hidden
  114708. */
  114709. PostProcessRenderEffect.prototype._disable = function (cameras) {
  114710. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  114711. if (!cams) {
  114712. return;
  114713. }
  114714. for (var i = 0; i < cams.length; i++) {
  114715. var camera = cams[i];
  114716. var cameraName = camera.name;
  114717. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  114718. camera.detachPostProcess(postProcess);
  114719. });
  114720. }
  114721. };
  114722. /**
  114723. * Gets a list of the post processes contained in the effect.
  114724. * @param camera The camera to get the post processes on.
  114725. * @returns The list of the post processes in the effect.
  114726. */
  114727. PostProcessRenderEffect.prototype.getPostProcesses = function (camera) {
  114728. if (this._singleInstance) {
  114729. return this._postProcesses[0];
  114730. }
  114731. else {
  114732. if (!camera) {
  114733. return null;
  114734. }
  114735. return this._postProcesses[camera.name];
  114736. }
  114737. };
  114738. return PostProcessRenderEffect;
  114739. }());
  114740. /***/ }),
  114741. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts":
  114742. /*!*******************************************************************!*\
  114743. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts ***!
  114744. \*******************************************************************/
  114745. /*! exports provided: PostProcessRenderPipeline */
  114746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114747. "use strict";
  114748. __webpack_require__.r(__webpack_exports__);
  114749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return PostProcessRenderPipeline; });
  114750. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114751. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  114752. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  114753. /**
  114754. * PostProcessRenderPipeline
  114755. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  114756. */
  114757. var PostProcessRenderPipeline = /** @class */ (function () {
  114758. /**
  114759. * Initializes a PostProcessRenderPipeline
  114760. * @param engine engine to add the pipeline to
  114761. * @param name name of the pipeline
  114762. */
  114763. function PostProcessRenderPipeline(engine, name) {
  114764. this.engine = engine;
  114765. this._name = name;
  114766. this._renderEffects = {};
  114767. this._renderEffectsForIsolatedPass = new Array();
  114768. this._cameras = [];
  114769. }
  114770. /**
  114771. * "PostProcessRenderPipeline"
  114772. * @returns "PostProcessRenderPipeline"
  114773. */
  114774. PostProcessRenderPipeline.prototype.getClassName = function () {
  114775. return "PostProcessRenderPipeline";
  114776. };
  114777. Object.defineProperty(PostProcessRenderPipeline.prototype, "isSupported", {
  114778. /**
  114779. * If all the render effects in the pipeline are support
  114780. */
  114781. get: function () {
  114782. for (var renderEffectName in this._renderEffects) {
  114783. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  114784. if (!this._renderEffects[renderEffectName].isSupported) {
  114785. return false;
  114786. }
  114787. }
  114788. }
  114789. return true;
  114790. },
  114791. enumerable: true,
  114792. configurable: true
  114793. });
  114794. /**
  114795. * Adds an effect to the pipeline
  114796. * @param renderEffect the effect to add
  114797. */
  114798. PostProcessRenderPipeline.prototype.addEffect = function (renderEffect) {
  114799. this._renderEffects[renderEffect._name] = renderEffect;
  114800. };
  114801. // private
  114802. /** @hidden */
  114803. PostProcessRenderPipeline.prototype._rebuild = function () {
  114804. };
  114805. /** @hidden */
  114806. PostProcessRenderPipeline.prototype._enableEffect = function (renderEffectName, cameras) {
  114807. var renderEffects = this._renderEffects[renderEffectName];
  114808. if (!renderEffects) {
  114809. return;
  114810. }
  114811. renderEffects._enable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  114812. };
  114813. /** @hidden */
  114814. PostProcessRenderPipeline.prototype._disableEffect = function (renderEffectName, cameras) {
  114815. var renderEffects = this._renderEffects[renderEffectName];
  114816. if (!renderEffects) {
  114817. return;
  114818. }
  114819. renderEffects._disable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  114820. };
  114821. /** @hidden */
  114822. PostProcessRenderPipeline.prototype._attachCameras = function (cameras, unique) {
  114823. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  114824. if (!cams) {
  114825. return;
  114826. }
  114827. var indicesToDelete = [];
  114828. var i;
  114829. for (i = 0; i < cams.length; i++) {
  114830. var camera = cams[i];
  114831. var cameraName = camera.name;
  114832. if (this._cameras.indexOf(camera) === -1) {
  114833. this._cameras[cameraName] = camera;
  114834. }
  114835. else if (unique) {
  114836. indicesToDelete.push(i);
  114837. }
  114838. }
  114839. for (i = 0; i < indicesToDelete.length; i++) {
  114840. cameras.splice(indicesToDelete[i], 1);
  114841. }
  114842. for (var renderEffectName in this._renderEffects) {
  114843. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  114844. this._renderEffects[renderEffectName]._attachCameras(cams);
  114845. }
  114846. }
  114847. };
  114848. /** @hidden */
  114849. PostProcessRenderPipeline.prototype._detachCameras = function (cameras) {
  114850. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  114851. if (!cams) {
  114852. return;
  114853. }
  114854. for (var renderEffectName in this._renderEffects) {
  114855. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  114856. this._renderEffects[renderEffectName]._detachCameras(cams);
  114857. }
  114858. }
  114859. for (var i = 0; i < cams.length; i++) {
  114860. this._cameras.splice(this._cameras.indexOf(cams[i]), 1);
  114861. }
  114862. };
  114863. /** @hidden */
  114864. PostProcessRenderPipeline.prototype._update = function () {
  114865. for (var renderEffectName in this._renderEffects) {
  114866. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  114867. this._renderEffects[renderEffectName]._update();
  114868. }
  114869. }
  114870. for (var i = 0; i < this._cameras.length; i++) {
  114871. var cameraName = this._cameras[i].name;
  114872. if (this._renderEffectsForIsolatedPass[cameraName]) {
  114873. this._renderEffectsForIsolatedPass[cameraName]._update();
  114874. }
  114875. }
  114876. };
  114877. /** @hidden */
  114878. PostProcessRenderPipeline.prototype._reset = function () {
  114879. this._renderEffects = {};
  114880. this._renderEffectsForIsolatedPass = new Array();
  114881. };
  114882. PostProcessRenderPipeline.prototype._enableMSAAOnFirstPostProcess = function (sampleCount) {
  114883. // 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)
  114884. var effectKeys = Object.keys(this._renderEffects);
  114885. if (this.engine.webGLVersion >= 2 && effectKeys.length > 0) {
  114886. var postProcesses = this._renderEffects[effectKeys[0]].getPostProcesses();
  114887. if (postProcesses) {
  114888. postProcesses[0].samples = sampleCount;
  114889. return true;
  114890. }
  114891. }
  114892. return false;
  114893. };
  114894. /**
  114895. * Disposes of the pipeline
  114896. */
  114897. PostProcessRenderPipeline.prototype.dispose = function () {
  114898. // Must be implemented by children
  114899. };
  114900. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114901. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  114902. ], PostProcessRenderPipeline.prototype, "_name", void 0);
  114903. return PostProcessRenderPipeline;
  114904. }());
  114905. /***/ }),
  114906. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts":
  114907. /*!**************************************************************************!*\
  114908. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts ***!
  114909. \**************************************************************************/
  114910. /*! exports provided: PostProcessRenderPipelineManager */
  114911. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114912. "use strict";
  114913. __webpack_require__.r(__webpack_exports__);
  114914. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return PostProcessRenderPipelineManager; });
  114915. /**
  114916. * PostProcessRenderPipelineManager class
  114917. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  114918. */
  114919. var PostProcessRenderPipelineManager = /** @class */ (function () {
  114920. /**
  114921. * Initializes a PostProcessRenderPipelineManager
  114922. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  114923. */
  114924. function PostProcessRenderPipelineManager() {
  114925. this._renderPipelines = {};
  114926. }
  114927. /**
  114928. * Adds a pipeline to the manager
  114929. * @param renderPipeline The pipeline to add
  114930. */
  114931. PostProcessRenderPipelineManager.prototype.addPipeline = function (renderPipeline) {
  114932. this._renderPipelines[renderPipeline._name] = renderPipeline;
  114933. };
  114934. /**
  114935. * Attaches a camera to the pipeline
  114936. * @param renderPipelineName The name of the pipeline to attach to
  114937. * @param cameras the camera to attach
  114938. * @param unique if the camera can be attached multiple times to the pipeline
  114939. */
  114940. PostProcessRenderPipelineManager.prototype.attachCamerasToRenderPipeline = function (renderPipelineName, cameras, unique) {
  114941. if (unique === void 0) { unique = false; }
  114942. var renderPipeline = this._renderPipelines[renderPipelineName];
  114943. if (!renderPipeline) {
  114944. return;
  114945. }
  114946. renderPipeline._attachCameras(cameras, unique);
  114947. };
  114948. /**
  114949. * Detaches a camera from the pipeline
  114950. * @param renderPipelineName The name of the pipeline to detach from
  114951. * @param cameras the camera to detach
  114952. */
  114953. PostProcessRenderPipelineManager.prototype.detachCamerasFromRenderPipeline = function (renderPipelineName, cameras) {
  114954. var renderPipeline = this._renderPipelines[renderPipelineName];
  114955. if (!renderPipeline) {
  114956. return;
  114957. }
  114958. renderPipeline._detachCameras(cameras);
  114959. };
  114960. /**
  114961. * Enables an effect by name on a pipeline
  114962. * @param renderPipelineName the name of the pipeline to enable the effect in
  114963. * @param renderEffectName the name of the effect to enable
  114964. * @param cameras the cameras that the effect should be enabled on
  114965. */
  114966. PostProcessRenderPipelineManager.prototype.enableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  114967. var renderPipeline = this._renderPipelines[renderPipelineName];
  114968. if (!renderPipeline) {
  114969. return;
  114970. }
  114971. renderPipeline._enableEffect(renderEffectName, cameras);
  114972. };
  114973. /**
  114974. * Disables an effect by name on a pipeline
  114975. * @param renderPipelineName the name of the pipeline to disable the effect in
  114976. * @param renderEffectName the name of the effect to disable
  114977. * @param cameras the cameras that the effect should be disabled on
  114978. */
  114979. PostProcessRenderPipelineManager.prototype.disableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  114980. var renderPipeline = this._renderPipelines[renderPipelineName];
  114981. if (!renderPipeline) {
  114982. return;
  114983. }
  114984. renderPipeline._disableEffect(renderEffectName, cameras);
  114985. };
  114986. /**
  114987. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  114988. */
  114989. PostProcessRenderPipelineManager.prototype.update = function () {
  114990. for (var renderPipelineName in this._renderPipelines) {
  114991. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  114992. var pipeline = this._renderPipelines[renderPipelineName];
  114993. if (!pipeline.isSupported) {
  114994. pipeline.dispose();
  114995. delete this._renderPipelines[renderPipelineName];
  114996. }
  114997. else {
  114998. pipeline._update();
  114999. }
  115000. }
  115001. }
  115002. };
  115003. /** @hidden */
  115004. PostProcessRenderPipelineManager.prototype._rebuild = function () {
  115005. for (var renderPipelineName in this._renderPipelines) {
  115006. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  115007. var pipeline = this._renderPipelines[renderPipelineName];
  115008. pipeline._rebuild();
  115009. }
  115010. }
  115011. };
  115012. /**
  115013. * Disposes of the manager and pipelines
  115014. */
  115015. PostProcessRenderPipelineManager.prototype.dispose = function () {
  115016. for (var renderPipelineName in this._renderPipelines) {
  115017. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  115018. var pipeline = this._renderPipelines[renderPipelineName];
  115019. pipeline.dispose();
  115020. }
  115021. }
  115022. };
  115023. return PostProcessRenderPipelineManager;
  115024. }());
  115025. /***/ }),
  115026. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts":
  115027. /*!****************************************************************************************!*\
  115028. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts ***!
  115029. \****************************************************************************************/
  115030. /*! exports provided: PostProcessRenderPipelineManagerSceneComponent */
  115031. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115032. "use strict";
  115033. __webpack_require__.r(__webpack_exports__);
  115034. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return PostProcessRenderPipelineManagerSceneComponent; });
  115035. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  115036. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  115037. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  115038. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype, "postProcessRenderPipelineManager", {
  115039. get: function () {
  115040. if (!this._postProcessRenderPipelineManager) {
  115041. // Register the G Buffer component to the scene.
  115042. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER);
  115043. if (!component) {
  115044. component = new PostProcessRenderPipelineManagerSceneComponent(this);
  115045. this._addComponent(component);
  115046. }
  115047. this._postProcessRenderPipelineManager = new _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderPipelineManager"]();
  115048. }
  115049. return this._postProcessRenderPipelineManager;
  115050. },
  115051. enumerable: true,
  115052. configurable: true
  115053. });
  115054. /**
  115055. * Defines the Render Pipeline scene component responsible to rendering pipelines
  115056. */
  115057. var PostProcessRenderPipelineManagerSceneComponent = /** @class */ (function () {
  115058. /**
  115059. * Creates a new instance of the component for the given scene
  115060. * @param scene Defines the scene to register the component in
  115061. */
  115062. function PostProcessRenderPipelineManagerSceneComponent(scene) {
  115063. /**
  115064. * The component name helpfull to identify the component in the list of scene components.
  115065. */
  115066. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER;
  115067. this.scene = scene;
  115068. }
  115069. /**
  115070. * Registers the component in a given scene
  115071. */
  115072. PostProcessRenderPipelineManagerSceneComponent.prototype.register = function () {
  115073. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets);
  115074. };
  115075. /**
  115076. * Rebuilds the elements related to this component in case of
  115077. * context lost for instance.
  115078. */
  115079. PostProcessRenderPipelineManagerSceneComponent.prototype.rebuild = function () {
  115080. if (this.scene._postProcessRenderPipelineManager) {
  115081. this.scene._postProcessRenderPipelineManager._rebuild();
  115082. }
  115083. };
  115084. /**
  115085. * Disposes the component and the associated ressources
  115086. */
  115087. PostProcessRenderPipelineManagerSceneComponent.prototype.dispose = function () {
  115088. if (this.scene._postProcessRenderPipelineManager) {
  115089. this.scene._postProcessRenderPipelineManager.dispose();
  115090. }
  115091. };
  115092. PostProcessRenderPipelineManagerSceneComponent.prototype._gatherRenderTargets = function () {
  115093. if (this.scene._postProcessRenderPipelineManager) {
  115094. this.scene._postProcessRenderPipelineManager.update();
  115095. }
  115096. };
  115097. return PostProcessRenderPipelineManagerSceneComponent;
  115098. }());
  115099. /***/ }),
  115100. /***/ "./PostProcesses/anaglyphPostProcess.ts":
  115101. /*!**********************************************!*\
  115102. !*** ./PostProcesses/anaglyphPostProcess.ts ***!
  115103. \**********************************************/
  115104. /*! exports provided: AnaglyphPostProcess */
  115105. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115106. "use strict";
  115107. __webpack_require__.r(__webpack_exports__);
  115108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return AnaglyphPostProcess; });
  115109. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115110. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115111. /* harmony import */ var _Shaders_anaglyph_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/anaglyph.fragment */ "./Shaders/anaglyph.fragment.ts");
  115112. /**
  115113. * Postprocess used to generate anaglyphic rendering
  115114. */
  115115. var AnaglyphPostProcess = /** @class */ (function (_super) {
  115116. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphPostProcess, _super);
  115117. /**
  115118. * Creates a new AnaglyphPostProcess
  115119. * @param name defines postprocess name
  115120. * @param options defines creation options or target ratio scale
  115121. * @param rigCameras defines cameras using this postprocess
  115122. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  115123. * @param engine defines hosting engine
  115124. * @param reusable defines if the postprocess will be reused multiple times per frame
  115125. */
  115126. function AnaglyphPostProcess(name, options, rigCameras, samplingMode, engine, reusable) {
  115127. var _this = _super.call(this, name, "anaglyph", null, ["leftSampler"], options, rigCameras[1], samplingMode, engine, reusable) || this;
  115128. _this._passedProcess = rigCameras[0]._rigPostProcess;
  115129. _this.onApplyObservable.add(function (effect) {
  115130. effect.setTextureFromPostProcess("leftSampler", _this._passedProcess);
  115131. });
  115132. return _this;
  115133. }
  115134. return AnaglyphPostProcess;
  115135. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  115136. /***/ }),
  115137. /***/ "./PostProcesses/blackAndWhitePostProcess.ts":
  115138. /*!***************************************************!*\
  115139. !*** ./PostProcesses/blackAndWhitePostProcess.ts ***!
  115140. \***************************************************/
  115141. /*! exports provided: BlackAndWhitePostProcess */
  115142. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115143. "use strict";
  115144. __webpack_require__.r(__webpack_exports__);
  115145. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return BlackAndWhitePostProcess; });
  115146. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115147. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115148. /* harmony import */ var _Shaders_blackAndWhite_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/blackAndWhite.fragment */ "./Shaders/blackAndWhite.fragment.ts");
  115149. /**
  115150. * Post process used to render in black and white
  115151. */
  115152. var BlackAndWhitePostProcess = /** @class */ (function (_super) {
  115153. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlackAndWhitePostProcess, _super);
  115154. /**
  115155. * Creates a black and white post process
  115156. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  115157. * @param name The name of the effect.
  115158. * @param options The required width/height ratio to downsize to before computing the render pass.
  115159. * @param camera The camera to apply the render pass to.
  115160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115161. * @param engine The engine which the post process will be applied. (default: current engine)
  115162. * @param reusable If the post process can be reused on the same frame. (default: false)
  115163. */
  115164. function BlackAndWhitePostProcess(name, options, camera, samplingMode, engine, reusable) {
  115165. var _this = _super.call(this, name, "blackAndWhite", ["degree"], null, options, camera, samplingMode, engine, reusable) || this;
  115166. /**
  115167. * Linear about to convert he result to black and white (default: 1)
  115168. */
  115169. _this.degree = 1;
  115170. _this.onApplyObservable.add(function (effect) {
  115171. effect.setFloat("degree", _this.degree);
  115172. });
  115173. return _this;
  115174. }
  115175. return BlackAndWhitePostProcess;
  115176. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  115177. /***/ }),
  115178. /***/ "./PostProcesses/bloomEffect.ts":
  115179. /*!**************************************!*\
  115180. !*** ./PostProcesses/bloomEffect.ts ***!
  115181. \**************************************/
  115182. /*! exports provided: BloomEffect */
  115183. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115184. "use strict";
  115185. __webpack_require__.r(__webpack_exports__);
  115186. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return BloomEffect; });
  115187. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115188. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  115189. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  115190. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  115191. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  115192. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  115193. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  115194. /**
  115195. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  115196. */
  115197. var BloomEffect = /** @class */ (function (_super) {
  115198. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomEffect, _super);
  115199. /**
  115200. * Creates a new instance of @see BloomEffect
  115201. * @param scene The scene the effect belongs to.
  115202. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  115203. * @param bloomKernel The size of the kernel to be used when applying the blur.
  115204. * @param bloomWeight The the strength of bloom.
  115205. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  115206. * @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)
  115207. */
  115208. function BloomEffect(scene, bloomScale, bloomWeight, bloomKernel, pipelineTextureType, blockCompilation) {
  115209. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  115210. if (blockCompilation === void 0) { blockCompilation = false; }
  115211. var _this = _super.call(this, scene.getEngine(), "bloom", function () {
  115212. return _this._effects;
  115213. }, true) || this;
  115214. _this.bloomScale = bloomScale;
  115215. /**
  115216. * @hidden Internal
  115217. */
  115218. _this._effects = [];
  115219. _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);
  115220. _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);
  115221. _this._blurX.alwaysForcePOT = true;
  115222. _this._blurX.autoClear = false;
  115223. _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);
  115224. _this._blurY.alwaysForcePOT = true;
  115225. _this._blurY.autoClear = false;
  115226. _this.kernel = bloomKernel;
  115227. _this._effects = [_this._downscale, _this._blurX, _this._blurY];
  115228. _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);
  115229. _this._merge.autoClear = false;
  115230. _this._effects.push(_this._merge);
  115231. return _this;
  115232. }
  115233. Object.defineProperty(BloomEffect.prototype, "threshold", {
  115234. /**
  115235. * The luminance threshold to find bright areas of the image to bloom.
  115236. */
  115237. get: function () {
  115238. return this._downscale.threshold;
  115239. },
  115240. set: function (value) {
  115241. this._downscale.threshold = value;
  115242. },
  115243. enumerable: true,
  115244. configurable: true
  115245. });
  115246. Object.defineProperty(BloomEffect.prototype, "weight", {
  115247. /**
  115248. * The strength of the bloom.
  115249. */
  115250. get: function () {
  115251. return this._merge.weight;
  115252. },
  115253. set: function (value) {
  115254. this._merge.weight = value;
  115255. },
  115256. enumerable: true,
  115257. configurable: true
  115258. });
  115259. Object.defineProperty(BloomEffect.prototype, "kernel", {
  115260. /**
  115261. * Specifies the size of the bloom blur kernel, relative to the final output size
  115262. */
  115263. get: function () {
  115264. return this._blurX.kernel / this.bloomScale;
  115265. },
  115266. set: function (value) {
  115267. this._blurX.kernel = value * this.bloomScale;
  115268. this._blurY.kernel = value * this.bloomScale;
  115269. },
  115270. enumerable: true,
  115271. configurable: true
  115272. });
  115273. /**
  115274. * Disposes each of the internal effects for a given camera.
  115275. * @param camera The camera to dispose the effect on.
  115276. */
  115277. BloomEffect.prototype.disposeEffects = function (camera) {
  115278. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  115279. this._effects[effectIndex].dispose(camera);
  115280. }
  115281. };
  115282. /**
  115283. * @hidden Internal
  115284. */
  115285. BloomEffect.prototype._updateEffects = function () {
  115286. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  115287. this._effects[effectIndex].updateEffect();
  115288. }
  115289. };
  115290. /**
  115291. * Internal
  115292. * @returns if all the contained post processes are ready.
  115293. * @hidden
  115294. */
  115295. BloomEffect.prototype._isReady = function () {
  115296. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  115297. if (!this._effects[effectIndex].isReady()) {
  115298. return false;
  115299. }
  115300. }
  115301. return true;
  115302. };
  115303. return BloomEffect;
  115304. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]));
  115305. /***/ }),
  115306. /***/ "./PostProcesses/bloomMergePostProcess.ts":
  115307. /*!************************************************!*\
  115308. !*** ./PostProcesses/bloomMergePostProcess.ts ***!
  115309. \************************************************/
  115310. /*! exports provided: BloomMergePostProcess */
  115311. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115312. "use strict";
  115313. __webpack_require__.r(__webpack_exports__);
  115314. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return BloomMergePostProcess; });
  115315. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115316. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115317. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  115318. /* harmony import */ var _Shaders_bloomMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/bloomMerge.fragment */ "./Shaders/bloomMerge.fragment.ts");
  115319. /**
  115320. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  115321. */
  115322. var BloomMergePostProcess = /** @class */ (function (_super) {
  115323. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomMergePostProcess, _super);
  115324. /**
  115325. * Creates a new instance of @see BloomMergePostProcess
  115326. * @param name The name of the effect.
  115327. * @param originalFromInput Post process which's input will be used for the merge.
  115328. * @param blurred Blurred highlights post process which's output will be used.
  115329. * @param weight Weight of the bloom to be added to the original input.
  115330. * @param options The required width/height ratio to downsize to before computing the render pass.
  115331. * @param camera The camera to apply the render pass to.
  115332. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115333. * @param engine The engine which the post process will be applied. (default: current engine)
  115334. * @param reusable If the post process can be reused on the same frame. (default: false)
  115335. * @param textureType Type of textures used when performing the post process. (default: 0)
  115336. * @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)
  115337. */
  115338. function BloomMergePostProcess(name, originalFromInput, blurred,
  115339. /** Weight of the bloom to be added to the original input. */
  115340. weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  115341. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  115342. if (blockCompilation === void 0) { blockCompilation = false; }
  115343. var _this = _super.call(this, name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  115344. _this.weight = weight;
  115345. _this.onApplyObservable.add(function (effect) {
  115346. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  115347. effect.setTextureFromPostProcessOutput("bloomBlur", blurred);
  115348. effect.setFloat("bloomWeight", _this.weight);
  115349. });
  115350. if (!blockCompilation) {
  115351. _this.updateEffect();
  115352. }
  115353. return _this;
  115354. }
  115355. return BloomMergePostProcess;
  115356. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  115357. /***/ }),
  115358. /***/ "./PostProcesses/blurPostProcess.ts":
  115359. /*!******************************************!*\
  115360. !*** ./PostProcesses/blurPostProcess.ts ***!
  115361. \******************************************/
  115362. /*! exports provided: BlurPostProcess */
  115363. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115364. "use strict";
  115365. __webpack_require__.r(__webpack_exports__);
  115366. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return BlurPostProcess; });
  115367. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115368. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115369. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  115370. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  115371. /* harmony import */ var _Shaders_kernelBlur_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/kernelBlur.fragment */ "./Shaders/kernelBlur.fragment.ts");
  115372. /* harmony import */ var _Shaders_kernelBlur_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/kernelBlur.vertex */ "./Shaders/kernelBlur.vertex.ts");
  115373. /**
  115374. * The Blur Post Process which blurs an image based on a kernel and direction.
  115375. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  115376. */
  115377. var BlurPostProcess = /** @class */ (function (_super) {
  115378. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlurPostProcess, _super);
  115379. /**
  115380. * Creates a new instance BlurPostProcess
  115381. * @param name The name of the effect.
  115382. * @param direction The direction in which to blur the image.
  115383. * @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.
  115384. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  115385. * @param camera The camera to apply the render pass to.
  115386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115387. * @param engine The engine which the post process will be applied. (default: current engine)
  115388. * @param reusable If the post process can be reused on the same frame. (default: false)
  115389. * @param textureType Type of textures used when performing the post process. (default: 0)
  115390. * @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)
  115391. */
  115392. function BlurPostProcess(name,
  115393. /** The direction in which to blur the image. */
  115394. direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
  115395. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  115396. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  115397. if (defines === void 0) { defines = ""; }
  115398. if (blockCompilation === void 0) { blockCompilation = false; }
  115399. 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;
  115400. _this.direction = direction;
  115401. _this.blockCompilation = blockCompilation;
  115402. _this._packedFloat = false;
  115403. _this._staticDefines = "";
  115404. _this._staticDefines = defines;
  115405. _this.onApplyObservable.add(function (effect) {
  115406. if (_this._outputTexture) {
  115407. effect.setFloat2('delta', (1 / _this._outputTexture.width) * _this.direction.x, (1 / _this._outputTexture.height) * _this.direction.y);
  115408. }
  115409. else {
  115410. effect.setFloat2('delta', (1 / _this.width) * _this.direction.x, (1 / _this.height) * _this.direction.y);
  115411. }
  115412. });
  115413. _this.kernel = kernel;
  115414. return _this;
  115415. }
  115416. Object.defineProperty(BlurPostProcess.prototype, "kernel", {
  115417. /**
  115418. * Gets the length in pixels of the blur sample region
  115419. */
  115420. get: function () {
  115421. return this._idealKernel;
  115422. },
  115423. /**
  115424. * Sets the length in pixels of the blur sample region
  115425. */
  115426. set: function (v) {
  115427. if (this._idealKernel === v) {
  115428. return;
  115429. }
  115430. v = Math.max(v, 1);
  115431. this._idealKernel = v;
  115432. this._kernel = this._nearestBestKernel(v);
  115433. if (!this.blockCompilation) {
  115434. this._updateParameters();
  115435. }
  115436. },
  115437. enumerable: true,
  115438. configurable: true
  115439. });
  115440. Object.defineProperty(BlurPostProcess.prototype, "packedFloat", {
  115441. /**
  115442. * Gets wether or not the blur is unpacking/repacking floats
  115443. */
  115444. get: function () {
  115445. return this._packedFloat;
  115446. },
  115447. /**
  115448. * Sets wether or not the blur needs to unpack/repack floats
  115449. */
  115450. set: function (v) {
  115451. if (this._packedFloat === v) {
  115452. return;
  115453. }
  115454. this._packedFloat = v;
  115455. if (!this.blockCompilation) {
  115456. this._updateParameters();
  115457. }
  115458. },
  115459. enumerable: true,
  115460. configurable: true
  115461. });
  115462. /**
  115463. * Updates the effect with the current post process compile time values and recompiles the shader.
  115464. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  115465. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  115466. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  115467. * @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
  115468. * @param onCompiled Called when the shader has been compiled.
  115469. * @param onError Called if there is an error when compiling a shader.
  115470. */
  115471. BlurPostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  115472. if (defines === void 0) { defines = null; }
  115473. if (uniforms === void 0) { uniforms = null; }
  115474. if (samplers === void 0) { samplers = null; }
  115475. this._updateParameters(onCompiled, onError);
  115476. };
  115477. BlurPostProcess.prototype._updateParameters = function (onCompiled, onError) {
  115478. // Generate sampling offsets and weights
  115479. var N = this._kernel;
  115480. var centerIndex = (N - 1) / 2;
  115481. // Generate Gaussian sampling weights over kernel
  115482. var offsets = [];
  115483. var weights = [];
  115484. var totalWeight = 0;
  115485. for (var i = 0; i < N; i++) {
  115486. var u = i / (N - 1);
  115487. var w = this._gaussianWeight(u * 2.0 - 1);
  115488. offsets[i] = (i - centerIndex);
  115489. weights[i] = w;
  115490. totalWeight += w;
  115491. }
  115492. // Normalize weights
  115493. for (var i = 0; i < weights.length; i++) {
  115494. weights[i] /= totalWeight;
  115495. }
  115496. // Optimize: combine samples to take advantage of hardware linear sampling
  115497. // Walk from left to center, combining pairs (symmetrically)
  115498. var linearSamplingWeights = [];
  115499. var linearSamplingOffsets = [];
  115500. var linearSamplingMap = [];
  115501. for (var i = 0; i <= centerIndex; i += 2) {
  115502. var j = Math.min(i + 1, Math.floor(centerIndex));
  115503. var singleCenterSample = i === j;
  115504. if (singleCenterSample) {
  115505. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  115506. }
  115507. else {
  115508. var sharedCell = j === centerIndex;
  115509. var weightLinear = (weights[i] + weights[j] * (sharedCell ? .5 : 1.));
  115510. var offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);
  115511. if (offsetLinear === 0) {
  115512. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  115513. linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });
  115514. }
  115515. else {
  115516. linearSamplingMap.push({ o: offsetLinear, w: weightLinear });
  115517. linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });
  115518. }
  115519. }
  115520. }
  115521. for (var i = 0; i < linearSamplingMap.length; i++) {
  115522. linearSamplingOffsets[i] = linearSamplingMap[i].o;
  115523. linearSamplingWeights[i] = linearSamplingMap[i].w;
  115524. }
  115525. // Replace with optimized
  115526. offsets = linearSamplingOffsets;
  115527. weights = linearSamplingWeights;
  115528. // Generate shaders
  115529. var maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors;
  115530. var freeVaryingVec2 = Math.max(maxVaryingRows, 0.) - 1; // Because of sampleCenter
  115531. var varyingCount = Math.min(offsets.length, freeVaryingVec2);
  115532. var defines = "";
  115533. defines += this._staticDefines;
  115534. // The DOF fragment should ignore the center pixel when looping as it is handled manualy in the fragment shader.
  115535. if (this._staticDefines.indexOf("DOF") != -1) {
  115536. defines += "#define CENTER_WEIGHT " + this._glslFloat(weights[varyingCount - 1]) + "\r\n";
  115537. varyingCount--;
  115538. }
  115539. for (var i = 0; i < varyingCount; i++) {
  115540. defines += "#define KERNEL_OFFSET" + i + " " + this._glslFloat(offsets[i]) + "\r\n";
  115541. defines += "#define KERNEL_WEIGHT" + i + " " + this._glslFloat(weights[i]) + "\r\n";
  115542. }
  115543. var depCount = 0;
  115544. for (var i = freeVaryingVec2; i < offsets.length; i++) {
  115545. defines += "#define KERNEL_DEP_OFFSET" + depCount + " " + this._glslFloat(offsets[i]) + "\r\n";
  115546. defines += "#define KERNEL_DEP_WEIGHT" + depCount + " " + this._glslFloat(weights[i]) + "\r\n";
  115547. depCount++;
  115548. }
  115549. if (this.packedFloat) {
  115550. defines += "#define PACKEDFLOAT 1";
  115551. }
  115552. this.blockCompilation = false;
  115553. _super.prototype.updateEffect.call(this, defines, null, null, {
  115554. varyingCount: varyingCount,
  115555. depCount: depCount
  115556. }, onCompiled, onError);
  115557. };
  115558. /**
  115559. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  115560. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  115561. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  115562. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  115563. * The gaps between physical kernels are compensated for in the weighting of the samples
  115564. * @param idealKernel Ideal blur kernel.
  115565. * @return Nearest best kernel.
  115566. */
  115567. BlurPostProcess.prototype._nearestBestKernel = function (idealKernel) {
  115568. var v = Math.round(idealKernel);
  115569. for (var _i = 0, _a = [v, v - 1, v + 1, v - 2, v + 2]; _i < _a.length; _i++) {
  115570. var k = _a[_i];
  115571. if (((k % 2) !== 0) && ((Math.floor(k / 2) % 2) === 0) && k > 0) {
  115572. return Math.max(k, 3);
  115573. }
  115574. }
  115575. return Math.max(v, 3);
  115576. };
  115577. /**
  115578. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  115579. * @param x The point on the Gaussian distribution to sample.
  115580. * @return the value of the Gaussian function at x.
  115581. */
  115582. BlurPostProcess.prototype._gaussianWeight = function (x) {
  115583. //reference: Engines/ImageProcessingBlur.cpp #dcc760
  115584. // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],
  115585. // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.
  115586. // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is
  115587. // truncated at around 1.3% of peak strength.
  115588. //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size
  115589. var sigma = (1 / 3);
  115590. var denominator = Math.sqrt(2.0 * Math.PI) * sigma;
  115591. var exponent = -((x * x) / (2.0 * sigma * sigma));
  115592. var weight = (1.0 / denominator) * Math.exp(exponent);
  115593. return weight;
  115594. };
  115595. /**
  115596. * Generates a string that can be used as a floating point number in GLSL.
  115597. * @param x Value to print.
  115598. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  115599. * @return GLSL float string.
  115600. */
  115601. BlurPostProcess.prototype._glslFloat = function (x, decimalFigures) {
  115602. if (decimalFigures === void 0) { decimalFigures = 8; }
  115603. return x.toFixed(decimalFigures).replace(/0+$/, '');
  115604. };
  115605. return BlurPostProcess;
  115606. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  115607. /***/ }),
  115608. /***/ "./PostProcesses/chromaticAberrationPostProcess.ts":
  115609. /*!*********************************************************!*\
  115610. !*** ./PostProcesses/chromaticAberrationPostProcess.ts ***!
  115611. \*********************************************************/
  115612. /*! exports provided: ChromaticAberrationPostProcess */
  115613. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115614. "use strict";
  115615. __webpack_require__.r(__webpack_exports__);
  115616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return ChromaticAberrationPostProcess; });
  115617. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115618. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  115619. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115620. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  115621. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  115622. /**
  115623. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  115624. */
  115625. var ChromaticAberrationPostProcess = /** @class */ (function (_super) {
  115626. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ChromaticAberrationPostProcess, _super);
  115627. /**
  115628. * Creates a new instance ChromaticAberrationPostProcess
  115629. * @param name The name of the effect.
  115630. * @param screenWidth The width of the screen to apply the effect on.
  115631. * @param screenHeight The height of the screen to apply the effect on.
  115632. * @param options The required width/height ratio to downsize to before computing the render pass.
  115633. * @param camera The camera to apply the render pass to.
  115634. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115635. * @param engine The engine which the post process will be applied. (default: current engine)
  115636. * @param reusable If the post process can be reused on the same frame. (default: false)
  115637. * @param textureType Type of textures used when performing the post process. (default: 0)
  115638. * @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)
  115639. */
  115640. function ChromaticAberrationPostProcess(name, screenWidth, screenHeight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  115641. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  115642. if (blockCompilation === void 0) { blockCompilation = false; }
  115643. 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;
  115644. /**
  115645. * The amount of seperation of rgb channels (default: 30)
  115646. */
  115647. _this.aberrationAmount = 30;
  115648. /**
  115649. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  115650. */
  115651. _this.radialIntensity = 0;
  115652. /**
  115653. * 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))
  115654. */
  115655. _this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.707, 0.707);
  115656. /**
  115657. * 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))
  115658. */
  115659. _this.centerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.5, 0.5);
  115660. _this.onApplyObservable.add(function (effect) {
  115661. effect.setFloat('chromatic_aberration', _this.aberrationAmount);
  115662. effect.setFloat('screen_width', screenWidth);
  115663. effect.setFloat('screen_height', screenHeight);
  115664. effect.setFloat('radialIntensity', _this.radialIntensity);
  115665. effect.setFloat2('direction', _this.direction.x, _this.direction.y);
  115666. effect.setFloat2('centerPosition', _this.centerPosition.x, _this.centerPosition.y);
  115667. });
  115668. return _this;
  115669. }
  115670. return ChromaticAberrationPostProcess;
  115671. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  115672. /***/ }),
  115673. /***/ "./PostProcesses/circleOfConfusionPostProcess.ts":
  115674. /*!*******************************************************!*\
  115675. !*** ./PostProcesses/circleOfConfusionPostProcess.ts ***!
  115676. \*******************************************************/
  115677. /*! exports provided: CircleOfConfusionPostProcess */
  115678. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115679. "use strict";
  115680. __webpack_require__.r(__webpack_exports__);
  115681. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return CircleOfConfusionPostProcess; });
  115682. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115683. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115684. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  115685. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  115686. /* harmony import */ var _Shaders_circleOfConfusion_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/circleOfConfusion.fragment */ "./Shaders/circleOfConfusion.fragment.ts");
  115687. /**
  115688. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  115689. */
  115690. var CircleOfConfusionPostProcess = /** @class */ (function (_super) {
  115691. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleOfConfusionPostProcess, _super);
  115692. /**
  115693. * Creates a new instance CircleOfConfusionPostProcess
  115694. * @param name The name of the effect.
  115695. * @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.
  115696. * @param options The required width/height ratio to downsize to before computing the render pass.
  115697. * @param camera The camera to apply the render pass to.
  115698. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115699. * @param engine The engine which the post process will be applied. (default: current engine)
  115700. * @param reusable If the post process can be reused on the same frame. (default: false)
  115701. * @param textureType Type of textures used when performing the post process. (default: 0)
  115702. * @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)
  115703. */
  115704. function CircleOfConfusionPostProcess(name, depthTexture, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  115705. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  115706. if (blockCompilation === void 0) { blockCompilation = false; }
  115707. var _this = _super.call(this, name, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  115708. /**
  115709. * 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.
  115710. */
  115711. _this.lensSize = 50;
  115712. /**
  115713. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  115714. */
  115715. _this.fStop = 1.4;
  115716. /**
  115717. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  115718. */
  115719. _this.focusDistance = 2000;
  115720. /**
  115721. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  115722. */
  115723. _this.focalLength = 50;
  115724. _this._depthTexture = null;
  115725. _this._depthTexture = depthTexture;
  115726. _this.onApplyObservable.add(function (effect) {
  115727. if (!_this._depthTexture) {
  115728. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("No depth texture set on CircleOfConfusionPostProcess");
  115729. return;
  115730. }
  115731. effect.setTexture("depthSampler", _this._depthTexture);
  115732. // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
  115733. var aperture = _this.lensSize / _this.fStop;
  115734. var cocPrecalculation = ((aperture * _this.focalLength) / ((_this.focusDistance - _this.focalLength))); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]
  115735. effect.setFloat('focusDistance', _this.focusDistance);
  115736. effect.setFloat('cocPrecalculation', cocPrecalculation);
  115737. effect.setFloat2('cameraMinMaxZ', _this._depthTexture.activeCamera.minZ, _this._depthTexture.activeCamera.maxZ);
  115738. });
  115739. return _this;
  115740. }
  115741. Object.defineProperty(CircleOfConfusionPostProcess.prototype, "depthTexture", {
  115742. /**
  115743. * 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.
  115744. */
  115745. set: function (value) {
  115746. this._depthTexture = value;
  115747. },
  115748. enumerable: true,
  115749. configurable: true
  115750. });
  115751. return CircleOfConfusionPostProcess;
  115752. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  115753. /***/ }),
  115754. /***/ "./PostProcesses/colorCorrectionPostProcess.ts":
  115755. /*!*****************************************************!*\
  115756. !*** ./PostProcesses/colorCorrectionPostProcess.ts ***!
  115757. \*****************************************************/
  115758. /*! exports provided: ColorCorrectionPostProcess */
  115759. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115760. "use strict";
  115761. __webpack_require__.r(__webpack_exports__);
  115762. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return ColorCorrectionPostProcess; });
  115763. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115764. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115765. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  115766. /* harmony import */ var _Shaders_colorCorrection_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/colorCorrection.fragment */ "./Shaders/colorCorrection.fragment.ts");
  115767. /**
  115768. *
  115769. * This post-process allows the modification of rendered colors by using
  115770. * a 'look-up table' (LUT). This effect is also called Color Grading.
  115771. *
  115772. * The object needs to be provided an url to a texture containing the color
  115773. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  115774. * Use an image editing software to tweak the LUT to match your needs.
  115775. *
  115776. * For an example of a color LUT, see here:
  115777. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  115778. * For explanations on color grading, see here:
  115779. * @see http://udn.epicgames.com/Three/ColorGrading.html
  115780. *
  115781. */
  115782. var ColorCorrectionPostProcess = /** @class */ (function (_super) {
  115783. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorCorrectionPostProcess, _super);
  115784. function ColorCorrectionPostProcess(name, colorTableUrl, options, camera, samplingMode, engine, reusable) {
  115785. var _this = _super.call(this, name, 'colorCorrection', null, ['colorTable'], options, camera, samplingMode, engine, reusable) || this;
  115786. _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);
  115787. _this._colorTableTexture.anisotropicFilteringLevel = 1;
  115788. _this._colorTableTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  115789. _this._colorTableTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  115790. _this.onApply = function (effect) {
  115791. effect.setTexture("colorTable", _this._colorTableTexture);
  115792. };
  115793. return _this;
  115794. }
  115795. return ColorCorrectionPostProcess;
  115796. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  115797. /***/ }),
  115798. /***/ "./PostProcesses/convolutionPostProcess.ts":
  115799. /*!*************************************************!*\
  115800. !*** ./PostProcesses/convolutionPostProcess.ts ***!
  115801. \*************************************************/
  115802. /*! exports provided: ConvolutionPostProcess */
  115803. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115804. "use strict";
  115805. __webpack_require__.r(__webpack_exports__);
  115806. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return ConvolutionPostProcess; });
  115807. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115808. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  115809. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  115810. /* harmony import */ var _Shaders_convolution_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/convolution.fragment */ "./Shaders/convolution.fragment.ts");
  115811. /**
  115812. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  115813. * input texture to perform effects such as edge detection or sharpening
  115814. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  115815. */
  115816. var ConvolutionPostProcess = /** @class */ (function (_super) {
  115817. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ConvolutionPostProcess, _super);
  115818. /**
  115819. * Creates a new instance ConvolutionPostProcess
  115820. * @param name The name of the effect.
  115821. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  115822. * @param options The required width/height ratio to downsize to before computing the render pass.
  115823. * @param camera The camera to apply the render pass to.
  115824. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115825. * @param engine The engine which the post process will be applied. (default: current engine)
  115826. * @param reusable If the post process can be reused on the same frame. (default: false)
  115827. * @param textureType Type of textures used when performing the post process. (default: 0)
  115828. */
  115829. function ConvolutionPostProcess(name,
  115830. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  115831. kernel, options, camera, samplingMode, engine, reusable, textureType) {
  115832. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  115833. var _this = _super.call(this, name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  115834. _this.kernel = kernel;
  115835. _this.onApply = function (effect) {
  115836. effect.setFloat2("screenSize", _this.width, _this.height);
  115837. effect.setArray("kernel", _this.kernel);
  115838. };
  115839. return _this;
  115840. }
  115841. // Statics
  115842. /**
  115843. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  115844. */
  115845. ConvolutionPostProcess.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
  115846. /**
  115847. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  115848. */
  115849. ConvolutionPostProcess.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
  115850. /**
  115851. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  115852. */
  115853. ConvolutionPostProcess.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
  115854. /**
  115855. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  115856. */
  115857. ConvolutionPostProcess.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
  115858. /**
  115859. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  115860. */
  115861. ConvolutionPostProcess.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
  115862. /**
  115863. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  115864. */
  115865. ConvolutionPostProcess.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
  115866. return ConvolutionPostProcess;
  115867. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  115868. /***/ }),
  115869. /***/ "./PostProcesses/depthOfFieldBlurPostProcess.ts":
  115870. /*!******************************************************!*\
  115871. !*** ./PostProcesses/depthOfFieldBlurPostProcess.ts ***!
  115872. \******************************************************/
  115873. /*! exports provided: DepthOfFieldBlurPostProcess */
  115874. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115875. "use strict";
  115876. __webpack_require__.r(__webpack_exports__);
  115877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return DepthOfFieldBlurPostProcess; });
  115878. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115879. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  115880. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  115881. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  115882. /**
  115883. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  115884. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  115885. * based on samples that have a large difference in distance than the center pixel.
  115886. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  115887. */
  115888. var DepthOfFieldBlurPostProcess = /** @class */ (function (_super) {
  115889. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldBlurPostProcess, _super);
  115890. /**
  115891. * Creates a new instance CircleOfConfusionPostProcess
  115892. * @param name The name of the effect.
  115893. * @param scene The scene the effect belongs to.
  115894. * @param direction The direction the blur should be applied.
  115895. * @param kernel The size of the kernel used to blur.
  115896. * @param options The required width/height ratio to downsize to before computing the render pass.
  115897. * @param camera The camera to apply the render pass to.
  115898. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  115899. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  115900. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115901. * @param engine The engine which the post process will be applied. (default: current engine)
  115902. * @param reusable If the post process can be reused on the same frame. (default: false)
  115903. * @param textureType Type of textures used when performing the post process. (default: 0)
  115904. * @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)
  115905. */
  115906. function DepthOfFieldBlurPostProcess(name, scene, direction, kernel, options, camera, circleOfConfusion, imageToBlur, samplingMode, engine, reusable, textureType, blockCompilation) {
  115907. if (imageToBlur === void 0) { imageToBlur = null; }
  115908. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  115909. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  115910. if (blockCompilation === void 0) { blockCompilation = false; }
  115911. 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;
  115912. _this.direction = direction;
  115913. _this.onApplyObservable.add(function (effect) {
  115914. if (imageToBlur != null) {
  115915. effect.setTextureFromPostProcess("textureSampler", imageToBlur);
  115916. }
  115917. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  115918. if (scene.activeCamera) {
  115919. effect.setFloat2('cameraMinMaxZ', scene.activeCamera.minZ, scene.activeCamera.maxZ);
  115920. }
  115921. });
  115922. return _this;
  115923. }
  115924. return DepthOfFieldBlurPostProcess;
  115925. }(_blurPostProcess__WEBPACK_IMPORTED_MODULE_2__["BlurPostProcess"]));
  115926. /***/ }),
  115927. /***/ "./PostProcesses/depthOfFieldEffect.ts":
  115928. /*!*********************************************!*\
  115929. !*** ./PostProcesses/depthOfFieldEffect.ts ***!
  115930. \*********************************************/
  115931. /*! exports provided: DepthOfFieldEffectBlurLevel, DepthOfFieldEffect */
  115932. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115933. "use strict";
  115934. __webpack_require__.r(__webpack_exports__);
  115935. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return DepthOfFieldEffectBlurLevel; });
  115936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return DepthOfFieldEffect; });
  115937. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115938. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  115939. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  115940. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  115941. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  115942. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  115943. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  115944. /**
  115945. * Specifies the level of max blur that should be applied when using the depth of field effect
  115946. */
  115947. var DepthOfFieldEffectBlurLevel;
  115948. (function (DepthOfFieldEffectBlurLevel) {
  115949. /**
  115950. * Subtle blur
  115951. */
  115952. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Low"] = 0] = "Low";
  115953. /**
  115954. * Medium blur
  115955. */
  115956. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Medium"] = 1] = "Medium";
  115957. /**
  115958. * Large blur
  115959. */
  115960. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["High"] = 2] = "High";
  115961. })(DepthOfFieldEffectBlurLevel || (DepthOfFieldEffectBlurLevel = {}));
  115962. /**
  115963. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  115964. */
  115965. var DepthOfFieldEffect = /** @class */ (function (_super) {
  115966. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldEffect, _super);
  115967. /**
  115968. * Creates a new instance DepthOfFieldEffect
  115969. * @param scene The scene the effect belongs to.
  115970. * @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.
  115971. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  115972. * @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)
  115973. */
  115974. function DepthOfFieldEffect(scene, depthTexture, blurLevel, pipelineTextureType, blockCompilation) {
  115975. if (blurLevel === void 0) { blurLevel = DepthOfFieldEffectBlurLevel.Low; }
  115976. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  115977. if (blockCompilation === void 0) { blockCompilation = false; }
  115978. var _this = _super.call(this, scene.getEngine(), "depth of field", function () {
  115979. return _this._effects;
  115980. }, true) || this;
  115981. /**
  115982. * @hidden Internal post processes in depth of field effect
  115983. */
  115984. _this._effects = [];
  115985. // Circle of confusion value for each pixel is used to determine how much to blur that pixel
  115986. _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);
  115987. // 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)
  115988. // Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts
  115989. // See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  115990. _this._depthOfFieldBlurY = [];
  115991. _this._depthOfFieldBlurX = [];
  115992. var blurCount = 1;
  115993. var kernelSize = 15;
  115994. switch (blurLevel) {
  115995. case DepthOfFieldEffectBlurLevel.High: {
  115996. blurCount = 3;
  115997. kernelSize = 51;
  115998. break;
  115999. }
  116000. case DepthOfFieldEffectBlurLevel.Medium: {
  116001. blurCount = 2;
  116002. kernelSize = 31;
  116003. break;
  116004. }
  116005. default: {
  116006. kernelSize = 15;
  116007. blurCount = 1;
  116008. break;
  116009. }
  116010. }
  116011. var adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);
  116012. var ratio = 1.0;
  116013. for (var i = 0; i < blurCount; i++) {
  116014. 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);
  116015. blurY.autoClear = false;
  116016. ratio = 0.75 / Math.pow(2, i);
  116017. 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);
  116018. blurX.autoClear = false;
  116019. _this._depthOfFieldBlurY.push(blurY);
  116020. _this._depthOfFieldBlurX.push(blurX);
  116021. }
  116022. // Set all post processes on the effect.
  116023. _this._effects = [_this._circleOfConfusion];
  116024. for (var i = 0; i < _this._depthOfFieldBlurX.length; i++) {
  116025. _this._effects.push(_this._depthOfFieldBlurY[i]);
  116026. _this._effects.push(_this._depthOfFieldBlurX[i]);
  116027. }
  116028. // Merge blurred images with original image based on circleOfConfusion
  116029. _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);
  116030. _this._dofMerge.autoClear = false;
  116031. _this._effects.push(_this._dofMerge);
  116032. return _this;
  116033. }
  116034. Object.defineProperty(DepthOfFieldEffect.prototype, "focalLength", {
  116035. get: function () {
  116036. return this._circleOfConfusion.focalLength;
  116037. },
  116038. /**
  116039. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  116040. */
  116041. set: function (value) {
  116042. this._circleOfConfusion.focalLength = value;
  116043. },
  116044. enumerable: true,
  116045. configurable: true
  116046. });
  116047. Object.defineProperty(DepthOfFieldEffect.prototype, "fStop", {
  116048. get: function () {
  116049. return this._circleOfConfusion.fStop;
  116050. },
  116051. /**
  116052. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  116053. */
  116054. set: function (value) {
  116055. this._circleOfConfusion.fStop = value;
  116056. },
  116057. enumerable: true,
  116058. configurable: true
  116059. });
  116060. Object.defineProperty(DepthOfFieldEffect.prototype, "focusDistance", {
  116061. get: function () {
  116062. return this._circleOfConfusion.focusDistance;
  116063. },
  116064. /**
  116065. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  116066. */
  116067. set: function (value) {
  116068. this._circleOfConfusion.focusDistance = value;
  116069. },
  116070. enumerable: true,
  116071. configurable: true
  116072. });
  116073. Object.defineProperty(DepthOfFieldEffect.prototype, "lensSize", {
  116074. get: function () {
  116075. return this._circleOfConfusion.lensSize;
  116076. },
  116077. /**
  116078. * 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.
  116079. */
  116080. set: function (value) {
  116081. this._circleOfConfusion.lensSize = value;
  116082. },
  116083. enumerable: true,
  116084. configurable: true
  116085. });
  116086. Object.defineProperty(DepthOfFieldEffect.prototype, "depthTexture", {
  116087. /**
  116088. * 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.
  116089. */
  116090. set: function (value) {
  116091. this._circleOfConfusion.depthTexture = value;
  116092. },
  116093. enumerable: true,
  116094. configurable: true
  116095. });
  116096. /**
  116097. * Disposes each of the internal effects for a given camera.
  116098. * @param camera The camera to dispose the effect on.
  116099. */
  116100. DepthOfFieldEffect.prototype.disposeEffects = function (camera) {
  116101. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116102. this._effects[effectIndex].dispose(camera);
  116103. }
  116104. };
  116105. /**
  116106. * @hidden Internal
  116107. */
  116108. DepthOfFieldEffect.prototype._updateEffects = function () {
  116109. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116110. this._effects[effectIndex].updateEffect();
  116111. }
  116112. };
  116113. /**
  116114. * Internal
  116115. * @returns if all the contained post processes are ready.
  116116. * @hidden
  116117. */
  116118. DepthOfFieldEffect.prototype._isReady = function () {
  116119. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  116120. if (!this._effects[effectIndex].isReady()) {
  116121. return false;
  116122. }
  116123. }
  116124. return true;
  116125. };
  116126. return DepthOfFieldEffect;
  116127. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderEffect"]));
  116128. /***/ }),
  116129. /***/ "./PostProcesses/depthOfFieldMergePostProcess.ts":
  116130. /*!*******************************************************!*\
  116131. !*** ./PostProcesses/depthOfFieldMergePostProcess.ts ***!
  116132. \*******************************************************/
  116133. /*! exports provided: DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess */
  116134. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116135. "use strict";
  116136. __webpack_require__.r(__webpack_exports__);
  116137. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return DepthOfFieldMergePostProcessOptions; });
  116138. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return DepthOfFieldMergePostProcess; });
  116139. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116140. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116141. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116142. /* harmony import */ var _Shaders_depthOfFieldMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/depthOfFieldMerge.fragment */ "./Shaders/depthOfFieldMerge.fragment.ts");
  116143. /**
  116144. * Options to be set when merging outputs from the default pipeline.
  116145. */
  116146. var DepthOfFieldMergePostProcessOptions = /** @class */ (function () {
  116147. function DepthOfFieldMergePostProcessOptions() {
  116148. }
  116149. return DepthOfFieldMergePostProcessOptions;
  116150. }());
  116151. /**
  116152. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  116153. */
  116154. var DepthOfFieldMergePostProcess = /** @class */ (function (_super) {
  116155. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldMergePostProcess, _super);
  116156. /**
  116157. * Creates a new instance of DepthOfFieldMergePostProcess
  116158. * @param name The name of the effect.
  116159. * @param originalFromInput Post process which's input will be used for the merge.
  116160. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  116161. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  116162. * @param options The required width/height ratio to downsize to before computing the render pass.
  116163. * @param camera The camera to apply the render pass to.
  116164. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116165. * @param engine The engine which the post process will be applied. (default: current engine)
  116166. * @param reusable If the post process can be reused on the same frame. (default: false)
  116167. * @param textureType Type of textures used when performing the post process. (default: 0)
  116168. * @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)
  116169. */
  116170. function DepthOfFieldMergePostProcess(name, originalFromInput, circleOfConfusion, blurSteps, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116171. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116172. if (blockCompilation === void 0) { blockCompilation = false; }
  116173. var _this = _super.call(this, name, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  116174. _this.blurSteps = blurSteps;
  116175. _this.onApplyObservable.add(function (effect) {
  116176. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  116177. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  116178. blurSteps.forEach(function (step, index) {
  116179. effect.setTextureFromPostProcessOutput("blurStep" + (blurSteps.length - index - 1), step);
  116180. });
  116181. });
  116182. if (!blockCompilation) {
  116183. _this.updateEffect();
  116184. }
  116185. return _this;
  116186. }
  116187. /**
  116188. * Updates the effect with the current post process compile time values and recompiles the shader.
  116189. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  116190. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  116191. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  116192. * @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
  116193. * @param onCompiled Called when the shader has been compiled.
  116194. * @param onError Called if there is an error when compiling a shader.
  116195. */
  116196. DepthOfFieldMergePostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  116197. if (defines === void 0) { defines = null; }
  116198. if (uniforms === void 0) { uniforms = null; }
  116199. if (samplers === void 0) { samplers = null; }
  116200. if (!defines) {
  116201. defines = "";
  116202. defines += "#define BLUR_LEVEL " + (this.blurSteps.length - 1) + "\n";
  116203. }
  116204. _super.prototype.updateEffect.call(this, defines, uniforms, samplers, indexParameters, onCompiled, onError);
  116205. };
  116206. return DepthOfFieldMergePostProcess;
  116207. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116208. /***/ }),
  116209. /***/ "./PostProcesses/displayPassPostProcess.ts":
  116210. /*!*************************************************!*\
  116211. !*** ./PostProcesses/displayPassPostProcess.ts ***!
  116212. \*************************************************/
  116213. /*! exports provided: DisplayPassPostProcess */
  116214. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116215. "use strict";
  116216. __webpack_require__.r(__webpack_exports__);
  116217. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return DisplayPassPostProcess; });
  116218. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116219. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116220. /* harmony import */ var _Shaders_displayPass_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/displayPass.fragment */ "./Shaders/displayPass.fragment.ts");
  116221. /**
  116222. * DisplayPassPostProcess which produces an output the same as it's input
  116223. */
  116224. var DisplayPassPostProcess = /** @class */ (function (_super) {
  116225. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayPassPostProcess, _super);
  116226. /**
  116227. * Creates the DisplayPassPostProcess
  116228. * @param name The name of the effect.
  116229. * @param options The required width/height ratio to downsize to before computing the render pass.
  116230. * @param camera The camera to apply the render pass to.
  116231. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116232. * @param engine The engine which the post process will be applied. (default: current engine)
  116233. * @param reusable If the post process can be reused on the same frame. (default: false)
  116234. */
  116235. function DisplayPassPostProcess(name, options, camera, samplingMode, engine, reusable) {
  116236. return _super.call(this, name, "displayPass", ["passSampler"], ["passSampler"], options, camera, samplingMode, engine, reusable) || this;
  116237. }
  116238. return DisplayPassPostProcess;
  116239. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116240. /***/ }),
  116241. /***/ "./PostProcesses/extractHighlightsPostProcess.ts":
  116242. /*!*******************************************************!*\
  116243. !*** ./PostProcesses/extractHighlightsPostProcess.ts ***!
  116244. \*******************************************************/
  116245. /*! exports provided: ExtractHighlightsPostProcess */
  116246. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116247. "use strict";
  116248. __webpack_require__.r(__webpack_exports__);
  116249. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return ExtractHighlightsPostProcess; });
  116250. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116251. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116252. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116253. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116254. /* harmony import */ var _Shaders_extractHighlights_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/extractHighlights.fragment */ "./Shaders/extractHighlights.fragment.ts");
  116255. /**
  116256. * 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.
  116257. */
  116258. var ExtractHighlightsPostProcess = /** @class */ (function (_super) {
  116259. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExtractHighlightsPostProcess, _super);
  116260. function ExtractHighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116261. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116262. if (blockCompilation === void 0) { blockCompilation = false; }
  116263. var _this = _super.call(this, name, "extractHighlights", ["threshold", "exposure"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  116264. /**
  116265. * The luminance threshold, pixels below this value will be set to black.
  116266. */
  116267. _this.threshold = 0.9;
  116268. /** @hidden */
  116269. _this._exposure = 1;
  116270. /**
  116271. * Post process which has the input texture to be used when performing highlight extraction
  116272. * @hidden
  116273. */
  116274. _this._inputPostProcess = null;
  116275. _this.onApplyObservable.add(function (effect) {
  116276. if (_this._inputPostProcess) {
  116277. effect.setTextureFromPostProcess("textureSampler", _this._inputPostProcess);
  116278. }
  116279. effect.setFloat('threshold', Math.pow(_this.threshold, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["ToGammaSpace"]));
  116280. effect.setFloat('exposure', _this._exposure);
  116281. });
  116282. return _this;
  116283. }
  116284. return ExtractHighlightsPostProcess;
  116285. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116286. /***/ }),
  116287. /***/ "./PostProcesses/filterPostProcess.ts":
  116288. /*!********************************************!*\
  116289. !*** ./PostProcesses/filterPostProcess.ts ***!
  116290. \********************************************/
  116291. /*! exports provided: FilterPostProcess */
  116292. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116293. "use strict";
  116294. __webpack_require__.r(__webpack_exports__);
  116295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return FilterPostProcess; });
  116296. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116297. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116298. /* harmony import */ var _Shaders_filter_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/filter.fragment */ "./Shaders/filter.fragment.ts");
  116299. /**
  116300. * Applies a kernel filter to the image
  116301. */
  116302. var FilterPostProcess = /** @class */ (function (_super) {
  116303. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FilterPostProcess, _super);
  116304. /**
  116305. *
  116306. * @param name The name of the effect.
  116307. * @param kernelMatrix The matrix to be applied to the image
  116308. * @param options The required width/height ratio to downsize to before computing the render pass.
  116309. * @param camera The camera to apply the render pass to.
  116310. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116311. * @param engine The engine which the post process will be applied. (default: current engine)
  116312. * @param reusable If the post process can be reused on the same frame. (default: false)
  116313. */
  116314. function FilterPostProcess(name,
  116315. /** The matrix to be applied to the image */
  116316. kernelMatrix, options, camera, samplingMode, engine, reusable) {
  116317. var _this = _super.call(this, name, "filter", ["kernelMatrix"], null, options, camera, samplingMode, engine, reusable) || this;
  116318. _this.kernelMatrix = kernelMatrix;
  116319. _this.onApply = function (effect) {
  116320. effect.setMatrix("kernelMatrix", _this.kernelMatrix);
  116321. };
  116322. return _this;
  116323. }
  116324. return FilterPostProcess;
  116325. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116326. /***/ }),
  116327. /***/ "./PostProcesses/fxaaPostProcess.ts":
  116328. /*!******************************************!*\
  116329. !*** ./PostProcesses/fxaaPostProcess.ts ***!
  116330. \******************************************/
  116331. /*! exports provided: FxaaPostProcess */
  116332. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116333. "use strict";
  116334. __webpack_require__.r(__webpack_exports__);
  116335. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return FxaaPostProcess; });
  116336. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116337. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  116338. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116339. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116340. /* harmony import */ var _Shaders_fxaa_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/fxaa.fragment */ "./Shaders/fxaa.fragment.ts");
  116341. /* harmony import */ var _Shaders_fxaa_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/fxaa.vertex */ "./Shaders/fxaa.vertex.ts");
  116342. /**
  116343. * Fxaa post process
  116344. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  116345. */
  116346. var FxaaPostProcess = /** @class */ (function (_super) {
  116347. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FxaaPostProcess, _super);
  116348. function FxaaPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  116349. if (camera === void 0) { camera = null; }
  116350. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116351. 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;
  116352. var defines = _this._getDefines();
  116353. _this.updateEffect(defines);
  116354. _this.onApplyObservable.add(function (effect) {
  116355. var texelSize = _this.texelSize;
  116356. effect.setFloat2("texelSize", texelSize.x, texelSize.y);
  116357. });
  116358. return _this;
  116359. }
  116360. FxaaPostProcess.prototype._getDefines = function () {
  116361. var engine = this.getEngine();
  116362. if (!engine) {
  116363. return null;
  116364. }
  116365. var glInfo = engine.getGlInfo();
  116366. if (glInfo && glInfo.renderer && glInfo.renderer.toLowerCase().indexOf("mali") > -1) {
  116367. return "#define MALI 1\n";
  116368. }
  116369. return null;
  116370. };
  116371. return FxaaPostProcess;
  116372. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  116373. /***/ }),
  116374. /***/ "./PostProcesses/grainPostProcess.ts":
  116375. /*!*******************************************!*\
  116376. !*** ./PostProcesses/grainPostProcess.ts ***!
  116377. \*******************************************/
  116378. /*! exports provided: GrainPostProcess */
  116379. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116380. "use strict";
  116381. __webpack_require__.r(__webpack_exports__);
  116382. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return GrainPostProcess; });
  116383. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116384. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116385. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116386. /* harmony import */ var _Shaders_grain_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/grain.fragment */ "./Shaders/grain.fragment.ts");
  116387. /**
  116388. * The GrainPostProcess adds noise to the image at mid luminance levels
  116389. */
  116390. var GrainPostProcess = /** @class */ (function (_super) {
  116391. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GrainPostProcess, _super);
  116392. /**
  116393. * Creates a new instance of @see GrainPostProcess
  116394. * @param name The name of the effect.
  116395. * @param options The required width/height ratio to downsize to before computing the render pass.
  116396. * @param camera The camera to apply the render pass to.
  116397. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116398. * @param engine The engine which the post process will be applied. (default: current engine)
  116399. * @param reusable If the post process can be reused on the same frame. (default: false)
  116400. * @param textureType Type of textures used when performing the post process. (default: 0)
  116401. * @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)
  116402. */
  116403. function GrainPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  116404. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116405. if (blockCompilation === void 0) { blockCompilation = false; }
  116406. var _this = _super.call(this, name, "grain", ["intensity", "animatedSeed"], [], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  116407. /**
  116408. * The intensity of the grain added (default: 30)
  116409. */
  116410. _this.intensity = 30;
  116411. /**
  116412. * If the grain should be randomized on every frame
  116413. */
  116414. _this.animated = false;
  116415. _this.onApplyObservable.add(function (effect) {
  116416. effect.setFloat('intensity', _this.intensity);
  116417. effect.setFloat('animatedSeed', _this.animated ? Math.random() + 1 : 1);
  116418. });
  116419. return _this;
  116420. }
  116421. return GrainPostProcess;
  116422. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116423. /***/ }),
  116424. /***/ "./PostProcesses/highlightsPostProcess.ts":
  116425. /*!************************************************!*\
  116426. !*** ./PostProcesses/highlightsPostProcess.ts ***!
  116427. \************************************************/
  116428. /*! exports provided: HighlightsPostProcess */
  116429. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116430. "use strict";
  116431. __webpack_require__.r(__webpack_exports__);
  116432. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return HighlightsPostProcess; });
  116433. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116434. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116435. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116436. /* harmony import */ var _Shaders_highlights_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/highlights.fragment */ "./Shaders/highlights.fragment.ts");
  116437. /**
  116438. * Extracts highlights from the image
  116439. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  116440. */
  116441. var HighlightsPostProcess = /** @class */ (function (_super) {
  116442. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightsPostProcess, _super);
  116443. /**
  116444. * Extracts highlights from the image
  116445. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  116446. * @param name The name of the effect.
  116447. * @param options The required width/height ratio to downsize to before computing the render pass.
  116448. * @param camera The camera to apply the render pass to.
  116449. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116450. * @param engine The engine which the post process will be applied. (default: current engine)
  116451. * @param reusable If the post process can be reused on the same frame. (default: false)
  116452. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  116453. */
  116454. function HighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  116455. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116456. return _super.call(this, name, "highlights", null, null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  116457. }
  116458. return HighlightsPostProcess;
  116459. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  116460. /***/ }),
  116461. /***/ "./PostProcesses/imageProcessingPostProcess.ts":
  116462. /*!*****************************************************!*\
  116463. !*** ./PostProcesses/imageProcessingPostProcess.ts ***!
  116464. \*****************************************************/
  116465. /*! exports provided: ImageProcessingPostProcess */
  116466. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116467. "use strict";
  116468. __webpack_require__.r(__webpack_exports__);
  116469. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return ImageProcessingPostProcess; });
  116470. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116471. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  116472. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  116473. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116474. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  116475. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116476. /* harmony import */ var _Shaders_imageProcessing_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/imageProcessing.fragment */ "./Shaders/imageProcessing.fragment.ts");
  116477. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  116478. /**
  116479. * ImageProcessingPostProcess
  116480. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  116481. */
  116482. var ImageProcessingPostProcess = /** @class */ (function (_super) {
  116483. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingPostProcess, _super);
  116484. function ImageProcessingPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, imageProcessingConfiguration) {
  116485. if (camera === void 0) { camera = null; }
  116486. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  116487. var _this = _super.call(this, name, "imageProcessing", [], [], options, camera, samplingMode, engine, reusable, null, textureType, "postprocess", null, true) || this;
  116488. _this._fromLinearSpace = true;
  116489. /**
  116490. * Defines cache preventing GC.
  116491. */
  116492. _this._defines = {
  116493. IMAGEPROCESSING: false,
  116494. VIGNETTE: false,
  116495. VIGNETTEBLENDMODEMULTIPLY: false,
  116496. VIGNETTEBLENDMODEOPAQUE: false,
  116497. TONEMAPPING: false,
  116498. TONEMAPPING_ACES: false,
  116499. CONTRAST: false,
  116500. COLORCURVES: false,
  116501. COLORGRADING: false,
  116502. COLORGRADING3D: false,
  116503. FROMLINEARSPACE: false,
  116504. SAMPLER3DGREENDEPTH: false,
  116505. SAMPLER3DBGRMAP: false,
  116506. IMAGEPROCESSINGPOSTPROCESS: false,
  116507. EXPOSURE: false,
  116508. };
  116509. // Setup the configuration as forced by the constructor. This would then not force the
  116510. // scene materials output in linear space and let untouched the default forward pass.
  116511. if (imageProcessingConfiguration) {
  116512. imageProcessingConfiguration.applyByPostProcess = true;
  116513. _this._attachImageProcessingConfiguration(imageProcessingConfiguration, true);
  116514. // This will cause the shader to be compiled
  116515. _this.fromLinearSpace = false;
  116516. }
  116517. // Setup the default processing configuration to the scene.
  116518. else {
  116519. _this._attachImageProcessingConfiguration(null, true);
  116520. _this.imageProcessingConfiguration.applyByPostProcess = true;
  116521. }
  116522. _this.onApply = function (effect) {
  116523. _this.imageProcessingConfiguration.bind(effect, _this.aspectRatio);
  116524. };
  116525. return _this;
  116526. }
  116527. Object.defineProperty(ImageProcessingPostProcess.prototype, "imageProcessingConfiguration", {
  116528. /**
  116529. * Gets the image processing configuration used either in this material.
  116530. */
  116531. get: function () {
  116532. return this._imageProcessingConfiguration;
  116533. },
  116534. /**
  116535. * Sets the Default image processing configuration used either in the this material.
  116536. *
  116537. * If sets to null, the scene one is in use.
  116538. */
  116539. set: function (value) {
  116540. this._attachImageProcessingConfiguration(value);
  116541. },
  116542. enumerable: true,
  116543. configurable: true
  116544. });
  116545. /**
  116546. * Attaches a new image processing configuration to the PBR Material.
  116547. * @param configuration
  116548. */
  116549. ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration, doNotBuild) {
  116550. var _this = this;
  116551. if (doNotBuild === void 0) { doNotBuild = false; }
  116552. if (configuration === this._imageProcessingConfiguration) {
  116553. return;
  116554. }
  116555. // Detaches observer.
  116556. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  116557. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  116558. }
  116559. // Pick the scene configuration if needed.
  116560. if (!configuration) {
  116561. var scene = null;
  116562. var engine = this.getEngine();
  116563. var camera = this.getCamera();
  116564. if (camera) {
  116565. scene = camera.getScene();
  116566. }
  116567. else if (engine && engine.scenes) {
  116568. var scenes = engine.scenes;
  116569. scene = scenes[scenes.length - 1];
  116570. }
  116571. else {
  116572. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  116573. }
  116574. this._imageProcessingConfiguration = scene.imageProcessingConfiguration;
  116575. }
  116576. else {
  116577. this._imageProcessingConfiguration = configuration;
  116578. }
  116579. // Attaches observer.
  116580. if (this._imageProcessingConfiguration) {
  116581. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  116582. _this._updateParameters();
  116583. });
  116584. }
  116585. // Ensure the effect will be rebuilt.
  116586. if (!doNotBuild) {
  116587. this._updateParameters();
  116588. }
  116589. };
  116590. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurves", {
  116591. /**
  116592. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  116593. */
  116594. get: function () {
  116595. return this.imageProcessingConfiguration.colorCurves;
  116596. },
  116597. /**
  116598. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  116599. */
  116600. set: function (value) {
  116601. this.imageProcessingConfiguration.colorCurves = value;
  116602. },
  116603. enumerable: true,
  116604. configurable: true
  116605. });
  116606. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurvesEnabled", {
  116607. /**
  116608. * Gets wether the color curves effect is enabled.
  116609. */
  116610. get: function () {
  116611. return this.imageProcessingConfiguration.colorCurvesEnabled;
  116612. },
  116613. /**
  116614. * Sets wether the color curves effect is enabled.
  116615. */
  116616. set: function (value) {
  116617. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  116618. },
  116619. enumerable: true,
  116620. configurable: true
  116621. });
  116622. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingTexture", {
  116623. /**
  116624. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  116625. */
  116626. get: function () {
  116627. return this.imageProcessingConfiguration.colorGradingTexture;
  116628. },
  116629. /**
  116630. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  116631. */
  116632. set: function (value) {
  116633. this.imageProcessingConfiguration.colorGradingTexture = value;
  116634. },
  116635. enumerable: true,
  116636. configurable: true
  116637. });
  116638. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingEnabled", {
  116639. /**
  116640. * Gets wether the color grading effect is enabled.
  116641. */
  116642. get: function () {
  116643. return this.imageProcessingConfiguration.colorGradingEnabled;
  116644. },
  116645. /**
  116646. * Gets wether the color grading effect is enabled.
  116647. */
  116648. set: function (value) {
  116649. this.imageProcessingConfiguration.colorGradingEnabled = value;
  116650. },
  116651. enumerable: true,
  116652. configurable: true
  116653. });
  116654. Object.defineProperty(ImageProcessingPostProcess.prototype, "exposure", {
  116655. /**
  116656. * Gets exposure used in the effect.
  116657. */
  116658. get: function () {
  116659. return this.imageProcessingConfiguration.exposure;
  116660. },
  116661. /**
  116662. * Sets exposure used in the effect.
  116663. */
  116664. set: function (value) {
  116665. this.imageProcessingConfiguration.exposure = value;
  116666. },
  116667. enumerable: true,
  116668. configurable: true
  116669. });
  116670. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingEnabled", {
  116671. /**
  116672. * Gets wether tonemapping is enabled or not.
  116673. */
  116674. get: function () {
  116675. return this._imageProcessingConfiguration.toneMappingEnabled;
  116676. },
  116677. /**
  116678. * Sets wether tonemapping is enabled or not
  116679. */
  116680. set: function (value) {
  116681. this._imageProcessingConfiguration.toneMappingEnabled = value;
  116682. },
  116683. enumerable: true,
  116684. configurable: true
  116685. });
  116686. Object.defineProperty(ImageProcessingPostProcess.prototype, "contrast", {
  116687. /**
  116688. * Gets contrast used in the effect.
  116689. */
  116690. get: function () {
  116691. return this.imageProcessingConfiguration.contrast;
  116692. },
  116693. /**
  116694. * Sets contrast used in the effect.
  116695. */
  116696. set: function (value) {
  116697. this.imageProcessingConfiguration.contrast = value;
  116698. },
  116699. enumerable: true,
  116700. configurable: true
  116701. });
  116702. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteStretch", {
  116703. /**
  116704. * Gets Vignette stretch size.
  116705. */
  116706. get: function () {
  116707. return this.imageProcessingConfiguration.vignetteStretch;
  116708. },
  116709. /**
  116710. * Sets Vignette stretch size.
  116711. */
  116712. set: function (value) {
  116713. this.imageProcessingConfiguration.vignetteStretch = value;
  116714. },
  116715. enumerable: true,
  116716. configurable: true
  116717. });
  116718. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreX", {
  116719. /**
  116720. * Gets Vignette centre X Offset.
  116721. */
  116722. get: function () {
  116723. return this.imageProcessingConfiguration.vignetteCentreX;
  116724. },
  116725. /**
  116726. * Sets Vignette centre X Offset.
  116727. */
  116728. set: function (value) {
  116729. this.imageProcessingConfiguration.vignetteCentreX = value;
  116730. },
  116731. enumerable: true,
  116732. configurable: true
  116733. });
  116734. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreY", {
  116735. /**
  116736. * Gets Vignette centre Y Offset.
  116737. */
  116738. get: function () {
  116739. return this.imageProcessingConfiguration.vignetteCentreY;
  116740. },
  116741. /**
  116742. * Sets Vignette centre Y Offset.
  116743. */
  116744. set: function (value) {
  116745. this.imageProcessingConfiguration.vignetteCentreY = value;
  116746. },
  116747. enumerable: true,
  116748. configurable: true
  116749. });
  116750. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteWeight", {
  116751. /**
  116752. * Gets Vignette weight or intensity of the vignette effect.
  116753. */
  116754. get: function () {
  116755. return this.imageProcessingConfiguration.vignetteWeight;
  116756. },
  116757. /**
  116758. * Sets Vignette weight or intensity of the vignette effect.
  116759. */
  116760. set: function (value) {
  116761. this.imageProcessingConfiguration.vignetteWeight = value;
  116762. },
  116763. enumerable: true,
  116764. configurable: true
  116765. });
  116766. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteColor", {
  116767. /**
  116768. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116769. * if vignetteEnabled is set to true.
  116770. */
  116771. get: function () {
  116772. return this.imageProcessingConfiguration.vignetteColor;
  116773. },
  116774. /**
  116775. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116776. * if vignetteEnabled is set to true.
  116777. */
  116778. set: function (value) {
  116779. this.imageProcessingConfiguration.vignetteColor = value;
  116780. },
  116781. enumerable: true,
  116782. configurable: true
  116783. });
  116784. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCameraFov", {
  116785. /**
  116786. * Gets Camera field of view used by the Vignette effect.
  116787. */
  116788. get: function () {
  116789. return this.imageProcessingConfiguration.vignetteCameraFov;
  116790. },
  116791. /**
  116792. * Sets Camera field of view used by the Vignette effect.
  116793. */
  116794. set: function (value) {
  116795. this.imageProcessingConfiguration.vignetteCameraFov = value;
  116796. },
  116797. enumerable: true,
  116798. configurable: true
  116799. });
  116800. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteBlendMode", {
  116801. /**
  116802. * Gets the vignette blend mode allowing different kind of effect.
  116803. */
  116804. get: function () {
  116805. return this.imageProcessingConfiguration.vignetteBlendMode;
  116806. },
  116807. /**
  116808. * Sets the vignette blend mode allowing different kind of effect.
  116809. */
  116810. set: function (value) {
  116811. this.imageProcessingConfiguration.vignetteBlendMode = value;
  116812. },
  116813. enumerable: true,
  116814. configurable: true
  116815. });
  116816. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteEnabled", {
  116817. /**
  116818. * Gets wether the vignette effect is enabled.
  116819. */
  116820. get: function () {
  116821. return this.imageProcessingConfiguration.vignetteEnabled;
  116822. },
  116823. /**
  116824. * Sets wether the vignette effect is enabled.
  116825. */
  116826. set: function (value) {
  116827. this.imageProcessingConfiguration.vignetteEnabled = value;
  116828. },
  116829. enumerable: true,
  116830. configurable: true
  116831. });
  116832. Object.defineProperty(ImageProcessingPostProcess.prototype, "fromLinearSpace", {
  116833. /**
  116834. * Gets wether the input of the processing is in Gamma or Linear Space.
  116835. */
  116836. get: function () {
  116837. return this._fromLinearSpace;
  116838. },
  116839. /**
  116840. * Sets wether the input of the processing is in Gamma or Linear Space.
  116841. */
  116842. set: function (value) {
  116843. if (this._fromLinearSpace === value) {
  116844. return;
  116845. }
  116846. this._fromLinearSpace = value;
  116847. this._updateParameters();
  116848. },
  116849. enumerable: true,
  116850. configurable: true
  116851. });
  116852. /**
  116853. * "ImageProcessingPostProcess"
  116854. * @returns "ImageProcessingPostProcess"
  116855. */
  116856. ImageProcessingPostProcess.prototype.getClassName = function () {
  116857. return "ImageProcessingPostProcess";
  116858. };
  116859. ImageProcessingPostProcess.prototype._updateParameters = function () {
  116860. this._defines.FROMLINEARSPACE = this._fromLinearSpace;
  116861. this.imageProcessingConfiguration.prepareDefines(this._defines, true);
  116862. var defines = "";
  116863. for (var define in this._defines) {
  116864. if (this._defines[define]) {
  116865. defines += "#define " + define + ";\r\n";
  116866. }
  116867. }
  116868. var samplers = ["textureSampler"];
  116869. var uniforms = ["scale"];
  116870. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"]) {
  116871. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._defines);
  116872. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._defines);
  116873. }
  116874. this.updateEffect(defines, uniforms, samplers);
  116875. };
  116876. ImageProcessingPostProcess.prototype.dispose = function (camera) {
  116877. _super.prototype.dispose.call(this, camera);
  116878. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  116879. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  116880. }
  116881. if (this._imageProcessingConfiguration) {
  116882. this.imageProcessingConfiguration.applyByPostProcess = false;
  116883. }
  116884. };
  116885. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116886. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116887. ], ImageProcessingPostProcess.prototype, "_fromLinearSpace", void 0);
  116888. return ImageProcessingPostProcess;
  116889. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  116890. /***/ }),
  116891. /***/ "./PostProcesses/index.ts":
  116892. /*!********************************!*\
  116893. !*** ./PostProcesses/index.ts ***!
  116894. \********************************/
  116895. /*! 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 */
  116896. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116897. "use strict";
  116898. __webpack_require__.r(__webpack_exports__);
  116899. /* harmony import */ var _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  116900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  116901. /* harmony import */ var _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./blackAndWhitePostProcess */ "./PostProcesses/blackAndWhitePostProcess.ts");
  116902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__["BlackAndWhitePostProcess"]; });
  116903. /* harmony import */ var _bloomEffect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bloomEffect */ "./PostProcesses/bloomEffect.ts");
  116904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _bloomEffect__WEBPACK_IMPORTED_MODULE_2__["BloomEffect"]; });
  116905. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  116906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__["BloomMergePostProcess"]; });
  116907. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  116908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]; });
  116909. /* harmony import */ var _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  116910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__["ChromaticAberrationPostProcess"]; });
  116911. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  116912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__["CircleOfConfusionPostProcess"]; });
  116913. /* harmony import */ var _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./colorCorrectionPostProcess */ "./PostProcesses/colorCorrectionPostProcess.ts");
  116914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__["ColorCorrectionPostProcess"]; });
  116915. /* harmony import */ var _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./convolutionPostProcess */ "./PostProcesses/convolutionPostProcess.ts");
  116916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__["ConvolutionPostProcess"]; });
  116917. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  116918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__["DepthOfFieldBlurPostProcess"]; });
  116919. /* harmony import */ var _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  116920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffectBlurLevel"]; });
  116921. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffect"]; });
  116922. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  116923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcessOptions"]; });
  116924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcess"]; });
  116925. /* harmony import */ var _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./displayPassPostProcess */ "./PostProcesses/displayPassPostProcess.ts");
  116926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__["DisplayPassPostProcess"]; });
  116927. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  116928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__["ExtractHighlightsPostProcess"]; });
  116929. /* harmony import */ var _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./filterPostProcess */ "./PostProcesses/filterPostProcess.ts");
  116930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__["FilterPostProcess"]; });
  116931. /* harmony import */ var _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  116932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__["FxaaPostProcess"]; });
  116933. /* harmony import */ var _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  116934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__["GrainPostProcess"]; });
  116935. /* harmony import */ var _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./highlightsPostProcess */ "./PostProcesses/highlightsPostProcess.ts");
  116936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__["HighlightsPostProcess"]; });
  116937. /* harmony import */ var _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  116938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__["ImageProcessingPostProcess"]; });
  116939. /* harmony import */ var _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./motionBlurPostProcess */ "./PostProcesses/motionBlurPostProcess.ts");
  116940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__["MotionBlurPostProcess"]; });
  116941. /* harmony import */ var _passPostProcess__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./passPostProcess */ "./PostProcesses/passPostProcess.ts");
  116942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassPostProcess"]; });
  116943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassCubePostProcess"]; });
  116944. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _postProcess__WEBPACK_IMPORTED_MODULE_21__["PostProcess"]; });
  116946. /* harmony import */ var _postProcessManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./postProcessManager */ "./PostProcesses/postProcessManager.ts");
  116947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"]; });
  116948. /* harmony import */ var _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./refractionPostProcess */ "./PostProcesses/refractionPostProcess.ts");
  116949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__["RefractionPostProcess"]; });
  116950. /* harmony import */ var _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./RenderPipeline/index */ "./PostProcesses/RenderPipeline/index.ts");
  116951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderEffect"]; });
  116952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipeline"]; });
  116953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManager"]; });
  116954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManagerSceneComponent"]; });
  116955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["DefaultRenderingPipeline"]; });
  116956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["LensRenderingPipeline"]; });
  116957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAO2RenderingPipeline"]; });
  116958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAORenderingPipeline"]; });
  116959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["StandardRenderingPipeline"]; });
  116960. /* harmony import */ var _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  116961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__["SharpenPostProcess"]; });
  116962. /* harmony import */ var _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  116963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__["StereoscopicInterlacePostProcess"]; });
  116964. /* harmony import */ var _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./tonemapPostProcess */ "./PostProcesses/tonemapPostProcess.ts");
  116965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemappingOperator"]; });
  116966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemapPostProcess"]; });
  116967. /* harmony import */ var _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./volumetricLightScatteringPostProcess */ "./PostProcesses/volumetricLightScatteringPostProcess.ts");
  116968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__["VolumetricLightScatteringPostProcess"]; });
  116969. /* harmony import */ var _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  116970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  116971. /***/ }),
  116972. /***/ "./PostProcesses/motionBlurPostProcess.ts":
  116973. /*!************************************************!*\
  116974. !*** ./PostProcesses/motionBlurPostProcess.ts ***!
  116975. \************************************************/
  116976. /*! exports provided: MotionBlurPostProcess */
  116977. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116978. "use strict";
  116979. __webpack_require__.r(__webpack_exports__);
  116980. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return MotionBlurPostProcess; });
  116981. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116982. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  116983. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116984. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  116985. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  116986. /* harmony import */ var _Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Rendering/geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  116987. /* harmony import */ var _Shaders_motionBlur_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/motionBlur.fragment */ "./Shaders/motionBlur.fragment.ts");
  116988. /**
  116989. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  116990. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  116991. * As an example, all you have to do is to create the post-process:
  116992. * var mb = new BABYLON.MotionBlurPostProcess(
  116993. * 'mb', // The name of the effect.
  116994. * scene, // The scene containing the objects to blur according to their velocity.
  116995. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  116996. * camera // The camera to apply the render pass to.
  116997. * );
  116998. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  116999. */
  117000. var MotionBlurPostProcess = /** @class */ (function (_super) {
  117001. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotionBlurPostProcess, _super);
  117002. /**
  117003. * Creates a new instance MotionBlurPostProcess
  117004. * @param name The name of the effect.
  117005. * @param scene The scene containing the objects to blur according to their velocity.
  117006. * @param options The required width/height ratio to downsize to before computing the render pass.
  117007. * @param camera The camera to apply the render pass to.
  117008. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117009. * @param engine The engine which the post process will be applied. (default: current engine)
  117010. * @param reusable If the post process can be reused on the same frame. (default: false)
  117011. * @param textureType Type of textures used when performing the post process. (default: 0)
  117012. * @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)
  117013. */
  117014. function MotionBlurPostProcess(name, scene, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117015. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117016. if (blockCompilation === void 0) { blockCompilation = false; }
  117017. 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;
  117018. /**
  117019. * Defines how much the image is blurred by the movement. Default value is equal to 1
  117020. */
  117021. _this.motionStrength = 1;
  117022. _this._motionBlurSamples = 32;
  117023. _this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  117024. if (!_this._geometryBufferRenderer) {
  117025. // Geometry buffer renderer is not supported. So, work as a passthrough.
  117026. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Multiple Render Target support needed to compute object based motion blur");
  117027. _this.updateEffect();
  117028. }
  117029. else {
  117030. // Geometry buffer renderer is supported.
  117031. _this._geometryBufferRenderer.enableVelocity = true;
  117032. _this.onApply = function (effect) {
  117033. effect.setVector2("screenSize", new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](_this.width, _this.height));
  117034. effect.setFloat("motionScale", scene.getAnimationRatio());
  117035. effect.setFloat("motionStrength", _this.motionStrength);
  117036. if (_this._geometryBufferRenderer) {
  117037. var velocityIndex = _this._geometryBufferRenderer.getTextureIndex(_Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRenderer"].VELOCITY_TEXTURE_TYPE);
  117038. effect.setTexture("velocitySampler", _this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);
  117039. }
  117040. };
  117041. }
  117042. return _this;
  117043. }
  117044. Object.defineProperty(MotionBlurPostProcess.prototype, "motionBlurSamples", {
  117045. /**
  117046. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  117047. */
  117048. get: function () {
  117049. return this._motionBlurSamples;
  117050. },
  117051. /**
  117052. * Sets the number of iterations to be used for motion blur quality
  117053. */
  117054. set: function (samples) {
  117055. this._motionBlurSamples = samples;
  117056. if (this._geometryBufferRenderer) {
  117057. this.updateEffect("#define GEOMETRY_SUPPORTED\n#define SAMPLES " + samples.toFixed(1));
  117058. }
  117059. },
  117060. enumerable: true,
  117061. configurable: true
  117062. });
  117063. /**
  117064. * Disposes the post process.
  117065. * @param camera The camera to dispose the post process on.
  117066. */
  117067. MotionBlurPostProcess.prototype.dispose = function (camera) {
  117068. if (this._geometryBufferRenderer) {
  117069. // Clear previous transformation matrices dictionary used to compute objects velocities
  117070. this._geometryBufferRenderer._previousTransformationMatrices = {};
  117071. }
  117072. _super.prototype.dispose.call(this, camera);
  117073. };
  117074. return MotionBlurPostProcess;
  117075. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  117076. /***/ }),
  117077. /***/ "./PostProcesses/passPostProcess.ts":
  117078. /*!******************************************!*\
  117079. !*** ./PostProcesses/passPostProcess.ts ***!
  117080. \******************************************/
  117081. /*! exports provided: PassPostProcess, PassCubePostProcess */
  117082. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117083. "use strict";
  117084. __webpack_require__.r(__webpack_exports__);
  117085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return PassPostProcess; });
  117086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return PassCubePostProcess; });
  117087. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117088. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117089. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117090. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  117091. /* harmony import */ var _Shaders_pass_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/pass.fragment */ "./Shaders/pass.fragment.ts");
  117092. /* harmony import */ var _Shaders_passCube_fragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/passCube.fragment */ "./Shaders/passCube.fragment.ts");
  117093. /**
  117094. * PassPostProcess which produces an output the same as it's input
  117095. */
  117096. var PassPostProcess = /** @class */ (function (_super) {
  117097. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassPostProcess, _super);
  117098. /**
  117099. * Creates the PassPostProcess
  117100. * @param name The name of the effect.
  117101. * @param options The required width/height ratio to downsize to before computing the render pass.
  117102. * @param camera The camera to apply the render pass to.
  117103. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117104. * @param engine The engine which the post process will be applied. (default: current engine)
  117105. * @param reusable If the post process can be reused on the same frame. (default: false)
  117106. * @param textureType The type of texture to be used when performing the post processing.
  117107. * @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)
  117108. */
  117109. function PassPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117110. if (camera === void 0) { camera = null; }
  117111. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117112. if (blockCompilation === void 0) { blockCompilation = false; }
  117113. return _super.call(this, name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation) || this;
  117114. }
  117115. return PassPostProcess;
  117116. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  117117. /**
  117118. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  117119. */
  117120. var PassCubePostProcess = /** @class */ (function (_super) {
  117121. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassCubePostProcess, _super);
  117122. /**
  117123. * Creates the PassCubePostProcess
  117124. * @param name The name of the effect.
  117125. * @param options The required width/height ratio to downsize to before computing the render pass.
  117126. * @param camera The camera to apply the render pass to.
  117127. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117128. * @param engine The engine which the post process will be applied. (default: current engine)
  117129. * @param reusable If the post process can be reused on the same frame. (default: false)
  117130. * @param textureType The type of texture to be used when performing the post processing.
  117131. * @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)
  117132. */
  117133. function PassCubePostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117134. if (camera === void 0) { camera = null; }
  117135. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117136. if (blockCompilation === void 0) { blockCompilation = false; }
  117137. var _this = _super.call(this, name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation) || this;
  117138. _this._face = 0;
  117139. return _this;
  117140. }
  117141. Object.defineProperty(PassCubePostProcess.prototype, "face", {
  117142. /**
  117143. * Gets or sets the cube face to display.
  117144. * * 0 is +X
  117145. * * 1 is -X
  117146. * * 2 is +Y
  117147. * * 3 is -Y
  117148. * * 4 is +Z
  117149. * * 5 is -Z
  117150. */
  117151. get: function () {
  117152. return this._face;
  117153. },
  117154. set: function (value) {
  117155. if (value < 0 || value > 5) {
  117156. return;
  117157. }
  117158. this._face = value;
  117159. switch (this._face) {
  117160. case 0:
  117161. this.updateEffect("#define POSITIVEX");
  117162. break;
  117163. case 1:
  117164. this.updateEffect("#define NEGATIVEX");
  117165. break;
  117166. case 2:
  117167. this.updateEffect("#define POSITIVEY");
  117168. break;
  117169. case 3:
  117170. this.updateEffect("#define NEGATIVEY");
  117171. break;
  117172. case 4:
  117173. this.updateEffect("#define POSITIVEZ");
  117174. break;
  117175. case 5:
  117176. this.updateEffect("#define NEGATIVEZ");
  117177. break;
  117178. }
  117179. },
  117180. enumerable: true,
  117181. configurable: true
  117182. });
  117183. return PassCubePostProcess;
  117184. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  117185. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"]._RescalePostProcessFactory = function (engine) {
  117186. 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);
  117187. };
  117188. /***/ }),
  117189. /***/ "./PostProcesses/postProcess.ts":
  117190. /*!**************************************!*\
  117191. !*** ./PostProcesses/postProcess.ts ***!
  117192. \**************************************/
  117193. /*! exports provided: PostProcess */
  117194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117195. "use strict";
  117196. __webpack_require__.r(__webpack_exports__);
  117197. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return PostProcess; });
  117198. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  117199. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  117200. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  117201. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117202. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117203. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  117204. /**
  117205. * PostProcess can be used to apply a shader to a texture after it has been rendered
  117206. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117207. */
  117208. var PostProcess = /** @class */ (function () {
  117209. /**
  117210. * Creates a new instance PostProcess
  117211. * @param name The name of the PostProcess.
  117212. * @param fragmentUrl The url of the fragment shader to be used.
  117213. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  117214. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  117215. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  117216. * @param camera The camera to apply the render pass to.
  117217. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117218. * @param engine The engine which the post process will be applied. (default: current engine)
  117219. * @param reusable If the post process can be reused on the same frame. (default: false)
  117220. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  117221. * @param textureType Type of textures used when performing the post process. (default: 0)
  117222. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  117223. * @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
  117224. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  117225. */
  117226. function PostProcess(
  117227. /** Name of the PostProcess. */
  117228. name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
  117229. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE; }
  117230. if (defines === void 0) { defines = null; }
  117231. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117232. if (vertexUrl === void 0) { vertexUrl = "postprocess"; }
  117233. if (blockCompilation === void 0) { blockCompilation = false; }
  117234. this.name = name;
  117235. /**
  117236. * Width of the texture to apply the post process on
  117237. */
  117238. this.width = -1;
  117239. /**
  117240. * Height of the texture to apply the post process on
  117241. */
  117242. this.height = -1;
  117243. /**
  117244. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  117245. * @hidden
  117246. */
  117247. this._outputTexture = null;
  117248. /**
  117249. * If the buffer needs to be cleared before applying the post process. (default: true)
  117250. * Should be set to false if shader will overwrite all previous pixels.
  117251. */
  117252. this.autoClear = true;
  117253. /**
  117254. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  117255. */
  117256. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE;
  117257. /**
  117258. * Animations to be used for the post processing
  117259. */
  117260. this.animations = new Array();
  117261. /**
  117262. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  117263. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  117264. */
  117265. this.enablePixelPerfectMode = false;
  117266. /**
  117267. * Force the postprocess to be applied without taking in account viewport
  117268. */
  117269. this.forceFullscreenViewport = true;
  117270. /**
  117271. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  117272. *
  117273. * | Value | Type | Description |
  117274. * | ----- | ----------------------------------- | ----------- |
  117275. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  117276. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  117277. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  117278. *
  117279. */
  117280. this.scaleMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].SCALEMODE_FLOOR;
  117281. /**
  117282. * Force textures to be a power of two (default: false)
  117283. */
  117284. this.alwaysForcePOT = false;
  117285. this._samples = 1;
  117286. /**
  117287. * Modify the scale of the post process to be the same as the viewport (default: false)
  117288. */
  117289. this.adaptScaleToCurrentViewport = false;
  117290. this._reusable = false;
  117291. /**
  117292. * Smart array of input and output textures for the post process.
  117293. * @hidden
  117294. */
  117295. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  117296. /**
  117297. * The index in _textures that corresponds to the output texture.
  117298. * @hidden
  117299. */
  117300. this._currentRenderTextureInd = 0;
  117301. this._scaleRatio = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 1);
  117302. this._texelSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  117303. // Events
  117304. /**
  117305. * An event triggered when the postprocess is activated.
  117306. */
  117307. this.onActivateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  117308. /**
  117309. * An event triggered when the postprocess changes its size.
  117310. */
  117311. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  117312. /**
  117313. * An event triggered when the postprocess applies its effect.
  117314. */
  117315. this.onApplyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  117316. /**
  117317. * An event triggered before rendering the postprocess
  117318. */
  117319. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  117320. /**
  117321. * An event triggered after rendering the postprocess
  117322. */
  117323. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  117324. if (camera != null) {
  117325. this._camera = camera;
  117326. this._scene = camera.getScene();
  117327. camera.attachPostProcess(this);
  117328. this._engine = this._scene.getEngine();
  117329. this._scene.postProcesses.push(this);
  117330. }
  117331. else if (engine) {
  117332. this._engine = engine;
  117333. this._engine.postProcesses.push(this);
  117334. }
  117335. this._options = options;
  117336. this.renderTargetSamplingMode = samplingMode ? samplingMode : _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  117337. this._reusable = reusable || false;
  117338. this._textureType = textureType;
  117339. this._samplers = samplers || [];
  117340. this._samplers.push("textureSampler");
  117341. this._fragmentUrl = fragmentUrl;
  117342. this._vertexUrl = vertexUrl;
  117343. this._parameters = parameters || [];
  117344. this._parameters.push("scale");
  117345. this._indexParameters = indexParameters;
  117346. if (!blockCompilation) {
  117347. this.updateEffect(defines);
  117348. }
  117349. }
  117350. Object.defineProperty(PostProcess.prototype, "samples", {
  117351. /**
  117352. * Number of sample textures (default: 1)
  117353. */
  117354. get: function () {
  117355. return this._samples;
  117356. },
  117357. set: function (n) {
  117358. var _this = this;
  117359. this._samples = n;
  117360. this._textures.forEach(function (texture) {
  117361. if (texture.samples !== _this._samples) {
  117362. _this._engine.updateRenderTargetTextureSampleCount(texture, _this._samples);
  117363. }
  117364. });
  117365. },
  117366. enumerable: true,
  117367. configurable: true
  117368. });
  117369. /**
  117370. * Returns the fragment url or shader name used in the post process.
  117371. * @returns the fragment url or name in the shader store.
  117372. */
  117373. PostProcess.prototype.getEffectName = function () {
  117374. return this._fragmentUrl;
  117375. };
  117376. Object.defineProperty(PostProcess.prototype, "onActivate", {
  117377. /**
  117378. * A function that is added to the onActivateObservable
  117379. */
  117380. set: function (callback) {
  117381. if (this._onActivateObserver) {
  117382. this.onActivateObservable.remove(this._onActivateObserver);
  117383. }
  117384. if (callback) {
  117385. this._onActivateObserver = this.onActivateObservable.add(callback);
  117386. }
  117387. },
  117388. enumerable: true,
  117389. configurable: true
  117390. });
  117391. Object.defineProperty(PostProcess.prototype, "onSizeChanged", {
  117392. /**
  117393. * A function that is added to the onSizeChangedObservable
  117394. */
  117395. set: function (callback) {
  117396. if (this._onSizeChangedObserver) {
  117397. this.onSizeChangedObservable.remove(this._onSizeChangedObserver);
  117398. }
  117399. this._onSizeChangedObserver = this.onSizeChangedObservable.add(callback);
  117400. },
  117401. enumerable: true,
  117402. configurable: true
  117403. });
  117404. Object.defineProperty(PostProcess.prototype, "onApply", {
  117405. /**
  117406. * A function that is added to the onApplyObservable
  117407. */
  117408. set: function (callback) {
  117409. if (this._onApplyObserver) {
  117410. this.onApplyObservable.remove(this._onApplyObserver);
  117411. }
  117412. this._onApplyObserver = this.onApplyObservable.add(callback);
  117413. },
  117414. enumerable: true,
  117415. configurable: true
  117416. });
  117417. Object.defineProperty(PostProcess.prototype, "onBeforeRender", {
  117418. /**
  117419. * A function that is added to the onBeforeRenderObservable
  117420. */
  117421. set: function (callback) {
  117422. if (this._onBeforeRenderObserver) {
  117423. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  117424. }
  117425. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  117426. },
  117427. enumerable: true,
  117428. configurable: true
  117429. });
  117430. Object.defineProperty(PostProcess.prototype, "onAfterRender", {
  117431. /**
  117432. * A function that is added to the onAfterRenderObservable
  117433. */
  117434. set: function (callback) {
  117435. if (this._onAfterRenderObserver) {
  117436. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  117437. }
  117438. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  117439. },
  117440. enumerable: true,
  117441. configurable: true
  117442. });
  117443. Object.defineProperty(PostProcess.prototype, "inputTexture", {
  117444. /**
  117445. * 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
  117446. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  117447. */
  117448. get: function () {
  117449. return this._textures.data[this._currentRenderTextureInd];
  117450. },
  117451. set: function (value) {
  117452. this._forcedOutputTexture = value;
  117453. },
  117454. enumerable: true,
  117455. configurable: true
  117456. });
  117457. /**
  117458. * Gets the camera which post process is applied to.
  117459. * @returns The camera the post process is applied to.
  117460. */
  117461. PostProcess.prototype.getCamera = function () {
  117462. return this._camera;
  117463. };
  117464. Object.defineProperty(PostProcess.prototype, "texelSize", {
  117465. /**
  117466. * Gets the texel size of the postprocess.
  117467. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  117468. */
  117469. get: function () {
  117470. if (this._shareOutputWithPostProcess) {
  117471. return this._shareOutputWithPostProcess.texelSize;
  117472. }
  117473. if (this._forcedOutputTexture) {
  117474. this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);
  117475. }
  117476. return this._texelSize;
  117477. },
  117478. enumerable: true,
  117479. configurable: true
  117480. });
  117481. /**
  117482. * Gets the engine which this post process belongs to.
  117483. * @returns The engine the post process was enabled with.
  117484. */
  117485. PostProcess.prototype.getEngine = function () {
  117486. return this._engine;
  117487. };
  117488. /**
  117489. * The effect that is created when initializing the post process.
  117490. * @returns The created effect corrisponding the the postprocess.
  117491. */
  117492. PostProcess.prototype.getEffect = function () {
  117493. return this._effect;
  117494. };
  117495. /**
  117496. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  117497. * @param postProcess The post process to share the output with.
  117498. * @returns This post process.
  117499. */
  117500. PostProcess.prototype.shareOutputWith = function (postProcess) {
  117501. this._disposeTextures();
  117502. this._shareOutputWithPostProcess = postProcess;
  117503. return this;
  117504. };
  117505. /**
  117506. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  117507. * This should be called if the post process that shares output with this post process is disabled/disposed.
  117508. */
  117509. PostProcess.prototype.useOwnOutput = function () {
  117510. if (this._textures.length == 0) {
  117511. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  117512. }
  117513. this._shareOutputWithPostProcess = null;
  117514. };
  117515. /**
  117516. * Updates the effect with the current post process compile time values and recompiles the shader.
  117517. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  117518. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  117519. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  117520. * @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
  117521. * @param onCompiled Called when the shader has been compiled.
  117522. * @param onError Called if there is an error when compiling a shader.
  117523. */
  117524. PostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  117525. if (defines === void 0) { defines = null; }
  117526. if (uniforms === void 0) { uniforms = null; }
  117527. if (samplers === void 0) { samplers = null; }
  117528. 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);
  117529. };
  117530. /**
  117531. * The post process is reusable if it can be used multiple times within one frame.
  117532. * @returns If the post process is reusable
  117533. */
  117534. PostProcess.prototype.isReusable = function () {
  117535. return this._reusable;
  117536. };
  117537. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  117538. PostProcess.prototype.markTextureDirty = function () {
  117539. this.width = -1;
  117540. };
  117541. /**
  117542. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  117543. * 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.
  117544. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  117545. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  117546. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  117547. * @returns The target texture that was bound to be written to.
  117548. */
  117549. PostProcess.prototype.activate = function (camera, sourceTexture, forceDepthStencil) {
  117550. var _this = this;
  117551. if (sourceTexture === void 0) { sourceTexture = null; }
  117552. camera = camera || this._camera;
  117553. var scene = camera.getScene();
  117554. var engine = scene.getEngine();
  117555. var maxSize = engine.getCaps().maxTextureSize;
  117556. var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * this._options) | 0;
  117557. var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * this._options) | 0;
  117558. // 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
  117559. var webVRCamera = camera.parent;
  117560. if (webVRCamera && (webVRCamera.leftCamera == camera || webVRCamera.rightCamera == camera)) {
  117561. requiredWidth /= 2;
  117562. }
  117563. var desiredWidth = (this._options.width || requiredWidth);
  117564. var desiredHeight = this._options.height || requiredHeight;
  117565. if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
  117566. if (this.adaptScaleToCurrentViewport) {
  117567. var currentViewport = engine.currentViewport;
  117568. if (currentViewport) {
  117569. desiredWidth *= currentViewport.width;
  117570. desiredHeight *= currentViewport.height;
  117571. }
  117572. }
  117573. if (this.renderTargetSamplingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE || this.alwaysForcePOT) {
  117574. if (!this._options.width) {
  117575. desiredWidth = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;
  117576. }
  117577. if (!this._options.height) {
  117578. desiredHeight = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredHeight, maxSize, this.scaleMode) : desiredHeight;
  117579. }
  117580. }
  117581. if (this.width !== desiredWidth || this.height !== desiredHeight) {
  117582. if (this._textures.length > 0) {
  117583. for (var i = 0; i < this._textures.length; i++) {
  117584. this._engine._releaseTexture(this._textures.data[i]);
  117585. }
  117586. this._textures.reset();
  117587. }
  117588. this.width = desiredWidth;
  117589. this.height = desiredHeight;
  117590. var textureSize = { width: this.width, height: this.height };
  117591. var textureOptions = {
  117592. generateMipMaps: false,
  117593. generateDepthBuffer: forceDepthStencil || camera._postProcesses.indexOf(this) === 0,
  117594. generateStencilBuffer: (forceDepthStencil || camera._postProcesses.indexOf(this) === 0) && this._engine.isStencilEnable,
  117595. samplingMode: this.renderTargetSamplingMode,
  117596. type: this._textureType
  117597. };
  117598. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  117599. if (this._reusable) {
  117600. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  117601. }
  117602. this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);
  117603. this.onSizeChangedObservable.notifyObservers(this);
  117604. }
  117605. this._textures.forEach(function (texture) {
  117606. if (texture.samples !== _this.samples) {
  117607. _this._engine.updateRenderTargetTextureSampleCount(texture, _this.samples);
  117608. }
  117609. });
  117610. }
  117611. var target;
  117612. if (this._shareOutputWithPostProcess) {
  117613. target = this._shareOutputWithPostProcess.inputTexture;
  117614. }
  117615. else if (this._forcedOutputTexture) {
  117616. target = this._forcedOutputTexture;
  117617. this.width = this._forcedOutputTexture.width;
  117618. this.height = this._forcedOutputTexture.height;
  117619. }
  117620. else {
  117621. target = this.inputTexture;
  117622. }
  117623. // Bind the input of this post process to be used as the output of the previous post process.
  117624. if (this.enablePixelPerfectMode) {
  117625. this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
  117626. this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, this.forceFullscreenViewport);
  117627. }
  117628. else {
  117629. this._scaleRatio.copyFromFloats(1, 1);
  117630. this._engine.bindFramebuffer(target, 0, undefined, undefined, this.forceFullscreenViewport);
  117631. }
  117632. this.onActivateObservable.notifyObservers(camera);
  117633. // Clear
  117634. if (this.autoClear && this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE) {
  117635. this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);
  117636. }
  117637. if (this._reusable) {
  117638. this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
  117639. }
  117640. return target;
  117641. };
  117642. Object.defineProperty(PostProcess.prototype, "isSupported", {
  117643. /**
  117644. * If the post process is supported.
  117645. */
  117646. get: function () {
  117647. return this._effect.isSupported;
  117648. },
  117649. enumerable: true,
  117650. configurable: true
  117651. });
  117652. Object.defineProperty(PostProcess.prototype, "aspectRatio", {
  117653. /**
  117654. * The aspect ratio of the output texture.
  117655. */
  117656. get: function () {
  117657. if (this._shareOutputWithPostProcess) {
  117658. return this._shareOutputWithPostProcess.aspectRatio;
  117659. }
  117660. if (this._forcedOutputTexture) {
  117661. return this._forcedOutputTexture.width / this._forcedOutputTexture.height;
  117662. }
  117663. return this.width / this.height;
  117664. },
  117665. enumerable: true,
  117666. configurable: true
  117667. });
  117668. /**
  117669. * Get a value indicating if the post-process is ready to be used
  117670. * @returns true if the post-process is ready (shader is compiled)
  117671. */
  117672. PostProcess.prototype.isReady = function () {
  117673. return this._effect && this._effect.isReady();
  117674. };
  117675. /**
  117676. * Binds all textures and uniforms to the shader, this will be run on every pass.
  117677. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  117678. */
  117679. PostProcess.prototype.apply = function () {
  117680. // Check
  117681. if (!this._effect || !this._effect.isReady()) {
  117682. return null;
  117683. }
  117684. // States
  117685. this._engine.enableEffect(this._effect);
  117686. this._engine.setState(false);
  117687. this._engine.setDepthBuffer(false);
  117688. this._engine.setDepthWrite(false);
  117689. // Alpha
  117690. this._engine.setAlphaMode(this.alphaMode);
  117691. if (this.alphaConstants) {
  117692. this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
  117693. }
  117694. // Bind the output texture of the preivous post process as the input to this post process.
  117695. var source;
  117696. if (this._shareOutputWithPostProcess) {
  117697. source = this._shareOutputWithPostProcess.inputTexture;
  117698. }
  117699. else if (this._forcedOutputTexture) {
  117700. source = this._forcedOutputTexture;
  117701. }
  117702. else {
  117703. source = this.inputTexture;
  117704. }
  117705. this._effect._bindTexture("textureSampler", source);
  117706. // Parameters
  117707. this._effect.setVector2("scale", this._scaleRatio);
  117708. this.onApplyObservable.notifyObservers(this._effect);
  117709. return this._effect;
  117710. };
  117711. PostProcess.prototype._disposeTextures = function () {
  117712. if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
  117713. return;
  117714. }
  117715. if (this._textures.length > 0) {
  117716. for (var i = 0; i < this._textures.length; i++) {
  117717. this._engine._releaseTexture(this._textures.data[i]);
  117718. }
  117719. }
  117720. this._textures.dispose();
  117721. };
  117722. /**
  117723. * Disposes the post process.
  117724. * @param camera The camera to dispose the post process on.
  117725. */
  117726. PostProcess.prototype.dispose = function (camera) {
  117727. camera = camera || this._camera;
  117728. this._disposeTextures();
  117729. if (this._scene) {
  117730. var index_1 = this._scene.postProcesses.indexOf(this);
  117731. if (index_1 !== -1) {
  117732. this._scene.postProcesses.splice(index_1, 1);
  117733. }
  117734. }
  117735. else {
  117736. var index_2 = this._engine.postProcesses.indexOf(this);
  117737. if (index_2 !== -1) {
  117738. this._engine.postProcesses.splice(index_2, 1);
  117739. }
  117740. }
  117741. if (!camera) {
  117742. return;
  117743. }
  117744. camera.detachPostProcess(this);
  117745. var index = camera._postProcesses.indexOf(this);
  117746. if (index === 0 && camera._postProcesses.length > 0) {
  117747. var firstPostProcess = this._camera._getFirstPostProcess();
  117748. if (firstPostProcess) {
  117749. firstPostProcess.markTextureDirty();
  117750. }
  117751. }
  117752. this.onActivateObservable.clear();
  117753. this.onAfterRenderObservable.clear();
  117754. this.onApplyObservable.clear();
  117755. this.onBeforeRenderObservable.clear();
  117756. this.onSizeChangedObservable.clear();
  117757. };
  117758. return PostProcess;
  117759. }());
  117760. /***/ }),
  117761. /***/ "./PostProcesses/postProcessManager.ts":
  117762. /*!*********************************************!*\
  117763. !*** ./PostProcesses/postProcessManager.ts ***!
  117764. \*********************************************/
  117765. /*! exports provided: PostProcessManager */
  117766. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117767. "use strict";
  117768. __webpack_require__.r(__webpack_exports__);
  117769. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return PostProcessManager; });
  117770. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  117771. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  117772. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117773. /**
  117774. * PostProcessManager is used to manage one or more post processes or post process pipelines
  117775. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117776. */
  117777. var PostProcessManager = /** @class */ (function () {
  117778. /**
  117779. * Creates a new instance PostProcess
  117780. * @param scene The scene that the post process is associated with.
  117781. */
  117782. function PostProcessManager(scene) {
  117783. this._vertexBuffers = {};
  117784. this._scene = scene;
  117785. }
  117786. PostProcessManager.prototype._prepareBuffers = function () {
  117787. if (this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind]) {
  117788. return;
  117789. }
  117790. // VBO
  117791. var vertices = [];
  117792. vertices.push(1, 1);
  117793. vertices.push(-1, 1);
  117794. vertices.push(-1, -1);
  117795. vertices.push(1, -1);
  117796. 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);
  117797. this._buildIndexBuffer();
  117798. };
  117799. PostProcessManager.prototype._buildIndexBuffer = function () {
  117800. // Indices
  117801. var indices = [];
  117802. indices.push(0);
  117803. indices.push(1);
  117804. indices.push(2);
  117805. indices.push(0);
  117806. indices.push(2);
  117807. indices.push(3);
  117808. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  117809. };
  117810. /**
  117811. * Rebuilds the vertex buffers of the manager.
  117812. * @hidden
  117813. */
  117814. PostProcessManager.prototype._rebuild = function () {
  117815. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  117816. if (!vb) {
  117817. return;
  117818. }
  117819. vb._rebuild();
  117820. this._buildIndexBuffer();
  117821. };
  117822. // Methods
  117823. /**
  117824. * Prepares a frame to be run through a post process.
  117825. * @param sourceTexture The input texture to the post procesess. (default: null)
  117826. * @param postProcesses An array of post processes to be run. (default: null)
  117827. * @returns True if the post processes were able to be run.
  117828. * @hidden
  117829. */
  117830. PostProcessManager.prototype._prepareFrame = function (sourceTexture, postProcesses) {
  117831. if (sourceTexture === void 0) { sourceTexture = null; }
  117832. if (postProcesses === void 0) { postProcesses = null; }
  117833. var camera = this._scene.activeCamera;
  117834. if (!camera) {
  117835. return false;
  117836. }
  117837. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  117838. if (!postProcesses || postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  117839. return false;
  117840. }
  117841. postProcesses[0].activate(camera, sourceTexture, postProcesses !== null && postProcesses !== undefined);
  117842. return true;
  117843. };
  117844. /**
  117845. * Manually render a set of post processes to a texture.
  117846. * @param postProcesses An array of post processes to be run.
  117847. * @param targetTexture The target texture to render to.
  117848. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  117849. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  117850. * @param lodLevel defines which lod of the texture to render to
  117851. */
  117852. PostProcessManager.prototype.directRender = function (postProcesses, targetTexture, forceFullscreenViewport, faceIndex, lodLevel) {
  117853. if (targetTexture === void 0) { targetTexture = null; }
  117854. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  117855. if (faceIndex === void 0) { faceIndex = 0; }
  117856. if (lodLevel === void 0) { lodLevel = 0; }
  117857. var engine = this._scene.getEngine();
  117858. for (var index = 0; index < postProcesses.length; index++) {
  117859. if (index < postProcesses.length - 1) {
  117860. postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture);
  117861. }
  117862. else {
  117863. if (targetTexture) {
  117864. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport, undefined, lodLevel);
  117865. }
  117866. else {
  117867. engine.restoreDefaultFramebuffer();
  117868. }
  117869. }
  117870. var pp = postProcesses[index];
  117871. var effect = pp.apply();
  117872. if (effect) {
  117873. pp.onBeforeRenderObservable.notifyObservers(effect);
  117874. // VBOs
  117875. this._prepareBuffers();
  117876. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  117877. // Draw order
  117878. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  117879. pp.onAfterRenderObservable.notifyObservers(effect);
  117880. }
  117881. }
  117882. // Restore depth buffer
  117883. engine.setDepthBuffer(true);
  117884. engine.setDepthWrite(true);
  117885. };
  117886. /**
  117887. * Finalize the result of the output of the postprocesses.
  117888. * @param doNotPresent If true the result will not be displayed to the screen.
  117889. * @param targetTexture The target texture to render to.
  117890. * @param faceIndex The index of the face to bind the target texture to.
  117891. * @param postProcesses The array of post processes to render.
  117892. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  117893. * @hidden
  117894. */
  117895. PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, faceIndex, postProcesses, forceFullscreenViewport) {
  117896. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  117897. var camera = this._scene.activeCamera;
  117898. if (!camera) {
  117899. return;
  117900. }
  117901. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  117902. if (postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  117903. return;
  117904. }
  117905. var engine = this._scene.getEngine();
  117906. for (var index = 0, len = postProcesses.length; index < len; index++) {
  117907. var pp = postProcesses[index];
  117908. if (index < len - 1) {
  117909. pp._outputTexture = postProcesses[index + 1].activate(camera, targetTexture);
  117910. }
  117911. else {
  117912. if (targetTexture) {
  117913. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport);
  117914. pp._outputTexture = targetTexture;
  117915. }
  117916. else {
  117917. engine.restoreDefaultFramebuffer();
  117918. pp._outputTexture = null;
  117919. }
  117920. }
  117921. if (doNotPresent) {
  117922. break;
  117923. }
  117924. var effect = pp.apply();
  117925. if (effect) {
  117926. pp.onBeforeRenderObservable.notifyObservers(effect);
  117927. // VBOs
  117928. this._prepareBuffers();
  117929. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  117930. // Draw order
  117931. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  117932. pp.onAfterRenderObservable.notifyObservers(effect);
  117933. }
  117934. }
  117935. // Restore states
  117936. engine.setDepthBuffer(true);
  117937. engine.setDepthWrite(true);
  117938. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  117939. };
  117940. /**
  117941. * Disposes of the post process manager.
  117942. */
  117943. PostProcessManager.prototype.dispose = function () {
  117944. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  117945. if (buffer) {
  117946. buffer.dispose();
  117947. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  117948. }
  117949. if (this._indexBuffer) {
  117950. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  117951. this._indexBuffer = null;
  117952. }
  117953. };
  117954. return PostProcessManager;
  117955. }());
  117956. /***/ }),
  117957. /***/ "./PostProcesses/refractionPostProcess.ts":
  117958. /*!************************************************!*\
  117959. !*** ./PostProcesses/refractionPostProcess.ts ***!
  117960. \************************************************/
  117961. /*! exports provided: RefractionPostProcess */
  117962. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117963. "use strict";
  117964. __webpack_require__.r(__webpack_exports__);
  117965. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return RefractionPostProcess; });
  117966. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117967. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  117968. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117969. /* harmony import */ var _Shaders_refraction_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/refraction.fragment */ "./Shaders/refraction.fragment.ts");
  117970. /**
  117971. * Post process which applies a refractin texture
  117972. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  117973. */
  117974. var RefractionPostProcess = /** @class */ (function (_super) {
  117975. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionPostProcess, _super);
  117976. /**
  117977. * Initializes the RefractionPostProcess
  117978. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  117979. * @param name The name of the effect.
  117980. * @param refractionTextureUrl Url of the refraction texture to use
  117981. * @param color the base color of the refraction (used to taint the rendering)
  117982. * @param depth simulated refraction depth
  117983. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  117984. * @param camera The camera to apply the render pass to.
  117985. * @param options The required width/height ratio to downsize to before computing the render pass.
  117986. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117987. * @param engine The engine which the post process will be applied. (default: current engine)
  117988. * @param reusable If the post process can be reused on the same frame. (default: false)
  117989. */
  117990. function RefractionPostProcess(name, refractionTextureUrl,
  117991. /** the base color of the refraction (used to taint the rendering) */
  117992. color,
  117993. /** simulated refraction depth */
  117994. depth,
  117995. /** the coefficient of the base color (0 to remove base color tainting) */
  117996. colorLevel, options, camera, samplingMode, engine, reusable) {
  117997. var _this = _super.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], options, camera, samplingMode, engine, reusable) || this;
  117998. _this.color = color;
  117999. _this.depth = depth;
  118000. _this.colorLevel = colorLevel;
  118001. _this._ownRefractionTexture = true;
  118002. _this.onActivateObservable.add(function (cam) {
  118003. _this._refTexture = _this._refTexture || new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](refractionTextureUrl, cam.getScene());
  118004. });
  118005. _this.onApplyObservable.add(function (effect) {
  118006. effect.setColor3("baseColor", _this.color);
  118007. effect.setFloat("depth", _this.depth);
  118008. effect.setFloat("colorLevel", _this.colorLevel);
  118009. effect.setTexture("refractionSampler", _this._refTexture);
  118010. });
  118011. return _this;
  118012. }
  118013. Object.defineProperty(RefractionPostProcess.prototype, "refractionTexture", {
  118014. /**
  118015. * Gets or sets the refraction texture
  118016. * Please note that you are responsible for disposing the texture if you set it manually
  118017. */
  118018. get: function () {
  118019. return this._refTexture;
  118020. },
  118021. set: function (value) {
  118022. if (this._refTexture && this._ownRefractionTexture) {
  118023. this._refTexture.dispose();
  118024. }
  118025. this._refTexture = value;
  118026. this._ownRefractionTexture = false;
  118027. },
  118028. enumerable: true,
  118029. configurable: true
  118030. });
  118031. // Methods
  118032. /**
  118033. * Disposes of the post process
  118034. * @param camera Camera to dispose post process on
  118035. */
  118036. RefractionPostProcess.prototype.dispose = function (camera) {
  118037. if (this._refTexture && this._ownRefractionTexture) {
  118038. this._refTexture.dispose();
  118039. this._refTexture = null;
  118040. }
  118041. _super.prototype.dispose.call(this, camera);
  118042. };
  118043. return RefractionPostProcess;
  118044. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  118045. /***/ }),
  118046. /***/ "./PostProcesses/sharpenPostProcess.ts":
  118047. /*!*********************************************!*\
  118048. !*** ./PostProcesses/sharpenPostProcess.ts ***!
  118049. \*********************************************/
  118050. /*! exports provided: SharpenPostProcess */
  118051. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118052. "use strict";
  118053. __webpack_require__.r(__webpack_exports__);
  118054. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return SharpenPostProcess; });
  118055. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118056. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118057. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118058. /* harmony import */ var _Shaders_sharpen_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/sharpen.fragment */ "./Shaders/sharpen.fragment.ts");
  118059. /**
  118060. * The SharpenPostProcess applies a sharpen kernel to every pixel
  118061. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118062. */
  118063. var SharpenPostProcess = /** @class */ (function (_super) {
  118064. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SharpenPostProcess, _super);
  118065. /**
  118066. * Creates a new instance ConvolutionPostProcess
  118067. * @param name The name of the effect.
  118068. * @param options The required width/height ratio to downsize to before computing the render pass.
  118069. * @param camera The camera to apply the render pass to.
  118070. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118071. * @param engine The engine which the post process will be applied. (default: current engine)
  118072. * @param reusable If the post process can be reused on the same frame. (default: false)
  118073. * @param textureType Type of textures used when performing the post process. (default: 0)
  118074. * @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)
  118075. */
  118076. function SharpenPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118077. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118078. if (blockCompilation === void 0) { blockCompilation = false; }
  118079. var _this = _super.call(this, name, "sharpen", ["sharpnessAmounts", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  118080. /**
  118081. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  118082. */
  118083. _this.colorAmount = 1.0;
  118084. /**
  118085. * How much sharpness should be applied (default: 0.3)
  118086. */
  118087. _this.edgeAmount = 0.3;
  118088. _this.onApply = function (effect) {
  118089. effect.setFloat2("screenSize", _this.width, _this.height);
  118090. effect.setFloat2("sharpnessAmounts", _this.edgeAmount, _this.colorAmount);
  118091. };
  118092. return _this;
  118093. }
  118094. return SharpenPostProcess;
  118095. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  118096. /***/ }),
  118097. /***/ "./PostProcesses/stereoscopicInterlacePostProcess.ts":
  118098. /*!***********************************************************!*\
  118099. !*** ./PostProcesses/stereoscopicInterlacePostProcess.ts ***!
  118100. \***********************************************************/
  118101. /*! exports provided: StereoscopicInterlacePostProcess */
  118102. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118103. "use strict";
  118104. __webpack_require__.r(__webpack_exports__);
  118105. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return StereoscopicInterlacePostProcess; });
  118106. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118107. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118108. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118109. /* harmony import */ var _Shaders_stereoscopicInterlace_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/stereoscopicInterlace.fragment */ "./Shaders/stereoscopicInterlace.fragment.ts");
  118110. /**
  118111. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  118112. */
  118113. var StereoscopicInterlacePostProcess = /** @class */ (function (_super) {
  118114. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicInterlacePostProcess, _super);
  118115. /**
  118116. * Initializes a StereoscopicInterlacePostProcess
  118117. * @param name The name of the effect.
  118118. * @param rigCameras The rig cameras to be appled to the post process
  118119. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  118120. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118121. * @param engine The engine which the post process will be applied. (default: current engine)
  118122. * @param reusable If the post process can be reused on the same frame. (default: false)
  118123. */
  118124. function StereoscopicInterlacePostProcess(name, rigCameras, isStereoscopicHoriz, samplingMode, engine, reusable) {
  118125. var _this = _super.call(this, name, "stereoscopicInterlace", ['stepSize'], ['camASampler'], 1, rigCameras[1], samplingMode, engine, reusable, isStereoscopicHoriz ? "#define IS_STEREOSCOPIC_HORIZ 1" : undefined) || this;
  118126. _this._passedProcess = rigCameras[0]._rigPostProcess;
  118127. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  118128. _this.onSizeChangedObservable.add(function () {
  118129. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  118130. });
  118131. _this.onApplyObservable.add(function (effect) {
  118132. effect.setTextureFromPostProcess("camASampler", _this._passedProcess);
  118133. effect.setFloat2("stepSize", _this._stepSize.x, _this._stepSize.y);
  118134. });
  118135. return _this;
  118136. }
  118137. return StereoscopicInterlacePostProcess;
  118138. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  118139. /***/ }),
  118140. /***/ "./PostProcesses/tonemapPostProcess.ts":
  118141. /*!*********************************************!*\
  118142. !*** ./PostProcesses/tonemapPostProcess.ts ***!
  118143. \*********************************************/
  118144. /*! exports provided: TonemappingOperator, TonemapPostProcess */
  118145. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118146. "use strict";
  118147. __webpack_require__.r(__webpack_exports__);
  118148. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return TonemappingOperator; });
  118149. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return TonemapPostProcess; });
  118150. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118151. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118152. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118153. /* harmony import */ var _Shaders_tonemap_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/tonemap.fragment */ "./Shaders/tonemap.fragment.ts");
  118154. /** Defines operator used for tonemapping */
  118155. var TonemappingOperator;
  118156. (function (TonemappingOperator) {
  118157. /** Hable */
  118158. TonemappingOperator[TonemappingOperator["Hable"] = 0] = "Hable";
  118159. /** Reinhard */
  118160. TonemappingOperator[TonemappingOperator["Reinhard"] = 1] = "Reinhard";
  118161. /** HejiDawson */
  118162. TonemappingOperator[TonemappingOperator["HejiDawson"] = 2] = "HejiDawson";
  118163. /** Photographic */
  118164. TonemappingOperator[TonemappingOperator["Photographic"] = 3] = "Photographic";
  118165. })(TonemappingOperator || (TonemappingOperator = {}));
  118166. /**
  118167. * Defines a post process to apply tone mapping
  118168. */
  118169. var TonemapPostProcess = /** @class */ (function (_super) {
  118170. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TonemapPostProcess, _super);
  118171. /**
  118172. * Creates a new TonemapPostProcess
  118173. * @param name defines the name of the postprocess
  118174. * @param _operator defines the operator to use
  118175. * @param exposureAdjustment defines the required exposure adjustement
  118176. * @param camera defines the camera to use (can be null)
  118177. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  118178. * @param engine defines the hosting engine (can be ignore if camera is set)
  118179. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  118180. */
  118181. function TonemapPostProcess(name, _operator,
  118182. /** Defines the required exposure adjustement */
  118183. exposureAdjustment, camera, samplingMode, engine, textureFormat) {
  118184. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE; }
  118185. if (textureFormat === void 0) { textureFormat = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118186. var _this = _super.call(this, name, "tonemap", ["_ExposureAdjustment"], null, 1.0, camera, samplingMode, engine, true, null, textureFormat) || this;
  118187. _this._operator = _operator;
  118188. _this.exposureAdjustment = exposureAdjustment;
  118189. var defines = "#define ";
  118190. if (_this._operator === TonemappingOperator.Hable) {
  118191. defines += "HABLE_TONEMAPPING";
  118192. }
  118193. else if (_this._operator === TonemappingOperator.Reinhard) {
  118194. defines += "REINHARD_TONEMAPPING";
  118195. }
  118196. else if (_this._operator === TonemappingOperator.HejiDawson) {
  118197. defines += "OPTIMIZED_HEJIDAWSON_TONEMAPPING";
  118198. }
  118199. else if (_this._operator === TonemappingOperator.Photographic) {
  118200. defines += "PHOTOGRAPHIC_TONEMAPPING";
  118201. }
  118202. //sadly a second call to create the effect.
  118203. _this.updateEffect(defines);
  118204. _this.onApply = function (effect) {
  118205. effect.setFloat("_ExposureAdjustment", _this.exposureAdjustment);
  118206. };
  118207. return _this;
  118208. }
  118209. return TonemapPostProcess;
  118210. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  118211. /***/ }),
  118212. /***/ "./PostProcesses/volumetricLightScatteringPostProcess.ts":
  118213. /*!***************************************************************!*\
  118214. !*** ./PostProcesses/volumetricLightScatteringPostProcess.ts ***!
  118215. \***************************************************************/
  118216. /*! exports provided: VolumetricLightScatteringPostProcess */
  118217. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118218. "use strict";
  118219. __webpack_require__.r(__webpack_exports__);
  118220. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return VolumetricLightScatteringPostProcess; });
  118221. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118222. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  118223. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  118224. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118225. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  118226. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  118227. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  118228. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  118229. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  118230. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118231. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  118232. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118233. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118234. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  118235. /* harmony import */ var _Shaders_volumetricLightScattering_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/volumetricLightScattering.fragment */ "./Shaders/volumetricLightScattering.fragment.ts");
  118236. /* harmony import */ var _Shaders_volumetricLightScatteringPass_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/volumetricLightScatteringPass.fragment */ "./Shaders/volumetricLightScatteringPass.fragment.ts");
  118237. /**
  118238. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  118239. */
  118240. var VolumetricLightScatteringPostProcess = /** @class */ (function (_super) {
  118241. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumetricLightScatteringPostProcess, _super);
  118242. /**
  118243. * @constructor
  118244. * @param name The post-process name
  118245. * @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)
  118246. * @param camera The camera that the post-process will be attached to
  118247. * @param mesh The mesh used to create the light scattering
  118248. * @param samples The post-process quality, default 100
  118249. * @param samplingModeThe post-process filtering mode
  118250. * @param engine The babylon engine
  118251. * @param reusable If the post-process is reusable
  118252. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  118253. */
  118254. function VolumetricLightScatteringPostProcess(name, ratio, camera, mesh, samples, samplingMode, engine, reusable, scene) {
  118255. if (samples === void 0) { samples = 100; }
  118256. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].BILINEAR_SAMPLINGMODE; }
  118257. 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;
  118258. _this._screenCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  118259. /**
  118260. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  118261. */
  118262. _this.customMeshPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  118263. /**
  118264. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  118265. */
  118266. _this.useCustomMeshPosition = false;
  118267. /**
  118268. * If the post-process should inverse the light scattering direction
  118269. */
  118270. _this.invert = true;
  118271. /**
  118272. * Array containing the excluded meshes not rendered in the internal pass
  118273. */
  118274. _this.excludedMeshes = new Array();
  118275. /**
  118276. * Controls the overall intensity of the post-process
  118277. */
  118278. _this.exposure = 0.3;
  118279. /**
  118280. * Dissipates each sample's contribution in range [0, 1]
  118281. */
  118282. _this.decay = 0.96815;
  118283. /**
  118284. * Controls the overall intensity of each sample
  118285. */
  118286. _this.weight = 0.58767;
  118287. /**
  118288. * Controls the density of each sample
  118289. */
  118290. _this.density = 0.926;
  118291. scene = ((camera === null) ? scene : camera.getScene()); // parameter "scene" can be null.
  118292. engine = scene.getEngine();
  118293. _this._viewPort = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Viewport"](0, 0, 1, 1).toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  118294. // Configure mesh
  118295. _this.mesh = ((mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene));
  118296. // Configure
  118297. _this._createPass(scene, ratio.passRatio || ratio);
  118298. _this.onActivate = function (camera) {
  118299. if (!_this.isSupported) {
  118300. _this.dispose(camera);
  118301. }
  118302. _this.onActivate = null;
  118303. };
  118304. _this.onApplyObservable.add(function (effect) {
  118305. _this._updateMeshScreenCoordinates(scene);
  118306. effect.setTexture("lightScatteringSampler", _this._volumetricLightScatteringRTT);
  118307. effect.setFloat("exposure", _this.exposure);
  118308. effect.setFloat("decay", _this.decay);
  118309. effect.setFloat("weight", _this.weight);
  118310. effect.setFloat("density", _this.density);
  118311. effect.setVector2("meshPositionOnScreen", _this._screenCoordinates);
  118312. });
  118313. return _this;
  118314. }
  118315. Object.defineProperty(VolumetricLightScatteringPostProcess.prototype, "useDiffuseColor", {
  118316. /**
  118317. * @hidden
  118318. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  118319. */
  118320. get: function () {
  118321. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  118322. return false;
  118323. },
  118324. set: function (useDiffuseColor) {
  118325. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  118326. },
  118327. enumerable: true,
  118328. configurable: true
  118329. });
  118330. /**
  118331. * Returns the string "VolumetricLightScatteringPostProcess"
  118332. * @returns "VolumetricLightScatteringPostProcess"
  118333. */
  118334. VolumetricLightScatteringPostProcess.prototype.getClassName = function () {
  118335. return "VolumetricLightScatteringPostProcess";
  118336. };
  118337. VolumetricLightScatteringPostProcess.prototype._isReady = function (subMesh, useInstances) {
  118338. var mesh = subMesh.getMesh();
  118339. // Render this.mesh as default
  118340. if (mesh === this.mesh && mesh.material) {
  118341. return mesh.material.isReady(mesh);
  118342. }
  118343. var defines = [];
  118344. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  118345. var material = subMesh.getMaterial();
  118346. // Alpha test
  118347. if (material) {
  118348. if (material.needAlphaTesting()) {
  118349. defines.push("#define ALPHATEST");
  118350. }
  118351. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind)) {
  118352. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  118353. defines.push("#define UV1");
  118354. }
  118355. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind)) {
  118356. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  118357. defines.push("#define UV2");
  118358. }
  118359. }
  118360. // Bones
  118361. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  118362. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  118363. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  118364. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  118365. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  118366. }
  118367. else {
  118368. defines.push("#define NUM_BONE_INFLUENCERS 0");
  118369. }
  118370. // Instances
  118371. if (useInstances) {
  118372. defines.push("#define INSTANCES");
  118373. attribs.push("world0");
  118374. attribs.push("world1");
  118375. attribs.push("world2");
  118376. attribs.push("world3");
  118377. }
  118378. // Get correct effect
  118379. var join = defines.join("\n");
  118380. if (this._cachedDefines !== join) {
  118381. this._cachedDefines = join;
  118382. this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect({ vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" }, attribs, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], join);
  118383. }
  118384. return this._volumetricLightScatteringPass.isReady();
  118385. };
  118386. /**
  118387. * Sets the new light position for light scattering effect
  118388. * @param position The new custom light position
  118389. */
  118390. VolumetricLightScatteringPostProcess.prototype.setCustomMeshPosition = function (position) {
  118391. this.customMeshPosition = position;
  118392. };
  118393. /**
  118394. * Returns the light position for light scattering effect
  118395. * @return Vector3 The custom light position
  118396. */
  118397. VolumetricLightScatteringPostProcess.prototype.getCustomMeshPosition = function () {
  118398. return this.customMeshPosition;
  118399. };
  118400. /**
  118401. * Disposes the internal assets and detaches the post-process from the camera
  118402. */
  118403. VolumetricLightScatteringPostProcess.prototype.dispose = function (camera) {
  118404. var rttIndex = camera.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
  118405. if (rttIndex !== -1) {
  118406. camera.getScene().customRenderTargets.splice(rttIndex, 1);
  118407. }
  118408. this._volumetricLightScatteringRTT.dispose();
  118409. _super.prototype.dispose.call(this, camera);
  118410. };
  118411. /**
  118412. * Returns the render target texture used by the post-process
  118413. * @return the render target texture used by the post-process
  118414. */
  118415. VolumetricLightScatteringPostProcess.prototype.getPass = function () {
  118416. return this._volumetricLightScatteringRTT;
  118417. };
  118418. // Private methods
  118419. VolumetricLightScatteringPostProcess.prototype._meshExcluded = function (mesh) {
  118420. if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  118421. return true;
  118422. }
  118423. return false;
  118424. };
  118425. VolumetricLightScatteringPostProcess.prototype._createPass = function (scene, ratio) {
  118426. var _this = this;
  118427. var engine = scene.getEngine();
  118428. 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);
  118429. this._volumetricLightScatteringRTT.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  118430. this._volumetricLightScatteringRTT.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  118431. this._volumetricLightScatteringRTT.renderList = null;
  118432. this._volumetricLightScatteringRTT.renderParticles = false;
  118433. this._volumetricLightScatteringRTT.ignoreCameraViewport = true;
  118434. var camera = this.getCamera();
  118435. if (camera) {
  118436. camera.customRenderTargets.push(this._volumetricLightScatteringRTT);
  118437. }
  118438. else {
  118439. scene.customRenderTargets.push(this._volumetricLightScatteringRTT);
  118440. }
  118441. // Custom render function for submeshes
  118442. var renderSubMesh = function (subMesh) {
  118443. var mesh = subMesh.getRenderingMesh();
  118444. if (_this._meshExcluded(mesh)) {
  118445. return;
  118446. }
  118447. var material = subMesh.getMaterial();
  118448. if (!material) {
  118449. return;
  118450. }
  118451. var scene = mesh.getScene();
  118452. var engine = scene.getEngine();
  118453. // Culling
  118454. engine.setState(material.backFaceCulling);
  118455. // Managing instances
  118456. var batch = mesh._getInstancesRenderList(subMesh._id);
  118457. if (batch.mustReturn) {
  118458. return;
  118459. }
  118460. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  118461. if (_this._isReady(subMesh, hardwareInstancedRendering)) {
  118462. var effect = _this._volumetricLightScatteringPass;
  118463. if (mesh === _this.mesh) {
  118464. if (subMesh.effect) {
  118465. effect = subMesh.effect;
  118466. }
  118467. else {
  118468. effect = material.getEffect();
  118469. }
  118470. }
  118471. engine.enableEffect(effect);
  118472. mesh._bind(subMesh, effect, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode);
  118473. if (mesh === _this.mesh) {
  118474. material.bind(mesh.getWorldMatrix(), mesh);
  118475. }
  118476. else {
  118477. _this._volumetricLightScatteringPass.setMatrix("viewProjection", scene.getTransformMatrix());
  118478. // Alpha test
  118479. if (material && material.needAlphaTesting()) {
  118480. var alphaTexture = material.getAlphaTestTexture();
  118481. _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
  118482. if (alphaTexture) {
  118483. _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  118484. }
  118485. }
  118486. // Bones
  118487. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  118488. _this._volumetricLightScatteringPass.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  118489. }
  118490. }
  118491. // Draw
  118492. mesh._processRendering(subMesh, _this._volumetricLightScatteringPass, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return effect.setMatrix("world", world); });
  118493. }
  118494. };
  118495. // Render target texture callbacks
  118496. var savedSceneClearColor;
  118497. var sceneClearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0.0, 0.0, 0.0, 1.0);
  118498. this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function () {
  118499. savedSceneClearColor = scene.clearColor;
  118500. scene.clearColor = sceneClearColor;
  118501. });
  118502. this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function () {
  118503. scene.clearColor = savedSceneClearColor;
  118504. });
  118505. this._volumetricLightScatteringRTT.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  118506. var engine = scene.getEngine();
  118507. var index;
  118508. if (depthOnlySubMeshes.length) {
  118509. engine.setColorWrite(false);
  118510. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  118511. renderSubMesh(depthOnlySubMeshes.data[index]);
  118512. }
  118513. engine.setColorWrite(true);
  118514. }
  118515. for (index = 0; index < opaqueSubMeshes.length; index++) {
  118516. renderSubMesh(opaqueSubMeshes.data[index]);
  118517. }
  118518. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  118519. renderSubMesh(alphaTestSubMeshes.data[index]);
  118520. }
  118521. if (transparentSubMeshes.length) {
  118522. // Sort sub meshes
  118523. for (index = 0; index < transparentSubMeshes.length; index++) {
  118524. var submesh = transparentSubMeshes.data[index];
  118525. var boundingInfo = submesh.getBoundingInfo();
  118526. if (boundingInfo && scene.activeCamera) {
  118527. submesh._alphaIndex = submesh.getMesh().alphaIndex;
  118528. submesh._distanceToCamera = boundingInfo.boundingSphere.centerWorld.subtract(scene.activeCamera.position).length();
  118529. }
  118530. }
  118531. var sortedArray = transparentSubMeshes.data.slice(0, transparentSubMeshes.length);
  118532. sortedArray.sort(function (a, b) {
  118533. // Alpha index first
  118534. if (a._alphaIndex > b._alphaIndex) {
  118535. return 1;
  118536. }
  118537. if (a._alphaIndex < b._alphaIndex) {
  118538. return -1;
  118539. }
  118540. // Then distance to camera
  118541. if (a._distanceToCamera < b._distanceToCamera) {
  118542. return 1;
  118543. }
  118544. if (a._distanceToCamera > b._distanceToCamera) {
  118545. return -1;
  118546. }
  118547. return 0;
  118548. });
  118549. // Render sub meshes
  118550. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_COMBINE);
  118551. for (index = 0; index < sortedArray.length; index++) {
  118552. renderSubMesh(sortedArray[index]);
  118553. }
  118554. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_DISABLE);
  118555. }
  118556. };
  118557. };
  118558. VolumetricLightScatteringPostProcess.prototype._updateMeshScreenCoordinates = function (scene) {
  118559. var transform = scene.getTransformMatrix();
  118560. var meshPosition;
  118561. if (this.useCustomMeshPosition) {
  118562. meshPosition = this.customMeshPosition;
  118563. }
  118564. else if (this.attachedNode) {
  118565. meshPosition = this.attachedNode.position;
  118566. }
  118567. else {
  118568. meshPosition = this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
  118569. }
  118570. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Project(meshPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity(), transform, this._viewPort);
  118571. this._screenCoordinates.x = pos.x / this._viewPort.width;
  118572. this._screenCoordinates.y = pos.y / this._viewPort.height;
  118573. if (this.invert) {
  118574. this._screenCoordinates.y = 1.0 - this._screenCoordinates.y;
  118575. }
  118576. };
  118577. // Static methods
  118578. /**
  118579. * Creates a default mesh for the Volumeric Light Scattering post-process
  118580. * @param name The mesh name
  118581. * @param scene The scene where to create the mesh
  118582. * @return the default mesh
  118583. */
  118584. VolumetricLightScatteringPostProcess.CreateDefaultMesh = function (name, scene) {
  118585. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__["Mesh"].CreatePlane(name, 1, scene);
  118586. mesh.billboardMode = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__["AbstractMesh"].BILLBOARDMODE_ALL;
  118587. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"](name + "Material", scene);
  118588. material.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  118589. mesh.material = material;
  118590. return mesh;
  118591. };
  118592. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118593. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  118594. ], VolumetricLightScatteringPostProcess.prototype, "customMeshPosition", void 0);
  118595. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118596. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118597. ], VolumetricLightScatteringPostProcess.prototype, "useCustomMeshPosition", void 0);
  118598. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118599. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118600. ], VolumetricLightScatteringPostProcess.prototype, "invert", void 0);
  118601. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118602. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  118603. ], VolumetricLightScatteringPostProcess.prototype, "mesh", void 0);
  118604. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118605. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118606. ], VolumetricLightScatteringPostProcess.prototype, "excludedMeshes", void 0);
  118607. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118608. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118609. ], VolumetricLightScatteringPostProcess.prototype, "exposure", void 0);
  118610. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118611. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118612. ], VolumetricLightScatteringPostProcess.prototype, "decay", void 0);
  118613. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118614. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118615. ], VolumetricLightScatteringPostProcess.prototype, "weight", void 0);
  118616. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118617. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118618. ], VolumetricLightScatteringPostProcess.prototype, "density", void 0);
  118619. return VolumetricLightScatteringPostProcess;
  118620. }(_postProcess__WEBPACK_IMPORTED_MODULE_11__["PostProcess"]));
  118621. /***/ }),
  118622. /***/ "./PostProcesses/vrDistortionCorrectionPostProcess.ts":
  118623. /*!************************************************************!*\
  118624. !*** ./PostProcesses/vrDistortionCorrectionPostProcess.ts ***!
  118625. \************************************************************/
  118626. /*! exports provided: VRDistortionCorrectionPostProcess */
  118627. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118628. "use strict";
  118629. __webpack_require__.r(__webpack_exports__);
  118630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return VRDistortionCorrectionPostProcess; });
  118631. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118632. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118633. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118634. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118635. /* harmony import */ var _Shaders_vrDistortionCorrection_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/vrDistortionCorrection.fragment */ "./Shaders/vrDistortionCorrection.fragment.ts");
  118636. /**
  118637. * VRDistortionCorrectionPostProcess used for mobile VR
  118638. */
  118639. var VRDistortionCorrectionPostProcess = /** @class */ (function (_super) {
  118640. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDistortionCorrectionPostProcess, _super);
  118641. /**
  118642. * Initializes the VRDistortionCorrectionPostProcess
  118643. * @param name The name of the effect.
  118644. * @param camera The camera to apply the render pass to.
  118645. * @param isRightEye If this is for the right eye distortion
  118646. * @param vrMetrics All the required metrics for the VR camera
  118647. */
  118648. function VRDistortionCorrectionPostProcess(name, camera, isRightEye, vrMetrics) {
  118649. var _this = _super.call(this, name, "vrDistortionCorrection", [
  118650. 'LensCenter',
  118651. 'Scale',
  118652. 'ScaleIn',
  118653. 'HmdWarpParam'
  118654. ], null, vrMetrics.postProcessScaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  118655. _this._isRightEye = isRightEye;
  118656. _this._distortionFactors = vrMetrics.distortionK;
  118657. _this._postProcessScaleFactor = vrMetrics.postProcessScaleFactor;
  118658. _this._lensCenterOffset = vrMetrics.lensCenterOffset;
  118659. _this.adaptScaleToCurrentViewport = true;
  118660. _this.onSizeChangedObservable.add(function () {
  118661. _this._scaleIn = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](2, 2 / _this.aspectRatio);
  118662. _this._scaleFactor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
  118663. _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);
  118664. });
  118665. _this.onApplyObservable.add(function (effect) {
  118666. effect.setFloat2("LensCenter", _this._lensCenter.x, _this._lensCenter.y);
  118667. effect.setFloat2("Scale", _this._scaleFactor.x, _this._scaleFactor.y);
  118668. effect.setFloat2("ScaleIn", _this._scaleIn.x, _this._scaleIn.y);
  118669. effect.setFloat4("HmdWarpParam", _this._distortionFactors[0], _this._distortionFactors[1], _this._distortionFactors[2], _this._distortionFactors[3]);
  118670. });
  118671. return _this;
  118672. }
  118673. return VRDistortionCorrectionPostProcess;
  118674. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  118675. /***/ }),
  118676. /***/ "./Probes/index.ts":
  118677. /*!*************************!*\
  118678. !*** ./Probes/index.ts ***!
  118679. \*************************/
  118680. /*! exports provided: ReflectionProbe */
  118681. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118682. "use strict";
  118683. __webpack_require__.r(__webpack_exports__);
  118684. /* harmony import */ var _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./reflectionProbe */ "./Probes/reflectionProbe.ts");
  118685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  118686. /***/ }),
  118687. /***/ "./Probes/reflectionProbe.ts":
  118688. /*!***********************************!*\
  118689. !*** ./Probes/reflectionProbe.ts ***!
  118690. \***********************************/
  118691. /*! exports provided: ReflectionProbe */
  118692. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118693. "use strict";
  118694. __webpack_require__.r(__webpack_exports__);
  118695. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return ReflectionProbe; });
  118696. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118697. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  118698. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  118699. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118700. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  118701. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118702. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.removeReflectionProbe = function (toRemove) {
  118703. if (!this.reflectionProbes) {
  118704. return -1;
  118705. }
  118706. var index = this.reflectionProbes.indexOf(toRemove);
  118707. if (index !== -1) {
  118708. this.reflectionProbes.splice(index, 1);
  118709. }
  118710. return index;
  118711. };
  118712. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.addReflectionProbe = function (newReflectionProbe) {
  118713. if (!this.reflectionProbes) {
  118714. this.reflectionProbes = [];
  118715. }
  118716. this.reflectionProbes.push(newReflectionProbe);
  118717. };
  118718. /**
  118719. * Class used to generate realtime reflection / refraction cube textures
  118720. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118721. */
  118722. var ReflectionProbe = /** @class */ (function () {
  118723. /**
  118724. * Creates a new reflection probe
  118725. * @param name defines the name of the probe
  118726. * @param size defines the texture resolution (for each face)
  118727. * @param scene defines the hosting scene
  118728. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  118729. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  118730. */
  118731. function ReflectionProbe(
  118732. /** defines the name of the probe */
  118733. name, size, scene, generateMipMaps, useFloat) {
  118734. if (generateMipMaps === void 0) { generateMipMaps = true; }
  118735. if (useFloat === void 0) { useFloat = false; }
  118736. var _this = this;
  118737. this.name = name;
  118738. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  118739. this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  118740. this._add = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  118741. this._invertYAxis = false;
  118742. /** Gets or sets probe position (center of the cube map) */
  118743. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  118744. this._scene = scene;
  118745. // Create the scene field if not exist.
  118746. if (!this._scene.reflectionProbes) {
  118747. this._scene.reflectionProbes = new Array();
  118748. }
  118749. this._scene.reflectionProbes.push(this);
  118750. 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);
  118751. this._renderTargetTexture.onBeforeRenderObservable.add(function (faceIndex) {
  118752. switch (faceIndex) {
  118753. case 0:
  118754. _this._add.copyFromFloats(1, 0, 0);
  118755. break;
  118756. case 1:
  118757. _this._add.copyFromFloats(-1, 0, 0);
  118758. break;
  118759. case 2:
  118760. _this._add.copyFromFloats(0, _this._invertYAxis ? 1 : -1, 0);
  118761. break;
  118762. case 3:
  118763. _this._add.copyFromFloats(0, _this._invertYAxis ? -1 : 1, 0);
  118764. break;
  118765. case 4:
  118766. _this._add.copyFromFloats(0, 0, 1);
  118767. break;
  118768. case 5:
  118769. _this._add.copyFromFloats(0, 0, -1);
  118770. break;
  118771. }
  118772. if (_this._attachedMesh) {
  118773. _this.position.copyFrom(_this._attachedMesh.getAbsolutePosition());
  118774. }
  118775. _this.position.addToRef(_this._add, _this._target);
  118776. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(_this.position, _this._target, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), _this._viewMatrix);
  118777. if (scene.activeCamera) {
  118778. _this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
  118779. scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
  118780. }
  118781. scene._forcedViewPosition = _this.position;
  118782. });
  118783. this._renderTargetTexture.onAfterUnbindObservable.add(function () {
  118784. scene._forcedViewPosition = null;
  118785. scene.updateTransformMatrix(true);
  118786. });
  118787. }
  118788. Object.defineProperty(ReflectionProbe.prototype, "samples", {
  118789. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  118790. get: function () {
  118791. return this._renderTargetTexture.samples;
  118792. },
  118793. set: function (value) {
  118794. this._renderTargetTexture.samples = value;
  118795. },
  118796. enumerable: true,
  118797. configurable: true
  118798. });
  118799. Object.defineProperty(ReflectionProbe.prototype, "refreshRate", {
  118800. /** Gets or sets the refresh rate to use (on every frame by default) */
  118801. get: function () {
  118802. return this._renderTargetTexture.refreshRate;
  118803. },
  118804. set: function (value) {
  118805. this._renderTargetTexture.refreshRate = value;
  118806. },
  118807. enumerable: true,
  118808. configurable: true
  118809. });
  118810. /**
  118811. * Gets the hosting scene
  118812. * @returns a Scene
  118813. */
  118814. ReflectionProbe.prototype.getScene = function () {
  118815. return this._scene;
  118816. };
  118817. Object.defineProperty(ReflectionProbe.prototype, "cubeTexture", {
  118818. /** Gets the internal CubeTexture used to render to */
  118819. get: function () {
  118820. return this._renderTargetTexture;
  118821. },
  118822. enumerable: true,
  118823. configurable: true
  118824. });
  118825. Object.defineProperty(ReflectionProbe.prototype, "renderList", {
  118826. /** Gets the list of meshes to render */
  118827. get: function () {
  118828. return this._renderTargetTexture.renderList;
  118829. },
  118830. enumerable: true,
  118831. configurable: true
  118832. });
  118833. /**
  118834. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  118835. * @param mesh defines the mesh to attach to
  118836. */
  118837. ReflectionProbe.prototype.attachToMesh = function (mesh) {
  118838. this._attachedMesh = mesh;
  118839. };
  118840. /**
  118841. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  118842. * @param renderingGroupId The rendering group id corresponding to its index
  118843. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118844. */
  118845. ReflectionProbe.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  118846. this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  118847. };
  118848. /**
  118849. * Clean all associated resources
  118850. */
  118851. ReflectionProbe.prototype.dispose = function () {
  118852. var index = this._scene.reflectionProbes.indexOf(this);
  118853. if (index !== -1) {
  118854. // Remove from the scene if found
  118855. this._scene.reflectionProbes.splice(index, 1);
  118856. }
  118857. if (this._renderTargetTexture) {
  118858. this._renderTargetTexture.dispose();
  118859. this._renderTargetTexture = null;
  118860. }
  118861. };
  118862. /**
  118863. * Converts the reflection probe information to a readable string for debug purpose.
  118864. * @param fullDetails Supports for multiple levels of logging within scene loading
  118865. * @returns the human readable reflection probe info
  118866. */
  118867. ReflectionProbe.prototype.toString = function (fullDetails) {
  118868. var ret = "Name: " + this.name;
  118869. if (fullDetails) {
  118870. ret += ", position: " + this.position.toString();
  118871. if (this._attachedMesh) {
  118872. ret += ", attached mesh: " + this._attachedMesh.name;
  118873. }
  118874. }
  118875. return ret;
  118876. };
  118877. /**
  118878. * Get the class name of the relfection probe.
  118879. * @returns "ReflectionProbe"
  118880. */
  118881. ReflectionProbe.prototype.getClassName = function () {
  118882. return "ReflectionProbe";
  118883. };
  118884. /**
  118885. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  118886. * @returns The JSON representation of the texture
  118887. */
  118888. ReflectionProbe.prototype.serialize = function () {
  118889. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, this._renderTargetTexture.serialize());
  118890. serializationObject.isReflectionProbe = true;
  118891. return serializationObject;
  118892. };
  118893. /**
  118894. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  118895. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  118896. * @param scene Define the scene the parsed reflection probe should be instantiated in
  118897. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  118898. * @returns The parsed reflection probe if successful
  118899. */
  118900. ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
  118901. var reflectionProbe = null;
  118902. if (scene.reflectionProbes) {
  118903. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  118904. var rp = scene.reflectionProbes[index];
  118905. if (rp.name === parsedReflectionProbe.name) {
  118906. reflectionProbe = rp;
  118907. break;
  118908. }
  118909. }
  118910. }
  118911. reflectionProbe = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
  118912. reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
  118913. if (parsedReflectionProbe._attachedMesh) {
  118914. reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
  118915. }
  118916. return reflectionProbe;
  118917. };
  118918. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118919. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  118920. ], ReflectionProbe.prototype, "_attachedMesh", void 0);
  118921. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118922. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  118923. ], ReflectionProbe.prototype, "position", void 0);
  118924. return ReflectionProbe;
  118925. }());
  118926. /***/ }),
  118927. /***/ "./Rendering/boundingBoxRenderer.ts":
  118928. /*!******************************************!*\
  118929. !*** ./Rendering/boundingBoxRenderer.ts ***!
  118930. \******************************************/
  118931. /*! exports provided: BoundingBoxRenderer */
  118932. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118933. "use strict";
  118934. __webpack_require__.r(__webpack_exports__);
  118935. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return BoundingBoxRenderer; });
  118936. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  118937. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  118938. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  118939. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  118940. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118941. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  118942. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  118943. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  118944. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  118945. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  118946. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  118947. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "forceShowBoundingBoxes", {
  118948. get: function () {
  118949. return this._forceShowBoundingBoxes || false;
  118950. },
  118951. set: function (value) {
  118952. this._forceShowBoundingBoxes = value;
  118953. // Lazyly creates a BB renderer if needed.
  118954. if (value) {
  118955. this.getBoundingBoxRenderer();
  118956. }
  118957. },
  118958. enumerable: true,
  118959. configurable: true
  118960. });
  118961. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.getBoundingBoxRenderer = function () {
  118962. if (!this._boundingBoxRenderer) {
  118963. this._boundingBoxRenderer = new BoundingBoxRenderer(this);
  118964. }
  118965. return this._boundingBoxRenderer;
  118966. };
  118967. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "showBoundingBox", {
  118968. get: function () {
  118969. return this._showBoundingBox || false;
  118970. },
  118971. set: function (value) {
  118972. this._showBoundingBox = value;
  118973. // Lazyly creates a BB renderer if needed.
  118974. if (value) {
  118975. this.getScene().getBoundingBoxRenderer();
  118976. }
  118977. },
  118978. enumerable: true,
  118979. configurable: true
  118980. });
  118981. /**
  118982. * Component responsible of rendering the bounding box of the meshes in a scene.
  118983. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  118984. */
  118985. var BoundingBoxRenderer = /** @class */ (function () {
  118986. /**
  118987. * Instantiates a new bounding box renderer in a scene.
  118988. * @param scene the scene the renderer renders in
  118989. */
  118990. function BoundingBoxRenderer(scene) {
  118991. /**
  118992. * The component name helpfull to identify the component in the list of scene components.
  118993. */
  118994. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_BOUNDINGBOXRENDERER;
  118995. /**
  118996. * Color of the bounding box lines placed in front of an object
  118997. */
  118998. this.frontColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  118999. /**
  119000. * Color of the bounding box lines placed behind an object
  119001. */
  119002. this.backColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0.1, 0.1, 0.1);
  119003. /**
  119004. * Defines if the renderer should show the back lines or not
  119005. */
  119006. this.showBackLines = true;
  119007. /**
  119008. * @hidden
  119009. */
  119010. this.renderList = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__["SmartArray"](32);
  119011. this._vertexBuffers = {};
  119012. this.scene = scene;
  119013. scene._addComponent(this);
  119014. }
  119015. /**
  119016. * Registers the component in a given scene
  119017. */
  119018. BoundingBoxRenderer.prototype.register = function () {
  119019. this.scene._beforeEvaluateActiveMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);
  119020. this.scene._activeMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_ACTIVEMESH_BOUNDINGBOXRENDERER, this, this._activeMesh);
  119021. this.scene._evaluateSubMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);
  119022. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);
  119023. };
  119024. BoundingBoxRenderer.prototype._evaluateSubMesh = function (mesh, subMesh) {
  119025. if (mesh.showSubMeshesBoundingBox) {
  119026. var boundingInfo = subMesh.getBoundingInfo();
  119027. if (boundingInfo !== null && boundingInfo !== undefined) {
  119028. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  119029. this.renderList.push(boundingInfo.boundingBox);
  119030. }
  119031. }
  119032. };
  119033. BoundingBoxRenderer.prototype._activeMesh = function (sourceMesh, mesh) {
  119034. if (sourceMesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {
  119035. var boundingInfo = sourceMesh.getBoundingInfo();
  119036. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  119037. this.renderList.push(boundingInfo.boundingBox);
  119038. }
  119039. };
  119040. BoundingBoxRenderer.prototype._prepareRessources = function () {
  119041. if (this._colorShader) {
  119042. return;
  119043. }
  119044. this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__["ShaderMaterial"]("colorShader", this.scene, "color", {
  119045. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind],
  119046. uniforms: ["world", "viewProjection", "color"]
  119047. });
  119048. var engine = this.scene.getEngine();
  119049. var boxdata = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateBox({ size: 1.0 });
  119050. 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);
  119051. this._createIndexBuffer();
  119052. };
  119053. BoundingBoxRenderer.prototype._createIndexBuffer = function () {
  119054. var engine = this.scene.getEngine();
  119055. 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]);
  119056. };
  119057. /**
  119058. * Rebuilds the elements related to this component in case of
  119059. * context lost for instance.
  119060. */
  119061. BoundingBoxRenderer.prototype.rebuild = function () {
  119062. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  119063. if (vb) {
  119064. vb._rebuild();
  119065. }
  119066. this._createIndexBuffer();
  119067. };
  119068. /**
  119069. * @hidden
  119070. */
  119071. BoundingBoxRenderer.prototype.reset = function () {
  119072. this.renderList.reset();
  119073. };
  119074. /**
  119075. * Render the bounding boxes of a specific rendering group
  119076. * @param renderingGroupId defines the rendering group to render
  119077. */
  119078. BoundingBoxRenderer.prototype.render = function (renderingGroupId) {
  119079. if (this.renderList.length === 0) {
  119080. return;
  119081. }
  119082. this._prepareRessources();
  119083. if (!this._colorShader.isReady()) {
  119084. return;
  119085. }
  119086. var engine = this.scene.getEngine();
  119087. engine.setDepthWrite(false);
  119088. this._colorShader._preBind();
  119089. for (var boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {
  119090. var boundingBox = this.renderList.data[boundingBoxIndex];
  119091. if (boundingBox._tag !== renderingGroupId) {
  119092. continue;
  119093. }
  119094. var min = boundingBox.minimum;
  119095. var max = boundingBox.maximum;
  119096. var diff = max.subtract(min);
  119097. var median = min.add(diff.scale(0.5));
  119098. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  119099. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  119100. .multiply(boundingBox.getWorldMatrix());
  119101. // VBOs
  119102. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  119103. if (this.showBackLines) {
  119104. // Back
  119105. engine.setDepthFunctionToGreaterOrEqual();
  119106. this.scene.resetCachedMaterial();
  119107. this._colorShader.setColor4("color", this.backColor.toColor4());
  119108. this._colorShader.bind(worldMatrix);
  119109. // Draw order
  119110. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  119111. }
  119112. // Front
  119113. engine.setDepthFunctionToLess();
  119114. this.scene.resetCachedMaterial();
  119115. this._colorShader.setColor4("color", this.frontColor.toColor4());
  119116. this._colorShader.bind(worldMatrix);
  119117. // Draw order
  119118. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  119119. }
  119120. this._colorShader.unbind();
  119121. engine.setDepthFunctionToLessOrEqual();
  119122. engine.setDepthWrite(true);
  119123. };
  119124. /**
  119125. * In case of occlusion queries, we can render the occlusion bounding box through this method
  119126. * @param mesh Define the mesh to render the occlusion bounding box for
  119127. */
  119128. BoundingBoxRenderer.prototype.renderOcclusionBoundingBox = function (mesh) {
  119129. this._prepareRessources();
  119130. if (!this._colorShader.isReady() || !mesh._boundingInfo) {
  119131. return;
  119132. }
  119133. var engine = this.scene.getEngine();
  119134. engine.setDepthWrite(false);
  119135. engine.setColorWrite(false);
  119136. this._colorShader._preBind();
  119137. var boundingBox = mesh._boundingInfo.boundingBox;
  119138. var min = boundingBox.minimum;
  119139. var max = boundingBox.maximum;
  119140. var diff = max.subtract(min);
  119141. var median = min.add(diff.scale(0.5));
  119142. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  119143. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  119144. .multiply(boundingBox.getWorldMatrix());
  119145. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  119146. engine.setDepthFunctionToLess();
  119147. this.scene.resetCachedMaterial();
  119148. this._colorShader.bind(worldMatrix);
  119149. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  119150. this._colorShader.unbind();
  119151. engine.setDepthFunctionToLessOrEqual();
  119152. engine.setDepthWrite(true);
  119153. engine.setColorWrite(true);
  119154. };
  119155. /**
  119156. * Dispose and release the resources attached to this renderer.
  119157. */
  119158. BoundingBoxRenderer.prototype.dispose = function () {
  119159. if (!this._colorShader) {
  119160. return;
  119161. }
  119162. this.renderList.dispose();
  119163. this._colorShader.dispose();
  119164. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  119165. if (buffer) {
  119166. buffer.dispose();
  119167. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  119168. }
  119169. this.scene.getEngine()._releaseBuffer(this._indexBuffer);
  119170. };
  119171. return BoundingBoxRenderer;
  119172. }());
  119173. /***/ }),
  119174. /***/ "./Rendering/depthRenderer.ts":
  119175. /*!************************************!*\
  119176. !*** ./Rendering/depthRenderer.ts ***!
  119177. \************************************/
  119178. /*! exports provided: DepthRenderer */
  119179. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119180. "use strict";
  119181. __webpack_require__.r(__webpack_exports__);
  119182. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return DepthRenderer; });
  119183. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119184. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  119185. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119186. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  119187. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  119188. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119189. /* harmony import */ var _Shaders_depth_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/depth.fragment */ "./Shaders/depth.fragment.ts");
  119190. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  119191. /**
  119192. * This represents a depth renderer in Babylon.
  119193. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  119194. */
  119195. var DepthRenderer = /** @class */ (function () {
  119196. /**
  119197. * Instantiates a depth renderer
  119198. * @param scene The scene the renderer belongs to
  119199. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  119200. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  119201. */
  119202. function DepthRenderer(scene, type, camera) {
  119203. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT; }
  119204. if (camera === void 0) { camera = null; }
  119205. var _this = this;
  119206. /**
  119207. * Specifiess that the depth renderer will only be used within
  119208. * the camera it is created for.
  119209. * This can help forcing its rendering during the camera processing.
  119210. */
  119211. this.useOnlyInActiveCamera = false;
  119212. this._scene = scene;
  119213. DepthRenderer._SceneComponentInitialization(this._scene);
  119214. this._camera = camera;
  119215. var engine = scene.getEngine();
  119216. // Render target
  119217. this._depthMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]("depthMap", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, this._scene, false, true, type);
  119218. this._depthMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  119219. this._depthMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  119220. this._depthMap.refreshRate = 1;
  119221. this._depthMap.renderParticles = false;
  119222. this._depthMap.renderList = null;
  119223. // Camera to get depth map from to support multiple concurrent cameras
  119224. this._depthMap.activeCamera = this._camera;
  119225. this._depthMap.ignoreCameraViewport = true;
  119226. this._depthMap.useCameraPostProcesses = false;
  119227. // set default depth value to 1.0 (far away)
  119228. this._depthMap.onClearObservable.add(function (engine) {
  119229. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0), true, true, true);
  119230. });
  119231. // Custom render function
  119232. var renderSubMesh = function (subMesh) {
  119233. var mesh = subMesh.getRenderingMesh();
  119234. var scene = _this._scene;
  119235. var engine = scene.getEngine();
  119236. var material = subMesh.getMaterial();
  119237. if (!material) {
  119238. return;
  119239. }
  119240. // Culling and reverse (right handed system)
  119241. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  119242. // Managing instances
  119243. var batch = mesh._getInstancesRenderList(subMesh._id);
  119244. if (batch.mustReturn) {
  119245. return;
  119246. }
  119247. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  119248. var camera = _this._camera || scene.activeCamera;
  119249. if (_this.isReady(subMesh, hardwareInstancedRendering) && camera) {
  119250. engine.enableEffect(_this._effect);
  119251. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  119252. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  119253. _this._effect.setFloat2("depthValues", camera.minZ, camera.minZ + camera.maxZ);
  119254. // Alpha test
  119255. if (material && material.needAlphaTesting()) {
  119256. var alphaTexture = material.getAlphaTestTexture();
  119257. if (alphaTexture) {
  119258. _this._effect.setTexture("diffuseSampler", alphaTexture);
  119259. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  119260. }
  119261. }
  119262. // Bones
  119263. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  119264. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  119265. }
  119266. // Draw
  119267. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  119268. }
  119269. };
  119270. this._depthMap.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  119271. var index;
  119272. if (depthOnlySubMeshes.length) {
  119273. engine.setColorWrite(false);
  119274. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  119275. renderSubMesh(depthOnlySubMeshes.data[index]);
  119276. }
  119277. engine.setColorWrite(true);
  119278. }
  119279. for (index = 0; index < opaqueSubMeshes.length; index++) {
  119280. renderSubMesh(opaqueSubMeshes.data[index]);
  119281. }
  119282. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  119283. renderSubMesh(alphaTestSubMeshes.data[index]);
  119284. }
  119285. };
  119286. }
  119287. /**
  119288. * Creates the depth rendering effect and checks if the effect is ready.
  119289. * @param subMesh The submesh to be used to render the depth map of
  119290. * @param useInstances If multiple world instances should be used
  119291. * @returns if the depth renderer is ready to render the depth map
  119292. */
  119293. DepthRenderer.prototype.isReady = function (subMesh, useInstances) {
  119294. var material = subMesh.getMaterial();
  119295. if (material.disableDepthWrite) {
  119296. return false;
  119297. }
  119298. var defines = [];
  119299. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  119300. var mesh = subMesh.getMesh();
  119301. // Alpha test
  119302. if (material && material.needAlphaTesting() && material.getAlphaTestTexture()) {
  119303. defines.push("#define ALPHATEST");
  119304. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  119305. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  119306. defines.push("#define UV1");
  119307. }
  119308. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  119309. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  119310. defines.push("#define UV2");
  119311. }
  119312. }
  119313. // Bones
  119314. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  119315. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  119316. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  119317. if (mesh.numBoneInfluencers > 4) {
  119318. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  119319. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  119320. }
  119321. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  119322. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  119323. }
  119324. else {
  119325. defines.push("#define NUM_BONE_INFLUENCERS 0");
  119326. }
  119327. // Instances
  119328. if (useInstances) {
  119329. defines.push("#define INSTANCES");
  119330. attribs.push("world0");
  119331. attribs.push("world1");
  119332. attribs.push("world2");
  119333. attribs.push("world3");
  119334. }
  119335. // Get correct effect
  119336. var join = defines.join("\n");
  119337. if (this._cachedDefines !== join) {
  119338. this._cachedDefines = join;
  119339. this._effect = this._scene.getEngine().createEffect("depth", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "depthValues"], ["diffuseSampler"], join);
  119340. }
  119341. return this._effect.isReady();
  119342. };
  119343. /**
  119344. * Gets the texture which the depth map will be written to.
  119345. * @returns The depth map texture
  119346. */
  119347. DepthRenderer.prototype.getDepthMap = function () {
  119348. return this._depthMap;
  119349. };
  119350. /**
  119351. * Disposes of the depth renderer.
  119352. */
  119353. DepthRenderer.prototype.dispose = function () {
  119354. this._depthMap.dispose();
  119355. };
  119356. /** @hidden */
  119357. DepthRenderer._SceneComponentInitialization = function (_) {
  119358. throw "Import DepthRendererSceneComponent before creating DepthRenderer.";
  119359. };
  119360. return DepthRenderer;
  119361. }());
  119362. /***/ }),
  119363. /***/ "./Rendering/depthRendererSceneComponent.ts":
  119364. /*!**************************************************!*\
  119365. !*** ./Rendering/depthRendererSceneComponent.ts ***!
  119366. \**************************************************/
  119367. /*! exports provided: DepthRendererSceneComponent */
  119368. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119369. "use strict";
  119370. __webpack_require__.r(__webpack_exports__);
  119371. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return DepthRendererSceneComponent; });
  119372. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  119373. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  119374. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119375. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  119376. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableDepthRenderer = function (camera) {
  119377. camera = camera || this.activeCamera;
  119378. if (!camera) {
  119379. throw "No camera available to enable depth renderer";
  119380. }
  119381. if (!this._depthRenderer) {
  119382. this._depthRenderer = {};
  119383. }
  119384. if (!this._depthRenderer[camera.id]) {
  119385. var textureType = 0;
  119386. if (this.getEngine().getCaps().textureHalfFloatRender) {
  119387. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  119388. }
  119389. else if (this.getEngine().getCaps().textureFloatRender) {
  119390. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  119391. }
  119392. else {
  119393. throw "Depth renderer does not support int texture type";
  119394. }
  119395. this._depthRenderer[camera.id] = new _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"](this, textureType, camera);
  119396. }
  119397. return this._depthRenderer[camera.id];
  119398. };
  119399. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableDepthRenderer = function (camera) {
  119400. camera = camera || this.activeCamera;
  119401. if (!camera || !this._depthRenderer || !this._depthRenderer[camera.id]) {
  119402. return;
  119403. }
  119404. this._depthRenderer[camera.id].dispose();
  119405. delete this._depthRenderer[camera.id];
  119406. };
  119407. /**
  119408. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  119409. * in several rendering techniques.
  119410. */
  119411. var DepthRendererSceneComponent = /** @class */ (function () {
  119412. /**
  119413. * Creates a new instance of the component for the given scene
  119414. * @param scene Defines the scene to register the component in
  119415. */
  119416. function DepthRendererSceneComponent(scene) {
  119417. /**
  119418. * The component name helpfull to identify the component in the list of scene components.
  119419. */
  119420. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER;
  119421. this.scene = scene;
  119422. }
  119423. /**
  119424. * Registers the component in a given scene
  119425. */
  119426. DepthRendererSceneComponent.prototype.register = function () {
  119427. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets);
  119428. this.scene._gatherActiveCameraRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);
  119429. };
  119430. /**
  119431. * Rebuilds the elements related to this component in case of
  119432. * context lost for instance.
  119433. */
  119434. DepthRendererSceneComponent.prototype.rebuild = function () {
  119435. // Nothing to do for this component
  119436. };
  119437. /**
  119438. * Disposes the component and the associated ressources
  119439. */
  119440. DepthRendererSceneComponent.prototype.dispose = function () {
  119441. for (var key in this.scene._depthRenderer) {
  119442. this.scene._depthRenderer[key].dispose();
  119443. }
  119444. };
  119445. DepthRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  119446. if (this.scene._depthRenderer) {
  119447. for (var key in this.scene._depthRenderer) {
  119448. var depthRenderer = this.scene._depthRenderer[key];
  119449. if (!depthRenderer.useOnlyInActiveCamera) {
  119450. renderTargets.push(depthRenderer.getDepthMap());
  119451. }
  119452. }
  119453. }
  119454. };
  119455. DepthRendererSceneComponent.prototype._gatherActiveCameraRenderTargets = function (renderTargets) {
  119456. if (this.scene._depthRenderer) {
  119457. for (var key in this.scene._depthRenderer) {
  119458. var depthRenderer = this.scene._depthRenderer[key];
  119459. if (depthRenderer.useOnlyInActiveCamera && this.scene.activeCamera.id === key) {
  119460. renderTargets.push(depthRenderer.getDepthMap());
  119461. }
  119462. }
  119463. }
  119464. };
  119465. return DepthRendererSceneComponent;
  119466. }());
  119467. _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]._SceneComponentInitialization = function (scene) {
  119468. // Register the G Buffer component to the scene.
  119469. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER);
  119470. if (!component) {
  119471. component = new DepthRendererSceneComponent(scene);
  119472. scene._addComponent(component);
  119473. }
  119474. };
  119475. /***/ }),
  119476. /***/ "./Rendering/edgesRenderer.ts":
  119477. /*!************************************!*\
  119478. !*** ./Rendering/edgesRenderer.ts ***!
  119479. \************************************/
  119480. /*! exports provided: EdgesRenderer, LineEdgesRenderer */
  119481. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119482. "use strict";
  119483. __webpack_require__.r(__webpack_exports__);
  119484. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return EdgesRenderer; });
  119485. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return LineEdgesRenderer; });
  119486. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119487. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  119488. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  119489. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  119490. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119491. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  119492. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  119493. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  119494. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119495. /* harmony import */ var _Shaders_line_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/line.fragment */ "./Shaders/line.fragment.ts");
  119496. /* harmony import */ var _Shaders_line_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/line.vertex */ "./Shaders/line.vertex.ts");
  119497. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.disableEdgesRendering = function () {
  119498. if (this._edgesRenderer) {
  119499. this._edgesRenderer.dispose();
  119500. this._edgesRenderer = null;
  119501. }
  119502. return this;
  119503. };
  119504. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  119505. if (epsilon === void 0) { epsilon = 0.95; }
  119506. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  119507. this.disableEdgesRendering();
  119508. this._edgesRenderer = new EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  119509. return this;
  119510. };
  119511. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "edgesRenderer", {
  119512. get: function () {
  119513. return this._edgesRenderer;
  119514. },
  119515. enumerable: true,
  119516. configurable: true
  119517. });
  119518. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  119519. if (epsilon === void 0) { epsilon = 0.95; }
  119520. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  119521. this.disableEdgesRendering();
  119522. this._edgesRenderer = new LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  119523. return this;
  119524. };
  119525. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["InstancedLinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  119526. if (epsilon === void 0) { epsilon = 0.95; }
  119527. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  119528. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering.apply(this, arguments);
  119529. return this;
  119530. };
  119531. /**
  119532. * FaceAdjacencies Helper class to generate edges
  119533. */
  119534. var FaceAdjacencies = /** @class */ (function () {
  119535. function FaceAdjacencies() {
  119536. this.edges = new Array();
  119537. this.edgesConnectedCount = 0;
  119538. }
  119539. return FaceAdjacencies;
  119540. }());
  119541. /**
  119542. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  119543. */
  119544. var EdgesRenderer = /** @class */ (function () {
  119545. /**
  119546. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  119547. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  119548. * @param source Mesh used to create edges
  119549. * @param epsilon sum of angles in adjacency to check for edge
  119550. * @param checkVerticesInsteadOfIndices
  119551. * @param generateEdgesLines - should generate Lines or only prepare resources.
  119552. */
  119553. function EdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices, generateEdgesLines) {
  119554. if (epsilon === void 0) { epsilon = 0.95; }
  119555. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  119556. if (generateEdgesLines === void 0) { generateEdgesLines = true; }
  119557. var _this = this;
  119558. /**
  119559. * Define the size of the edges with an orthographic camera
  119560. */
  119561. this.edgesWidthScalerForOrthographic = 1000.0;
  119562. /**
  119563. * Define the size of the edges with a perspective camera
  119564. */
  119565. this.edgesWidthScalerForPerspective = 50.0;
  119566. this._linesPositions = new Array();
  119567. this._linesNormals = new Array();
  119568. this._linesIndices = new Array();
  119569. this._buffers = {};
  119570. this._checkVerticesInsteadOfIndices = false;
  119571. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  119572. this.isEnabled = true;
  119573. this._source = source;
  119574. this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;
  119575. this._epsilon = epsilon;
  119576. this._prepareRessources();
  119577. if (generateEdgesLines) {
  119578. this._generateEdgesLines();
  119579. }
  119580. this._meshRebuildObserver = this._source.onRebuildObservable.add(function () {
  119581. _this._rebuild();
  119582. });
  119583. this._meshDisposeObserver = this._source.onDisposeObservable.add(function () {
  119584. _this.dispose();
  119585. });
  119586. }
  119587. EdgesRenderer.prototype._prepareRessources = function () {
  119588. if (this._lineShader) {
  119589. return;
  119590. }
  119591. this._lineShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("lineShader", this._source.getScene(), "line", {
  119592. attributes: ["position", "normal"],
  119593. uniforms: ["worldViewProjection", "color", "width", "aspectRatio"]
  119594. });
  119595. this._lineShader.disableDepthWrite = true;
  119596. this._lineShader.backFaceCulling = false;
  119597. };
  119598. /** @hidden */
  119599. EdgesRenderer.prototype._rebuild = function () {
  119600. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  119601. if (buffer) {
  119602. buffer._rebuild();
  119603. }
  119604. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  119605. if (buffer) {
  119606. buffer._rebuild();
  119607. }
  119608. var scene = this._source.getScene();
  119609. var engine = scene.getEngine();
  119610. this._ib = engine.createIndexBuffer(this._linesIndices);
  119611. };
  119612. /**
  119613. * Releases the required resources for the edges renderer
  119614. */
  119615. EdgesRenderer.prototype.dispose = function () {
  119616. this._source.onRebuildObservable.remove(this._meshRebuildObserver);
  119617. this._source.onDisposeObservable.remove(this._meshDisposeObserver);
  119618. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  119619. if (buffer) {
  119620. buffer.dispose();
  119621. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  119622. }
  119623. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  119624. if (buffer) {
  119625. buffer.dispose();
  119626. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind] = null;
  119627. }
  119628. this._source.getScene().getEngine()._releaseBuffer(this._ib);
  119629. this._lineShader.dispose();
  119630. };
  119631. EdgesRenderer.prototype._processEdgeForAdjacencies = function (pa, pb, p0, p1, p2) {
  119632. if (pa === p0 && pb === p1 || pa === p1 && pb === p0) {
  119633. return 0;
  119634. }
  119635. if (pa === p1 && pb === p2 || pa === p2 && pb === p1) {
  119636. return 1;
  119637. }
  119638. if (pa === p2 && pb === p0 || pa === p0 && pb === p2) {
  119639. return 2;
  119640. }
  119641. return -1;
  119642. };
  119643. EdgesRenderer.prototype._processEdgeForAdjacenciesWithVertices = function (pa, pb, p0, p1, p2) {
  119644. if (pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p1) || pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p0)) {
  119645. return 0;
  119646. }
  119647. if (pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p2) || pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p1)) {
  119648. return 1;
  119649. }
  119650. if (pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p0) || pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p2)) {
  119651. return 2;
  119652. }
  119653. return -1;
  119654. };
  119655. /**
  119656. * Checks if the pair of p0 and p1 is en edge
  119657. * @param faceIndex
  119658. * @param edge
  119659. * @param faceNormals
  119660. * @param p0
  119661. * @param p1
  119662. * @private
  119663. */
  119664. EdgesRenderer.prototype._checkEdge = function (faceIndex, edge, faceNormals, p0, p1) {
  119665. var needToCreateLine;
  119666. if (edge === undefined) {
  119667. needToCreateLine = true;
  119668. }
  119669. else {
  119670. var dotProduct = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Dot(faceNormals[faceIndex], faceNormals[edge]);
  119671. needToCreateLine = dotProduct < this._epsilon;
  119672. }
  119673. if (needToCreateLine) {
  119674. this.createLine(p0, p1, this._linesPositions.length / 3);
  119675. }
  119676. };
  119677. /**
  119678. * push line into the position, normal and index buffer
  119679. * @protected
  119680. */
  119681. EdgesRenderer.prototype.createLine = function (p0, p1, offset) {
  119682. // Positions
  119683. 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);
  119684. // Normals
  119685. 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);
  119686. // Indices
  119687. this._linesIndices.push(offset, offset + 1, offset + 2, offset, offset + 2, offset + 3);
  119688. };
  119689. /**
  119690. * Generates lines edges from adjacencjes
  119691. * @private
  119692. */
  119693. EdgesRenderer.prototype._generateEdgesLines = function () {
  119694. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  119695. var indices = this._source.getIndices();
  119696. if (!indices || !positions) {
  119697. return;
  119698. }
  119699. // First let's find adjacencies
  119700. var adjacencies = new Array();
  119701. var faceNormals = new Array();
  119702. var index;
  119703. var faceAdjacencies;
  119704. // Prepare faces
  119705. for (index = 0; index < indices.length; index += 3) {
  119706. faceAdjacencies = new FaceAdjacencies();
  119707. var p0Index = indices[index];
  119708. var p1Index = indices[index + 1];
  119709. var p2Index = indices[index + 2];
  119710. faceAdjacencies.p0 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p0Index * 3], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);
  119711. faceAdjacencies.p1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p1Index * 3], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);
  119712. faceAdjacencies.p2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p2Index * 3], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);
  119713. var faceNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Cross(faceAdjacencies.p1.subtract(faceAdjacencies.p0), faceAdjacencies.p2.subtract(faceAdjacencies.p1));
  119714. faceNormal.normalize();
  119715. faceNormals.push(faceNormal);
  119716. adjacencies.push(faceAdjacencies);
  119717. }
  119718. // Scan
  119719. for (index = 0; index < adjacencies.length; index++) {
  119720. faceAdjacencies = adjacencies[index];
  119721. for (var otherIndex = index + 1; otherIndex < adjacencies.length; otherIndex++) {
  119722. var otherFaceAdjacencies = adjacencies[otherIndex];
  119723. if (faceAdjacencies.edgesConnectedCount === 3) { // Full
  119724. break;
  119725. }
  119726. if (otherFaceAdjacencies.edgesConnectedCount === 3) { // Full
  119727. continue;
  119728. }
  119729. var otherP0 = indices[otherIndex * 3];
  119730. var otherP1 = indices[otherIndex * 3 + 1];
  119731. var otherP2 = indices[otherIndex * 3 + 2];
  119732. for (var edgeIndex = 0; edgeIndex < 3; edgeIndex++) {
  119733. var otherEdgeIndex = 0;
  119734. if (faceAdjacencies.edges[edgeIndex] !== undefined) {
  119735. continue;
  119736. }
  119737. switch (edgeIndex) {
  119738. case 0:
  119739. if (this._checkVerticesInsteadOfIndices) {
  119740. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p0, faceAdjacencies.p1, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  119741. }
  119742. else {
  119743. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3], indices[index * 3 + 1], otherP0, otherP1, otherP2);
  119744. }
  119745. break;
  119746. case 1:
  119747. if (this._checkVerticesInsteadOfIndices) {
  119748. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p1, faceAdjacencies.p2, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  119749. }
  119750. else {
  119751. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 1], indices[index * 3 + 2], otherP0, otherP1, otherP2);
  119752. }
  119753. break;
  119754. case 2:
  119755. if (this._checkVerticesInsteadOfIndices) {
  119756. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p2, faceAdjacencies.p0, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  119757. }
  119758. else {
  119759. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 2], indices[index * 3], otherP0, otherP1, otherP2);
  119760. }
  119761. break;
  119762. }
  119763. if (otherEdgeIndex === -1) {
  119764. continue;
  119765. }
  119766. faceAdjacencies.edges[edgeIndex] = otherIndex;
  119767. otherFaceAdjacencies.edges[otherEdgeIndex] = index;
  119768. faceAdjacencies.edgesConnectedCount++;
  119769. otherFaceAdjacencies.edgesConnectedCount++;
  119770. if (faceAdjacencies.edgesConnectedCount === 3) {
  119771. break;
  119772. }
  119773. }
  119774. }
  119775. }
  119776. // Create lines
  119777. for (index = 0; index < adjacencies.length; index++) {
  119778. // 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
  119779. var current = adjacencies[index];
  119780. this._checkEdge(index, current.edges[0], faceNormals, current.p0, current.p1);
  119781. this._checkEdge(index, current.edges[1], faceNormals, current.p1, current.p2);
  119782. this._checkEdge(index, current.edges[2], faceNormals, current.p2, current.p0);
  119783. }
  119784. // Merge into a single mesh
  119785. var engine = this._source.getScene().getEngine();
  119786. 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);
  119787. 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);
  119788. this._ib = engine.createIndexBuffer(this._linesIndices);
  119789. this._indicesCount = this._linesIndices.length;
  119790. };
  119791. /**
  119792. * Checks wether or not the edges renderer is ready to render.
  119793. * @return true if ready, otherwise false.
  119794. */
  119795. EdgesRenderer.prototype.isReady = function () {
  119796. return this._lineShader.isReady();
  119797. };
  119798. /**
  119799. * Renders the edges of the attached mesh,
  119800. */
  119801. EdgesRenderer.prototype.render = function () {
  119802. var scene = this._source.getScene();
  119803. if (!this.isReady() || !scene.activeCamera) {
  119804. return;
  119805. }
  119806. var engine = scene.getEngine();
  119807. this._lineShader._preBind();
  119808. if (this._source.edgesColor.a !== 1) {
  119809. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE);
  119810. }
  119811. else {
  119812. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  119813. }
  119814. // VBOs
  119815. engine.bindBuffers(this._buffers, this._ib, this._lineShader.getEffect());
  119816. scene.resetCachedMaterial();
  119817. this._lineShader.setColor4("color", this._source.edgesColor);
  119818. if (scene.activeCamera.mode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__["Camera"].ORTHOGRAPHIC_CAMERA) {
  119819. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic);
  119820. }
  119821. else {
  119822. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective);
  119823. }
  119824. this._lineShader.setFloat("aspectRatio", engine.getAspectRatio(scene.activeCamera));
  119825. this._lineShader.bind(this._source.getWorldMatrix());
  119826. // Draw order
  119827. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, this._indicesCount);
  119828. this._lineShader.unbind();
  119829. };
  119830. return EdgesRenderer;
  119831. }());
  119832. /**
  119833. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  119834. */
  119835. var LineEdgesRenderer = /** @class */ (function (_super) {
  119836. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LineEdgesRenderer, _super);
  119837. /**
  119838. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  119839. * @param source LineMesh used to generate edges
  119840. * @param epsilon not important (specified angle for edge detection)
  119841. * @param checkVerticesInsteadOfIndices not important for LineMesh
  119842. */
  119843. function LineEdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices) {
  119844. if (epsilon === void 0) { epsilon = 0.95; }
  119845. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  119846. var _this = _super.call(this, source, epsilon, checkVerticesInsteadOfIndices, false) || this;
  119847. _this._generateEdgesLines();
  119848. return _this;
  119849. }
  119850. /**
  119851. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  119852. */
  119853. LineEdgesRenderer.prototype._generateEdgesLines = function () {
  119854. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  119855. var indices = this._source.getIndices();
  119856. if (!indices || !positions) {
  119857. return;
  119858. }
  119859. var p0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  119860. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  119861. var len = indices.length - 1;
  119862. for (var i = 0, offset = 0; i < len; i += 2, offset += 4) {
  119863. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i], p0);
  119864. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i + 1], p1);
  119865. this.createLine(p0, p1, offset);
  119866. }
  119867. // Merge into a single mesh
  119868. var engine = this._source.getScene().getEngine();
  119869. 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);
  119870. 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);
  119871. this._ib = engine.createIndexBuffer(this._linesIndices);
  119872. this._indicesCount = this._linesIndices.length;
  119873. };
  119874. return LineEdgesRenderer;
  119875. }(EdgesRenderer));
  119876. /***/ }),
  119877. /***/ "./Rendering/geometryBufferRenderer.ts":
  119878. /*!*********************************************!*\
  119879. !*** ./Rendering/geometryBufferRenderer.ts ***!
  119880. \*********************************************/
  119881. /*! exports provided: GeometryBufferRenderer */
  119882. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119883. "use strict";
  119884. __webpack_require__.r(__webpack_exports__);
  119885. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return GeometryBufferRenderer; });
  119886. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119887. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  119888. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119889. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119890. /* harmony import */ var _Materials_Textures_multiRenderTarget__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  119891. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  119892. /* harmony import */ var _Shaders_geometry_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/geometry.fragment */ "./Shaders/geometry.fragment.ts");
  119893. /* harmony import */ var _Shaders_geometry_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/geometry.vertex */ "./Shaders/geometry.vertex.ts");
  119894. /**
  119895. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  119896. */
  119897. var GeometryBufferRenderer = /** @class */ (function () {
  119898. /**
  119899. * Creates a new G Buffer for the scene
  119900. * @param scene The scene the buffer belongs to
  119901. * @param ratio How big is the buffer related to the main canvas.
  119902. */
  119903. function GeometryBufferRenderer(scene, ratio) {
  119904. if (ratio === void 0) { ratio = 1; }
  119905. /**
  119906. * Dictionary used to store the previous transformation matrices of each rendered mesh
  119907. * in order to compute objects velocities when enableVelocity is set to "true"
  119908. * @hidden
  119909. */
  119910. this._previousTransformationMatrices = {};
  119911. this._enablePosition = false;
  119912. this._enableVelocity = false;
  119913. this._positionIndex = -1;
  119914. this._velocityIndex = -1;
  119915. this._scene = scene;
  119916. this._ratio = ratio;
  119917. GeometryBufferRenderer._SceneComponentInitialization(this._scene);
  119918. // Render target
  119919. this._createRenderTargets();
  119920. }
  119921. Object.defineProperty(GeometryBufferRenderer.prototype, "renderList", {
  119922. /**
  119923. * Set the render list (meshes to be rendered) used in the G buffer.
  119924. */
  119925. set: function (meshes) {
  119926. this._multiRenderTarget.renderList = meshes;
  119927. },
  119928. enumerable: true,
  119929. configurable: true
  119930. });
  119931. Object.defineProperty(GeometryBufferRenderer.prototype, "isSupported", {
  119932. /**
  119933. * Gets wether or not G buffer are supported by the running hardware.
  119934. * This requires draw buffer supports
  119935. */
  119936. get: function () {
  119937. return this._multiRenderTarget.isSupported;
  119938. },
  119939. enumerable: true,
  119940. configurable: true
  119941. });
  119942. /**
  119943. * Returns the index of the given texture type in the G-Buffer textures array
  119944. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  119945. * @returns the index of the given texture type in the G-Buffer textures array
  119946. */
  119947. GeometryBufferRenderer.prototype.getTextureIndex = function (textureType) {
  119948. switch (textureType) {
  119949. case GeometryBufferRenderer.POSITION_TEXTURE_TYPE: return this._positionIndex;
  119950. case GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE: return this._velocityIndex;
  119951. default: return -1;
  119952. }
  119953. };
  119954. Object.defineProperty(GeometryBufferRenderer.prototype, "enablePosition", {
  119955. /**
  119956. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  119957. */
  119958. get: function () {
  119959. return this._enablePosition;
  119960. },
  119961. /**
  119962. * Sets whether or not objects positions are enabled for the G buffer.
  119963. */
  119964. set: function (enable) {
  119965. this._enablePosition = enable;
  119966. this.dispose();
  119967. this._createRenderTargets();
  119968. },
  119969. enumerable: true,
  119970. configurable: true
  119971. });
  119972. Object.defineProperty(GeometryBufferRenderer.prototype, "enableVelocity", {
  119973. /**
  119974. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  119975. */
  119976. get: function () {
  119977. return this._enableVelocity;
  119978. },
  119979. /**
  119980. * Sets wether or not objects velocities are enabled for the G buffer.
  119981. */
  119982. set: function (enable) {
  119983. this._enableVelocity = enable;
  119984. this.dispose();
  119985. this._createRenderTargets();
  119986. },
  119987. enumerable: true,
  119988. configurable: true
  119989. });
  119990. Object.defineProperty(GeometryBufferRenderer.prototype, "scene", {
  119991. /**
  119992. * Gets the scene associated with the buffer.
  119993. */
  119994. get: function () {
  119995. return this._scene;
  119996. },
  119997. enumerable: true,
  119998. configurable: true
  119999. });
  120000. Object.defineProperty(GeometryBufferRenderer.prototype, "ratio", {
  120001. /**
  120002. * Gets the ratio used by the buffer during its creation.
  120003. * How big is the buffer related to the main canvas.
  120004. */
  120005. get: function () {
  120006. return this._ratio;
  120007. },
  120008. enumerable: true,
  120009. configurable: true
  120010. });
  120011. /**
  120012. * Checks wether everything is ready to render a submesh to the G buffer.
  120013. * @param subMesh the submesh to check readiness for
  120014. * @param useInstances is the mesh drawn using instance or not
  120015. * @returns true if ready otherwise false
  120016. */
  120017. GeometryBufferRenderer.prototype.isReady = function (subMesh, useInstances) {
  120018. var material = subMesh.getMaterial();
  120019. if (material && material.disableDepthWrite) {
  120020. return false;
  120021. }
  120022. var defines = [];
  120023. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  120024. var mesh = subMesh.getMesh();
  120025. // Alpha test
  120026. if (material && material.needAlphaTesting()) {
  120027. defines.push("#define ALPHATEST");
  120028. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  120029. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  120030. defines.push("#define UV1");
  120031. }
  120032. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  120033. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  120034. defines.push("#define UV2");
  120035. }
  120036. }
  120037. // Buffers
  120038. if (this._enablePosition) {
  120039. defines.push("#define POSITION");
  120040. defines.push("#define POSITION_INDEX " + this._positionIndex);
  120041. }
  120042. if (this._enableVelocity) {
  120043. defines.push("#define VELOCITY");
  120044. defines.push("#define VELOCITY_INDEX " + this._velocityIndex);
  120045. }
  120046. // Bones
  120047. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  120048. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  120049. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  120050. if (mesh.numBoneInfluencers > 4) {
  120051. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  120052. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  120053. }
  120054. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  120055. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  120056. }
  120057. else {
  120058. defines.push("#define NUM_BONE_INFLUENCERS 0");
  120059. }
  120060. // Instances
  120061. if (useInstances) {
  120062. defines.push("#define INSTANCES");
  120063. attribs.push("world0");
  120064. attribs.push("world1");
  120065. attribs.push("world2");
  120066. attribs.push("world3");
  120067. }
  120068. // Setup textures count
  120069. defines.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length);
  120070. // Get correct effect
  120071. var join = defines.join("\n");
  120072. if (this._cachedDefines !== join) {
  120073. this._cachedDefines = join;
  120074. this._effect = this._scene.getEngine().createEffect("geometry", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorldViewProjection"], ["diffuseSampler"], join, undefined, undefined, undefined, { buffersCount: this._enablePosition ? 3 : 2 });
  120075. }
  120076. return this._effect.isReady();
  120077. };
  120078. /**
  120079. * Gets the current underlying G Buffer.
  120080. * @returns the buffer
  120081. */
  120082. GeometryBufferRenderer.prototype.getGBuffer = function () {
  120083. return this._multiRenderTarget;
  120084. };
  120085. Object.defineProperty(GeometryBufferRenderer.prototype, "samples", {
  120086. /**
  120087. * Gets the number of samples used to render the buffer (anti aliasing).
  120088. */
  120089. get: function () {
  120090. return this._multiRenderTarget.samples;
  120091. },
  120092. /**
  120093. * Sets the number of samples used to render the buffer (anti aliasing).
  120094. */
  120095. set: function (value) {
  120096. this._multiRenderTarget.samples = value;
  120097. },
  120098. enumerable: true,
  120099. configurable: true
  120100. });
  120101. /**
  120102. * Disposes the renderer and frees up associated resources.
  120103. */
  120104. GeometryBufferRenderer.prototype.dispose = function () {
  120105. this.getGBuffer().dispose();
  120106. };
  120107. GeometryBufferRenderer.prototype._createRenderTargets = function () {
  120108. var _this = this;
  120109. var engine = this._scene.getEngine();
  120110. var count = 2;
  120111. if (this._enablePosition) {
  120112. this._positionIndex = count;
  120113. count++;
  120114. }
  120115. if (this._enableVelocity) {
  120116. this._velocityIndex = count;
  120117. count++;
  120118. }
  120119. 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 });
  120120. if (!this.isSupported) {
  120121. return;
  120122. }
  120123. this._multiRenderTarget.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  120124. this._multiRenderTarget.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  120125. this._multiRenderTarget.refreshRate = 1;
  120126. this._multiRenderTarget.renderParticles = false;
  120127. this._multiRenderTarget.renderList = null;
  120128. // set default depth value to 1.0 (far away)
  120129. this._multiRenderTarget.onClearObservable.add(function (engine) {
  120130. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0.0, 0.0, 0.0, 1.0), true, true, true);
  120131. });
  120132. // Custom render function
  120133. var renderSubMesh = function (subMesh) {
  120134. var mesh = subMesh.getRenderingMesh();
  120135. var scene = _this._scene;
  120136. var engine = scene.getEngine();
  120137. var material = subMesh.getMaterial();
  120138. if (!material) {
  120139. return;
  120140. }
  120141. // Velocity
  120142. if (!_this._previousTransformationMatrices[mesh.uniqueId]) {
  120143. _this._previousTransformationMatrices[mesh.uniqueId] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  120144. }
  120145. // Culling
  120146. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  120147. // Managing instances
  120148. var batch = mesh._getInstancesRenderList(subMesh._id);
  120149. if (batch.mustReturn) {
  120150. return;
  120151. }
  120152. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  120153. if (_this.isReady(subMesh, hardwareInstancedRendering)) {
  120154. engine.enableEffect(_this._effect);
  120155. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  120156. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  120157. _this._effect.setMatrix("view", scene.getViewMatrix());
  120158. // Alpha test
  120159. if (material && material.needAlphaTesting()) {
  120160. var alphaTexture = material.getAlphaTestTexture();
  120161. if (alphaTexture) {
  120162. _this._effect.setTexture("diffuseSampler", alphaTexture);
  120163. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  120164. }
  120165. }
  120166. // Bones
  120167. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  120168. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  120169. }
  120170. // Velocity
  120171. _this._effect.setMatrix("previousWorldViewProjection", _this._previousTransformationMatrices[mesh.uniqueId]);
  120172. // Draw
  120173. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  120174. }
  120175. // Velocity
  120176. _this._previousTransformationMatrices[mesh.uniqueId] = mesh.getWorldMatrix().multiply(_this._scene.getTransformMatrix());
  120177. };
  120178. this._multiRenderTarget.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  120179. var index;
  120180. if (depthOnlySubMeshes.length) {
  120181. engine.setColorWrite(false);
  120182. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  120183. renderSubMesh(depthOnlySubMeshes.data[index]);
  120184. }
  120185. engine.setColorWrite(true);
  120186. }
  120187. for (index = 0; index < opaqueSubMeshes.length; index++) {
  120188. renderSubMesh(opaqueSubMeshes.data[index]);
  120189. }
  120190. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  120191. renderSubMesh(alphaTestSubMeshes.data[index]);
  120192. }
  120193. };
  120194. };
  120195. /**
  120196. * Constant used to retrieve the position texture index in the G-Buffer textures array
  120197. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  120198. */
  120199. GeometryBufferRenderer.POSITION_TEXTURE_TYPE = 1;
  120200. /**
  120201. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  120202. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  120203. */
  120204. GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE = 2;
  120205. /** @hidden */
  120206. GeometryBufferRenderer._SceneComponentInitialization = function (_) {
  120207. throw "Import GeometryBufferRendererSceneComponent before creating GeometryBufferRenderer.";
  120208. };
  120209. return GeometryBufferRenderer;
  120210. }());
  120211. /***/ }),
  120212. /***/ "./Rendering/geometryBufferRendererSceneComponent.ts":
  120213. /*!***********************************************************!*\
  120214. !*** ./Rendering/geometryBufferRendererSceneComponent.ts ***!
  120215. \***********************************************************/
  120216. /*! exports provided: GeometryBufferRendererSceneComponent */
  120217. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120218. "use strict";
  120219. __webpack_require__.r(__webpack_exports__);
  120220. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return GeometryBufferRendererSceneComponent; });
  120221. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  120222. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  120223. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  120224. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "geometryBufferRenderer", {
  120225. get: function () {
  120226. this._geometryBufferRenderer;
  120227. },
  120228. set: function (value) {
  120229. if (value && value.isSupported) {
  120230. this._geometryBufferRenderer = value;
  120231. }
  120232. },
  120233. enumerable: true,
  120234. configurable: true
  120235. });
  120236. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableGeometryBufferRenderer = function (ratio) {
  120237. if (ratio === void 0) { ratio = 1; }
  120238. if (this._geometryBufferRenderer) {
  120239. return this._geometryBufferRenderer;
  120240. }
  120241. this._geometryBufferRenderer = new _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"](this, ratio);
  120242. if (!this._geometryBufferRenderer.isSupported) {
  120243. this._geometryBufferRenderer = null;
  120244. }
  120245. return this._geometryBufferRenderer;
  120246. };
  120247. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableGeometryBufferRenderer = function () {
  120248. if (!this._geometryBufferRenderer) {
  120249. return;
  120250. }
  120251. this._geometryBufferRenderer.dispose();
  120252. this._geometryBufferRenderer = null;
  120253. };
  120254. /**
  120255. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  120256. * in several rendering techniques.
  120257. */
  120258. var GeometryBufferRendererSceneComponent = /** @class */ (function () {
  120259. /**
  120260. * Creates a new instance of the component for the given scene
  120261. * @param scene Defines the scene to register the component in
  120262. */
  120263. function GeometryBufferRendererSceneComponent(scene) {
  120264. /**
  120265. * The component name helpful to identify the component in the list of scene components.
  120266. */
  120267. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER;
  120268. this.scene = scene;
  120269. }
  120270. /**
  120271. * Registers the component in a given scene
  120272. */
  120273. GeometryBufferRendererSceneComponent.prototype.register = function () {
  120274. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets);
  120275. };
  120276. /**
  120277. * Rebuilds the elements related to this component in case of
  120278. * context lost for instance.
  120279. */
  120280. GeometryBufferRendererSceneComponent.prototype.rebuild = function () {
  120281. // Nothing to do for this component
  120282. };
  120283. /**
  120284. * Disposes the component and the associated ressources
  120285. */
  120286. GeometryBufferRendererSceneComponent.prototype.dispose = function () {
  120287. // Nothing to do for this component
  120288. };
  120289. GeometryBufferRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  120290. if (this.scene._geometryBufferRenderer) {
  120291. renderTargets.push(this.scene._geometryBufferRenderer.getGBuffer());
  120292. }
  120293. };
  120294. return GeometryBufferRendererSceneComponent;
  120295. }());
  120296. _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"]._SceneComponentInitialization = function (scene) {
  120297. // Register the G Buffer component to the scene.
  120298. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER);
  120299. if (!component) {
  120300. component = new GeometryBufferRendererSceneComponent(scene);
  120301. scene._addComponent(component);
  120302. }
  120303. };
  120304. /***/ }),
  120305. /***/ "./Rendering/index.ts":
  120306. /*!****************************!*\
  120307. !*** ./Rendering/index.ts ***!
  120308. \****************************/
  120309. /*! exports provided: BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer */
  120310. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120311. "use strict";
  120312. __webpack_require__.r(__webpack_exports__);
  120313. /* harmony import */ var _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBoxRenderer */ "./Rendering/boundingBoxRenderer.ts");
  120314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  120315. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  120316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]; });
  120317. /* harmony import */ var _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./depthRendererSceneComponent */ "./Rendering/depthRendererSceneComponent.ts");
  120318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__["DepthRendererSceneComponent"]; });
  120319. /* harmony import */ var _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./edgesRenderer */ "./Rendering/edgesRenderer.ts");
  120320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["EdgesRenderer"]; });
  120321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["LineEdgesRenderer"]; });
  120322. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  120323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__["GeometryBufferRenderer"]; });
  120324. /* harmony import */ var _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  120325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRendererSceneComponent"]; });
  120326. /* harmony import */ var _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./outlineRenderer */ "./Rendering/outlineRenderer.ts");
  120327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__["OutlineRenderer"]; });
  120328. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  120329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _renderingGroup__WEBPACK_IMPORTED_MODULE_7__["RenderingGroup"]; });
  120330. /* harmony import */ var _renderingManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./renderingManager */ "./Rendering/renderingManager.ts");
  120331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingGroupInfo"]; });
  120332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingManager"]; });
  120333. /* harmony import */ var _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  120334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"]; });
  120335. /***/ }),
  120336. /***/ "./Rendering/outlineRenderer.ts":
  120337. /*!**************************************!*\
  120338. !*** ./Rendering/outlineRenderer.ts ***!
  120339. \**************************************/
  120340. /*! exports provided: OutlineRenderer */
  120341. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120342. "use strict";
  120343. __webpack_require__.r(__webpack_exports__);
  120344. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return OutlineRenderer; });
  120345. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  120346. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  120347. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  120348. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120349. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  120350. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  120351. /* harmony import */ var _Shaders_outline_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/outline.fragment */ "./Shaders/outline.fragment.ts");
  120352. /* harmony import */ var _Shaders_outline_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/outline.vertex */ "./Shaders/outline.vertex.ts");
  120353. /**
  120354. * Gets the outline renderer associated with the scene
  120355. * @returns a OutlineRenderer
  120356. */
  120357. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype.getOutlineRenderer = function () {
  120358. if (!this._outlineRenderer) {
  120359. this._outlineRenderer = new OutlineRenderer(this);
  120360. }
  120361. return this._outlineRenderer;
  120362. };
  120363. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOutline", {
  120364. get: function () {
  120365. return this._renderOutline;
  120366. },
  120367. set: function (value) {
  120368. if (value) {
  120369. // Lazy Load the component.
  120370. this.getScene().getOutlineRenderer();
  120371. }
  120372. this._renderOutline = value;
  120373. },
  120374. enumerable: true,
  120375. configurable: true
  120376. });
  120377. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOverlay", {
  120378. get: function () {
  120379. return this._renderOverlay;
  120380. },
  120381. set: function (value) {
  120382. if (value) {
  120383. // Lazy Load the component.
  120384. this.getScene().getOutlineRenderer();
  120385. }
  120386. this._renderOverlay = value;
  120387. },
  120388. enumerable: true,
  120389. configurable: true
  120390. });
  120391. /**
  120392. * This class is responsible to draw bothe outline/overlay of meshes.
  120393. * It should not be used directly but through the available method on mesh.
  120394. */
  120395. var OutlineRenderer = /** @class */ (function () {
  120396. /**
  120397. * Instantiates a new outline renderer. (There could be only one per scene).
  120398. * @param scene Defines the scene it belongs to
  120399. */
  120400. function OutlineRenderer(scene) {
  120401. /**
  120402. * The name of the component. Each component must have a unique name.
  120403. */
  120404. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OUTLINERENDERER;
  120405. /**
  120406. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  120407. */
  120408. this.zOffset = 1;
  120409. this.scene = scene;
  120410. this._engine = scene.getEngine();
  120411. this.scene._addComponent(this);
  120412. }
  120413. /**
  120414. * Register the component to one instance of a scene.
  120415. */
  120416. OutlineRenderer.prototype.register = function () {
  120417. this.scene._beforeRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh);
  120418. this.scene._afterRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh);
  120419. };
  120420. /**
  120421. * Rebuilds the elements related to this component in case of
  120422. * context lost for instance.
  120423. */
  120424. OutlineRenderer.prototype.rebuild = function () {
  120425. // Nothing to do here.
  120426. };
  120427. /**
  120428. * Disposes the component and the associated ressources.
  120429. */
  120430. OutlineRenderer.prototype.dispose = function () {
  120431. // Nothing to do here.
  120432. };
  120433. /**
  120434. * Renders the outline in the canvas.
  120435. * @param subMesh Defines the sumesh to render
  120436. * @param batch Defines the batch of meshes in case of instances
  120437. * @param useOverlay Defines if the rendering is for the overlay or the outline
  120438. */
  120439. OutlineRenderer.prototype.render = function (subMesh, batch, useOverlay) {
  120440. var _this = this;
  120441. if (useOverlay === void 0) { useOverlay = false; }
  120442. var scene = this.scene;
  120443. var engine = scene.getEngine();
  120444. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  120445. if (!this.isReady(subMesh, hardwareInstancedRendering)) {
  120446. return;
  120447. }
  120448. var mesh = subMesh.getRenderingMesh();
  120449. var material = subMesh.getMaterial();
  120450. if (!material || !scene.activeCamera) {
  120451. return;
  120452. }
  120453. engine.enableEffect(this._effect);
  120454. // Logarithmic depth
  120455. if (material.useLogarithmicDepth) {
  120456. this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  120457. }
  120458. this._effect.setFloat("offset", useOverlay ? 0 : mesh.outlineWidth);
  120459. this._effect.setColor4("color", useOverlay ? mesh.overlayColor : mesh.outlineColor, useOverlay ? mesh.overlayAlpha : material.alpha);
  120460. this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  120461. // Bones
  120462. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  120463. this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  120464. }
  120465. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  120466. // Alpha test
  120467. if (material && material.needAlphaTesting()) {
  120468. var alphaTexture = material.getAlphaTestTexture();
  120469. if (alphaTexture) {
  120470. this._effect.setTexture("diffuseSampler", alphaTexture);
  120471. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  120472. }
  120473. }
  120474. engine.setZOffset(-this.zOffset);
  120475. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { _this._effect.setMatrix("world", world); });
  120476. engine.setZOffset(0);
  120477. };
  120478. /**
  120479. * Returns whether or not the outline renderer is ready for a given submesh.
  120480. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  120481. * @param subMesh Defines the submesh to check readyness for
  120482. * @param useInstances Defines wheter wee are trying to render instances or not
  120483. * @returns true if ready otherwise false
  120484. */
  120485. OutlineRenderer.prototype.isReady = function (subMesh, useInstances) {
  120486. var defines = [];
  120487. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].NormalKind];
  120488. var mesh = subMesh.getMesh();
  120489. var material = subMesh.getMaterial();
  120490. if (material) {
  120491. // Alpha test
  120492. if (material.needAlphaTesting()) {
  120493. defines.push("#define ALPHATEST");
  120494. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind)) {
  120495. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind);
  120496. defines.push("#define UV1");
  120497. }
  120498. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind)) {
  120499. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind);
  120500. defines.push("#define UV2");
  120501. }
  120502. }
  120503. //Logarithmic depth
  120504. if (material.useLogarithmicDepth) {
  120505. defines.push("#define LOGARITHMICDEPTH");
  120506. }
  120507. }
  120508. // Bones
  120509. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  120510. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesKind);
  120511. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsKind);
  120512. if (mesh.numBoneInfluencers > 4) {
  120513. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesExtraKind);
  120514. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsExtraKind);
  120515. }
  120516. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  120517. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  120518. }
  120519. else {
  120520. defines.push("#define NUM_BONE_INFLUENCERS 0");
  120521. }
  120522. // Instances
  120523. if (useInstances) {
  120524. defines.push("#define INSTANCES");
  120525. attribs.push("world0");
  120526. attribs.push("world1");
  120527. attribs.push("world2");
  120528. attribs.push("world3");
  120529. }
  120530. // Get correct effect
  120531. var join = defines.join("\n");
  120532. if (this._cachedDefines !== join) {
  120533. this._cachedDefines = join;
  120534. this._effect = this.scene.getEngine().createEffect("outline", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color", "logarithmicDepthConstant"], ["diffuseSampler"], join);
  120535. }
  120536. return this._effect.isReady();
  120537. };
  120538. OutlineRenderer.prototype._beforeRenderingMesh = function (mesh, subMesh, batch) {
  120539. // Outline - step 1
  120540. this._savedDepthWrite = this._engine.getDepthWrite();
  120541. if (mesh.renderOutline) {
  120542. this._engine.setDepthWrite(false);
  120543. this.render(subMesh, batch);
  120544. this._engine.setDepthWrite(this._savedDepthWrite);
  120545. }
  120546. };
  120547. OutlineRenderer.prototype._afterRenderingMesh = function (mesh, subMesh, batch) {
  120548. // Outline - step 2
  120549. if (mesh.renderOutline && this._savedDepthWrite) {
  120550. this._engine.setDepthWrite(true);
  120551. this._engine.setColorWrite(false);
  120552. this.render(subMesh, batch);
  120553. this._engine.setColorWrite(true);
  120554. }
  120555. // Overlay
  120556. if (mesh.renderOverlay) {
  120557. var currentMode = this._engine.getAlphaMode();
  120558. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALPHA_COMBINE);
  120559. this.render(subMesh, batch, true);
  120560. this._engine.setAlphaMode(currentMode);
  120561. }
  120562. };
  120563. return OutlineRenderer;
  120564. }());
  120565. /***/ }),
  120566. /***/ "./Rendering/renderingGroup.ts":
  120567. /*!*************************************!*\
  120568. !*** ./Rendering/renderingGroup.ts ***!
  120569. \*************************************/
  120570. /*! exports provided: RenderingGroup */
  120571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120572. "use strict";
  120573. __webpack_require__.r(__webpack_exports__);
  120574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return RenderingGroup; });
  120575. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  120576. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120577. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120578. /**
  120579. * This represents the object necessary to create a rendering group.
  120580. * This is exclusively used and created by the rendering manager.
  120581. * To modify the behavior, you use the available helpers in your scene or meshes.
  120582. * @hidden
  120583. */
  120584. var RenderingGroup = /** @class */ (function () {
  120585. /**
  120586. * Creates a new rendering group.
  120587. * @param index The rendering group index
  120588. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  120589. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  120590. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  120591. */
  120592. function RenderingGroup(index, scene, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  120593. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  120594. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  120595. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  120596. this.index = index;
  120597. this._opaqueSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  120598. this._transparentSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  120599. this._alphaTestSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  120600. this._depthOnlySubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  120601. this._particleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  120602. this._spriteManagers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  120603. this._edgesRenderers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  120604. this._scene = scene;
  120605. this.opaqueSortCompareFn = opaqueSortCompareFn;
  120606. this.alphaTestSortCompareFn = alphaTestSortCompareFn;
  120607. this.transparentSortCompareFn = transparentSortCompareFn;
  120608. }
  120609. Object.defineProperty(RenderingGroup.prototype, "opaqueSortCompareFn", {
  120610. /**
  120611. * Set the opaque sort comparison function.
  120612. * If null the sub meshes will be render in the order they were created
  120613. */
  120614. set: function (value) {
  120615. this._opaqueSortCompareFn = value;
  120616. if (value) {
  120617. this._renderOpaque = this.renderOpaqueSorted;
  120618. }
  120619. else {
  120620. this._renderOpaque = RenderingGroup.renderUnsorted;
  120621. }
  120622. },
  120623. enumerable: true,
  120624. configurable: true
  120625. });
  120626. Object.defineProperty(RenderingGroup.prototype, "alphaTestSortCompareFn", {
  120627. /**
  120628. * Set the alpha test sort comparison function.
  120629. * If null the sub meshes will be render in the order they were created
  120630. */
  120631. set: function (value) {
  120632. this._alphaTestSortCompareFn = value;
  120633. if (value) {
  120634. this._renderAlphaTest = this.renderAlphaTestSorted;
  120635. }
  120636. else {
  120637. this._renderAlphaTest = RenderingGroup.renderUnsorted;
  120638. }
  120639. },
  120640. enumerable: true,
  120641. configurable: true
  120642. });
  120643. Object.defineProperty(RenderingGroup.prototype, "transparentSortCompareFn", {
  120644. /**
  120645. * Set the transparent sort comparison function.
  120646. * If null the sub meshes will be render in the order they were created
  120647. */
  120648. set: function (value) {
  120649. if (value) {
  120650. this._transparentSortCompareFn = value;
  120651. }
  120652. else {
  120653. this._transparentSortCompareFn = RenderingGroup.defaultTransparentSortCompare;
  120654. }
  120655. this._renderTransparent = this.renderTransparentSorted;
  120656. },
  120657. enumerable: true,
  120658. configurable: true
  120659. });
  120660. /**
  120661. * Render all the sub meshes contained in the group.
  120662. * @param customRenderFunction Used to override the default render behaviour of the group.
  120663. * @returns true if rendered some submeshes.
  120664. */
  120665. RenderingGroup.prototype.render = function (customRenderFunction, renderSprites, renderParticles, activeMeshes) {
  120666. if (customRenderFunction) {
  120667. customRenderFunction(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
  120668. return;
  120669. }
  120670. var engine = this._scene.getEngine();
  120671. // Depth only
  120672. if (this._depthOnlySubMeshes.length !== 0) {
  120673. engine.setColorWrite(false);
  120674. this._renderAlphaTest(this._depthOnlySubMeshes);
  120675. engine.setColorWrite(true);
  120676. }
  120677. // Opaque
  120678. if (this._opaqueSubMeshes.length !== 0) {
  120679. this._renderOpaque(this._opaqueSubMeshes);
  120680. }
  120681. // Alpha test
  120682. if (this._alphaTestSubMeshes.length !== 0) {
  120683. this._renderAlphaTest(this._alphaTestSubMeshes);
  120684. }
  120685. var stencilState = engine.getStencilBuffer();
  120686. engine.setStencilBuffer(false);
  120687. // Sprites
  120688. if (renderSprites) {
  120689. this._renderSprites();
  120690. }
  120691. // Particles
  120692. if (renderParticles) {
  120693. this._renderParticles(activeMeshes);
  120694. }
  120695. if (this.onBeforeTransparentRendering) {
  120696. this.onBeforeTransparentRendering();
  120697. }
  120698. // Transparent
  120699. if (this._transparentSubMeshes.length !== 0) {
  120700. this._renderTransparent(this._transparentSubMeshes);
  120701. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  120702. }
  120703. // Set back stencil to false in case it changes before the edge renderer.
  120704. engine.setStencilBuffer(false);
  120705. // Edges
  120706. if (this._edgesRenderers.length) {
  120707. for (var edgesRendererIndex = 0; edgesRendererIndex < this._edgesRenderers.length; edgesRendererIndex++) {
  120708. this._edgesRenderers.data[edgesRendererIndex].render();
  120709. }
  120710. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  120711. }
  120712. // Restore Stencil state.
  120713. engine.setStencilBuffer(stencilState);
  120714. };
  120715. /**
  120716. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  120717. * @param subMeshes The submeshes to render
  120718. */
  120719. RenderingGroup.prototype.renderOpaqueSorted = function (subMeshes) {
  120720. return RenderingGroup.renderSorted(subMeshes, this._opaqueSortCompareFn, this._scene.activeCamera, false);
  120721. };
  120722. /**
  120723. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  120724. * @param subMeshes The submeshes to render
  120725. */
  120726. RenderingGroup.prototype.renderAlphaTestSorted = function (subMeshes) {
  120727. return RenderingGroup.renderSorted(subMeshes, this._alphaTestSortCompareFn, this._scene.activeCamera, false);
  120728. };
  120729. /**
  120730. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  120731. * @param subMeshes The submeshes to render
  120732. */
  120733. RenderingGroup.prototype.renderTransparentSorted = function (subMeshes) {
  120734. return RenderingGroup.renderSorted(subMeshes, this._transparentSortCompareFn, this._scene.activeCamera, true);
  120735. };
  120736. /**
  120737. * Renders the submeshes in a specified order.
  120738. * @param subMeshes The submeshes to sort before render
  120739. * @param sortCompareFn The comparison function use to sort
  120740. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  120741. * @param transparent Specifies to activate blending if true
  120742. */
  120743. RenderingGroup.renderSorted = function (subMeshes, sortCompareFn, camera, transparent) {
  120744. var subIndex = 0;
  120745. var subMesh;
  120746. var cameraPosition = camera ? camera.globalPosition : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  120747. for (; subIndex < subMeshes.length; subIndex++) {
  120748. subMesh = subMeshes.data[subIndex];
  120749. subMesh._alphaIndex = subMesh.getMesh().alphaIndex;
  120750. subMesh._distanceToCamera = subMesh.getBoundingInfo().boundingSphere.centerWorld.subtract(cameraPosition).length();
  120751. }
  120752. var sortedArray = subMeshes.data.slice(0, subMeshes.length);
  120753. if (sortCompareFn) {
  120754. sortedArray.sort(sortCompareFn);
  120755. }
  120756. for (subIndex = 0; subIndex < sortedArray.length; subIndex++) {
  120757. subMesh = sortedArray[subIndex];
  120758. if (transparent) {
  120759. var material = subMesh.getMaterial();
  120760. if (material && material.needDepthPrePass) {
  120761. var engine = material.getScene().getEngine();
  120762. engine.setColorWrite(false);
  120763. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  120764. subMesh.render(false);
  120765. engine.setColorWrite(true);
  120766. }
  120767. }
  120768. subMesh.render(transparent);
  120769. }
  120770. };
  120771. /**
  120772. * Renders the submeshes in the order they were dispatched (no sort applied).
  120773. * @param subMeshes The submeshes to render
  120774. */
  120775. RenderingGroup.renderUnsorted = function (subMeshes) {
  120776. for (var subIndex = 0; subIndex < subMeshes.length; subIndex++) {
  120777. var submesh = subMeshes.data[subIndex];
  120778. submesh.render(false);
  120779. }
  120780. };
  120781. /**
  120782. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  120783. * are rendered back to front if in the same alpha index.
  120784. *
  120785. * @param a The first submesh
  120786. * @param b The second submesh
  120787. * @returns The result of the comparison
  120788. */
  120789. RenderingGroup.defaultTransparentSortCompare = function (a, b) {
  120790. // Alpha index first
  120791. if (a._alphaIndex > b._alphaIndex) {
  120792. return 1;
  120793. }
  120794. if (a._alphaIndex < b._alphaIndex) {
  120795. return -1;
  120796. }
  120797. // Then distance to camera
  120798. return RenderingGroup.backToFrontSortCompare(a, b);
  120799. };
  120800. /**
  120801. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  120802. * are rendered back to front.
  120803. *
  120804. * @param a The first submesh
  120805. * @param b The second submesh
  120806. * @returns The result of the comparison
  120807. */
  120808. RenderingGroup.backToFrontSortCompare = function (a, b) {
  120809. // Then distance to camera
  120810. if (a._distanceToCamera < b._distanceToCamera) {
  120811. return 1;
  120812. }
  120813. if (a._distanceToCamera > b._distanceToCamera) {
  120814. return -1;
  120815. }
  120816. return 0;
  120817. };
  120818. /**
  120819. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  120820. * are rendered front to back (prevent overdraw).
  120821. *
  120822. * @param a The first submesh
  120823. * @param b The second submesh
  120824. * @returns The result of the comparison
  120825. */
  120826. RenderingGroup.frontToBackSortCompare = function (a, b) {
  120827. // Then distance to camera
  120828. if (a._distanceToCamera < b._distanceToCamera) {
  120829. return -1;
  120830. }
  120831. if (a._distanceToCamera > b._distanceToCamera) {
  120832. return 1;
  120833. }
  120834. return 0;
  120835. };
  120836. /**
  120837. * Resets the different lists of submeshes to prepare a new frame.
  120838. */
  120839. RenderingGroup.prototype.prepare = function () {
  120840. this._opaqueSubMeshes.reset();
  120841. this._transparentSubMeshes.reset();
  120842. this._alphaTestSubMeshes.reset();
  120843. this._depthOnlySubMeshes.reset();
  120844. this._particleSystems.reset();
  120845. this._spriteManagers.reset();
  120846. this._edgesRenderers.reset();
  120847. };
  120848. RenderingGroup.prototype.dispose = function () {
  120849. this._opaqueSubMeshes.dispose();
  120850. this._transparentSubMeshes.dispose();
  120851. this._alphaTestSubMeshes.dispose();
  120852. this._depthOnlySubMeshes.dispose();
  120853. this._particleSystems.dispose();
  120854. this._spriteManagers.dispose();
  120855. this._edgesRenderers.dispose();
  120856. };
  120857. /**
  120858. * Inserts the submesh in its correct queue depending on its material.
  120859. * @param subMesh The submesh to dispatch
  120860. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  120861. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  120862. */
  120863. RenderingGroup.prototype.dispatch = function (subMesh, mesh, material) {
  120864. // Get mesh and materials if not provided
  120865. if (mesh === undefined) {
  120866. mesh = subMesh.getMesh();
  120867. }
  120868. if (material === undefined) {
  120869. material = subMesh.getMaterial();
  120870. }
  120871. if (material === null || material === undefined) {
  120872. return;
  120873. }
  120874. if (material.needAlphaBlendingForMesh(mesh)) { // Transparent
  120875. this._transparentSubMeshes.push(subMesh);
  120876. }
  120877. else if (material.needAlphaTesting()) { // Alpha test
  120878. if (material.needDepthPrePass) {
  120879. this._depthOnlySubMeshes.push(subMesh);
  120880. }
  120881. this._alphaTestSubMeshes.push(subMesh);
  120882. }
  120883. else {
  120884. if (material.needDepthPrePass) {
  120885. this._depthOnlySubMeshes.push(subMesh);
  120886. }
  120887. this._opaqueSubMeshes.push(subMesh); // Opaque
  120888. }
  120889. if (mesh._edgesRenderer && mesh._edgesRenderer.isEnabled) {
  120890. this._edgesRenderers.push(mesh._edgesRenderer);
  120891. }
  120892. };
  120893. RenderingGroup.prototype.dispatchSprites = function (spriteManager) {
  120894. this._spriteManagers.push(spriteManager);
  120895. };
  120896. RenderingGroup.prototype.dispatchParticles = function (particleSystem) {
  120897. this._particleSystems.push(particleSystem);
  120898. };
  120899. RenderingGroup.prototype._renderParticles = function (activeMeshes) {
  120900. if (this._particleSystems.length === 0) {
  120901. return;
  120902. }
  120903. // Particles
  120904. var activeCamera = this._scene.activeCamera;
  120905. this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
  120906. for (var particleIndex = 0; particleIndex < this._particleSystems.length; particleIndex++) {
  120907. var particleSystem = this._particleSystems.data[particleIndex];
  120908. if ((activeCamera && activeCamera.layerMask & particleSystem.layerMask) === 0) {
  120909. continue;
  120910. }
  120911. var emitter = particleSystem.emitter;
  120912. if (!emitter.position || !activeMeshes || activeMeshes.indexOf(emitter) !== -1) {
  120913. this._scene._activeParticles.addCount(particleSystem.render(), false);
  120914. }
  120915. }
  120916. this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene);
  120917. };
  120918. RenderingGroup.prototype._renderSprites = function () {
  120919. if (!this._scene.spritesEnabled || this._spriteManagers.length === 0) {
  120920. return;
  120921. }
  120922. // Sprites
  120923. var activeCamera = this._scene.activeCamera;
  120924. this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
  120925. for (var id = 0; id < this._spriteManagers.length; id++) {
  120926. var spriteManager = this._spriteManagers.data[id];
  120927. if (((activeCamera && activeCamera.layerMask & spriteManager.layerMask) !== 0)) {
  120928. spriteManager.render();
  120929. }
  120930. }
  120931. this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene);
  120932. };
  120933. return RenderingGroup;
  120934. }());
  120935. /***/ }),
  120936. /***/ "./Rendering/renderingManager.ts":
  120937. /*!***************************************!*\
  120938. !*** ./Rendering/renderingManager.ts ***!
  120939. \***************************************/
  120940. /*! exports provided: RenderingGroupInfo, RenderingManager */
  120941. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120942. "use strict";
  120943. __webpack_require__.r(__webpack_exports__);
  120944. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return RenderingGroupInfo; });
  120945. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return RenderingManager; });
  120946. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  120947. /**
  120948. * This class is used by the onRenderingGroupObservable
  120949. */
  120950. var RenderingGroupInfo = /** @class */ (function () {
  120951. function RenderingGroupInfo() {
  120952. }
  120953. return RenderingGroupInfo;
  120954. }());
  120955. /**
  120956. * This is the manager responsible of all the rendering for meshes sprites and particles.
  120957. * It is enable to manage the different groups as well as the different necessary sort functions.
  120958. * This should not be used directly aside of the few static configurations
  120959. */
  120960. var RenderingManager = /** @class */ (function () {
  120961. /**
  120962. * Instantiates a new rendering group for a particular scene
  120963. * @param scene Defines the scene the groups belongs to
  120964. */
  120965. function RenderingManager(scene) {
  120966. /**
  120967. * @hidden
  120968. */
  120969. this._useSceneAutoClearSetup = false;
  120970. this._renderingGroups = new Array();
  120971. this._autoClearDepthStencil = {};
  120972. this._customOpaqueSortCompareFn = {};
  120973. this._customAlphaTestSortCompareFn = {};
  120974. this._customTransparentSortCompareFn = {};
  120975. this._renderingGroupInfo = new RenderingGroupInfo();
  120976. this._scene = scene;
  120977. for (var i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {
  120978. this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };
  120979. }
  120980. }
  120981. RenderingManager.prototype._clearDepthStencilBuffer = function (depth, stencil) {
  120982. if (depth === void 0) { depth = true; }
  120983. if (stencil === void 0) { stencil = true; }
  120984. if (this._depthStencilBufferAlreadyCleaned) {
  120985. return;
  120986. }
  120987. this._scene.getEngine().clear(null, false, depth, stencil);
  120988. this._depthStencilBufferAlreadyCleaned = true;
  120989. };
  120990. /**
  120991. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  120992. * @hidden
  120993. */
  120994. RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
  120995. // Update the observable context (not null as it only goes away on dispose)
  120996. var info = this._renderingGroupInfo;
  120997. info.scene = this._scene;
  120998. info.camera = this._scene.activeCamera;
  120999. // Dispatch sprites
  121000. if (this._scene.spriteManagers && renderSprites) {
  121001. for (var index = 0; index < this._scene.spriteManagers.length; index++) {
  121002. var manager = this._scene.spriteManagers[index];
  121003. this.dispatchSprites(manager);
  121004. }
  121005. }
  121006. // Render
  121007. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  121008. this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;
  121009. var renderingGroup = this._renderingGroups[index];
  121010. if (!renderingGroup) {
  121011. continue;
  121012. }
  121013. var renderingGroupMask = Math.pow(2, index);
  121014. info.renderingGroupId = index;
  121015. // Before Observable
  121016. this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  121017. // Clear depth/stencil if needed
  121018. if (RenderingManager.AUTOCLEAR) {
  121019. var autoClear = this._useSceneAutoClearSetup ?
  121020. this._scene.getAutoClearDepthStencilSetup(index) :
  121021. this._autoClearDepthStencil[index];
  121022. if (autoClear && autoClear.autoClear) {
  121023. this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);
  121024. }
  121025. }
  121026. // Render
  121027. for (var _i = 0, _a = this._scene._beforeRenderingGroupDrawStage; _i < _a.length; _i++) {
  121028. var step = _a[_i];
  121029. step.action(index);
  121030. }
  121031. renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);
  121032. for (var _b = 0, _c = this._scene._afterRenderingGroupDrawStage; _b < _c.length; _b++) {
  121033. var step = _c[_b];
  121034. step.action(index);
  121035. }
  121036. // After Observable
  121037. this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  121038. }
  121039. };
  121040. /**
  121041. * Resets the different information of the group to prepare a new frame
  121042. * @hidden
  121043. */
  121044. RenderingManager.prototype.reset = function () {
  121045. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  121046. var renderingGroup = this._renderingGroups[index];
  121047. if (renderingGroup) {
  121048. renderingGroup.prepare();
  121049. }
  121050. }
  121051. };
  121052. /**
  121053. * Dispose and release the group and its associated resources.
  121054. * @hidden
  121055. */
  121056. RenderingManager.prototype.dispose = function () {
  121057. this.freeRenderingGroups();
  121058. this._renderingGroups.length = 0;
  121059. this._renderingGroupInfo = null;
  121060. };
  121061. /**
  121062. * Clear the info related to rendering groups preventing retention points during dispose.
  121063. */
  121064. RenderingManager.prototype.freeRenderingGroups = function () {
  121065. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  121066. var renderingGroup = this._renderingGroups[index];
  121067. if (renderingGroup) {
  121068. renderingGroup.dispose();
  121069. }
  121070. }
  121071. };
  121072. RenderingManager.prototype._prepareRenderingGroup = function (renderingGroupId) {
  121073. if (this._renderingGroups[renderingGroupId] === undefined) {
  121074. this._renderingGroups[renderingGroupId] = new _renderingGroup__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"](renderingGroupId, this._scene, this._customOpaqueSortCompareFn[renderingGroupId], this._customAlphaTestSortCompareFn[renderingGroupId], this._customTransparentSortCompareFn[renderingGroupId]);
  121075. }
  121076. };
  121077. /**
  121078. * Add a sprite manager to the rendering manager in order to render it this frame.
  121079. * @param spriteManager Define the sprite manager to render
  121080. */
  121081. RenderingManager.prototype.dispatchSprites = function (spriteManager) {
  121082. var renderingGroupId = spriteManager.renderingGroupId || 0;
  121083. this._prepareRenderingGroup(renderingGroupId);
  121084. this._renderingGroups[renderingGroupId].dispatchSprites(spriteManager);
  121085. };
  121086. /**
  121087. * Add a particle system to the rendering manager in order to render it this frame.
  121088. * @param particleSystem Define the particle system to render
  121089. */
  121090. RenderingManager.prototype.dispatchParticles = function (particleSystem) {
  121091. var renderingGroupId = particleSystem.renderingGroupId || 0;
  121092. this._prepareRenderingGroup(renderingGroupId);
  121093. this._renderingGroups[renderingGroupId].dispatchParticles(particleSystem);
  121094. };
  121095. /**
  121096. * Add a submesh to the manager in order to render it this frame
  121097. * @param subMesh The submesh to dispatch
  121098. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  121099. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  121100. */
  121101. RenderingManager.prototype.dispatch = function (subMesh, mesh, material) {
  121102. if (mesh === undefined) {
  121103. mesh = subMesh.getMesh();
  121104. }
  121105. var renderingGroupId = mesh.renderingGroupId || 0;
  121106. this._prepareRenderingGroup(renderingGroupId);
  121107. this._renderingGroups[renderingGroupId].dispatch(subMesh, mesh, material);
  121108. };
  121109. /**
  121110. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  121111. * This allowed control for front to back rendering or reversly depending of the special needs.
  121112. *
  121113. * @param renderingGroupId The rendering group id corresponding to its index
  121114. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  121115. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  121116. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  121117. */
  121118. RenderingManager.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  121119. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  121120. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  121121. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  121122. this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;
  121123. this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;
  121124. this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;
  121125. if (this._renderingGroups[renderingGroupId]) {
  121126. var group = this._renderingGroups[renderingGroupId];
  121127. group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];
  121128. group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];
  121129. group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];
  121130. }
  121131. };
  121132. /**
  121133. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  121134. *
  121135. * @param renderingGroupId The rendering group id corresponding to its index
  121136. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121137. * @param depth Automatically clears depth between groups if true and autoClear is true.
  121138. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  121139. */
  121140. RenderingManager.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  121141. if (depth === void 0) { depth = true; }
  121142. if (stencil === void 0) { stencil = true; }
  121143. this._autoClearDepthStencil[renderingGroupId] = {
  121144. autoClear: autoClearDepthStencil,
  121145. depth: depth,
  121146. stencil: stencil
  121147. };
  121148. };
  121149. /**
  121150. * Gets the current auto clear configuration for one rendering group of the rendering
  121151. * manager.
  121152. * @param index the rendering group index to get the information for
  121153. * @returns The auto clear setup for the requested rendering group
  121154. */
  121155. RenderingManager.prototype.getAutoClearDepthStencilSetup = function (index) {
  121156. return this._autoClearDepthStencil[index];
  121157. };
  121158. /**
  121159. * The max id used for rendering groups (not included)
  121160. */
  121161. RenderingManager.MAX_RENDERINGGROUPS = 4;
  121162. /**
  121163. * The min id used for rendering groups (included)
  121164. */
  121165. RenderingManager.MIN_RENDERINGGROUPS = 0;
  121166. /**
  121167. * Used to globally prevent autoclearing scenes.
  121168. */
  121169. RenderingManager.AUTOCLEAR = true;
  121170. return RenderingManager;
  121171. }());
  121172. /***/ }),
  121173. /***/ "./Rendering/utilityLayerRenderer.ts":
  121174. /*!*******************************************!*\
  121175. !*** ./Rendering/utilityLayerRenderer.ts ***!
  121176. \*******************************************/
  121177. /*! exports provided: UtilityLayerRenderer */
  121178. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121179. "use strict";
  121180. __webpack_require__.r(__webpack_exports__);
  121181. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return UtilityLayerRenderer; });
  121182. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  121183. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  121184. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  121185. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  121186. /**
  121187. * Renders a layer on top of an existing scene
  121188. */
  121189. var UtilityLayerRenderer = /** @class */ (function () {
  121190. /**
  121191. * Instantiates a UtilityLayerRenderer
  121192. * @param originalScene the original scene that will be rendered on top of
  121193. * @param handleEvents boolean indicating if the utility layer should handle events
  121194. */
  121195. function UtilityLayerRenderer(
  121196. /** the original scene that will be rendered on top of */
  121197. originalScene, handleEvents) {
  121198. if (handleEvents === void 0) { handleEvents = true; }
  121199. var _this = this;
  121200. this.originalScene = originalScene;
  121201. this._pointerCaptures = {};
  121202. this._lastPointerEvents = {};
  121203. /**
  121204. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  121205. */
  121206. this.pickUtilitySceneFirst = true;
  121207. /**
  121208. * If the utility layer should automatically be rendered on top of existing scene
  121209. */
  121210. this.shouldRender = true;
  121211. /**
  121212. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  121213. */
  121214. this.onlyCheckPointerDownEvents = true;
  121215. /**
  121216. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  121217. */
  121218. this.processAllEvents = false;
  121219. /**
  121220. * Observable raised when the pointer move from the utility layer scene to the main scene
  121221. */
  121222. this.onPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  121223. // Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
  121224. this.utilityLayerScene = new _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"](originalScene.getEngine());
  121225. this.utilityLayerScene.useRightHandedSystem = originalScene.useRightHandedSystem;
  121226. this.utilityLayerScene._allowPostProcessClearColor = false;
  121227. originalScene.getEngine().scenes.pop();
  121228. // Detach controls on utility scene, events will be fired by logic below to handle picking priority
  121229. this.utilityLayerScene.detachControl();
  121230. if (handleEvents) {
  121231. this._originalPointerObserver = originalScene.onPrePointerObservable.add(function (prePointerInfo, eventState) {
  121232. if (!_this.utilityLayerScene.activeCamera) {
  121233. return;
  121234. }
  121235. if (!_this.processAllEvents) {
  121236. if (prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE
  121237. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP
  121238. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  121239. return;
  121240. }
  121241. }
  121242. _this.utilityLayerScene.pointerX = originalScene.pointerX;
  121243. _this.utilityLayerScene.pointerY = originalScene.pointerY;
  121244. var pointerEvent = (prePointerInfo.event);
  121245. if (originalScene.isPointerCaptured(pointerEvent.pointerId)) {
  121246. _this._pointerCaptures[pointerEvent.pointerId] = false;
  121247. return;
  121248. }
  121249. var utilityScenePick = prePointerInfo.ray ? _this.utilityLayerScene.pickWithRay(prePointerInfo.ray) : _this.utilityLayerScene.pick(originalScene.pointerX, originalScene.pointerY);
  121250. if (!prePointerInfo.ray && utilityScenePick) {
  121251. prePointerInfo.ray = utilityScenePick.ray;
  121252. }
  121253. // always fire the prepointer oversvable
  121254. _this.utilityLayerScene.onPrePointerObservable.notifyObservers(prePointerInfo);
  121255. // allow every non pointer down event to flow to the utility layer
  121256. if (_this.onlyCheckPointerDownEvents && prePointerInfo.type != _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  121257. if (!prePointerInfo.skipOnPointerObservable) {
  121258. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  121259. }
  121260. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent.pointerId]) {
  121261. _this._pointerCaptures[pointerEvent.pointerId] = false;
  121262. }
  121263. return;
  121264. }
  121265. if (_this.utilityLayerScene.autoClearDepthAndStencil || _this.pickUtilitySceneFirst) {
  121266. // If this layer is an overlay, check if this layer was hit and if so, skip pointer events for the main scene
  121267. if (utilityScenePick && utilityScenePick.hit) {
  121268. if (!prePointerInfo.skipOnPointerObservable) {
  121269. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  121270. }
  121271. prePointerInfo.skipOnPointerObservable = true;
  121272. }
  121273. }
  121274. else {
  121275. var originalScenePick = prePointerInfo.ray ? originalScene.pickWithRay(prePointerInfo.ray) : originalScene.pick(originalScene.pointerX, originalScene.pointerY);
  121276. var pointerEvent_1 = (prePointerInfo.event);
  121277. // If the layer can be occluded by the original scene, only fire pointer events to the first layer that hit they ray
  121278. if (originalScenePick && utilityScenePick) {
  121279. // No pick in utility scene
  121280. if (utilityScenePick.distance === 0 && originalScenePick.pickedMesh) {
  121281. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  121282. // We touched an utility mesh present in the main scene
  121283. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  121284. prePointerInfo.skipOnPointerObservable = true;
  121285. }
  121286. else if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  121287. _this._pointerCaptures[pointerEvent_1.pointerId] = true;
  121288. }
  121289. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  121290. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  121291. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  121292. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  121293. }
  121294. }
  121295. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance < originalScenePick.distance || originalScenePick.distance === 0)) {
  121296. // We pick something in utility scene or the pick in utility is closer than the one in main scene
  121297. _this._notifyObservers(prePointerInfo, utilityScenePick, pointerEvent_1);
  121298. // If a previous utility layer set this, do not unset this
  121299. if (!prePointerInfo.skipOnPointerObservable) {
  121300. prePointerInfo.skipOnPointerObservable = utilityScenePick.distance > 0;
  121301. }
  121302. }
  121303. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance > originalScenePick.distance)) {
  121304. // We have a pick in both scenes but main is closer than utility
  121305. // We touched an utility mesh present in the main scene
  121306. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  121307. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  121308. prePointerInfo.skipOnPointerObservable = true;
  121309. }
  121310. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  121311. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  121312. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  121313. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  121314. }
  121315. }
  121316. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent_1.pointerId]) {
  121317. _this._pointerCaptures[pointerEvent_1.pointerId] = false;
  121318. }
  121319. }
  121320. }
  121321. });
  121322. }
  121323. // Render directly on top of existing scene without clearing
  121324. this.utilityLayerScene.autoClear = false;
  121325. this._afterRenderObserver = this.originalScene.onAfterRenderObservable.add(function () {
  121326. if (_this.shouldRender) {
  121327. _this.render();
  121328. }
  121329. });
  121330. this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function () {
  121331. _this.dispose();
  121332. });
  121333. this._updateCamera();
  121334. }
  121335. Object.defineProperty(UtilityLayerRenderer, "DefaultUtilityLayer", {
  121336. /**
  121337. * 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)
  121338. */
  121339. get: function () {
  121340. if (UtilityLayerRenderer._DefaultUtilityLayer == null) {
  121341. UtilityLayerRenderer._DefaultUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  121342. UtilityLayerRenderer._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  121343. UtilityLayerRenderer._DefaultUtilityLayer = null;
  121344. });
  121345. }
  121346. return UtilityLayerRenderer._DefaultUtilityLayer;
  121347. },
  121348. enumerable: true,
  121349. configurable: true
  121350. });
  121351. Object.defineProperty(UtilityLayerRenderer, "DefaultKeepDepthUtilityLayer", {
  121352. /**
  121353. * 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)
  121354. */
  121355. get: function () {
  121356. if (UtilityLayerRenderer._DefaultKeepDepthUtilityLayer == null) {
  121357. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  121358. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  121359. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  121360. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  121361. });
  121362. }
  121363. return UtilityLayerRenderer._DefaultKeepDepthUtilityLayer;
  121364. },
  121365. enumerable: true,
  121366. configurable: true
  121367. });
  121368. UtilityLayerRenderer.prototype._notifyObservers = function (prePointerInfo, pickInfo, pointerEvent) {
  121369. if (!prePointerInfo.skipOnPointerObservable) {
  121370. this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, pickInfo));
  121371. this._lastPointerEvents[pointerEvent.pointerId] = true;
  121372. }
  121373. };
  121374. /**
  121375. * Renders the utility layers scene on top of the original scene
  121376. */
  121377. UtilityLayerRenderer.prototype.render = function () {
  121378. this._updateCamera();
  121379. if (this.utilityLayerScene.activeCamera) {
  121380. // Set the camera's scene to utility layers scene
  121381. var oldScene = this.utilityLayerScene.activeCamera.getScene();
  121382. var camera = this.utilityLayerScene.activeCamera;
  121383. camera._scene = this.utilityLayerScene;
  121384. if (camera.leftCamera) {
  121385. camera.leftCamera._scene = this.utilityLayerScene;
  121386. }
  121387. if (camera.rightCamera) {
  121388. camera.rightCamera._scene = this.utilityLayerScene;
  121389. }
  121390. this.utilityLayerScene.render(false);
  121391. // Reset camera's scene back to original
  121392. camera._scene = oldScene;
  121393. if (camera.leftCamera) {
  121394. camera.leftCamera._scene = oldScene;
  121395. }
  121396. if (camera.rightCamera) {
  121397. camera.rightCamera._scene = oldScene;
  121398. }
  121399. }
  121400. };
  121401. /**
  121402. * Disposes of the renderer
  121403. */
  121404. UtilityLayerRenderer.prototype.dispose = function () {
  121405. this.onPointerOutObservable.clear();
  121406. if (this._afterRenderObserver) {
  121407. this.originalScene.onAfterRenderObservable.remove(this._afterRenderObserver);
  121408. }
  121409. if (this._sceneDisposeObserver) {
  121410. this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver);
  121411. }
  121412. if (this._originalPointerObserver) {
  121413. this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver);
  121414. }
  121415. this.utilityLayerScene.dispose();
  121416. };
  121417. UtilityLayerRenderer.prototype._updateCamera = function () {
  121418. if (this.originalScene.activeCameras.length > 1) {
  121419. this.utilityLayerScene.activeCamera = this.originalScene.activeCameras[0];
  121420. }
  121421. else {
  121422. this.utilityLayerScene.activeCamera = this.originalScene.activeCamera;
  121423. }
  121424. };
  121425. UtilityLayerRenderer._DefaultUtilityLayer = null;
  121426. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  121427. return UtilityLayerRenderer;
  121428. }());
  121429. /***/ }),
  121430. /***/ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts":
  121431. /*!*****************************************************************!*\
  121432. !*** ./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts ***!
  121433. \*****************************************************************/
  121434. /*! exports provided: backgroundFragmentDeclaration */
  121435. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121436. "use strict";
  121437. __webpack_require__.r(__webpack_exports__);
  121438. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundFragmentDeclaration", function() { return backgroundFragmentDeclaration; });
  121439. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121440. var name = 'backgroundFragmentDeclaration';
  121441. 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";
  121442. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121443. /** @hidden */
  121444. var backgroundFragmentDeclaration = { name: name, shader: shader };
  121445. /***/ }),
  121446. /***/ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts":
  121447. /*!************************************************************!*\
  121448. !*** ./Shaders/ShadersInclude/backgroundUboDeclaration.ts ***!
  121449. \************************************************************/
  121450. /*! exports provided: backgroundUboDeclaration */
  121451. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121452. "use strict";
  121453. __webpack_require__.r(__webpack_exports__);
  121454. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundUboDeclaration", function() { return backgroundUboDeclaration; });
  121455. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121456. var name = 'backgroundUboDeclaration';
  121457. 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};";
  121458. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121459. /** @hidden */
  121460. var backgroundUboDeclaration = { name: name, shader: shader };
  121461. /***/ }),
  121462. /***/ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts":
  121463. /*!***************************************************************!*\
  121464. !*** ./Shaders/ShadersInclude/backgroundVertexDeclaration.ts ***!
  121465. \***************************************************************/
  121466. /*! exports provided: backgroundVertexDeclaration */
  121467. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121468. "use strict";
  121469. __webpack_require__.r(__webpack_exports__);
  121470. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexDeclaration", function() { return backgroundVertexDeclaration; });
  121471. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121472. var name = 'backgroundVertexDeclaration';
  121473. 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";
  121474. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121475. /** @hidden */
  121476. var backgroundVertexDeclaration = { name: name, shader: shader };
  121477. /***/ }),
  121478. /***/ "./Shaders/ShadersInclude/bonesDeclaration.ts":
  121479. /*!****************************************************!*\
  121480. !*** ./Shaders/ShadersInclude/bonesDeclaration.ts ***!
  121481. \****************************************************/
  121482. /*! exports provided: bonesDeclaration */
  121483. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121484. "use strict";
  121485. __webpack_require__.r(__webpack_exports__);
  121486. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesDeclaration", function() { return bonesDeclaration; });
  121487. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121488. var name = 'bonesDeclaration';
  121489. 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";
  121490. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121491. /** @hidden */
  121492. var bonesDeclaration = { name: name, shader: shader };
  121493. /***/ }),
  121494. /***/ "./Shaders/ShadersInclude/bonesVertex.ts":
  121495. /*!***********************************************!*\
  121496. !*** ./Shaders/ShadersInclude/bonesVertex.ts ***!
  121497. \***********************************************/
  121498. /*! exports provided: bonesVertex */
  121499. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121500. "use strict";
  121501. __webpack_require__.r(__webpack_exports__);
  121502. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesVertex", function() { return bonesVertex; });
  121503. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121504. var name = 'bonesVertex';
  121505. 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";
  121506. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121507. /** @hidden */
  121508. var bonesVertex = { name: name, shader: shader };
  121509. /***/ }),
  121510. /***/ "./Shaders/ShadersInclude/bumpFragment.ts":
  121511. /*!************************************************!*\
  121512. !*** ./Shaders/ShadersInclude/bumpFragment.ts ***!
  121513. \************************************************/
  121514. /*! exports provided: bumpFragment */
  121515. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121516. "use strict";
  121517. __webpack_require__.r(__webpack_exports__);
  121518. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragment", function() { return bumpFragment; });
  121519. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121520. var name = 'bumpFragment';
  121521. 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";
  121522. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121523. /** @hidden */
  121524. var bumpFragment = { name: name, shader: shader };
  121525. /***/ }),
  121526. /***/ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts":
  121527. /*!*********************************************************!*\
  121528. !*** ./Shaders/ShadersInclude/bumpFragmentFunctions.ts ***!
  121529. \*********************************************************/
  121530. /*! exports provided: bumpFragmentFunctions */
  121531. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121532. "use strict";
  121533. __webpack_require__.r(__webpack_exports__);
  121534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragmentFunctions", function() { return bumpFragmentFunctions; });
  121535. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121536. var name = 'bumpFragmentFunctions';
  121537. 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";
  121538. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121539. /** @hidden */
  121540. var bumpFragmentFunctions = { name: name, shader: shader };
  121541. /***/ }),
  121542. /***/ "./Shaders/ShadersInclude/bumpVertex.ts":
  121543. /*!**********************************************!*\
  121544. !*** ./Shaders/ShadersInclude/bumpVertex.ts ***!
  121545. \**********************************************/
  121546. /*! exports provided: bumpVertex */
  121547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121548. "use strict";
  121549. __webpack_require__.r(__webpack_exports__);
  121550. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertex", function() { return bumpVertex; });
  121551. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121552. var name = 'bumpVertex';
  121553. 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";
  121554. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121555. /** @hidden */
  121556. var bumpVertex = { name: name, shader: shader };
  121557. /***/ }),
  121558. /***/ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts":
  121559. /*!*********************************************************!*\
  121560. !*** ./Shaders/ShadersInclude/bumpVertexDeclaration.ts ***!
  121561. \*********************************************************/
  121562. /*! exports provided: bumpVertexDeclaration */
  121563. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121564. "use strict";
  121565. __webpack_require__.r(__webpack_exports__);
  121566. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertexDeclaration", function() { return bumpVertexDeclaration; });
  121567. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121568. var name = 'bumpVertexDeclaration';
  121569. var shader = "#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#endif\n";
  121570. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121571. /** @hidden */
  121572. var bumpVertexDeclaration = { name: name, shader: shader };
  121573. /***/ }),
  121574. /***/ "./Shaders/ShadersInclude/clipPlaneFragment.ts":
  121575. /*!*****************************************************!*\
  121576. !*** ./Shaders/ShadersInclude/clipPlaneFragment.ts ***!
  121577. \*****************************************************/
  121578. /*! exports provided: clipPlaneFragment */
  121579. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121580. "use strict";
  121581. __webpack_require__.r(__webpack_exports__);
  121582. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragment", function() { return clipPlaneFragment; });
  121583. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121584. var name = 'clipPlaneFragment';
  121585. 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";
  121586. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121587. /** @hidden */
  121588. var clipPlaneFragment = { name: name, shader: shader };
  121589. /***/ }),
  121590. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts":
  121591. /*!****************************************************************!*\
  121592. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts ***!
  121593. \****************************************************************/
  121594. /*! exports provided: clipPlaneFragmentDeclaration */
  121595. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121596. "use strict";
  121597. __webpack_require__.r(__webpack_exports__);
  121598. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration", function() { return clipPlaneFragmentDeclaration; });
  121599. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121600. var name = 'clipPlaneFragmentDeclaration';
  121601. 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";
  121602. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121603. /** @hidden */
  121604. var clipPlaneFragmentDeclaration = { name: name, shader: shader };
  121605. /***/ }),
  121606. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts":
  121607. /*!*****************************************************************!*\
  121608. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts ***!
  121609. \*****************************************************************/
  121610. /*! exports provided: clipPlaneFragmentDeclaration2 */
  121611. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121612. "use strict";
  121613. __webpack_require__.r(__webpack_exports__);
  121614. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration2", function() { return clipPlaneFragmentDeclaration2; });
  121615. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121616. var name = 'clipPlaneFragmentDeclaration2';
  121617. 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";
  121618. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121619. /** @hidden */
  121620. var clipPlaneFragmentDeclaration2 = { name: name, shader: shader };
  121621. /***/ }),
  121622. /***/ "./Shaders/ShadersInclude/clipPlaneVertex.ts":
  121623. /*!***************************************************!*\
  121624. !*** ./Shaders/ShadersInclude/clipPlaneVertex.ts ***!
  121625. \***************************************************/
  121626. /*! exports provided: clipPlaneVertex */
  121627. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121628. "use strict";
  121629. __webpack_require__.r(__webpack_exports__);
  121630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertex", function() { return clipPlaneVertex; });
  121631. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121632. var name = 'clipPlaneVertex';
  121633. 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";
  121634. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121635. /** @hidden */
  121636. var clipPlaneVertex = { name: name, shader: shader };
  121637. /***/ }),
  121638. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts":
  121639. /*!**************************************************************!*\
  121640. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts ***!
  121641. \**************************************************************/
  121642. /*! exports provided: clipPlaneVertexDeclaration */
  121643. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121644. "use strict";
  121645. __webpack_require__.r(__webpack_exports__);
  121646. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration", function() { return clipPlaneVertexDeclaration; });
  121647. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121648. var name = 'clipPlaneVertexDeclaration';
  121649. 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";
  121650. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121651. /** @hidden */
  121652. var clipPlaneVertexDeclaration = { name: name, shader: shader };
  121653. /***/ }),
  121654. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts":
  121655. /*!***************************************************************!*\
  121656. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts ***!
  121657. \***************************************************************/
  121658. /*! exports provided: clipPlaneVertexDeclaration2 */
  121659. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121660. "use strict";
  121661. __webpack_require__.r(__webpack_exports__);
  121662. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration2", function() { return clipPlaneVertexDeclaration2; });
  121663. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121664. var name = 'clipPlaneVertexDeclaration2';
  121665. 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";
  121666. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121667. /** @hidden */
  121668. var clipPlaneVertexDeclaration2 = { name: name, shader: shader };
  121669. /***/ }),
  121670. /***/ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts":
  121671. /*!**************************************************************!*\
  121672. !*** ./Shaders/ShadersInclude/defaultFragmentDeclaration.ts ***!
  121673. \**************************************************************/
  121674. /*! exports provided: defaultFragmentDeclaration */
  121675. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121676. "use strict";
  121677. __webpack_require__.r(__webpack_exports__);
  121678. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultFragmentDeclaration", function() { return defaultFragmentDeclaration; });
  121679. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121680. var name = 'defaultFragmentDeclaration';
  121681. 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";
  121682. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121683. /** @hidden */
  121684. var defaultFragmentDeclaration = { name: name, shader: shader };
  121685. /***/ }),
  121686. /***/ "./Shaders/ShadersInclude/defaultUboDeclaration.ts":
  121687. /*!*********************************************************!*\
  121688. !*** ./Shaders/ShadersInclude/defaultUboDeclaration.ts ***!
  121689. \*********************************************************/
  121690. /*! exports provided: defaultUboDeclaration */
  121691. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121692. "use strict";
  121693. __webpack_require__.r(__webpack_exports__);
  121694. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultUboDeclaration", function() { return defaultUboDeclaration; });
  121695. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121696. var name = 'defaultUboDeclaration';
  121697. 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};";
  121698. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121699. /** @hidden */
  121700. var defaultUboDeclaration = { name: name, shader: shader };
  121701. /***/ }),
  121702. /***/ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts":
  121703. /*!************************************************************!*\
  121704. !*** ./Shaders/ShadersInclude/defaultVertexDeclaration.ts ***!
  121705. \************************************************************/
  121706. /*! exports provided: defaultVertexDeclaration */
  121707. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121708. "use strict";
  121709. __webpack_require__.r(__webpack_exports__);
  121710. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexDeclaration", function() { return defaultVertexDeclaration; });
  121711. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121712. var name = 'defaultVertexDeclaration';
  121713. 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";
  121714. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121715. /** @hidden */
  121716. var defaultVertexDeclaration = { name: name, shader: shader };
  121717. /***/ }),
  121718. /***/ "./Shaders/ShadersInclude/depthPrePass.ts":
  121719. /*!************************************************!*\
  121720. !*** ./Shaders/ShadersInclude/depthPrePass.ts ***!
  121721. \************************************************/
  121722. /*! exports provided: depthPrePass */
  121723. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121724. "use strict";
  121725. __webpack_require__.r(__webpack_exports__);
  121726. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPrePass", function() { return depthPrePass; });
  121727. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121728. var name = 'depthPrePass';
  121729. var shader = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  121730. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121731. /** @hidden */
  121732. var depthPrePass = { name: name, shader: shader };
  121733. /***/ }),
  121734. /***/ "./Shaders/ShadersInclude/fogFragment.ts":
  121735. /*!***********************************************!*\
  121736. !*** ./Shaders/ShadersInclude/fogFragment.ts ***!
  121737. \***********************************************/
  121738. /*! exports provided: fogFragment */
  121739. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121740. "use strict";
  121741. __webpack_require__.r(__webpack_exports__);
  121742. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragment", function() { return fogFragment; });
  121743. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121744. var name = 'fogFragment';
  121745. var shader = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  121746. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121747. /** @hidden */
  121748. var fogFragment = { name: name, shader: shader };
  121749. /***/ }),
  121750. /***/ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts":
  121751. /*!**********************************************************!*\
  121752. !*** ./Shaders/ShadersInclude/fogFragmentDeclaration.ts ***!
  121753. \**********************************************************/
  121754. /*! exports provided: fogFragmentDeclaration */
  121755. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121756. "use strict";
  121757. __webpack_require__.r(__webpack_exports__);
  121758. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragmentDeclaration", function() { return fogFragmentDeclaration; });
  121759. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121760. var name = 'fogFragmentDeclaration';
  121761. 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";
  121762. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121763. /** @hidden */
  121764. var fogFragmentDeclaration = { name: name, shader: shader };
  121765. /***/ }),
  121766. /***/ "./Shaders/ShadersInclude/fogVertex.ts":
  121767. /*!*********************************************!*\
  121768. !*** ./Shaders/ShadersInclude/fogVertex.ts ***!
  121769. \*********************************************/
  121770. /*! exports provided: fogVertex */
  121771. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121772. "use strict";
  121773. __webpack_require__.r(__webpack_exports__);
  121774. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertex", function() { return fogVertex; });
  121775. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121776. var name = 'fogVertex';
  121777. var shader = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  121778. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121779. /** @hidden */
  121780. var fogVertex = { name: name, shader: shader };
  121781. /***/ }),
  121782. /***/ "./Shaders/ShadersInclude/fogVertexDeclaration.ts":
  121783. /*!********************************************************!*\
  121784. !*** ./Shaders/ShadersInclude/fogVertexDeclaration.ts ***!
  121785. \********************************************************/
  121786. /*! exports provided: fogVertexDeclaration */
  121787. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121788. "use strict";
  121789. __webpack_require__.r(__webpack_exports__);
  121790. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertexDeclaration", function() { return fogVertexDeclaration; });
  121791. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121792. var name = 'fogVertexDeclaration';
  121793. var shader = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  121794. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121795. /** @hidden */
  121796. var fogVertexDeclaration = { name: name, shader: shader };
  121797. /***/ }),
  121798. /***/ "./Shaders/ShadersInclude/fresnelFunction.ts":
  121799. /*!***************************************************!*\
  121800. !*** ./Shaders/ShadersInclude/fresnelFunction.ts ***!
  121801. \***************************************************/
  121802. /*! exports provided: fresnelFunction */
  121803. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121804. "use strict";
  121805. __webpack_require__.r(__webpack_exports__);
  121806. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fresnelFunction", function() { return fresnelFunction; });
  121807. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121808. var name = 'fresnelFunction';
  121809. 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";
  121810. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121811. /** @hidden */
  121812. var fresnelFunction = { name: name, shader: shader };
  121813. /***/ }),
  121814. /***/ "./Shaders/ShadersInclude/harmonicsFunctions.ts":
  121815. /*!******************************************************!*\
  121816. !*** ./Shaders/ShadersInclude/harmonicsFunctions.ts ***!
  121817. \******************************************************/
  121818. /*! exports provided: harmonicsFunctions */
  121819. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121820. "use strict";
  121821. __webpack_require__.r(__webpack_exports__);
  121822. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "harmonicsFunctions", function() { return harmonicsFunctions; });
  121823. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121824. var name = 'harmonicsFunctions';
  121825. 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";
  121826. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121827. /** @hidden */
  121828. var harmonicsFunctions = { name: name, shader: shader };
  121829. /***/ }),
  121830. /***/ "./Shaders/ShadersInclude/helperFunctions.ts":
  121831. /*!***************************************************!*\
  121832. !*** ./Shaders/ShadersInclude/helperFunctions.ts ***!
  121833. \***************************************************/
  121834. /*! exports provided: helperFunctions */
  121835. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121836. "use strict";
  121837. __webpack_require__.r(__webpack_exports__);
  121838. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "helperFunctions", function() { return helperFunctions; });
  121839. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121840. var name = 'helperFunctions';
  121841. 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}";
  121842. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121843. /** @hidden */
  121844. var helperFunctions = { name: name, shader: shader };
  121845. /***/ }),
  121846. /***/ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts":
  121847. /*!**************************************************************!*\
  121848. !*** ./Shaders/ShadersInclude/imageProcessingDeclaration.ts ***!
  121849. \**************************************************************/
  121850. /*! exports provided: imageProcessingDeclaration */
  121851. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121852. "use strict";
  121853. __webpack_require__.r(__webpack_exports__);
  121854. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingDeclaration", function() { return imageProcessingDeclaration; });
  121855. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121856. var name = 'imageProcessingDeclaration';
  121857. 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";
  121858. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121859. /** @hidden */
  121860. var imageProcessingDeclaration = { name: name, shader: shader };
  121861. /***/ }),
  121862. /***/ "./Shaders/ShadersInclude/imageProcessingFunctions.ts":
  121863. /*!************************************************************!*\
  121864. !*** ./Shaders/ShadersInclude/imageProcessingFunctions.ts ***!
  121865. \************************************************************/
  121866. /*! exports provided: imageProcessingFunctions */
  121867. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121868. "use strict";
  121869. __webpack_require__.r(__webpack_exports__);
  121870. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingFunctions", function() { return imageProcessingFunctions; });
  121871. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121872. var name = 'imageProcessingFunctions';
  121873. 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}";
  121874. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121875. /** @hidden */
  121876. var imageProcessingFunctions = { name: name, shader: shader };
  121877. /***/ }),
  121878. /***/ "./Shaders/ShadersInclude/instancesDeclaration.ts":
  121879. /*!********************************************************!*\
  121880. !*** ./Shaders/ShadersInclude/instancesDeclaration.ts ***!
  121881. \********************************************************/
  121882. /*! exports provided: instancesDeclaration */
  121883. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121884. "use strict";
  121885. __webpack_require__.r(__webpack_exports__);
  121886. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesDeclaration", function() { return instancesDeclaration; });
  121887. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121888. var name = 'instancesDeclaration';
  121889. var shader = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";
  121890. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121891. /** @hidden */
  121892. var instancesDeclaration = { name: name, shader: shader };
  121893. /***/ }),
  121894. /***/ "./Shaders/ShadersInclude/instancesVertex.ts":
  121895. /*!***************************************************!*\
  121896. !*** ./Shaders/ShadersInclude/instancesVertex.ts ***!
  121897. \***************************************************/
  121898. /*! exports provided: instancesVertex */
  121899. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121900. "use strict";
  121901. __webpack_require__.r(__webpack_exports__);
  121902. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesVertex", function() { return instancesVertex; });
  121903. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121904. var name = 'instancesVertex';
  121905. var shader = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  121906. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121907. /** @hidden */
  121908. var instancesVertex = { name: name, shader: shader };
  121909. /***/ }),
  121910. /***/ "./Shaders/ShadersInclude/kernelBlurFragment.ts":
  121911. /*!******************************************************!*\
  121912. !*** ./Shaders/ShadersInclude/kernelBlurFragment.ts ***!
  121913. \******************************************************/
  121914. /*! exports provided: kernelBlurFragment */
  121915. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121916. "use strict";
  121917. __webpack_require__.r(__webpack_exports__);
  121918. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment", function() { return kernelBlurFragment; });
  121919. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121920. var name = 'kernelBlurFragment';
  121921. 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";
  121922. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121923. /** @hidden */
  121924. var kernelBlurFragment = { name: name, shader: shader };
  121925. /***/ }),
  121926. /***/ "./Shaders/ShadersInclude/kernelBlurFragment2.ts":
  121927. /*!*******************************************************!*\
  121928. !*** ./Shaders/ShadersInclude/kernelBlurFragment2.ts ***!
  121929. \*******************************************************/
  121930. /*! exports provided: kernelBlurFragment2 */
  121931. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121932. "use strict";
  121933. __webpack_require__.r(__webpack_exports__);
  121934. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment2", function() { return kernelBlurFragment2; });
  121935. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121936. var name = 'kernelBlurFragment2';
  121937. 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";
  121938. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121939. /** @hidden */
  121940. var kernelBlurFragment2 = { name: name, shader: shader };
  121941. /***/ }),
  121942. /***/ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts":
  121943. /*!****************************************************************!*\
  121944. !*** ./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts ***!
  121945. \****************************************************************/
  121946. /*! exports provided: kernelBlurVaryingDeclaration */
  121947. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121948. "use strict";
  121949. __webpack_require__.r(__webpack_exports__);
  121950. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVaryingDeclaration", function() { return kernelBlurVaryingDeclaration; });
  121951. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121952. var name = 'kernelBlurVaryingDeclaration';
  121953. var shader = "varying vec2 sampleCoord{X};";
  121954. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121955. /** @hidden */
  121956. var kernelBlurVaryingDeclaration = { name: name, shader: shader };
  121957. /***/ }),
  121958. /***/ "./Shaders/ShadersInclude/kernelBlurVertex.ts":
  121959. /*!****************************************************!*\
  121960. !*** ./Shaders/ShadersInclude/kernelBlurVertex.ts ***!
  121961. \****************************************************/
  121962. /*! exports provided: kernelBlurVertex */
  121963. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121964. "use strict";
  121965. __webpack_require__.r(__webpack_exports__);
  121966. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertex", function() { return kernelBlurVertex; });
  121967. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121968. var name = 'kernelBlurVertex';
  121969. var shader = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
  121970. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121971. /** @hidden */
  121972. var kernelBlurVertex = { name: name, shader: shader };
  121973. /***/ }),
  121974. /***/ "./Shaders/ShadersInclude/lightFragment.ts":
  121975. /*!*************************************************!*\
  121976. !*** ./Shaders/ShadersInclude/lightFragment.ts ***!
  121977. \*************************************************/
  121978. /*! exports provided: lightFragment */
  121979. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121980. "use strict";
  121981. __webpack_require__.r(__webpack_exports__);
  121982. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragment", function() { return lightFragment; });
  121983. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  121984. var name = 'lightFragment';
  121985. 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";
  121986. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  121987. /** @hidden */
  121988. var lightFragment = { name: name, shader: shader };
  121989. /***/ }),
  121990. /***/ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts":
  121991. /*!************************************************************!*\
  121992. !*** ./Shaders/ShadersInclude/lightFragmentDeclaration.ts ***!
  121993. \************************************************************/
  121994. /*! exports provided: lightFragmentDeclaration */
  121995. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121996. "use strict";
  121997. __webpack_require__.r(__webpack_exports__);
  121998. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragmentDeclaration", function() { return lightFragmentDeclaration; });
  121999. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122000. var name = 'lightFragmentDeclaration';
  122001. 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";
  122002. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122003. /** @hidden */
  122004. var lightFragmentDeclaration = { name: name, shader: shader };
  122005. /***/ }),
  122006. /***/ "./Shaders/ShadersInclude/lightUboDeclaration.ts":
  122007. /*!*******************************************************!*\
  122008. !*** ./Shaders/ShadersInclude/lightUboDeclaration.ts ***!
  122009. \*******************************************************/
  122010. /*! exports provided: lightUboDeclaration */
  122011. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122012. "use strict";
  122013. __webpack_require__.r(__webpack_exports__);
  122014. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightUboDeclaration", function() { return lightUboDeclaration; });
  122015. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122016. var name = 'lightUboDeclaration';
  122017. 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";
  122018. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122019. /** @hidden */
  122020. var lightUboDeclaration = { name: name, shader: shader };
  122021. /***/ }),
  122022. /***/ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts":
  122023. /*!***********************************************************!*\
  122024. !*** ./Shaders/ShadersInclude/lightsFragmentFunctions.ts ***!
  122025. \***********************************************************/
  122026. /*! exports provided: lightsFragmentFunctions */
  122027. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122028. "use strict";
  122029. __webpack_require__.r(__webpack_exports__);
  122030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightsFragmentFunctions", function() { return lightsFragmentFunctions; });
  122031. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122032. var name = 'lightsFragmentFunctions';
  122033. 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}";
  122034. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122035. /** @hidden */
  122036. var lightsFragmentFunctions = { name: name, shader: shader };
  122037. /***/ }),
  122038. /***/ "./Shaders/ShadersInclude/logDepthDeclaration.ts":
  122039. /*!*******************************************************!*\
  122040. !*** ./Shaders/ShadersInclude/logDepthDeclaration.ts ***!
  122041. \*******************************************************/
  122042. /*! exports provided: logDepthDeclaration */
  122043. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122044. "use strict";
  122045. __webpack_require__.r(__webpack_exports__);
  122046. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthDeclaration", function() { return logDepthDeclaration; });
  122047. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122048. var name = 'logDepthDeclaration';
  122049. var shader = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  122050. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122051. /** @hidden */
  122052. var logDepthDeclaration = { name: name, shader: shader };
  122053. /***/ }),
  122054. /***/ "./Shaders/ShadersInclude/logDepthFragment.ts":
  122055. /*!****************************************************!*\
  122056. !*** ./Shaders/ShadersInclude/logDepthFragment.ts ***!
  122057. \****************************************************/
  122058. /*! exports provided: logDepthFragment */
  122059. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122060. "use strict";
  122061. __webpack_require__.r(__webpack_exports__);
  122062. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthFragment", function() { return logDepthFragment; });
  122063. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122064. var name = 'logDepthFragment';
  122065. var shader = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  122066. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122067. /** @hidden */
  122068. var logDepthFragment = { name: name, shader: shader };
  122069. /***/ }),
  122070. /***/ "./Shaders/ShadersInclude/logDepthVertex.ts":
  122071. /*!**************************************************!*\
  122072. !*** ./Shaders/ShadersInclude/logDepthVertex.ts ***!
  122073. \**************************************************/
  122074. /*! exports provided: logDepthVertex */
  122075. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122076. "use strict";
  122077. __webpack_require__.r(__webpack_exports__);
  122078. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthVertex", function() { return logDepthVertex; });
  122079. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122080. var name = 'logDepthVertex';
  122081. var shader = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  122082. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122083. /** @hidden */
  122084. var logDepthVertex = { name: name, shader: shader };
  122085. /***/ }),
  122086. /***/ "./Shaders/ShadersInclude/morphTargetsVertex.ts":
  122087. /*!******************************************************!*\
  122088. !*** ./Shaders/ShadersInclude/morphTargetsVertex.ts ***!
  122089. \******************************************************/
  122090. /*! exports provided: morphTargetsVertex */
  122091. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122092. "use strict";
  122093. __webpack_require__.r(__webpack_exports__);
  122094. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertex", function() { return morphTargetsVertex; });
  122095. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122096. var name = 'morphTargetsVertex';
  122097. 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";
  122098. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122099. /** @hidden */
  122100. var morphTargetsVertex = { name: name, shader: shader };
  122101. /***/ }),
  122102. /***/ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts":
  122103. /*!*****************************************************************!*\
  122104. !*** ./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts ***!
  122105. \*****************************************************************/
  122106. /*! exports provided: morphTargetsVertexDeclaration */
  122107. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122108. "use strict";
  122109. __webpack_require__.r(__webpack_exports__);
  122110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexDeclaration", function() { return morphTargetsVertexDeclaration; });
  122111. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122112. var name = 'morphTargetsVertexDeclaration';
  122113. 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";
  122114. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122115. /** @hidden */
  122116. var morphTargetsVertexDeclaration = { name: name, shader: shader };
  122117. /***/ }),
  122118. /***/ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts":
  122119. /*!***********************************************************************!*\
  122120. !*** ./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts ***!
  122121. \***********************************************************************/
  122122. /*! exports provided: morphTargetsVertexGlobalDeclaration */
  122123. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122124. "use strict";
  122125. __webpack_require__.r(__webpack_exports__);
  122126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexGlobalDeclaration", function() { return morphTargetsVertexGlobalDeclaration; });
  122127. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122128. var name = 'morphTargetsVertexGlobalDeclaration';
  122129. var shader = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  122130. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122131. /** @hidden */
  122132. var morphTargetsVertexGlobalDeclaration = { name: name, shader: shader };
  122133. /***/ }),
  122134. /***/ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts":
  122135. /*!**********************************************************!*\
  122136. !*** ./Shaders/ShadersInclude/mrtFragmentDeclaration.ts ***!
  122137. \**********************************************************/
  122138. /*! exports provided: mrtFragmentDeclaration */
  122139. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122140. "use strict";
  122141. __webpack_require__.r(__webpack_exports__);
  122142. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mrtFragmentDeclaration", function() { return mrtFragmentDeclaration; });
  122143. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122144. var name = 'mrtFragmentDeclaration';
  122145. var shader = "#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";
  122146. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122147. /** @hidden */
  122148. var mrtFragmentDeclaration = { name: name, shader: shader };
  122149. /***/ }),
  122150. /***/ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts":
  122151. /*!**********************************************************!*\
  122152. !*** ./Shaders/ShadersInclude/pbrFragmentDeclaration.ts ***!
  122153. \**********************************************************/
  122154. /*! exports provided: pbrFragmentDeclaration */
  122155. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122156. "use strict";
  122157. __webpack_require__.r(__webpack_exports__);
  122158. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentDeclaration", function() { return pbrFragmentDeclaration; });
  122159. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122160. var name = 'pbrFragmentDeclaration';
  122161. 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";
  122162. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122163. /** @hidden */
  122164. var pbrFragmentDeclaration = { name: name, shader: shader };
  122165. /***/ }),
  122166. /***/ "./Shaders/ShadersInclude/pbrFunctions.ts":
  122167. /*!************************************************!*\
  122168. !*** ./Shaders/ShadersInclude/pbrFunctions.ts ***!
  122169. \************************************************/
  122170. /*! exports provided: pbrFunctions */
  122171. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122172. "use strict";
  122173. __webpack_require__.r(__webpack_exports__);
  122174. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFunctions", function() { return pbrFunctions; });
  122175. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122176. var name = 'pbrFunctions';
  122177. 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}";
  122178. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122179. /** @hidden */
  122180. var pbrFunctions = { name: name, shader: shader };
  122181. /***/ }),
  122182. /***/ "./Shaders/ShadersInclude/pbrLightFunctions.ts":
  122183. /*!*****************************************************!*\
  122184. !*** ./Shaders/ShadersInclude/pbrLightFunctions.ts ***!
  122185. \*****************************************************/
  122186. /*! exports provided: pbrLightFunctions */
  122187. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122188. "use strict";
  122189. __webpack_require__.r(__webpack_exports__);
  122190. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrLightFunctions", function() { return pbrLightFunctions; });
  122191. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122192. var name = 'pbrLightFunctions';
  122193. 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}";
  122194. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122195. /** @hidden */
  122196. var pbrLightFunctions = { name: name, shader: shader };
  122197. /***/ }),
  122198. /***/ "./Shaders/ShadersInclude/pbrUboDeclaration.ts":
  122199. /*!*****************************************************!*\
  122200. !*** ./Shaders/ShadersInclude/pbrUboDeclaration.ts ***!
  122201. \*****************************************************/
  122202. /*! exports provided: pbrUboDeclaration */
  122203. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122204. "use strict";
  122205. __webpack_require__.r(__webpack_exports__);
  122206. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrUboDeclaration", function() { return pbrUboDeclaration; });
  122207. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122208. var name = 'pbrUboDeclaration';
  122209. 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};";
  122210. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122211. /** @hidden */
  122212. var pbrUboDeclaration = { name: name, shader: shader };
  122213. /***/ }),
  122214. /***/ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts":
  122215. /*!********************************************************!*\
  122216. !*** ./Shaders/ShadersInclude/pbrVertexDeclaration.ts ***!
  122217. \********************************************************/
  122218. /*! exports provided: pbrVertexDeclaration */
  122219. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122220. "use strict";
  122221. __webpack_require__.r(__webpack_exports__);
  122222. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexDeclaration", function() { return pbrVertexDeclaration; });
  122223. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122224. var name = 'pbrVertexDeclaration';
  122225. 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";
  122226. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122227. /** @hidden */
  122228. var pbrVertexDeclaration = { name: name, shader: shader };
  122229. /***/ }),
  122230. /***/ "./Shaders/ShadersInclude/pointCloudVertex.ts":
  122231. /*!****************************************************!*\
  122232. !*** ./Shaders/ShadersInclude/pointCloudVertex.ts ***!
  122233. \****************************************************/
  122234. /*! exports provided: pointCloudVertex */
  122235. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122236. "use strict";
  122237. __webpack_require__.r(__webpack_exports__);
  122238. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pointCloudVertex", function() { return pointCloudVertex; });
  122239. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122240. var name = 'pointCloudVertex';
  122241. var shader = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  122242. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122243. /** @hidden */
  122244. var pointCloudVertex = { name: name, shader: shader };
  122245. /***/ }),
  122246. /***/ "./Shaders/ShadersInclude/reflectionFunction.ts":
  122247. /*!******************************************************!*\
  122248. !*** ./Shaders/ShadersInclude/reflectionFunction.ts ***!
  122249. \******************************************************/
  122250. /*! exports provided: reflectionFunction */
  122251. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122252. "use strict";
  122253. __webpack_require__.r(__webpack_exports__);
  122254. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reflectionFunction", function() { return reflectionFunction; });
  122255. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122256. var name = 'reflectionFunction';
  122257. 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}";
  122258. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122259. /** @hidden */
  122260. var reflectionFunction = { name: name, shader: shader };
  122261. /***/ }),
  122262. /***/ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts":
  122263. /*!************************************************************!*\
  122264. !*** ./Shaders/ShadersInclude/shadowsFragmentFunctions.ts ***!
  122265. \************************************************************/
  122266. /*! exports provided: shadowsFragmentFunctions */
  122267. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122268. "use strict";
  122269. __webpack_require__.r(__webpack_exports__);
  122270. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsFragmentFunctions", function() { return shadowsFragmentFunctions; });
  122271. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122272. var name = 'shadowsFragmentFunctions';
  122273. 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";
  122274. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122275. /** @hidden */
  122276. var shadowsFragmentFunctions = { name: name, shader: shader };
  122277. /***/ }),
  122278. /***/ "./Shaders/ShadersInclude/shadowsVertex.ts":
  122279. /*!*************************************************!*\
  122280. !*** ./Shaders/ShadersInclude/shadowsVertex.ts ***!
  122281. \*************************************************/
  122282. /*! exports provided: shadowsVertex */
  122283. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122284. "use strict";
  122285. __webpack_require__.r(__webpack_exports__);
  122286. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsVertex", function() { return shadowsVertex; });
  122287. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  122288. var name = 'shadowsVertex';
  122289. 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";
  122290. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  122291. /** @hidden */
  122292. var shadowsVertex = { name: name, shader: shader };
  122293. /***/ }),
  122294. /***/ "./Shaders/anaglyph.fragment.ts":
  122295. /*!**************************************!*\
  122296. !*** ./Shaders/anaglyph.fragment.ts ***!
  122297. \**************************************/
  122298. /*! exports provided: anaglyphPixelShader */
  122299. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122300. "use strict";
  122301. __webpack_require__.r(__webpack_exports__);
  122302. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "anaglyphPixelShader", function() { return anaglyphPixelShader; });
  122303. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122304. var name = 'anaglyphPixelShader';
  122305. 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}";
  122306. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122307. /** @hidden */
  122308. var anaglyphPixelShader = { name: name, shader: shader };
  122309. /***/ }),
  122310. /***/ "./Shaders/background.fragment.ts":
  122311. /*!****************************************!*\
  122312. !*** ./Shaders/background.fragment.ts ***!
  122313. \****************************************/
  122314. /*! exports provided: backgroundPixelShader */
  122315. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122316. "use strict";
  122317. __webpack_require__.r(__webpack_exports__);
  122318. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundPixelShader", function() { return backgroundPixelShader; });
  122319. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122320. /* harmony import */ var _ShadersInclude_backgroundFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundFragmentDeclaration */ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts");
  122321. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  122322. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  122323. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  122324. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  122325. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  122326. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  122327. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  122328. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  122329. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  122330. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  122331. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  122332. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  122333. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  122334. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  122335. var name = 'backgroundPixelShader';
  122336. 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";
  122337. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122338. /** @hidden */
  122339. var backgroundPixelShader = { name: name, shader: shader };
  122340. /***/ }),
  122341. /***/ "./Shaders/background.vertex.ts":
  122342. /*!**************************************!*\
  122343. !*** ./Shaders/background.vertex.ts ***!
  122344. \**************************************/
  122345. /*! exports provided: backgroundVertexShader */
  122346. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122347. "use strict";
  122348. __webpack_require__.r(__webpack_exports__);
  122349. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexShader", function() { return backgroundVertexShader; });
  122350. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122351. /* harmony import */ var _ShadersInclude_backgroundVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundVertexDeclaration */ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts");
  122352. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  122353. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  122354. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  122355. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  122356. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  122357. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  122358. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  122359. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  122360. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  122361. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  122362. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  122363. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  122364. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  122365. var name = 'backgroundVertexShader';
  122366. 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";
  122367. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122368. /** @hidden */
  122369. var backgroundVertexShader = { name: name, shader: shader };
  122370. /***/ }),
  122371. /***/ "./Shaders/blackAndWhite.fragment.ts":
  122372. /*!*******************************************!*\
  122373. !*** ./Shaders/blackAndWhite.fragment.ts ***!
  122374. \*******************************************/
  122375. /*! exports provided: blackAndWhitePixelShader */
  122376. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122377. "use strict";
  122378. __webpack_require__.r(__webpack_exports__);
  122379. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "blackAndWhitePixelShader", function() { return blackAndWhitePixelShader; });
  122380. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122381. var name = 'blackAndWhitePixelShader';
  122382. 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}";
  122383. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122384. /** @hidden */
  122385. var blackAndWhitePixelShader = { name: name, shader: shader };
  122386. /***/ }),
  122387. /***/ "./Shaders/bloomMerge.fragment.ts":
  122388. /*!****************************************!*\
  122389. !*** ./Shaders/bloomMerge.fragment.ts ***!
  122390. \****************************************/
  122391. /*! exports provided: bloomMergePixelShader */
  122392. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122393. "use strict";
  122394. __webpack_require__.r(__webpack_exports__);
  122395. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bloomMergePixelShader", function() { return bloomMergePixelShader; });
  122396. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122397. var name = 'bloomMergePixelShader';
  122398. 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";
  122399. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122400. /** @hidden */
  122401. var bloomMergePixelShader = { name: name, shader: shader };
  122402. /***/ }),
  122403. /***/ "./Shaders/chromaticAberration.fragment.ts":
  122404. /*!*************************************************!*\
  122405. !*** ./Shaders/chromaticAberration.fragment.ts ***!
  122406. \*************************************************/
  122407. /*! exports provided: chromaticAberrationPixelShader */
  122408. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122409. "use strict";
  122410. __webpack_require__.r(__webpack_exports__);
  122411. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "chromaticAberrationPixelShader", function() { return chromaticAberrationPixelShader; });
  122412. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122413. var name = 'chromaticAberrationPixelShader';
  122414. 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}";
  122415. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122416. /** @hidden */
  122417. var chromaticAberrationPixelShader = { name: name, shader: shader };
  122418. /***/ }),
  122419. /***/ "./Shaders/circleOfConfusion.fragment.ts":
  122420. /*!***********************************************!*\
  122421. !*** ./Shaders/circleOfConfusion.fragment.ts ***!
  122422. \***********************************************/
  122423. /*! exports provided: circleOfConfusionPixelShader */
  122424. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122425. "use strict";
  122426. __webpack_require__.r(__webpack_exports__);
  122427. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "circleOfConfusionPixelShader", function() { return circleOfConfusionPixelShader; });
  122428. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122429. var name = 'circleOfConfusionPixelShader';
  122430. 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";
  122431. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122432. /** @hidden */
  122433. var circleOfConfusionPixelShader = { name: name, shader: shader };
  122434. /***/ }),
  122435. /***/ "./Shaders/color.fragment.ts":
  122436. /*!***********************************!*\
  122437. !*** ./Shaders/color.fragment.ts ***!
  122438. \***********************************/
  122439. /*! exports provided: colorPixelShader */
  122440. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122441. "use strict";
  122442. __webpack_require__.r(__webpack_exports__);
  122443. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorPixelShader", function() { return colorPixelShader; });
  122444. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122445. var name = 'colorPixelShader';
  122446. 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}";
  122447. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122448. /** @hidden */
  122449. var colorPixelShader = { name: name, shader: shader };
  122450. /***/ }),
  122451. /***/ "./Shaders/color.vertex.ts":
  122452. /*!*********************************!*\
  122453. !*** ./Shaders/color.vertex.ts ***!
  122454. \*********************************/
  122455. /*! exports provided: colorVertexShader */
  122456. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122457. "use strict";
  122458. __webpack_require__.r(__webpack_exports__);
  122459. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorVertexShader", function() { return colorVertexShader; });
  122460. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122461. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  122462. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  122463. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  122464. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  122465. var name = 'colorVertexShader';
  122466. 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}";
  122467. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122468. /** @hidden */
  122469. var colorVertexShader = { name: name, shader: shader };
  122470. /***/ }),
  122471. /***/ "./Shaders/colorCorrection.fragment.ts":
  122472. /*!*********************************************!*\
  122473. !*** ./Shaders/colorCorrection.fragment.ts ***!
  122474. \*********************************************/
  122475. /*! exports provided: colorCorrectionPixelShader */
  122476. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122477. "use strict";
  122478. __webpack_require__.r(__webpack_exports__);
  122479. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorCorrectionPixelShader", function() { return colorCorrectionPixelShader; });
  122480. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122481. var name = 'colorCorrectionPixelShader';
  122482. 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}";
  122483. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122484. /** @hidden */
  122485. var colorCorrectionPixelShader = { name: name, shader: shader };
  122486. /***/ }),
  122487. /***/ "./Shaders/convolution.fragment.ts":
  122488. /*!*****************************************!*\
  122489. !*** ./Shaders/convolution.fragment.ts ***!
  122490. \*****************************************/
  122491. /*! exports provided: convolutionPixelShader */
  122492. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122493. "use strict";
  122494. __webpack_require__.r(__webpack_exports__);
  122495. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convolutionPixelShader", function() { return convolutionPixelShader; });
  122496. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122497. var name = 'convolutionPixelShader';
  122498. 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}";
  122499. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122500. /** @hidden */
  122501. var convolutionPixelShader = { name: name, shader: shader };
  122502. /***/ }),
  122503. /***/ "./Shaders/default.fragment.ts":
  122504. /*!*************************************!*\
  122505. !*** ./Shaders/default.fragment.ts ***!
  122506. \*************************************/
  122507. /*! exports provided: defaultPixelShader */
  122508. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122509. "use strict";
  122510. __webpack_require__.r(__webpack_exports__);
  122511. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultPixelShader", function() { return defaultPixelShader; });
  122512. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122513. /* harmony import */ var _ShadersInclude_defaultFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultFragmentDeclaration */ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts");
  122514. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  122515. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  122516. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  122517. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  122518. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  122519. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  122520. /* harmony import */ var _ShadersInclude_fresnelFunction__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fresnelFunction */ "./Shaders/ShadersInclude/fresnelFunction.ts");
  122521. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  122522. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  122523. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  122524. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  122525. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  122526. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  122527. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  122528. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  122529. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  122530. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  122531. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  122532. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  122533. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  122534. var name = 'defaultPixelShader';
  122535. 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";
  122536. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122537. /** @hidden */
  122538. var defaultPixelShader = { name: name, shader: shader };
  122539. /***/ }),
  122540. /***/ "./Shaders/default.vertex.ts":
  122541. /*!***********************************!*\
  122542. !*** ./Shaders/default.vertex.ts ***!
  122543. \***********************************/
  122544. /*! exports provided: defaultVertexShader */
  122545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122546. "use strict";
  122547. __webpack_require__.r(__webpack_exports__);
  122548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexShader", function() { return defaultVertexShader; });
  122549. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122550. /* harmony import */ var _ShadersInclude_defaultVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultVertexDeclaration */ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts");
  122551. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  122552. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  122553. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  122554. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  122555. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  122556. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  122557. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  122558. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  122559. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  122560. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  122561. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  122562. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  122563. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  122564. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  122565. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  122566. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  122567. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  122568. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  122569. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  122570. /* harmony import */ var _ShadersInclude_pointCloudVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/pointCloudVertex */ "./Shaders/ShadersInclude/pointCloudVertex.ts");
  122571. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  122572. var name = 'defaultVertexShader';
  122573. 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";
  122574. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122575. /** @hidden */
  122576. var defaultVertexShader = { name: name, shader: shader };
  122577. /***/ }),
  122578. /***/ "./Shaders/depth.fragment.ts":
  122579. /*!***********************************!*\
  122580. !*** ./Shaders/depth.fragment.ts ***!
  122581. \***********************************/
  122582. /*! exports provided: depthPixelShader */
  122583. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122584. "use strict";
  122585. __webpack_require__.r(__webpack_exports__);
  122586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPixelShader", function() { return depthPixelShader; });
  122587. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122588. var name = 'depthPixelShader';
  122589. 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}";
  122590. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122591. /** @hidden */
  122592. var depthPixelShader = { name: name, shader: shader };
  122593. /***/ }),
  122594. /***/ "./Shaders/depth.vertex.ts":
  122595. /*!*********************************!*\
  122596. !*** ./Shaders/depth.vertex.ts ***!
  122597. \*********************************/
  122598. /*! exports provided: depthVertexShader */
  122599. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122600. "use strict";
  122601. __webpack_require__.r(__webpack_exports__);
  122602. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthVertexShader", function() { return depthVertexShader; });
  122603. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122604. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  122605. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  122606. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  122607. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  122608. var name = 'depthVertexShader';
  122609. 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}";
  122610. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122611. /** @hidden */
  122612. var depthVertexShader = { name: name, shader: shader };
  122613. /***/ }),
  122614. /***/ "./Shaders/depthBoxBlur.fragment.ts":
  122615. /*!******************************************!*\
  122616. !*** ./Shaders/depthBoxBlur.fragment.ts ***!
  122617. \******************************************/
  122618. /*! exports provided: depthBoxBlurPixelShader */
  122619. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122620. "use strict";
  122621. __webpack_require__.r(__webpack_exports__);
  122622. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthBoxBlurPixelShader", function() { return depthBoxBlurPixelShader; });
  122623. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122624. var name = 'depthBoxBlurPixelShader';
  122625. 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}";
  122626. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122627. /** @hidden */
  122628. var depthBoxBlurPixelShader = { name: name, shader: shader };
  122629. /***/ }),
  122630. /***/ "./Shaders/depthOfField.fragment.ts":
  122631. /*!******************************************!*\
  122632. !*** ./Shaders/depthOfField.fragment.ts ***!
  122633. \******************************************/
  122634. /*! exports provided: depthOfFieldPixelShader */
  122635. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122636. "use strict";
  122637. __webpack_require__.r(__webpack_exports__);
  122638. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldPixelShader", function() { return depthOfFieldPixelShader; });
  122639. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122640. var name = 'depthOfFieldPixelShader';
  122641. 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";
  122642. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122643. /** @hidden */
  122644. var depthOfFieldPixelShader = { name: name, shader: shader };
  122645. /***/ }),
  122646. /***/ "./Shaders/depthOfFieldMerge.fragment.ts":
  122647. /*!***********************************************!*\
  122648. !*** ./Shaders/depthOfFieldMerge.fragment.ts ***!
  122649. \***********************************************/
  122650. /*! exports provided: depthOfFieldMergePixelShader */
  122651. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122652. "use strict";
  122653. __webpack_require__.r(__webpack_exports__);
  122654. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldMergePixelShader", function() { return depthOfFieldMergePixelShader; });
  122655. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122656. var name = 'depthOfFieldMergePixelShader';
  122657. 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";
  122658. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122659. /** @hidden */
  122660. var depthOfFieldMergePixelShader = { name: name, shader: shader };
  122661. /***/ }),
  122662. /***/ "./Shaders/displayPass.fragment.ts":
  122663. /*!*****************************************!*\
  122664. !*** ./Shaders/displayPass.fragment.ts ***!
  122665. \*****************************************/
  122666. /*! exports provided: displayPassPixelShader */
  122667. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122668. "use strict";
  122669. __webpack_require__.r(__webpack_exports__);
  122670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayPassPixelShader", function() { return displayPassPixelShader; });
  122671. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122672. var name = 'displayPassPixelShader';
  122673. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";
  122674. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122675. /** @hidden */
  122676. var displayPassPixelShader = { name: name, shader: shader };
  122677. /***/ }),
  122678. /***/ "./Shaders/extractHighlights.fragment.ts":
  122679. /*!***********************************************!*\
  122680. !*** ./Shaders/extractHighlights.fragment.ts ***!
  122681. \***********************************************/
  122682. /*! exports provided: extractHighlightsPixelShader */
  122683. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122684. "use strict";
  122685. __webpack_require__.r(__webpack_exports__);
  122686. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractHighlightsPixelShader", function() { return extractHighlightsPixelShader; });
  122687. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122688. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  122689. var name = 'extractHighlightsPixelShader';
  122690. 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}";
  122691. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122692. /** @hidden */
  122693. var extractHighlightsPixelShader = { name: name, shader: shader };
  122694. /***/ }),
  122695. /***/ "./Shaders/filter.fragment.ts":
  122696. /*!************************************!*\
  122697. !*** ./Shaders/filter.fragment.ts ***!
  122698. \************************************/
  122699. /*! exports provided: filterPixelShader */
  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__, "filterPixelShader", function() { return filterPixelShader; });
  122704. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122705. var name = 'filterPixelShader';
  122706. 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}";
  122707. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122708. /** @hidden */
  122709. var filterPixelShader = { name: name, shader: shader };
  122710. /***/ }),
  122711. /***/ "./Shaders/fxaa.fragment.ts":
  122712. /*!**********************************!*\
  122713. !*** ./Shaders/fxaa.fragment.ts ***!
  122714. \**********************************/
  122715. /*! exports provided: fxaaPixelShader */
  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__, "fxaaPixelShader", function() { return fxaaPixelShader; });
  122720. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122721. var name = 'fxaaPixelShader';
  122722. 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}";
  122723. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122724. /** @hidden */
  122725. var fxaaPixelShader = { name: name, shader: shader };
  122726. /***/ }),
  122727. /***/ "./Shaders/fxaa.vertex.ts":
  122728. /*!********************************!*\
  122729. !*** ./Shaders/fxaa.vertex.ts ***!
  122730. \********************************/
  122731. /*! exports provided: fxaaVertexShader */
  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__, "fxaaVertexShader", function() { return fxaaVertexShader; });
  122736. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122737. var name = 'fxaaVertexShader';
  122738. 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}";
  122739. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122740. /** @hidden */
  122741. var fxaaVertexShader = { name: name, shader: shader };
  122742. /***/ }),
  122743. /***/ "./Shaders/geometry.fragment.ts":
  122744. /*!**************************************!*\
  122745. !*** ./Shaders/geometry.fragment.ts ***!
  122746. \**************************************/
  122747. /*! exports provided: geometryPixelShader */
  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__, "geometryPixelShader", function() { return geometryPixelShader; });
  122752. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122753. /* harmony import */ var _ShadersInclude_mrtFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/mrtFragmentDeclaration */ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts");
  122754. var name = 'geometryPixelShader';
  122755. 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}";
  122756. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122757. /** @hidden */
  122758. var geometryPixelShader = { name: name, shader: shader };
  122759. /***/ }),
  122760. /***/ "./Shaders/geometry.vertex.ts":
  122761. /*!************************************!*\
  122762. !*** ./Shaders/geometry.vertex.ts ***!
  122763. \************************************/
  122764. /*! exports provided: geometryVertexShader */
  122765. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122766. "use strict";
  122767. __webpack_require__.r(__webpack_exports__);
  122768. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryVertexShader", function() { return geometryVertexShader; });
  122769. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122770. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  122771. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  122772. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  122773. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  122774. var name = 'geometryVertexShader';
  122775. 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}";
  122776. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122777. /** @hidden */
  122778. var geometryVertexShader = { name: name, shader: shader };
  122779. /***/ }),
  122780. /***/ "./Shaders/glowBlurPostProcess.fragment.ts":
  122781. /*!*************************************************!*\
  122782. !*** ./Shaders/glowBlurPostProcess.fragment.ts ***!
  122783. \*************************************************/
  122784. /*! exports provided: glowBlurPostProcessPixelShader */
  122785. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122786. "use strict";
  122787. __webpack_require__.r(__webpack_exports__);
  122788. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowBlurPostProcessPixelShader", function() { return glowBlurPostProcessPixelShader; });
  122789. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122790. var name = 'glowBlurPostProcessPixelShader';
  122791. 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}";
  122792. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122793. /** @hidden */
  122794. var glowBlurPostProcessPixelShader = { name: name, shader: shader };
  122795. /***/ }),
  122796. /***/ "./Shaders/glowMapGeneration.fragment.ts":
  122797. /*!***********************************************!*\
  122798. !*** ./Shaders/glowMapGeneration.fragment.ts ***!
  122799. \***********************************************/
  122800. /*! exports provided: glowMapGenerationPixelShader */
  122801. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122802. "use strict";
  122803. __webpack_require__.r(__webpack_exports__);
  122804. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationPixelShader", function() { return glowMapGenerationPixelShader; });
  122805. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122806. var name = 'glowMapGenerationPixelShader';
  122807. 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}";
  122808. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122809. /** @hidden */
  122810. var glowMapGenerationPixelShader = { name: name, shader: shader };
  122811. /***/ }),
  122812. /***/ "./Shaders/glowMapGeneration.vertex.ts":
  122813. /*!*********************************************!*\
  122814. !*** ./Shaders/glowMapGeneration.vertex.ts ***!
  122815. \*********************************************/
  122816. /*! exports provided: glowMapGenerationVertexShader */
  122817. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122818. "use strict";
  122819. __webpack_require__.r(__webpack_exports__);
  122820. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationVertexShader", function() { return glowMapGenerationVertexShader; });
  122821. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122822. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  122823. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  122824. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  122825. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  122826. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  122827. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  122828. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  122829. var name = 'glowMapGenerationVertexShader';
  122830. 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}";
  122831. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122832. /** @hidden */
  122833. var glowMapGenerationVertexShader = { name: name, shader: shader };
  122834. /***/ }),
  122835. /***/ "./Shaders/glowMapMerge.fragment.ts":
  122836. /*!******************************************!*\
  122837. !*** ./Shaders/glowMapMerge.fragment.ts ***!
  122838. \******************************************/
  122839. /*! exports provided: glowMapMergePixelShader */
  122840. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122841. "use strict";
  122842. __webpack_require__.r(__webpack_exports__);
  122843. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergePixelShader", function() { return glowMapMergePixelShader; });
  122844. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122845. var name = 'glowMapMergePixelShader';
  122846. 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}";
  122847. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122848. /** @hidden */
  122849. var glowMapMergePixelShader = { name: name, shader: shader };
  122850. /***/ }),
  122851. /***/ "./Shaders/glowMapMerge.vertex.ts":
  122852. /*!****************************************!*\
  122853. !*** ./Shaders/glowMapMerge.vertex.ts ***!
  122854. \****************************************/
  122855. /*! exports provided: glowMapMergeVertexShader */
  122856. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122857. "use strict";
  122858. __webpack_require__.r(__webpack_exports__);
  122859. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergeVertexShader", function() { return glowMapMergeVertexShader; });
  122860. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122861. var name = 'glowMapMergeVertexShader';
  122862. 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}";
  122863. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122864. /** @hidden */
  122865. var glowMapMergeVertexShader = { name: name, shader: shader };
  122866. /***/ }),
  122867. /***/ "./Shaders/gpuRenderParticles.fragment.ts":
  122868. /*!************************************************!*\
  122869. !*** ./Shaders/gpuRenderParticles.fragment.ts ***!
  122870. \************************************************/
  122871. /*! exports provided: gpuRenderParticlesPixelShader */
  122872. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122873. "use strict";
  122874. __webpack_require__.r(__webpack_exports__);
  122875. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesPixelShader", function() { return gpuRenderParticlesPixelShader; });
  122876. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122877. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts");
  122878. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  122879. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  122880. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  122881. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  122882. var name = 'gpuRenderParticlesPixelShader';
  122883. 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";
  122884. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122885. /** @hidden */
  122886. var gpuRenderParticlesPixelShader = { name: name, shader: shader };
  122887. /***/ }),
  122888. /***/ "./Shaders/gpuRenderParticles.vertex.ts":
  122889. /*!**********************************************!*\
  122890. !*** ./Shaders/gpuRenderParticles.vertex.ts ***!
  122891. \**********************************************/
  122892. /*! exports provided: gpuRenderParticlesVertexShader */
  122893. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122894. "use strict";
  122895. __webpack_require__.r(__webpack_exports__);
  122896. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesVertexShader", function() { return gpuRenderParticlesVertexShader; });
  122897. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122898. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts");
  122899. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  122900. var name = 'gpuRenderParticlesVertexShader';
  122901. 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}";
  122902. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122903. /** @hidden */
  122904. var gpuRenderParticlesVertexShader = { name: name, shader: shader };
  122905. /***/ }),
  122906. /***/ "./Shaders/gpuUpdateParticles.fragment.ts":
  122907. /*!************************************************!*\
  122908. !*** ./Shaders/gpuUpdateParticles.fragment.ts ***!
  122909. \************************************************/
  122910. /*! exports provided: gpuUpdateParticlesPixelShader */
  122911. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122912. "use strict";
  122913. __webpack_require__.r(__webpack_exports__);
  122914. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesPixelShader", function() { return gpuUpdateParticlesPixelShader; });
  122915. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122916. var name = 'gpuUpdateParticlesPixelShader';
  122917. var shader = "#version 300 es\nvoid main() {\ndiscard;\n}\n";
  122918. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122919. /** @hidden */
  122920. var gpuUpdateParticlesPixelShader = { name: name, shader: shader };
  122921. /***/ }),
  122922. /***/ "./Shaders/gpuUpdateParticles.vertex.ts":
  122923. /*!**********************************************!*\
  122924. !*** ./Shaders/gpuUpdateParticles.vertex.ts ***!
  122925. \**********************************************/
  122926. /*! exports provided: gpuUpdateParticlesVertexShader */
  122927. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122928. "use strict";
  122929. __webpack_require__.r(__webpack_exports__);
  122930. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesVertexShader", function() { return gpuUpdateParticlesVertexShader; });
  122931. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122932. var name = 'gpuUpdateParticlesVertexShader';
  122933. 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}";
  122934. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122935. /** @hidden */
  122936. var gpuUpdateParticlesVertexShader = { name: name, shader: shader };
  122937. /***/ }),
  122938. /***/ "./Shaders/grain.fragment.ts":
  122939. /*!***********************************!*\
  122940. !*** ./Shaders/grain.fragment.ts ***!
  122941. \***********************************/
  122942. /*! exports provided: grainPixelShader */
  122943. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122944. "use strict";
  122945. __webpack_require__.r(__webpack_exports__);
  122946. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "grainPixelShader", function() { return grainPixelShader; });
  122947. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122948. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  122949. var name = 'grainPixelShader';
  122950. 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}";
  122951. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122952. /** @hidden */
  122953. var grainPixelShader = { name: name, shader: shader };
  122954. /***/ }),
  122955. /***/ "./Shaders/highlights.fragment.ts":
  122956. /*!****************************************!*\
  122957. !*** ./Shaders/highlights.fragment.ts ***!
  122958. \****************************************/
  122959. /*! exports provided: highlightsPixelShader */
  122960. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122961. "use strict";
  122962. __webpack_require__.r(__webpack_exports__);
  122963. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "highlightsPixelShader", function() { return highlightsPixelShader; });
  122964. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122965. var name = 'highlightsPixelShader';
  122966. 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}";
  122967. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122968. /** @hidden */
  122969. var highlightsPixelShader = { name: name, shader: shader };
  122970. /***/ }),
  122971. /***/ "./Shaders/imageProcessing.fragment.ts":
  122972. /*!*********************************************!*\
  122973. !*** ./Shaders/imageProcessing.fragment.ts ***!
  122974. \*********************************************/
  122975. /*! exports provided: imageProcessingPixelShader */
  122976. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122977. "use strict";
  122978. __webpack_require__.r(__webpack_exports__);
  122979. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingPixelShader", function() { return imageProcessingPixelShader; });
  122980. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  122981. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  122982. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  122983. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  122984. var name = 'imageProcessingPixelShader';
  122985. 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}";
  122986. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  122987. /** @hidden */
  122988. var imageProcessingPixelShader = { name: name, shader: shader };
  122989. /***/ }),
  122990. /***/ "./Shaders/kernelBlur.fragment.ts":
  122991. /*!****************************************!*\
  122992. !*** ./Shaders/kernelBlur.fragment.ts ***!
  122993. \****************************************/
  122994. /*! exports provided: kernelBlurPixelShader */
  122995. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122996. "use strict";
  122997. __webpack_require__.r(__webpack_exports__);
  122998. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurPixelShader", function() { return kernelBlurPixelShader; });
  122999. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123000. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  123001. /* harmony import */ var _ShadersInclude_kernelBlurFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment */ "./Shaders/ShadersInclude/kernelBlurFragment.ts");
  123002. /* harmony import */ var _ShadersInclude_kernelBlurFragment2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment2 */ "./Shaders/ShadersInclude/kernelBlurFragment2.ts");
  123003. var name = 'kernelBlurPixelShader';
  123004. 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}";
  123005. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123006. /** @hidden */
  123007. var kernelBlurPixelShader = { name: name, shader: shader };
  123008. /***/ }),
  123009. /***/ "./Shaders/kernelBlur.vertex.ts":
  123010. /*!**************************************!*\
  123011. !*** ./Shaders/kernelBlur.vertex.ts ***!
  123012. \**************************************/
  123013. /*! exports provided: kernelBlurVertexShader */
  123014. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123015. "use strict";
  123016. __webpack_require__.r(__webpack_exports__);
  123017. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertexShader", function() { return kernelBlurVertexShader; });
  123018. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123019. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  123020. /* harmony import */ var _ShadersInclude_kernelBlurVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVertex */ "./Shaders/ShadersInclude/kernelBlurVertex.ts");
  123021. var name = 'kernelBlurVertexShader';
  123022. 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}";
  123023. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123024. /** @hidden */
  123025. var kernelBlurVertexShader = { name: name, shader: shader };
  123026. /***/ }),
  123027. /***/ "./Shaders/layer.fragment.ts":
  123028. /*!***********************************!*\
  123029. !*** ./Shaders/layer.fragment.ts ***!
  123030. \***********************************/
  123031. /*! exports provided: layerPixelShader */
  123032. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123033. "use strict";
  123034. __webpack_require__.r(__webpack_exports__);
  123035. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerPixelShader", function() { return layerPixelShader; });
  123036. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123037. var name = 'layerPixelShader';
  123038. 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}";
  123039. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123040. /** @hidden */
  123041. var layerPixelShader = { name: name, shader: shader };
  123042. /***/ }),
  123043. /***/ "./Shaders/layer.vertex.ts":
  123044. /*!*********************************!*\
  123045. !*** ./Shaders/layer.vertex.ts ***!
  123046. \*********************************/
  123047. /*! exports provided: layerVertexShader */
  123048. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123049. "use strict";
  123050. __webpack_require__.r(__webpack_exports__);
  123051. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerVertexShader", function() { return layerVertexShader; });
  123052. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123053. var name = 'layerVertexShader';
  123054. 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}";
  123055. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123056. /** @hidden */
  123057. var layerVertexShader = { name: name, shader: shader };
  123058. /***/ }),
  123059. /***/ "./Shaders/lensFlare.fragment.ts":
  123060. /*!***************************************!*\
  123061. !*** ./Shaders/lensFlare.fragment.ts ***!
  123062. \***************************************/
  123063. /*! exports provided: lensFlarePixelShader */
  123064. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123065. "use strict";
  123066. __webpack_require__.r(__webpack_exports__);
  123067. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlarePixelShader", function() { return lensFlarePixelShader; });
  123068. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123069. var name = 'lensFlarePixelShader';
  123070. 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}";
  123071. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123072. /** @hidden */
  123073. var lensFlarePixelShader = { name: name, shader: shader };
  123074. /***/ }),
  123075. /***/ "./Shaders/lensFlare.vertex.ts":
  123076. /*!*************************************!*\
  123077. !*** ./Shaders/lensFlare.vertex.ts ***!
  123078. \*************************************/
  123079. /*! exports provided: lensFlareVertexShader */
  123080. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123081. "use strict";
  123082. __webpack_require__.r(__webpack_exports__);
  123083. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlareVertexShader", function() { return lensFlareVertexShader; });
  123084. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123085. var name = 'lensFlareVertexShader';
  123086. 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}";
  123087. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123088. /** @hidden */
  123089. var lensFlareVertexShader = { name: name, shader: shader };
  123090. /***/ }),
  123091. /***/ "./Shaders/lensHighlights.fragment.ts":
  123092. /*!********************************************!*\
  123093. !*** ./Shaders/lensHighlights.fragment.ts ***!
  123094. \********************************************/
  123095. /*! exports provided: lensHighlightsPixelShader */
  123096. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123097. "use strict";
  123098. __webpack_require__.r(__webpack_exports__);
  123099. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensHighlightsPixelShader", function() { return lensHighlightsPixelShader; });
  123100. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123101. var name = 'lensHighlightsPixelShader';
  123102. 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}";
  123103. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123104. /** @hidden */
  123105. var lensHighlightsPixelShader = { name: name, shader: shader };
  123106. /***/ }),
  123107. /***/ "./Shaders/line.fragment.ts":
  123108. /*!**********************************!*\
  123109. !*** ./Shaders/line.fragment.ts ***!
  123110. \**********************************/
  123111. /*! exports provided: linePixelShader */
  123112. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123113. "use strict";
  123114. __webpack_require__.r(__webpack_exports__);
  123115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "linePixelShader", function() { return linePixelShader; });
  123116. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123117. var name = 'linePixelShader';
  123118. var shader = "uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}";
  123119. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123120. /** @hidden */
  123121. var linePixelShader = { name: name, shader: shader };
  123122. /***/ }),
  123123. /***/ "./Shaders/line.vertex.ts":
  123124. /*!********************************!*\
  123125. !*** ./Shaders/line.vertex.ts ***!
  123126. \********************************/
  123127. /*! exports provided: lineVertexShader */
  123128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123129. "use strict";
  123130. __webpack_require__.r(__webpack_exports__);
  123131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lineVertexShader", function() { return lineVertexShader; });
  123132. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123133. var name = 'lineVertexShader';
  123134. 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}";
  123135. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123136. /** @hidden */
  123137. var lineVertexShader = { name: name, shader: shader };
  123138. /***/ }),
  123139. /***/ "./Shaders/motionBlur.fragment.ts":
  123140. /*!****************************************!*\
  123141. !*** ./Shaders/motionBlur.fragment.ts ***!
  123142. \****************************************/
  123143. /*! exports provided: motionBlurPixelShader */
  123144. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123145. "use strict";
  123146. __webpack_require__.r(__webpack_exports__);
  123147. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "motionBlurPixelShader", function() { return motionBlurPixelShader; });
  123148. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123149. var name = 'motionBlurPixelShader';
  123150. 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";
  123151. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123152. /** @hidden */
  123153. var motionBlurPixelShader = { name: name, shader: shader };
  123154. /***/ }),
  123155. /***/ "./Shaders/noise.fragment.ts":
  123156. /*!***********************************!*\
  123157. !*** ./Shaders/noise.fragment.ts ***!
  123158. \***********************************/
  123159. /*! exports provided: noisePixelShader */
  123160. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123161. "use strict";
  123162. __webpack_require__.r(__webpack_exports__);
  123163. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "noisePixelShader", function() { return noisePixelShader; });
  123164. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123165. var name = 'noisePixelShader';
  123166. 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";
  123167. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123168. /** @hidden */
  123169. var noisePixelShader = { name: name, shader: shader };
  123170. /***/ }),
  123171. /***/ "./Shaders/outline.fragment.ts":
  123172. /*!*************************************!*\
  123173. !*** ./Shaders/outline.fragment.ts ***!
  123174. \*************************************/
  123175. /*! exports provided: outlinePixelShader */
  123176. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123177. "use strict";
  123178. __webpack_require__.r(__webpack_exports__);
  123179. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlinePixelShader", function() { return outlinePixelShader; });
  123180. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123181. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123182. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  123183. var name = 'outlinePixelShader';
  123184. 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}";
  123185. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123186. /** @hidden */
  123187. var outlinePixelShader = { name: name, shader: shader };
  123188. /***/ }),
  123189. /***/ "./Shaders/outline.vertex.ts":
  123190. /*!***********************************!*\
  123191. !*** ./Shaders/outline.vertex.ts ***!
  123192. \***********************************/
  123193. /*! exports provided: outlineVertexShader */
  123194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123195. "use strict";
  123196. __webpack_require__.r(__webpack_exports__);
  123197. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlineVertexShader", function() { return outlineVertexShader; });
  123198. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123199. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123200. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123201. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123202. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123203. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123204. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  123205. var name = 'outlineVertexShader';
  123206. 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";
  123207. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123208. /** @hidden */
  123209. var outlineVertexShader = { name: name, shader: shader };
  123210. /***/ }),
  123211. /***/ "./Shaders/particles.fragment.ts":
  123212. /*!***************************************!*\
  123213. !*** ./Shaders/particles.fragment.ts ***!
  123214. \***************************************/
  123215. /*! exports provided: particlesPixelShader */
  123216. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123217. "use strict";
  123218. __webpack_require__.r(__webpack_exports__);
  123219. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesPixelShader", function() { return particlesPixelShader; });
  123220. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123221. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  123222. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  123223. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123224. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  123225. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  123226. var name = 'particlesPixelShader';
  123227. 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}";
  123228. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123229. /** @hidden */
  123230. var particlesPixelShader = { name: name, shader: shader };
  123231. /***/ }),
  123232. /***/ "./Shaders/particles.vertex.ts":
  123233. /*!*************************************!*\
  123234. !*** ./Shaders/particles.vertex.ts ***!
  123235. \*************************************/
  123236. /*! exports provided: particlesVertexShader */
  123237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123238. "use strict";
  123239. __webpack_require__.r(__webpack_exports__);
  123240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesVertexShader", function() { return particlesVertexShader; });
  123241. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123242. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  123243. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  123244. var name = 'particlesVertexShader';
  123245. 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}";
  123246. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123247. /** @hidden */
  123248. var particlesVertexShader = { name: name, shader: shader };
  123249. /***/ }),
  123250. /***/ "./Shaders/pass.fragment.ts":
  123251. /*!**********************************!*\
  123252. !*** ./Shaders/pass.fragment.ts ***!
  123253. \**********************************/
  123254. /*! exports provided: passPixelShader */
  123255. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123256. "use strict";
  123257. __webpack_require__.r(__webpack_exports__);
  123258. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passPixelShader", function() { return passPixelShader; });
  123259. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123260. var name = 'passPixelShader';
  123261. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";
  123262. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123263. /** @hidden */
  123264. var passPixelShader = { name: name, shader: shader };
  123265. /***/ }),
  123266. /***/ "./Shaders/passCube.fragment.ts":
  123267. /*!**************************************!*\
  123268. !*** ./Shaders/passCube.fragment.ts ***!
  123269. \**************************************/
  123270. /*! exports provided: passCubePixelShader */
  123271. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123272. "use strict";
  123273. __webpack_require__.r(__webpack_exports__);
  123274. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passCubePixelShader", function() { return passCubePixelShader; });
  123275. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123276. var name = 'passCubePixelShader';
  123277. 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}";
  123278. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123279. /** @hidden */
  123280. var passCubePixelShader = { name: name, shader: shader };
  123281. /***/ }),
  123282. /***/ "./Shaders/pbr.fragment.ts":
  123283. /*!*********************************!*\
  123284. !*** ./Shaders/pbr.fragment.ts ***!
  123285. \*********************************/
  123286. /*! exports provided: pbrPixelShader */
  123287. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123288. "use strict";
  123289. __webpack_require__.r(__webpack_exports__);
  123290. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrPixelShader", function() { return pbrPixelShader; });
  123291. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123292. /* harmony import */ var _ShadersInclude_pbrFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentDeclaration */ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts");
  123293. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  123294. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123295. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123296. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  123297. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  123298. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123299. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  123300. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  123301. /* harmony import */ var _ShadersInclude_pbrFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/pbrFunctions */ "./Shaders/ShadersInclude/pbrFunctions.ts");
  123302. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  123303. /* harmony import */ var _ShadersInclude_pbrLightFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/pbrLightFunctions */ "./Shaders/ShadersInclude/pbrLightFunctions.ts");
  123304. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  123305. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  123306. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123307. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  123308. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  123309. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  123310. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  123311. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  123312. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  123313. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  123314. var name = 'pbrPixelShader';
  123315. 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";
  123316. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123317. /** @hidden */
  123318. var pbrPixelShader = { name: name, shader: shader };
  123319. /***/ }),
  123320. /***/ "./Shaders/pbr.vertex.ts":
  123321. /*!*******************************!*\
  123322. !*** ./Shaders/pbr.vertex.ts ***!
  123323. \*******************************/
  123324. /*! exports provided: pbrVertexShader */
  123325. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123326. "use strict";
  123327. __webpack_require__.r(__webpack_exports__);
  123328. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexShader", function() { return pbrVertexShader; });
  123329. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123330. /* harmony import */ var _ShadersInclude_pbrVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrVertexDeclaration */ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts");
  123331. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  123332. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123333. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123334. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123335. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  123336. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  123337. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  123338. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  123339. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  123340. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  123341. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  123342. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  123343. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  123344. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  123345. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123346. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123347. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  123348. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  123349. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  123350. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  123351. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  123352. var name = 'pbrVertexShader';
  123353. 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}";
  123354. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123355. /** @hidden */
  123356. var pbrVertexShader = { name: name, shader: shader };
  123357. /***/ }),
  123358. /***/ "./Shaders/postprocess.vertex.ts":
  123359. /*!***************************************!*\
  123360. !*** ./Shaders/postprocess.vertex.ts ***!
  123361. \***************************************/
  123362. /*! exports provided: postprocessVertexShader */
  123363. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123364. "use strict";
  123365. __webpack_require__.r(__webpack_exports__);
  123366. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postprocessVertexShader", function() { return postprocessVertexShader; });
  123367. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123368. var name = 'postprocessVertexShader';
  123369. 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}";
  123370. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123371. /** @hidden */
  123372. var postprocessVertexShader = { name: name, shader: shader };
  123373. /***/ }),
  123374. /***/ "./Shaders/procedural.vertex.ts":
  123375. /*!**************************************!*\
  123376. !*** ./Shaders/procedural.vertex.ts ***!
  123377. \**************************************/
  123378. /*! exports provided: proceduralVertexShader */
  123379. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123380. "use strict";
  123381. __webpack_require__.r(__webpack_exports__);
  123382. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "proceduralVertexShader", function() { return proceduralVertexShader; });
  123383. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123384. var name = 'proceduralVertexShader';
  123385. 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}";
  123386. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123387. /** @hidden */
  123388. var proceduralVertexShader = { name: name, shader: shader };
  123389. /***/ }),
  123390. /***/ "./Shaders/refraction.fragment.ts":
  123391. /*!****************************************!*\
  123392. !*** ./Shaders/refraction.fragment.ts ***!
  123393. \****************************************/
  123394. /*! exports provided: refractionPixelShader */
  123395. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123396. "use strict";
  123397. __webpack_require__.r(__webpack_exports__);
  123398. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "refractionPixelShader", function() { return refractionPixelShader; });
  123399. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123400. var name = 'refractionPixelShader';
  123401. 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}";
  123402. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123403. /** @hidden */
  123404. var refractionPixelShader = { name: name, shader: shader };
  123405. /***/ }),
  123406. /***/ "./Shaders/rgbdDecode.fragment.ts":
  123407. /*!****************************************!*\
  123408. !*** ./Shaders/rgbdDecode.fragment.ts ***!
  123409. \****************************************/
  123410. /*! exports provided: rgbdDecodePixelShader */
  123411. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123412. "use strict";
  123413. __webpack_require__.r(__webpack_exports__);
  123414. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdDecodePixelShader", function() { return rgbdDecodePixelShader; });
  123415. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123416. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123417. var name = 'rgbdDecodePixelShader';
  123418. 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}";
  123419. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123420. /** @hidden */
  123421. var rgbdDecodePixelShader = { name: name, shader: shader };
  123422. /***/ }),
  123423. /***/ "./Shaders/rgbdEncode.fragment.ts":
  123424. /*!****************************************!*\
  123425. !*** ./Shaders/rgbdEncode.fragment.ts ***!
  123426. \****************************************/
  123427. /*! exports provided: rgbdEncodePixelShader */
  123428. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123429. "use strict";
  123430. __webpack_require__.r(__webpack_exports__);
  123431. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdEncodePixelShader", function() { return rgbdEncodePixelShader; });
  123432. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123433. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123434. var name = 'rgbdEncodePixelShader';
  123435. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";
  123436. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123437. /** @hidden */
  123438. var rgbdEncodePixelShader = { name: name, shader: shader };
  123439. /***/ }),
  123440. /***/ "./Shaders/shadowMap.fragment.ts":
  123441. /*!***************************************!*\
  123442. !*** ./Shaders/shadowMap.fragment.ts ***!
  123443. \***************************************/
  123444. /*! exports provided: shadowMapPixelShader */
  123445. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123446. "use strict";
  123447. __webpack_require__.r(__webpack_exports__);
  123448. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapPixelShader", function() { return shadowMapPixelShader; });
  123449. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123450. var name = 'shadowMapPixelShader';
  123451. 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}";
  123452. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123453. /** @hidden */
  123454. var shadowMapPixelShader = { name: name, shader: shader };
  123455. /***/ }),
  123456. /***/ "./Shaders/shadowMap.vertex.ts":
  123457. /*!*************************************!*\
  123458. !*** ./Shaders/shadowMap.vertex.ts ***!
  123459. \*************************************/
  123460. /*! exports provided: shadowMapVertexShader */
  123461. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123462. "use strict";
  123463. __webpack_require__.r(__webpack_exports__);
  123464. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapVertexShader", function() { return shadowMapVertexShader; });
  123465. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123466. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  123467. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  123468. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  123469. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  123470. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  123471. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  123472. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  123473. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  123474. var name = 'shadowMapVertexShader';
  123475. 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}";
  123476. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123477. /** @hidden */
  123478. var shadowMapVertexShader = { name: name, shader: shader };
  123479. /***/ }),
  123480. /***/ "./Shaders/sharpen.fragment.ts":
  123481. /*!*************************************!*\
  123482. !*** ./Shaders/sharpen.fragment.ts ***!
  123483. \*************************************/
  123484. /*! exports provided: sharpenPixelShader */
  123485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123486. "use strict";
  123487. __webpack_require__.r(__webpack_exports__);
  123488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sharpenPixelShader", function() { return sharpenPixelShader; });
  123489. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123490. var name = 'sharpenPixelShader';
  123491. 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}";
  123492. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123493. /** @hidden */
  123494. var sharpenPixelShader = { name: name, shader: shader };
  123495. /***/ }),
  123496. /***/ "./Shaders/sprites.fragment.ts":
  123497. /*!*************************************!*\
  123498. !*** ./Shaders/sprites.fragment.ts ***!
  123499. \*************************************/
  123500. /*! exports provided: spritesPixelShader */
  123501. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123502. "use strict";
  123503. __webpack_require__.r(__webpack_exports__);
  123504. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesPixelShader", function() { return spritesPixelShader; });
  123505. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123506. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  123507. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  123508. var name = 'spritesPixelShader';
  123509. 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}";
  123510. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123511. /** @hidden */
  123512. var spritesPixelShader = { name: name, shader: shader };
  123513. /***/ }),
  123514. /***/ "./Shaders/sprites.vertex.ts":
  123515. /*!***********************************!*\
  123516. !*** ./Shaders/sprites.vertex.ts ***!
  123517. \***********************************/
  123518. /*! exports provided: spritesVertexShader */
  123519. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123520. "use strict";
  123521. __webpack_require__.r(__webpack_exports__);
  123522. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesVertexShader", function() { return spritesVertexShader; });
  123523. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123524. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  123525. var name = 'spritesVertexShader';
  123526. 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}";
  123527. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123528. /** @hidden */
  123529. var spritesVertexShader = { name: name, shader: shader };
  123530. /***/ }),
  123531. /***/ "./Shaders/ssao.fragment.ts":
  123532. /*!**********************************!*\
  123533. !*** ./Shaders/ssao.fragment.ts ***!
  123534. \**********************************/
  123535. /*! exports provided: ssaoPixelShader */
  123536. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123537. "use strict";
  123538. __webpack_require__.r(__webpack_exports__);
  123539. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoPixelShader", function() { return ssaoPixelShader; });
  123540. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123541. var name = 'ssaoPixelShader';
  123542. 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";
  123543. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123544. /** @hidden */
  123545. var ssaoPixelShader = { name: name, shader: shader };
  123546. /***/ }),
  123547. /***/ "./Shaders/ssao2.fragment.ts":
  123548. /*!***********************************!*\
  123549. !*** ./Shaders/ssao2.fragment.ts ***!
  123550. \***********************************/
  123551. /*! exports provided: ssao2PixelShader */
  123552. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123553. "use strict";
  123554. __webpack_require__.r(__webpack_exports__);
  123555. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssao2PixelShader", function() { return ssao2PixelShader; });
  123556. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123557. var name = 'ssao2PixelShader';
  123558. 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";
  123559. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123560. /** @hidden */
  123561. var ssao2PixelShader = { name: name, shader: shader };
  123562. /***/ }),
  123563. /***/ "./Shaders/ssaoCombine.fragment.ts":
  123564. /*!*****************************************!*\
  123565. !*** ./Shaders/ssaoCombine.fragment.ts ***!
  123566. \*****************************************/
  123567. /*! exports provided: ssaoCombinePixelShader */
  123568. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123569. "use strict";
  123570. __webpack_require__.r(__webpack_exports__);
  123571. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoCombinePixelShader", function() { return ssaoCombinePixelShader; });
  123572. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123573. var name = 'ssaoCombinePixelShader';
  123574. 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";
  123575. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123576. /** @hidden */
  123577. var ssaoCombinePixelShader = { name: name, shader: shader };
  123578. /***/ }),
  123579. /***/ "./Shaders/standard.fragment.ts":
  123580. /*!**************************************!*\
  123581. !*** ./Shaders/standard.fragment.ts ***!
  123582. \**************************************/
  123583. /*! exports provided: standardPixelShader */
  123584. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123585. "use strict";
  123586. __webpack_require__.r(__webpack_exports__);
  123587. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "standardPixelShader", function() { return standardPixelShader; });
  123588. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123589. var name = 'standardPixelShader';
  123590. 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";
  123591. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123592. /** @hidden */
  123593. var standardPixelShader = { name: name, shader: shader };
  123594. /***/ }),
  123595. /***/ "./Shaders/stereoscopicInterlace.fragment.ts":
  123596. /*!***************************************************!*\
  123597. !*** ./Shaders/stereoscopicInterlace.fragment.ts ***!
  123598. \***************************************************/
  123599. /*! exports provided: stereoscopicInterlacePixelShader */
  123600. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123601. "use strict";
  123602. __webpack_require__.r(__webpack_exports__);
  123603. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stereoscopicInterlacePixelShader", function() { return stereoscopicInterlacePixelShader; });
  123604. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123605. var name = 'stereoscopicInterlacePixelShader';
  123606. 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}";
  123607. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123608. /** @hidden */
  123609. var stereoscopicInterlacePixelShader = { name: name, shader: shader };
  123610. /***/ }),
  123611. /***/ "./Shaders/tonemap.fragment.ts":
  123612. /*!*************************************!*\
  123613. !*** ./Shaders/tonemap.fragment.ts ***!
  123614. \*************************************/
  123615. /*! exports provided: tonemapPixelShader */
  123616. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123617. "use strict";
  123618. __webpack_require__.r(__webpack_exports__);
  123619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tonemapPixelShader", function() { return tonemapPixelShader; });
  123620. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123621. var name = 'tonemapPixelShader';
  123622. 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}";
  123623. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123624. /** @hidden */
  123625. var tonemapPixelShader = { name: name, shader: shader };
  123626. /***/ }),
  123627. /***/ "./Shaders/volumetricLightScattering.fragment.ts":
  123628. /*!*******************************************************!*\
  123629. !*** ./Shaders/volumetricLightScattering.fragment.ts ***!
  123630. \*******************************************************/
  123631. /*! exports provided: volumetricLightScatteringPixelShader */
  123632. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123633. "use strict";
  123634. __webpack_require__.r(__webpack_exports__);
  123635. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPixelShader", function() { return volumetricLightScatteringPixelShader; });
  123636. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123637. var name = 'volumetricLightScatteringPixelShader';
  123638. 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";
  123639. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123640. /** @hidden */
  123641. var volumetricLightScatteringPixelShader = { name: name, shader: shader };
  123642. /***/ }),
  123643. /***/ "./Shaders/volumetricLightScatteringPass.fragment.ts":
  123644. /*!***********************************************************!*\
  123645. !*** ./Shaders/volumetricLightScatteringPass.fragment.ts ***!
  123646. \***********************************************************/
  123647. /*! exports provided: volumetricLightScatteringPassPixelShader */
  123648. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123649. "use strict";
  123650. __webpack_require__.r(__webpack_exports__);
  123651. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPassPixelShader", function() { return volumetricLightScatteringPassPixelShader; });
  123652. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123653. var name = 'volumetricLightScatteringPassPixelShader';
  123654. 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";
  123655. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123656. /** @hidden */
  123657. var volumetricLightScatteringPassPixelShader = { name: name, shader: shader };
  123658. /***/ }),
  123659. /***/ "./Shaders/vrDistortionCorrection.fragment.ts":
  123660. /*!****************************************************!*\
  123661. !*** ./Shaders/vrDistortionCorrection.fragment.ts ***!
  123662. \****************************************************/
  123663. /*! exports provided: vrDistortionCorrectionPixelShader */
  123664. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123665. "use strict";
  123666. __webpack_require__.r(__webpack_exports__);
  123667. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrDistortionCorrectionPixelShader", function() { return vrDistortionCorrectionPixelShader; });
  123668. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  123669. var name = 'vrDistortionCorrectionPixelShader';
  123670. 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}";
  123671. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  123672. /** @hidden */
  123673. var vrDistortionCorrectionPixelShader = { name: name, shader: shader };
  123674. /***/ }),
  123675. /***/ "./Sprites/index.ts":
  123676. /*!**************************!*\
  123677. !*** ./Sprites/index.ts ***!
  123678. \**************************/
  123679. /*! exports provided: Sprite, SpriteManager, SpriteSceneComponent */
  123680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123681. "use strict";
  123682. __webpack_require__.r(__webpack_exports__);
  123683. /* harmony import */ var _sprite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sprite */ "./Sprites/sprite.ts");
  123684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _sprite__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  123685. /* harmony import */ var _spriteManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./spriteManager */ "./Sprites/spriteManager.ts");
  123686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _spriteManager__WEBPACK_IMPORTED_MODULE_1__["SpriteManager"]; });
  123687. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  123688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__["SpriteSceneComponent"]; });
  123689. /***/ }),
  123690. /***/ "./Sprites/sprite.ts":
  123691. /*!***************************!*\
  123692. !*** ./Sprites/sprite.ts ***!
  123693. \***************************/
  123694. /*! exports provided: Sprite */
  123695. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123696. "use strict";
  123697. __webpack_require__.r(__webpack_exports__);
  123698. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return Sprite; });
  123699. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  123700. /**
  123701. * Class used to represent a sprite
  123702. * @see http://doc.babylonjs.com/babylon101/sprites
  123703. */
  123704. var Sprite = /** @class */ (function () {
  123705. /**
  123706. * Creates a new Sprite
  123707. * @param name defines the name
  123708. * @param manager defines the manager
  123709. */
  123710. function Sprite(
  123711. /** defines the name */
  123712. name, manager) {
  123713. this.name = name;
  123714. /** Gets or sets the main color */
  123715. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  123716. /** Gets or sets the width */
  123717. this.width = 1.0;
  123718. /** Gets or sets the height */
  123719. this.height = 1.0;
  123720. /** Gets or sets rotation angle */
  123721. this.angle = 0;
  123722. /** Gets or sets the cell index in the sprite sheet */
  123723. this.cellIndex = 0;
  123724. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  123725. this.invertU = 0;
  123726. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  123727. this.invertV = 0;
  123728. /** Gets the list of attached animations */
  123729. this.animations = new Array();
  123730. /** Gets or sets a boolean indicating if the sprite can be picked */
  123731. this.isPickable = false;
  123732. this._animationStarted = false;
  123733. this._loopAnimation = false;
  123734. this._fromIndex = 0;
  123735. this._toIndex = 0;
  123736. this._delay = 0;
  123737. this._direction = 1;
  123738. this._time = 0;
  123739. /**
  123740. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  123741. */
  123742. this.isVisible = true;
  123743. this._manager = manager;
  123744. this._manager.sprites.push(this);
  123745. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  123746. }
  123747. Object.defineProperty(Sprite.prototype, "size", {
  123748. /**
  123749. * Gets or sets the sprite size
  123750. */
  123751. get: function () {
  123752. return this.width;
  123753. },
  123754. set: function (value) {
  123755. this.width = value;
  123756. this.height = value;
  123757. },
  123758. enumerable: true,
  123759. configurable: true
  123760. });
  123761. /**
  123762. * Starts an animation
  123763. * @param from defines the initial key
  123764. * @param to defines the end key
  123765. * @param loop defines if the animation must loop
  123766. * @param delay defines the start delay (in ms)
  123767. * @param onAnimationEnd defines a callback to call when animation ends
  123768. */
  123769. Sprite.prototype.playAnimation = function (from, to, loop, delay, onAnimationEnd) {
  123770. this._fromIndex = from;
  123771. this._toIndex = to;
  123772. this._loopAnimation = loop;
  123773. this._delay = delay;
  123774. this._animationStarted = true;
  123775. this._direction = from < to ? 1 : -1;
  123776. this.cellIndex = from;
  123777. this._time = 0;
  123778. this._onAnimationEnd = onAnimationEnd;
  123779. };
  123780. /** Stops current animation (if any) */
  123781. Sprite.prototype.stopAnimation = function () {
  123782. this._animationStarted = false;
  123783. };
  123784. /** @hidden */
  123785. Sprite.prototype._animate = function (deltaTime) {
  123786. if (!this._animationStarted) {
  123787. return;
  123788. }
  123789. this._time += deltaTime;
  123790. if (this._time > this._delay) {
  123791. this._time = this._time % this._delay;
  123792. this.cellIndex += this._direction;
  123793. if (this.cellIndex > this._toIndex) {
  123794. if (this._loopAnimation) {
  123795. this.cellIndex = this._fromIndex;
  123796. }
  123797. else {
  123798. this.cellIndex = this._toIndex;
  123799. this._animationStarted = false;
  123800. if (this._onAnimationEnd) {
  123801. this._onAnimationEnd();
  123802. }
  123803. if (this.disposeWhenFinishedAnimating) {
  123804. this.dispose();
  123805. }
  123806. }
  123807. }
  123808. }
  123809. };
  123810. /** Release associated resources */
  123811. Sprite.prototype.dispose = function () {
  123812. for (var i = 0; i < this._manager.sprites.length; i++) {
  123813. if (this._manager.sprites[i] == this) {
  123814. this._manager.sprites.splice(i, 1);
  123815. }
  123816. }
  123817. };
  123818. return Sprite;
  123819. }());
  123820. /***/ }),
  123821. /***/ "./Sprites/spriteManager.ts":
  123822. /*!**********************************!*\
  123823. !*** ./Sprites/spriteManager.ts ***!
  123824. \**********************************/
  123825. /*! exports provided: SpriteManager */
  123826. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123827. "use strict";
  123828. __webpack_require__.r(__webpack_exports__);
  123829. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return SpriteManager; });
  123830. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  123831. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  123832. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  123833. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  123834. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  123835. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  123836. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  123837. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  123838. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  123839. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123840. /* harmony import */ var _Shaders_sprites_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/sprites.fragment */ "./Shaders/sprites.fragment.ts");
  123841. /* harmony import */ var _Shaders_sprites_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/sprites.vertex */ "./Shaders/sprites.vertex.ts");
  123842. /**
  123843. * Class used to manage multiple sprites on the same spritesheet
  123844. * @see http://doc.babylonjs.com/babylon101/sprites
  123845. */
  123846. var SpriteManager = /** @class */ (function () {
  123847. /**
  123848. * Creates a new sprite manager
  123849. * @param name defines the manager's name
  123850. * @param imgUrl defines the sprite sheet url
  123851. * @param capacity defines the maximum allowed number of sprites
  123852. * @param cellSize defines the size of a sprite cell
  123853. * @param scene defines the hosting scene
  123854. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  123855. * @param samplingMode defines the smapling mode to use with spritesheet
  123856. */
  123857. function SpriteManager(
  123858. /** defines the manager's name */
  123859. name, imgUrl, capacity, cellSize, scene, epsilon, samplingMode) {
  123860. if (epsilon === void 0) { epsilon = 0.01; }
  123861. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].TRILINEAR_SAMPLINGMODE; }
  123862. this.name = name;
  123863. /** Gets the list of sprites */
  123864. this.sprites = new Array();
  123865. /** Gets or sets the rendering group id (0 by default) */
  123866. this.renderingGroupId = 0;
  123867. /** Gets or sets camera layer mask */
  123868. this.layerMask = 0x0FFFFFFF;
  123869. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  123870. this.fogEnabled = true;
  123871. /** Gets or sets a boolean indicating if the sprites are pickable */
  123872. this.isPickable = false;
  123873. /**
  123874. * An event triggered when the manager is disposed.
  123875. */
  123876. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  123877. this._vertexBuffers = {};
  123878. if (!scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_8__["SceneComponentConstants"].NAME_SPRITE)) {
  123879. scene._addComponent(new _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__["SpriteSceneComponent"](scene));
  123880. }
  123881. this._capacity = capacity;
  123882. this._spriteTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](imgUrl, scene, true, false, samplingMode);
  123883. this._spriteTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  123884. this._spriteTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  123885. if (cellSize.width && cellSize.height) {
  123886. this.cellWidth = cellSize.width;
  123887. this.cellHeight = cellSize.height;
  123888. }
  123889. else if (cellSize !== undefined) {
  123890. this.cellWidth = cellSize;
  123891. this.cellHeight = cellSize;
  123892. }
  123893. else {
  123894. return;
  123895. }
  123896. this._epsilon = epsilon;
  123897. this._scene = scene;
  123898. this._scene.spriteManagers.push(this);
  123899. var indices = [];
  123900. var index = 0;
  123901. for (var count = 0; count < capacity; count++) {
  123902. indices.push(index);
  123903. indices.push(index + 1);
  123904. indices.push(index + 2);
  123905. indices.push(index);
  123906. indices.push(index + 2);
  123907. indices.push(index + 3);
  123908. index += 4;
  123909. }
  123910. this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
  123911. // VBO
  123912. // 16 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color r, color g, color b, color a)
  123913. this._vertexData = new Float32Array(capacity * 16 * 4);
  123914. this._buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["Buffer"](scene.getEngine(), this._vertexData, true, 16);
  123915. var positions = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, 0, 4);
  123916. var options = this._buffer.createVertexBuffer("options", 4, 4);
  123917. var cellInfo = this._buffer.createVertexBuffer("cellInfo", 8, 4);
  123918. var colors = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, 12, 4);
  123919. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind] = positions;
  123920. this._vertexBuffers["options"] = options;
  123921. this._vertexBuffers["cellInfo"] = cellInfo;
  123922. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind] = colors;
  123923. // Effects
  123924. 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"], "");
  123925. 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");
  123926. }
  123927. Object.defineProperty(SpriteManager.prototype, "onDispose", {
  123928. /**
  123929. * Callback called when the manager is disposed
  123930. */
  123931. set: function (callback) {
  123932. if (this._onDisposeObserver) {
  123933. this.onDisposeObservable.remove(this._onDisposeObserver);
  123934. }
  123935. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  123936. },
  123937. enumerable: true,
  123938. configurable: true
  123939. });
  123940. Object.defineProperty(SpriteManager.prototype, "texture", {
  123941. /**
  123942. * Gets or sets the spritesheet texture
  123943. */
  123944. get: function () {
  123945. return this._spriteTexture;
  123946. },
  123947. set: function (value) {
  123948. this._spriteTexture = value;
  123949. },
  123950. enumerable: true,
  123951. configurable: true
  123952. });
  123953. SpriteManager.prototype._appendSpriteVertex = function (index, sprite, offsetX, offsetY, rowSize) {
  123954. var arrayOffset = index * 16;
  123955. if (offsetX === 0) {
  123956. offsetX = this._epsilon;
  123957. }
  123958. else if (offsetX === 1) {
  123959. offsetX = 1 - this._epsilon;
  123960. }
  123961. if (offsetY === 0) {
  123962. offsetY = this._epsilon;
  123963. }
  123964. else if (offsetY === 1) {
  123965. offsetY = 1 - this._epsilon;
  123966. }
  123967. this._vertexData[arrayOffset] = sprite.position.x;
  123968. this._vertexData[arrayOffset + 1] = sprite.position.y;
  123969. this._vertexData[arrayOffset + 2] = sprite.position.z;
  123970. this._vertexData[arrayOffset + 3] = sprite.angle;
  123971. this._vertexData[arrayOffset + 4] = sprite.width;
  123972. this._vertexData[arrayOffset + 5] = sprite.height;
  123973. this._vertexData[arrayOffset + 6] = offsetX;
  123974. this._vertexData[arrayOffset + 7] = offsetY;
  123975. this._vertexData[arrayOffset + 8] = sprite.invertU ? 1 : 0;
  123976. this._vertexData[arrayOffset + 9] = sprite.invertV ? 1 : 0;
  123977. var offset = (sprite.cellIndex / rowSize) >> 0;
  123978. this._vertexData[arrayOffset + 10] = sprite.cellIndex - offset * rowSize;
  123979. this._vertexData[arrayOffset + 11] = offset;
  123980. // Color
  123981. this._vertexData[arrayOffset + 12] = sprite.color.r;
  123982. this._vertexData[arrayOffset + 13] = sprite.color.g;
  123983. this._vertexData[arrayOffset + 14] = sprite.color.b;
  123984. this._vertexData[arrayOffset + 15] = sprite.color.a;
  123985. };
  123986. /**
  123987. * Intersects the sprites with a ray
  123988. * @param ray defines the ray to intersect with
  123989. * @param camera defines the current active camera
  123990. * @param predicate defines a predicate used to select candidate sprites
  123991. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  123992. * @returns null if no hit or a PickingInfo
  123993. */
  123994. SpriteManager.prototype.intersects = function (ray, camera, predicate, fastCheck) {
  123995. var count = Math.min(this._capacity, this.sprites.length);
  123996. var min = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  123997. var max = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  123998. var distance = Number.MAX_VALUE;
  123999. var currentSprite = null;
  124000. var cameraSpacePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  124001. var cameraView = camera.getViewMatrix();
  124002. for (var index = 0; index < count; index++) {
  124003. var sprite = this.sprites[index];
  124004. if (!sprite) {
  124005. continue;
  124006. }
  124007. if (predicate) {
  124008. if (!predicate(sprite)) {
  124009. continue;
  124010. }
  124011. }
  124012. else if (!sprite.isPickable) {
  124013. continue;
  124014. }
  124015. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);
  124016. min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);
  124017. max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);
  124018. if (ray.intersectsBoxMinMax(min, max)) {
  124019. var currentDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(cameraSpacePosition, ray.origin);
  124020. if (distance > currentDistance) {
  124021. distance = currentDistance;
  124022. currentSprite = sprite;
  124023. if (fastCheck) {
  124024. break;
  124025. }
  124026. }
  124027. }
  124028. }
  124029. if (currentSprite) {
  124030. var result = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__["PickingInfo"]();
  124031. result.hit = true;
  124032. result.pickedSprite = currentSprite;
  124033. result.distance = distance;
  124034. return result;
  124035. }
  124036. return null;
  124037. };
  124038. /**
  124039. * Render all child sprites
  124040. */
  124041. SpriteManager.prototype.render = function () {
  124042. // Check
  124043. if (!this._effectBase.isReady() || !this._effectFog.isReady() || !this._spriteTexture
  124044. || !this._spriteTexture.isReady() || !this.sprites.length) {
  124045. return;
  124046. }
  124047. var engine = this._scene.getEngine();
  124048. var baseSize = this._spriteTexture.getBaseSize();
  124049. // Sprites
  124050. var deltaTime = engine.getDeltaTime();
  124051. var max = Math.min(this._capacity, this.sprites.length);
  124052. var rowSize = baseSize.width / this.cellWidth;
  124053. var offset = 0;
  124054. for (var index = 0; index < max; index++) {
  124055. var sprite = this.sprites[index];
  124056. if (!sprite || !sprite.isVisible) {
  124057. continue;
  124058. }
  124059. sprite._animate(deltaTime);
  124060. this._appendSpriteVertex(offset++, sprite, 0, 0, rowSize);
  124061. this._appendSpriteVertex(offset++, sprite, 1, 0, rowSize);
  124062. this._appendSpriteVertex(offset++, sprite, 1, 1, rowSize);
  124063. this._appendSpriteVertex(offset++, sprite, 0, 1, rowSize);
  124064. }
  124065. this._buffer.update(this._vertexData);
  124066. // Render
  124067. var effect = this._effectBase;
  124068. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  124069. effect = this._effectFog;
  124070. }
  124071. engine.enableEffect(effect);
  124072. var viewMatrix = this._scene.getViewMatrix();
  124073. effect.setTexture("diffuseSampler", this._spriteTexture);
  124074. effect.setMatrix("view", viewMatrix);
  124075. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  124076. effect.setFloat2("textureInfos", this.cellWidth / baseSize.width, this.cellHeight / baseSize.height);
  124077. // Fog
  124078. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  124079. effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
  124080. effect.setColor3("vFogColor", this._scene.fogColor);
  124081. }
  124082. // VBOs
  124083. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  124084. // Draw order
  124085. engine.setDepthFunctionToLessOrEqual();
  124086. effect.setBool("alphaTest", true);
  124087. engine.setColorWrite(false);
  124088. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  124089. engine.setColorWrite(true);
  124090. effect.setBool("alphaTest", false);
  124091. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_COMBINE);
  124092. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  124093. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_DISABLE);
  124094. };
  124095. /**
  124096. * Release associated resources
  124097. */
  124098. SpriteManager.prototype.dispose = function () {
  124099. if (this._buffer) {
  124100. this._buffer.dispose();
  124101. this._buffer = null;
  124102. }
  124103. if (this._indexBuffer) {
  124104. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  124105. this._indexBuffer = null;
  124106. }
  124107. if (this._spriteTexture) {
  124108. this._spriteTexture.dispose();
  124109. this._spriteTexture = null;
  124110. }
  124111. // Remove from scene
  124112. var index = this._scene.spriteManagers.indexOf(this);
  124113. this._scene.spriteManagers.splice(index, 1);
  124114. // Callback
  124115. this.onDisposeObservable.notifyObservers(this);
  124116. this.onDisposeObservable.clear();
  124117. };
  124118. return SpriteManager;
  124119. }());
  124120. /***/ }),
  124121. /***/ "./Sprites/spriteSceneComponent.ts":
  124122. /*!*****************************************!*\
  124123. !*** ./Sprites/spriteSceneComponent.ts ***!
  124124. \*****************************************/
  124125. /*! exports provided: SpriteSceneComponent */
  124126. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124127. "use strict";
  124128. __webpack_require__.r(__webpack_exports__);
  124129. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return SpriteSceneComponent; });
  124130. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  124131. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  124132. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  124133. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  124134. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  124135. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Actions/actionEvent */ "./Actions/actionEvent.ts");
  124136. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124137. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype._internalPickSprites = function (ray, predicate, fastCheck, camera) {
  124138. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]) {
  124139. return null;
  124140. }
  124141. var pickingInfo = null;
  124142. if (!camera) {
  124143. if (!this.activeCamera) {
  124144. return null;
  124145. }
  124146. camera = this.activeCamera;
  124147. }
  124148. if (this.spriteManagers.length > 0) {
  124149. for (var spriteIndex = 0; spriteIndex < this.spriteManagers.length; spriteIndex++) {
  124150. var spriteManager = this.spriteManagers[spriteIndex];
  124151. if (!spriteManager.isPickable) {
  124152. continue;
  124153. }
  124154. var result = spriteManager.intersects(ray, camera, predicate, fastCheck);
  124155. if (!result || !result.hit) {
  124156. continue;
  124157. }
  124158. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  124159. continue;
  124160. }
  124161. pickingInfo = result;
  124162. if (fastCheck) {
  124163. break;
  124164. }
  124165. }
  124166. }
  124167. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]();
  124168. };
  124169. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSprite = function (x, y, predicate, fastCheck, camera) {
  124170. this.createPickingRayInCameraSpaceToRef(x, y, this._tempSpritePickingRay, camera);
  124171. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  124172. };
  124173. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSpriteWithRay = function (ray, predicate, fastCheck, camera) {
  124174. if (!this._tempSpritePickingRay) {
  124175. return null;
  124176. }
  124177. if (!camera) {
  124178. if (!this.activeCamera) {
  124179. return null;
  124180. }
  124181. camera = this.activeCamera;
  124182. }
  124183. _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].TransformToRef(ray, camera.getViewMatrix(), this._tempSpritePickingRay);
  124184. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  124185. };
  124186. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.setPointerOverSprite = function (sprite) {
  124187. if (this._pointerOverSprite === sprite) {
  124188. return;
  124189. }
  124190. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  124191. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  124192. }
  124193. this._pointerOverSprite = sprite;
  124194. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  124195. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  124196. }
  124197. };
  124198. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.getPointerOverSprite = function () {
  124199. return this._pointerOverSprite;
  124200. };
  124201. /**
  124202. * Defines the sprite scene component responsible to manage sprites
  124203. * in a given scene.
  124204. */
  124205. var SpriteSceneComponent = /** @class */ (function () {
  124206. /**
  124207. * Creates a new instance of the component for the given scene
  124208. * @param scene Defines the scene to register the component in
  124209. */
  124210. function SpriteSceneComponent(scene) {
  124211. /**
  124212. * The component name helpfull to identify the component in the list of scene components.
  124213. */
  124214. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_SPRITE;
  124215. this.scene = scene;
  124216. this.scene.spriteManagers = new Array();
  124217. this.scene._tempSpritePickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].Zero() : null;
  124218. this.scene.onBeforeSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  124219. this.scene.onAfterSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  124220. this._spritePredicate = function (sprite) {
  124221. if (!sprite.actionManager) {
  124222. return false;
  124223. }
  124224. return sprite.isPickable && sprite.actionManager.hasPointerTriggers;
  124225. };
  124226. }
  124227. /**
  124228. * Registers the component in a given scene
  124229. */
  124230. SpriteSceneComponent.prototype.register = function () {
  124231. this.scene._pointerMoveStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERMOVE_SPRITE, this, this._pointerMove);
  124232. this.scene._pointerDownStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERDOWN_SPRITE, this, this._pointerDown);
  124233. this.scene._pointerUpStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERUP_SPRITE, this, this._pointerUp);
  124234. };
  124235. /**
  124236. * Rebuilds the elements related to this component in case of
  124237. * context lost for instance.
  124238. */
  124239. SpriteSceneComponent.prototype.rebuild = function () {
  124240. /** Nothing to do for sprites */
  124241. };
  124242. /**
  124243. * Disposes the component and the associated ressources.
  124244. */
  124245. SpriteSceneComponent.prototype.dispose = function () {
  124246. this.scene.onBeforeSpritesRenderingObservable.clear();
  124247. this.scene.onAfterSpritesRenderingObservable.clear();
  124248. var spriteManagers = this.scene.spriteManagers;
  124249. while (spriteManagers.length) {
  124250. spriteManagers[0].dispose();
  124251. }
  124252. };
  124253. SpriteSceneComponent.prototype._pickSpriteButKeepRay = function (originalPointerInfo, x, y, fastCheck, camera) {
  124254. var result = this.scene.pickSprite(x, y, this._spritePredicate, fastCheck, camera);
  124255. if (result) {
  124256. result.ray = originalPointerInfo ? originalPointerInfo.ray : null;
  124257. }
  124258. return result;
  124259. };
  124260. SpriteSceneComponent.prototype._pointerMove = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, isMeshPicked, canvas) {
  124261. var scene = this.scene;
  124262. if (isMeshPicked) {
  124263. scene.setPointerOverSprite(null);
  124264. }
  124265. else {
  124266. pickResult = this._pickSpriteButKeepRay(pickResult, unTranslatedPointerX, unTranslatedPointerY, false, scene.cameraToUseForPointers || undefined);
  124267. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  124268. scene.setPointerOverSprite(pickResult.pickedSprite);
  124269. if (scene._pointerOverSprite && scene._pointerOverSprite.actionManager && scene._pointerOverSprite.actionManager.hoverCursor) {
  124270. canvas.style.cursor = scene._pointerOverSprite.actionManager.hoverCursor;
  124271. }
  124272. else {
  124273. canvas.style.cursor = scene.hoverCursor;
  124274. }
  124275. }
  124276. else {
  124277. scene.setPointerOverSprite(null);
  124278. }
  124279. }
  124280. return pickResult;
  124281. };
  124282. SpriteSceneComponent.prototype._pointerDown = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  124283. var scene = this.scene;
  124284. scene._pickedDownSprite = null;
  124285. if (scene.spriteManagers.length > 0) {
  124286. pickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  124287. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  124288. if (pickResult.pickedSprite.actionManager) {
  124289. scene._pickedDownSprite = pickResult.pickedSprite;
  124290. switch (evt.button) {
  124291. case 0:
  124292. 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));
  124293. break;
  124294. case 1:
  124295. 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));
  124296. break;
  124297. case 2:
  124298. 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));
  124299. break;
  124300. }
  124301. if (pickResult.pickedSprite.actionManager) {
  124302. 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));
  124303. }
  124304. }
  124305. }
  124306. }
  124307. return pickResult;
  124308. };
  124309. SpriteSceneComponent.prototype._pointerUp = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  124310. var scene = this.scene;
  124311. if (scene.spriteManagers.length > 0) {
  124312. var spritePickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  124313. if (spritePickResult) {
  124314. if (spritePickResult.hit && spritePickResult.pickedSprite) {
  124315. if (spritePickResult.pickedSprite.actionManager) {
  124316. 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));
  124317. if (spritePickResult.pickedSprite.actionManager) {
  124318. if (!this.scene._isPointerSwiping()) {
  124319. 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));
  124320. }
  124321. }
  124322. }
  124323. }
  124324. if (scene._pickedDownSprite && scene._pickedDownSprite.actionManager && scene._pickedDownSprite !== spritePickResult.pickedSprite) {
  124325. 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));
  124326. }
  124327. }
  124328. }
  124329. return pickResult;
  124330. };
  124331. return SpriteSceneComponent;
  124332. }());
  124333. /***/ }),
  124334. /***/ "./States/alphaCullingState.ts":
  124335. /*!*************************************!*\
  124336. !*** ./States/alphaCullingState.ts ***!
  124337. \*************************************/
  124338. /*! exports provided: _AlphaState */
  124339. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124340. "use strict";
  124341. __webpack_require__.r(__webpack_exports__);
  124342. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _AlphaState; });
  124343. /**
  124344. * @hidden
  124345. **/
  124346. var _AlphaState = /** @class */ (function () {
  124347. /**
  124348. * Initializes the state.
  124349. */
  124350. function _AlphaState() {
  124351. this._isAlphaBlendDirty = false;
  124352. this._isBlendFunctionParametersDirty = false;
  124353. this._isBlendEquationParametersDirty = false;
  124354. this._isBlendConstantsDirty = false;
  124355. this._alphaBlend = false;
  124356. this._blendFunctionParameters = new Array(4);
  124357. this._blendEquationParameters = new Array(2);
  124358. this._blendConstants = new Array(4);
  124359. this.reset();
  124360. }
  124361. Object.defineProperty(_AlphaState.prototype, "isDirty", {
  124362. get: function () {
  124363. return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty;
  124364. },
  124365. enumerable: true,
  124366. configurable: true
  124367. });
  124368. Object.defineProperty(_AlphaState.prototype, "alphaBlend", {
  124369. get: function () {
  124370. return this._alphaBlend;
  124371. },
  124372. set: function (value) {
  124373. if (this._alphaBlend === value) {
  124374. return;
  124375. }
  124376. this._alphaBlend = value;
  124377. this._isAlphaBlendDirty = true;
  124378. },
  124379. enumerable: true,
  124380. configurable: true
  124381. });
  124382. _AlphaState.prototype.setAlphaBlendConstants = function (r, g, b, a) {
  124383. if (this._blendConstants[0] === r &&
  124384. this._blendConstants[1] === g &&
  124385. this._blendConstants[2] === b &&
  124386. this._blendConstants[3] === a) {
  124387. return;
  124388. }
  124389. this._blendConstants[0] = r;
  124390. this._blendConstants[1] = g;
  124391. this._blendConstants[2] = b;
  124392. this._blendConstants[3] = a;
  124393. this._isBlendConstantsDirty = true;
  124394. };
  124395. _AlphaState.prototype.setAlphaBlendFunctionParameters = function (value0, value1, value2, value3) {
  124396. if (this._blendFunctionParameters[0] === value0 &&
  124397. this._blendFunctionParameters[1] === value1 &&
  124398. this._blendFunctionParameters[2] === value2 &&
  124399. this._blendFunctionParameters[3] === value3) {
  124400. return;
  124401. }
  124402. this._blendFunctionParameters[0] = value0;
  124403. this._blendFunctionParameters[1] = value1;
  124404. this._blendFunctionParameters[2] = value2;
  124405. this._blendFunctionParameters[3] = value3;
  124406. this._isBlendFunctionParametersDirty = true;
  124407. };
  124408. _AlphaState.prototype.setAlphaEquationParameters = function (rgb, alpha) {
  124409. if (this._blendEquationParameters[0] === rgb &&
  124410. this._blendEquationParameters[1] === alpha) {
  124411. return;
  124412. }
  124413. this._blendEquationParameters[0] = rgb;
  124414. this._blendEquationParameters[1] = alpha;
  124415. this._isBlendEquationParametersDirty = true;
  124416. };
  124417. _AlphaState.prototype.reset = function () {
  124418. this._alphaBlend = false;
  124419. this._blendFunctionParameters[0] = null;
  124420. this._blendFunctionParameters[1] = null;
  124421. this._blendFunctionParameters[2] = null;
  124422. this._blendFunctionParameters[3] = null;
  124423. this._blendEquationParameters[0] = null;
  124424. this._blendEquationParameters[1] = null;
  124425. this._blendConstants[0] = null;
  124426. this._blendConstants[1] = null;
  124427. this._blendConstants[2] = null;
  124428. this._blendConstants[3] = null;
  124429. this._isAlphaBlendDirty = true;
  124430. this._isBlendFunctionParametersDirty = false;
  124431. this._isBlendEquationParametersDirty = false;
  124432. this._isBlendConstantsDirty = false;
  124433. };
  124434. _AlphaState.prototype.apply = function (gl) {
  124435. if (!this.isDirty) {
  124436. return;
  124437. }
  124438. // Alpha blend
  124439. if (this._isAlphaBlendDirty) {
  124440. if (this._alphaBlend) {
  124441. gl.enable(gl.BLEND);
  124442. }
  124443. else {
  124444. gl.disable(gl.BLEND);
  124445. }
  124446. this._isAlphaBlendDirty = false;
  124447. }
  124448. // Alpha function
  124449. if (this._isBlendFunctionParametersDirty) {
  124450. gl.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]);
  124451. this._isBlendFunctionParametersDirty = false;
  124452. }
  124453. // Alpha equation
  124454. if (this._isBlendEquationParametersDirty) {
  124455. gl.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]);
  124456. this._isBlendEquationParametersDirty = false;
  124457. }
  124458. // Constants
  124459. if (this._isBlendConstantsDirty) {
  124460. gl.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]);
  124461. this._isBlendConstantsDirty = false;
  124462. }
  124463. };
  124464. return _AlphaState;
  124465. }());
  124466. /***/ }),
  124467. /***/ "./States/depthCullingState.ts":
  124468. /*!*************************************!*\
  124469. !*** ./States/depthCullingState.ts ***!
  124470. \*************************************/
  124471. /*! exports provided: _DepthCullingState */
  124472. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124473. "use strict";
  124474. __webpack_require__.r(__webpack_exports__);
  124475. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _DepthCullingState; });
  124476. /**
  124477. * @hidden
  124478. **/
  124479. var _DepthCullingState = /** @class */ (function () {
  124480. /**
  124481. * Initializes the state.
  124482. */
  124483. function _DepthCullingState() {
  124484. this._isDepthTestDirty = false;
  124485. this._isDepthMaskDirty = false;
  124486. this._isDepthFuncDirty = false;
  124487. this._isCullFaceDirty = false;
  124488. this._isCullDirty = false;
  124489. this._isZOffsetDirty = false;
  124490. this._isFrontFaceDirty = false;
  124491. this.reset();
  124492. }
  124493. Object.defineProperty(_DepthCullingState.prototype, "isDirty", {
  124494. get: function () {
  124495. return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty;
  124496. },
  124497. enumerable: true,
  124498. configurable: true
  124499. });
  124500. Object.defineProperty(_DepthCullingState.prototype, "zOffset", {
  124501. get: function () {
  124502. return this._zOffset;
  124503. },
  124504. set: function (value) {
  124505. if (this._zOffset === value) {
  124506. return;
  124507. }
  124508. this._zOffset = value;
  124509. this._isZOffsetDirty = true;
  124510. },
  124511. enumerable: true,
  124512. configurable: true
  124513. });
  124514. Object.defineProperty(_DepthCullingState.prototype, "cullFace", {
  124515. get: function () {
  124516. return this._cullFace;
  124517. },
  124518. set: function (value) {
  124519. if (this._cullFace === value) {
  124520. return;
  124521. }
  124522. this._cullFace = value;
  124523. this._isCullFaceDirty = true;
  124524. },
  124525. enumerable: true,
  124526. configurable: true
  124527. });
  124528. Object.defineProperty(_DepthCullingState.prototype, "cull", {
  124529. get: function () {
  124530. return this._cull;
  124531. },
  124532. set: function (value) {
  124533. if (this._cull === value) {
  124534. return;
  124535. }
  124536. this._cull = value;
  124537. this._isCullDirty = true;
  124538. },
  124539. enumerable: true,
  124540. configurable: true
  124541. });
  124542. Object.defineProperty(_DepthCullingState.prototype, "depthFunc", {
  124543. get: function () {
  124544. return this._depthFunc;
  124545. },
  124546. set: function (value) {
  124547. if (this._depthFunc === value) {
  124548. return;
  124549. }
  124550. this._depthFunc = value;
  124551. this._isDepthFuncDirty = true;
  124552. },
  124553. enumerable: true,
  124554. configurable: true
  124555. });
  124556. Object.defineProperty(_DepthCullingState.prototype, "depthMask", {
  124557. get: function () {
  124558. return this._depthMask;
  124559. },
  124560. set: function (value) {
  124561. if (this._depthMask === value) {
  124562. return;
  124563. }
  124564. this._depthMask = value;
  124565. this._isDepthMaskDirty = true;
  124566. },
  124567. enumerable: true,
  124568. configurable: true
  124569. });
  124570. Object.defineProperty(_DepthCullingState.prototype, "depthTest", {
  124571. get: function () {
  124572. return this._depthTest;
  124573. },
  124574. set: function (value) {
  124575. if (this._depthTest === value) {
  124576. return;
  124577. }
  124578. this._depthTest = value;
  124579. this._isDepthTestDirty = true;
  124580. },
  124581. enumerable: true,
  124582. configurable: true
  124583. });
  124584. Object.defineProperty(_DepthCullingState.prototype, "frontFace", {
  124585. get: function () {
  124586. return this._frontFace;
  124587. },
  124588. set: function (value) {
  124589. if (this._frontFace === value) {
  124590. return;
  124591. }
  124592. this._frontFace = value;
  124593. this._isFrontFaceDirty = true;
  124594. },
  124595. enumerable: true,
  124596. configurable: true
  124597. });
  124598. _DepthCullingState.prototype.reset = function () {
  124599. this._depthMask = true;
  124600. this._depthTest = true;
  124601. this._depthFunc = null;
  124602. this._cullFace = null;
  124603. this._cull = null;
  124604. this._zOffset = 0;
  124605. this._frontFace = null;
  124606. this._isDepthTestDirty = true;
  124607. this._isDepthMaskDirty = true;
  124608. this._isDepthFuncDirty = false;
  124609. this._isCullFaceDirty = false;
  124610. this._isCullDirty = false;
  124611. this._isZOffsetDirty = false;
  124612. this._isFrontFaceDirty = false;
  124613. };
  124614. _DepthCullingState.prototype.apply = function (gl) {
  124615. if (!this.isDirty) {
  124616. return;
  124617. }
  124618. // Cull
  124619. if (this._isCullDirty) {
  124620. if (this.cull) {
  124621. gl.enable(gl.CULL_FACE);
  124622. }
  124623. else {
  124624. gl.disable(gl.CULL_FACE);
  124625. }
  124626. this._isCullDirty = false;
  124627. }
  124628. // Cull face
  124629. if (this._isCullFaceDirty) {
  124630. gl.cullFace(this.cullFace);
  124631. this._isCullFaceDirty = false;
  124632. }
  124633. // Depth mask
  124634. if (this._isDepthMaskDirty) {
  124635. gl.depthMask(this.depthMask);
  124636. this._isDepthMaskDirty = false;
  124637. }
  124638. // Depth test
  124639. if (this._isDepthTestDirty) {
  124640. if (this.depthTest) {
  124641. gl.enable(gl.DEPTH_TEST);
  124642. }
  124643. else {
  124644. gl.disable(gl.DEPTH_TEST);
  124645. }
  124646. this._isDepthTestDirty = false;
  124647. }
  124648. // Depth func
  124649. if (this._isDepthFuncDirty) {
  124650. gl.depthFunc(this.depthFunc);
  124651. this._isDepthFuncDirty = false;
  124652. }
  124653. // zOffset
  124654. if (this._isZOffsetDirty) {
  124655. if (this.zOffset) {
  124656. gl.enable(gl.POLYGON_OFFSET_FILL);
  124657. gl.polygonOffset(this.zOffset, 0);
  124658. }
  124659. else {
  124660. gl.disable(gl.POLYGON_OFFSET_FILL);
  124661. }
  124662. this._isZOffsetDirty = false;
  124663. }
  124664. // Front face
  124665. if (this._isFrontFaceDirty) {
  124666. gl.frontFace(this.frontFace);
  124667. this._isFrontFaceDirty = false;
  124668. }
  124669. };
  124670. return _DepthCullingState;
  124671. }());
  124672. /***/ }),
  124673. /***/ "./States/index.ts":
  124674. /*!*************************!*\
  124675. !*** ./States/index.ts ***!
  124676. \*************************/
  124677. /*! exports provided: _AlphaState, _DepthCullingState, _StencilState */
  124678. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124679. "use strict";
  124680. __webpack_require__.r(__webpack_exports__);
  124681. /* harmony import */ var _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./alphaCullingState */ "./States/alphaCullingState.ts");
  124682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  124683. /* harmony import */ var _depthCullingState__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthCullingState */ "./States/depthCullingState.ts");
  124684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _depthCullingState__WEBPACK_IMPORTED_MODULE_1__["_DepthCullingState"]; });
  124685. /* harmony import */ var _stencilState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stencilState */ "./States/stencilState.ts");
  124686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _stencilState__WEBPACK_IMPORTED_MODULE_2__["_StencilState"]; });
  124687. /***/ }),
  124688. /***/ "./States/stencilState.ts":
  124689. /*!********************************!*\
  124690. !*** ./States/stencilState.ts ***!
  124691. \********************************/
  124692. /*! exports provided: _StencilState */
  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__, "_StencilState", function() { return _StencilState; });
  124697. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124698. /**
  124699. * @hidden
  124700. **/
  124701. var _StencilState = /** @class */ (function () {
  124702. function _StencilState() {
  124703. this._isStencilTestDirty = false;
  124704. this._isStencilMaskDirty = false;
  124705. this._isStencilFuncDirty = false;
  124706. this._isStencilOpDirty = false;
  124707. this.reset();
  124708. }
  124709. Object.defineProperty(_StencilState.prototype, "isDirty", {
  124710. get: function () {
  124711. return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty;
  124712. },
  124713. enumerable: true,
  124714. configurable: true
  124715. });
  124716. Object.defineProperty(_StencilState.prototype, "stencilFunc", {
  124717. get: function () {
  124718. return this._stencilFunc;
  124719. },
  124720. set: function (value) {
  124721. if (this._stencilFunc === value) {
  124722. return;
  124723. }
  124724. this._stencilFunc = value;
  124725. this._isStencilFuncDirty = true;
  124726. },
  124727. enumerable: true,
  124728. configurable: true
  124729. });
  124730. Object.defineProperty(_StencilState.prototype, "stencilFuncRef", {
  124731. get: function () {
  124732. return this._stencilFuncRef;
  124733. },
  124734. set: function (value) {
  124735. if (this._stencilFuncRef === value) {
  124736. return;
  124737. }
  124738. this._stencilFuncRef = value;
  124739. this._isStencilFuncDirty = true;
  124740. },
  124741. enumerable: true,
  124742. configurable: true
  124743. });
  124744. Object.defineProperty(_StencilState.prototype, "stencilFuncMask", {
  124745. get: function () {
  124746. return this._stencilFuncMask;
  124747. },
  124748. set: function (value) {
  124749. if (this._stencilFuncMask === value) {
  124750. return;
  124751. }
  124752. this._stencilFuncMask = value;
  124753. this._isStencilFuncDirty = true;
  124754. },
  124755. enumerable: true,
  124756. configurable: true
  124757. });
  124758. Object.defineProperty(_StencilState.prototype, "stencilOpStencilFail", {
  124759. get: function () {
  124760. return this._stencilOpStencilFail;
  124761. },
  124762. set: function (value) {
  124763. if (this._stencilOpStencilFail === value) {
  124764. return;
  124765. }
  124766. this._stencilOpStencilFail = value;
  124767. this._isStencilOpDirty = true;
  124768. },
  124769. enumerable: true,
  124770. configurable: true
  124771. });
  124772. Object.defineProperty(_StencilState.prototype, "stencilOpDepthFail", {
  124773. get: function () {
  124774. return this._stencilOpDepthFail;
  124775. },
  124776. set: function (value) {
  124777. if (this._stencilOpDepthFail === value) {
  124778. return;
  124779. }
  124780. this._stencilOpDepthFail = value;
  124781. this._isStencilOpDirty = true;
  124782. },
  124783. enumerable: true,
  124784. configurable: true
  124785. });
  124786. Object.defineProperty(_StencilState.prototype, "stencilOpStencilDepthPass", {
  124787. get: function () {
  124788. return this._stencilOpStencilDepthPass;
  124789. },
  124790. set: function (value) {
  124791. if (this._stencilOpStencilDepthPass === value) {
  124792. return;
  124793. }
  124794. this._stencilOpStencilDepthPass = value;
  124795. this._isStencilOpDirty = true;
  124796. },
  124797. enumerable: true,
  124798. configurable: true
  124799. });
  124800. Object.defineProperty(_StencilState.prototype, "stencilMask", {
  124801. get: function () {
  124802. return this._stencilMask;
  124803. },
  124804. set: function (value) {
  124805. if (this._stencilMask === value) {
  124806. return;
  124807. }
  124808. this._stencilMask = value;
  124809. this._isStencilMaskDirty = true;
  124810. },
  124811. enumerable: true,
  124812. configurable: true
  124813. });
  124814. Object.defineProperty(_StencilState.prototype, "stencilTest", {
  124815. get: function () {
  124816. return this._stencilTest;
  124817. },
  124818. set: function (value) {
  124819. if (this._stencilTest === value) {
  124820. return;
  124821. }
  124822. this._stencilTest = value;
  124823. this._isStencilTestDirty = true;
  124824. },
  124825. enumerable: true,
  124826. configurable: true
  124827. });
  124828. _StencilState.prototype.reset = function () {
  124829. this._stencilTest = false;
  124830. this._stencilMask = 0xFF;
  124831. this._stencilFunc = _StencilState.ALWAYS;
  124832. this._stencilFuncRef = 1;
  124833. this._stencilFuncMask = 0xFF;
  124834. this._stencilOpStencilFail = _StencilState.KEEP;
  124835. this._stencilOpDepthFail = _StencilState.KEEP;
  124836. this._stencilOpStencilDepthPass = _StencilState.REPLACE;
  124837. this._isStencilTestDirty = true;
  124838. this._isStencilMaskDirty = true;
  124839. this._isStencilFuncDirty = true;
  124840. this._isStencilOpDirty = true;
  124841. };
  124842. _StencilState.prototype.apply = function (gl) {
  124843. if (!this.isDirty) {
  124844. return;
  124845. }
  124846. // Stencil test
  124847. if (this._isStencilTestDirty) {
  124848. if (this.stencilTest) {
  124849. gl.enable(gl.STENCIL_TEST);
  124850. }
  124851. else {
  124852. gl.disable(gl.STENCIL_TEST);
  124853. }
  124854. this._isStencilTestDirty = false;
  124855. }
  124856. // Stencil mask
  124857. if (this._isStencilMaskDirty) {
  124858. gl.stencilMask(this.stencilMask);
  124859. this._isStencilMaskDirty = false;
  124860. }
  124861. // Stencil func
  124862. if (this._isStencilFuncDirty) {
  124863. gl.stencilFunc(this.stencilFunc, this.stencilFuncRef, this.stencilFuncMask);
  124864. this._isStencilFuncDirty = false;
  124865. }
  124866. // Stencil op
  124867. if (this._isStencilOpDirty) {
  124868. gl.stencilOp(this.stencilOpStencilFail, this.stencilOpDepthFail, this.stencilOpStencilDepthPass);
  124869. this._isStencilOpDirty = false;
  124870. }
  124871. };
  124872. /** 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 */
  124873. _StencilState.ALWAYS = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ALWAYS;
  124874. /** Passed to stencilOperation to specify that stencil value must be kept */
  124875. _StencilState.KEEP = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].KEEP;
  124876. /** Passed to stencilOperation to specify that stencil value must be replaced */
  124877. _StencilState.REPLACE = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].REPLACE;
  124878. return _StencilState;
  124879. }());
  124880. /***/ }),
  124881. /***/ "./abstractScene.ts":
  124882. /*!**************************!*\
  124883. !*** ./abstractScene.ts ***!
  124884. \**************************/
  124885. /*! exports provided: AbstractScene */
  124886. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124887. "use strict";
  124888. __webpack_require__.r(__webpack_exports__);
  124889. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return AbstractScene; });
  124890. /**
  124891. * Base class of the scene acting as a container for the different elements composing a scene.
  124892. * This class is dynamically extended by the different components of the scene increasing
  124893. * flexibility and reducing coupling
  124894. */
  124895. var AbstractScene = /** @class */ (function () {
  124896. function AbstractScene() {
  124897. /**
  124898. * Gets the list of root nodes (ie. nodes with no parent)
  124899. */
  124900. this.rootNodes = new Array();
  124901. /** All of the cameras added to this scene
  124902. * @see http://doc.babylonjs.com/babylon101/cameras
  124903. */
  124904. this.cameras = new Array();
  124905. /**
  124906. * All of the lights added to this scene
  124907. * @see http://doc.babylonjs.com/babylon101/lights
  124908. */
  124909. this.lights = new Array();
  124910. /**
  124911. * All of the (abstract) meshes added to this scene
  124912. */
  124913. this.meshes = new Array();
  124914. /**
  124915. * The list of skeletons added to the scene
  124916. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  124917. */
  124918. this.skeletons = new Array();
  124919. /**
  124920. * All of the particle systems added to this scene
  124921. * @see http://doc.babylonjs.com/babylon101/particles
  124922. */
  124923. this.particleSystems = new Array();
  124924. /**
  124925. * Gets a list of Animations associated with the scene
  124926. */
  124927. this.animations = [];
  124928. /**
  124929. * All of the animation groups added to this scene
  124930. * @see http://doc.babylonjs.com/how_to/group
  124931. */
  124932. this.animationGroups = new Array();
  124933. /**
  124934. * All of the multi-materials added to this scene
  124935. * @see http://doc.babylonjs.com/how_to/multi_materials
  124936. */
  124937. this.multiMaterials = new Array();
  124938. /**
  124939. * All of the materials added to this scene
  124940. * In the context of a Scene, it is not supposed to be modified manually.
  124941. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  124942. * Note also that the order of the Material wihin the array is not significant and might change.
  124943. * @see http://doc.babylonjs.com/babylon101/materials
  124944. */
  124945. this.materials = new Array();
  124946. /**
  124947. * The list of morph target managers added to the scene
  124948. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  124949. */
  124950. this.morphTargetManagers = new Array();
  124951. /**
  124952. * The list of geometries used in the scene.
  124953. */
  124954. this.geometries = new Array();
  124955. /**
  124956. * All of the tranform nodes added to this scene
  124957. * In the context of a Scene, it is not supposed to be modified manually.
  124958. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  124959. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  124960. * @see http://doc.babylonjs.com/how_to/transformnode
  124961. */
  124962. this.transformNodes = new Array();
  124963. /**
  124964. * ActionManagers available on the scene.
  124965. */
  124966. this.actionManagers = new Array();
  124967. /**
  124968. * Textures to keep.
  124969. */
  124970. this.textures = new Array();
  124971. }
  124972. /**
  124973. * Adds a parser in the list of available ones
  124974. * @param name Defines the name of the parser
  124975. * @param parser Defines the parser to add
  124976. */
  124977. AbstractScene.AddParser = function (name, parser) {
  124978. this._BabylonFileParsers[name] = parser;
  124979. };
  124980. /**
  124981. * Gets a general parser from the list of avaialble ones
  124982. * @param name Defines the name of the parser
  124983. * @returns the requested parser or null
  124984. */
  124985. AbstractScene.GetParser = function (name) {
  124986. if (this._BabylonFileParsers[name]) {
  124987. return this._BabylonFileParsers[name];
  124988. }
  124989. return null;
  124990. };
  124991. /**
  124992. * Adds n individual parser in the list of available ones
  124993. * @param name Defines the name of the parser
  124994. * @param parser Defines the parser to add
  124995. */
  124996. AbstractScene.AddIndividualParser = function (name, parser) {
  124997. this._IndividualBabylonFileParsers[name] = parser;
  124998. };
  124999. /**
  125000. * Gets an individual parser from the list of avaialble ones
  125001. * @param name Defines the name of the parser
  125002. * @returns the requested parser or null
  125003. */
  125004. AbstractScene.GetIndividualParser = function (name) {
  125005. if (this._IndividualBabylonFileParsers[name]) {
  125006. return this._IndividualBabylonFileParsers[name];
  125007. }
  125008. return null;
  125009. };
  125010. /**
  125011. * Parser json data and populate both a scene and its associated container object
  125012. * @param jsonData Defines the data to parse
  125013. * @param scene Defines the scene to parse the data for
  125014. * @param container Defines the container attached to the parsing sequence
  125015. * @param rootUrl Defines the root url of the data
  125016. */
  125017. AbstractScene.Parse = function (jsonData, scene, container, rootUrl) {
  125018. for (var parserName in this._BabylonFileParsers) {
  125019. if (this._BabylonFileParsers.hasOwnProperty(parserName)) {
  125020. this._BabylonFileParsers[parserName](jsonData, scene, container, rootUrl);
  125021. }
  125022. }
  125023. };
  125024. /**
  125025. * Stores the list of available parsers in the application.
  125026. */
  125027. AbstractScene._BabylonFileParsers = {};
  125028. /**
  125029. * Stores the list of available individual parsers in the application.
  125030. */
  125031. AbstractScene._IndividualBabylonFileParsers = {};
  125032. return AbstractScene;
  125033. }());
  125034. /***/ }),
  125035. /***/ "./assetContainer.ts":
  125036. /*!***************************!*\
  125037. !*** ./assetContainer.ts ***!
  125038. \***************************/
  125039. /*! exports provided: KeepAssets, AssetContainer */
  125040. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125041. "use strict";
  125042. __webpack_require__.r(__webpack_exports__);
  125043. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return KeepAssets; });
  125044. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return AssetContainer; });
  125045. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125046. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  125047. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Meshes/mesh */ "./Meshes/mesh.ts");
  125048. /**
  125049. * Set of assets to keep when moving a scene into an asset container.
  125050. */
  125051. var KeepAssets = /** @class */ (function (_super) {
  125052. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeepAssets, _super);
  125053. function KeepAssets() {
  125054. return _super !== null && _super.apply(this, arguments) || this;
  125055. }
  125056. return KeepAssets;
  125057. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  125058. /**
  125059. * Container with a set of assets that can be added or removed from a scene.
  125060. */
  125061. var AssetContainer = /** @class */ (function (_super) {
  125062. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AssetContainer, _super);
  125063. /**
  125064. * Instantiates an AssetContainer.
  125065. * @param scene The scene the AssetContainer belongs to.
  125066. */
  125067. function AssetContainer(scene) {
  125068. var _this = _super.call(this) || this;
  125069. _this.scene = scene;
  125070. _this["sounds"] = [];
  125071. _this["effectLayers"] = [];
  125072. _this["layers"] = [];
  125073. _this["lensFlareSystems"] = [];
  125074. _this["proceduralTextures"] = [];
  125075. _this["reflectionProbes"] = [];
  125076. return _this;
  125077. }
  125078. /**
  125079. * Adds all the assets from the container to the scene.
  125080. */
  125081. AssetContainer.prototype.addAllToScene = function () {
  125082. var _this = this;
  125083. this.cameras.forEach(function (o) {
  125084. _this.scene.addCamera(o);
  125085. });
  125086. this.lights.forEach(function (o) {
  125087. _this.scene.addLight(o);
  125088. });
  125089. this.meshes.forEach(function (o) {
  125090. _this.scene.addMesh(o);
  125091. });
  125092. this.skeletons.forEach(function (o) {
  125093. _this.scene.addSkeleton(o);
  125094. });
  125095. this.animations.forEach(function (o) {
  125096. _this.scene.addAnimation(o);
  125097. });
  125098. this.animationGroups.forEach(function (o) {
  125099. _this.scene.addAnimationGroup(o);
  125100. });
  125101. this.multiMaterials.forEach(function (o) {
  125102. _this.scene.addMultiMaterial(o);
  125103. });
  125104. this.materials.forEach(function (o) {
  125105. _this.scene.addMaterial(o);
  125106. });
  125107. this.morphTargetManagers.forEach(function (o) {
  125108. _this.scene.addMorphTargetManager(o);
  125109. });
  125110. this.geometries.forEach(function (o) {
  125111. _this.scene.addGeometry(o);
  125112. });
  125113. this.transformNodes.forEach(function (o) {
  125114. _this.scene.addTransformNode(o);
  125115. });
  125116. this.actionManagers.forEach(function (o) {
  125117. _this.scene.addActionManager(o);
  125118. });
  125119. this.textures.forEach(function (o) {
  125120. _this.scene.addTexture(o);
  125121. });
  125122. this.reflectionProbes.forEach(function (o) {
  125123. _this.scene.addReflectionProbe(o);
  125124. });
  125125. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  125126. var component = _a[_i];
  125127. component.addFromContainer(this);
  125128. }
  125129. };
  125130. /**
  125131. * Removes all the assets in the container from the scene
  125132. */
  125133. AssetContainer.prototype.removeAllFromScene = function () {
  125134. var _this = this;
  125135. this.cameras.forEach(function (o) {
  125136. _this.scene.removeCamera(o);
  125137. });
  125138. this.lights.forEach(function (o) {
  125139. _this.scene.removeLight(o);
  125140. });
  125141. this.meshes.forEach(function (o) {
  125142. _this.scene.removeMesh(o);
  125143. });
  125144. this.skeletons.forEach(function (o) {
  125145. _this.scene.removeSkeleton(o);
  125146. });
  125147. this.animations.forEach(function (o) {
  125148. _this.scene.removeAnimation(o);
  125149. });
  125150. this.animationGroups.forEach(function (o) {
  125151. _this.scene.removeAnimationGroup(o);
  125152. });
  125153. this.multiMaterials.forEach(function (o) {
  125154. _this.scene.removeMultiMaterial(o);
  125155. });
  125156. this.materials.forEach(function (o) {
  125157. _this.scene.removeMaterial(o);
  125158. });
  125159. this.morphTargetManagers.forEach(function (o) {
  125160. _this.scene.removeMorphTargetManager(o);
  125161. });
  125162. this.geometries.forEach(function (o) {
  125163. _this.scene.removeGeometry(o);
  125164. });
  125165. this.transformNodes.forEach(function (o) {
  125166. _this.scene.removeTransformNode(o);
  125167. });
  125168. this.actionManagers.forEach(function (o) {
  125169. _this.scene.removeActionManager(o);
  125170. });
  125171. this.textures.forEach(function (o) {
  125172. _this.scene.removeTexture(o);
  125173. });
  125174. this.reflectionProbes.forEach(function (o) {
  125175. _this.scene.removeReflectionProbe(o);
  125176. });
  125177. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  125178. var component = _a[_i];
  125179. component.removeFromContainer(this);
  125180. }
  125181. };
  125182. /**
  125183. * Disposes all the assets in the container
  125184. */
  125185. AssetContainer.prototype.dispose = function () {
  125186. this.cameras.forEach(function (o) {
  125187. o.dispose();
  125188. });
  125189. this.lights.forEach(function (o) {
  125190. o.dispose();
  125191. });
  125192. this.meshes.forEach(function (o) {
  125193. o.dispose();
  125194. });
  125195. this.skeletons.forEach(function (o) {
  125196. o.dispose();
  125197. });
  125198. this.animationGroups.forEach(function (o) {
  125199. o.dispose();
  125200. });
  125201. this.multiMaterials.forEach(function (o) {
  125202. o.dispose();
  125203. });
  125204. this.materials.forEach(function (o) {
  125205. o.dispose();
  125206. });
  125207. this.geometries.forEach(function (o) {
  125208. o.dispose();
  125209. });
  125210. this.transformNodes.forEach(function (o) {
  125211. o.dispose();
  125212. });
  125213. this.actionManagers.forEach(function (o) {
  125214. o.dispose();
  125215. });
  125216. this.textures.forEach(function (o) {
  125217. o.dispose();
  125218. });
  125219. this.reflectionProbes.forEach(function (o) {
  125220. o.dispose();
  125221. });
  125222. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  125223. var component = _a[_i];
  125224. component.dispose();
  125225. }
  125226. };
  125227. AssetContainer.prototype._moveAssets = function (sourceAssets, targetAssets, keepAssets) {
  125228. if (!sourceAssets) {
  125229. return;
  125230. }
  125231. for (var _i = 0, sourceAssets_1 = sourceAssets; _i < sourceAssets_1.length; _i++) {
  125232. var asset = sourceAssets_1[_i];
  125233. var move = true;
  125234. if (keepAssets) {
  125235. for (var _a = 0, keepAssets_1 = keepAssets; _a < keepAssets_1.length; _a++) {
  125236. var keepAsset = keepAssets_1[_a];
  125237. if (asset === keepAsset) {
  125238. move = false;
  125239. break;
  125240. }
  125241. }
  125242. }
  125243. if (move) {
  125244. targetAssets.push(asset);
  125245. }
  125246. }
  125247. };
  125248. /**
  125249. * Removes all the assets contained in the scene and adds them to the container.
  125250. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  125251. */
  125252. AssetContainer.prototype.moveAllFromScene = function (keepAssets) {
  125253. if (keepAssets === undefined) {
  125254. keepAssets = new KeepAssets();
  125255. }
  125256. for (var key in this) {
  125257. if (this.hasOwnProperty(key)) {
  125258. this[key] = this[key] || [];
  125259. this._moveAssets(this.scene[key], this[key], keepAssets[key]);
  125260. }
  125261. }
  125262. this.removeAllFromScene();
  125263. };
  125264. /**
  125265. * 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.
  125266. * @returns the root mesh
  125267. */
  125268. AssetContainer.prototype.createRootMesh = function () {
  125269. var rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("assetContainerRootMesh", this.scene);
  125270. this.meshes.forEach(function (m) {
  125271. if (!m.parent) {
  125272. rootMesh.addChild(m);
  125273. }
  125274. });
  125275. this.meshes.unshift(rootMesh);
  125276. return rootMesh;
  125277. };
  125278. return AssetContainer;
  125279. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  125280. /***/ }),
  125281. /***/ "./index.ts":
  125282. /*!******************!*\
  125283. !*** ./index.ts ***!
  125284. \******************/
  125285. /*! 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, AnimationRange, AnimationEvent, PathCursor, AnimationKeyInterpolation, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, 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, CollisionCoordinatorLegacy, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, _PrimitiveGeometry, RibbonGeometry, BoxGeometry, SphereGeometry, DiscGeometry, CylinderGeometry, TorusGeometry, GroundGeometry, TiledGroundGeometry, PlaneGeometry, TorusKnotGeometry, GroundMesh, InstancedMesh, LinesMesh, InstancedLinesMesh, MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh, VertexData, MeshBuilder, SimplificationSettings, SimplificationQueue, SimplificationType, SimplicationQueueSceneComponent, Polygon, PolygonMeshBuilder, BaseSubMesh, SubMesh, TransformNode, 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, 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 */
  125286. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125287. "use strict";
  125288. __webpack_require__.r(__webpack_exports__);
  125289. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  125290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _abstractScene__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  125291. /* harmony import */ var _Actions_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Actions/index */ "./Actions/index.ts");
  125292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Action"]; });
  125293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  125294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionManager"]; });
  125295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Condition"]; });
  125296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ValueCondition"]; });
  125297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PredicateCondition"]; });
  125298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StateCondition"]; });
  125299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SwitchBooleanAction"]; });
  125300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetStateAction"]; });
  125301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetValueAction"]; });
  125302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["IncrementValueAction"]; });
  125303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlayAnimationAction"]; });
  125304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopAnimationAction"]; });
  125305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["DoNothingAction"]; });
  125306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["CombineAction"]; });
  125307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ExecuteCodeAction"]; });
  125308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetParentAction"]; });
  125309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlaySoundAction"]; });
  125310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopSoundAction"]; });
  125311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["InterpolateValueAction"]; });
  125312. /* harmony import */ var _Animations_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Animations/index */ "./Animations/index.ts");
  125313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animatable"]; });
  125314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationRange"]; });
  125315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationEvent"]; });
  125316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PathCursor", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["PathCursor"]; });
  125317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationKeyInterpolation"]; });
  125318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animation"]; });
  125319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  125320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  125321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationPropertiesOverride"]; });
  125322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["EasingFunction"]; });
  125323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CircleEase"]; });
  125324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BackEase"]; });
  125325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BounceEase"]; });
  125326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CubicEase"]; });
  125327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ElasticEase"]; });
  125328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ExponentialEase"]; });
  125329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["PowerEase"]; });
  125330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuadraticEase"]; });
  125331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuarticEase"]; });
  125332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuinticEase"]; });
  125333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["SineEase"]; });
  125334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BezierCurveEase"]; });
  125335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["RuntimeAnimation"]; });
  125336. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./assetContainer */ "./assetContainer.ts");
  125337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["KeepAssets"]; });
  125338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["AssetContainer"]; });
  125339. /* harmony import */ var _Audio_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Audio/index */ "./Audio/index.ts");
  125340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Analyser"]; });
  125341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioEngine"]; });
  125342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioSceneComponent"]; });
  125343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Sound"]; });
  125344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  125345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["WeightedSound"]; });
  125346. /* harmony import */ var _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Behaviors/index */ "./Behaviors/index.ts");
  125347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AutoRotationBehavior"]; });
  125348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["BouncingBehavior"]; });
  125349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FramingBehavior"]; });
  125350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AttachToBoxBehavior"]; });
  125351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FadeInOutBehavior"]; });
  125352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["MultiPointerScaleBehavior"]; });
  125353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]; });
  125354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]; });
  125355. /* harmony import */ var _Bones_index__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Bones/index */ "./Bones/index.ts");
  125356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Bone"]; });
  125357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneIKController"]; });
  125358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneLookController"]; });
  125359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Skeleton"]; });
  125360. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Cameras/index */ "./Cameras/index.ts");
  125361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputTypes"]; });
  125362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputsManager"]; });
  125363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["Camera"]; });
  125364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TargetCamera"]; });
  125365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCamera"]; });
  125366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraInputsManager"]; });
  125367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TouchCamera"]; });
  125368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  125369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraInputsManager"]; });
  125370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["DeviceOrientationCamera"]; });
  125371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCamera"]; });
  125372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraInputsManager"]; });
  125373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCamera"]; });
  125374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcFollowCamera"]; });
  125375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["GamepadCamera"]; });
  125376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["UniversalCamera"]; });
  125377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VirtualJoysticksCamera"]; });
  125378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraGamepadInput"]; });
  125379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraKeyboardMoveInput"]; });
  125380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraMouseWheelInput"]; });
  125381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraPointersInput"]; });
  125382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraVRDeviceOrientationInput"]; });
  125383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraKeyboardInput"]; });
  125384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraMouseInput"]; });
  125385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  125386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraGamepadInput"]; });
  125387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraKeyboardMoveInput"]; });
  125388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraMouseInput"]; });
  125389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraTouchInput"]; });
  125390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraVirtualJoystickInput"]; });
  125391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphArcRotateCamera"]; });
  125392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphFreeCamera"]; });
  125393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphGamepadCamera"]; });
  125394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphUniversalCamera"]; });
  125395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicArcRotateCamera"]; });
  125396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicFreeCamera"]; });
  125397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicGamepadCamera"]; });
  125398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  125399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRCameraMetrics"]; });
  125400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationArcRotateCamera"]; });
  125401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationFreeCamera"]; });
  125402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationGamepadCamera"]; });
  125403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRExperienceHelper"]; });
  125404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]; });
  125405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRCamera"]; });
  125406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIButton"]; });
  125407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIOptions"]; });
  125408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUI"]; });
  125409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRState"]; });
  125410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRExperienceHelper"]; });
  125411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRController"]; });
  125412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRInput"]; });
  125413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRManagedOutputCanvas"]; });
  125414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRSessionManager"]; });
  125415. /* harmony import */ var _Collisions_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Collisions/index */ "./Collisions/index.ts");
  125416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["Collider"]; });
  125417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CollisionCoordinatorLegacy", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["CollisionCoordinatorLegacy"]; });
  125418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]; });
  125419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["IntersectionInfo"]; });
  125420. /* harmony import */ var _Culling_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Culling/index */ "./Culling/index.ts");
  125421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingBox"]; });
  125422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"]; });
  125423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingSphere"]; });
  125424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Ray"]; });
  125425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Octree"]; });
  125426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeBlock"]; });
  125427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeSceneComponent"]; });
  125428. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Debug/index */ "./Debug/index.ts");
  125429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["AxesViewer"]; });
  125430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["BoneAxesViewer"]; });
  125431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["DebugLayer"]; });
  125432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["PhysicsViewer"]; });
  125433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["RayHelper"]; });
  125434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["SkeletonViewer"]; });
  125435. /* harmony import */ var _Engines_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Engines/index */ "./Engines/index.ts");
  125436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Constants"]; });
  125437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["InstancingAttributeInfo"]; });
  125438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["DepthTextureCreationOptions"]; });
  125439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineCapabilities"]; });
  125440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Engine"]; });
  125441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineStore"]; });
  125442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngineOptions"]; });
  125443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngine"]; });
  125444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_OcclusionDataStorage"]; });
  125445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_forceTransformFeedbackToBundle"]; });
  125446. /* harmony import */ var _Events_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Events/index */ "./Events/index.ts");
  125447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardEventTypes"]; });
  125448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfo"]; });
  125449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfoPre"]; });
  125450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerEventTypes"]; });
  125451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoBase"]; });
  125452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoPre"]; });
  125453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfo"]; });
  125454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardEventTypes"]; });
  125455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardInfo"]; });
  125456. /* harmony import */ var _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Gamepads/index */ "./Gamepads/index.ts");
  125457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["DaydreamController"]; });
  125458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GearVRController"]; });
  125459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericController"]; });
  125460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["OculusTouchController"]; });
  125461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerType"]; });
  125462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerHelper"]; });
  125463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledController"]; });
  125464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["ViveController"]; });
  125465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WebVRController"]; });
  125466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WindowsMotionController"]; });
  125467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["StickValues"]; });
  125468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Gamepad"]; });
  125469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericPad"]; });
  125470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadManager"]; });
  125471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadSystemSceneComponent"]; });
  125472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"]; });
  125473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Dpad"]; });
  125474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Pad"]; });
  125475. /* harmony import */ var _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Gizmos/index */ "./Gizmos/index.ts");
  125476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisDragGizmo"]; });
  125477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisScaleGizmo"]; });
  125478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["BoundingBoxGizmo"]; });
  125479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["Gizmo"]; });
  125480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["GizmoManager"]; });
  125481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PlaneRotationGizmo"]; });
  125482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PositionGizmo"]; });
  125483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["RotationGizmo"]; });
  125484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["ScaleGizmo"]; });
  125485. /* harmony import */ var _Helpers_index__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Helpers/index */ "./Helpers/index.ts");
  125486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["EnvironmentHelper"]; });
  125487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["PhotoDome"]; });
  125488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["_forceSceneHelpersToBundle"]; });
  125489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["VideoDome"]; });
  125490. /* harmony import */ var _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Instrumentation/index */ "./Instrumentation/index.ts");
  125491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["EngineInstrumentation"]; });
  125492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["SceneInstrumentation"]; });
  125493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["_TimeToken"]; });
  125494. /* harmony import */ var _Layers_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Layers/index */ "./Layers/index.ts");
  125495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayer"]; });
  125496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayerSceneComponent"]; });
  125497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["GlowLayer"]; });
  125498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["HighlightLayer"]; });
  125499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["Layer"]; });
  125500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["LayerSceneComponent"]; });
  125501. /* harmony import */ var _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./LensFlares/index */ "./LensFlares/index.ts");
  125502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlare"]; });
  125503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystem"]; });
  125504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystemSceneComponent"]; });
  125505. /* harmony import */ var _Lights_index__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Lights/index */ "./Lights/index.ts");
  125506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["Light"]; });
  125507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowLight"]; });
  125508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["DirectionalLight"]; });
  125509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["HemisphericLight"]; });
  125510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["PointLight"]; });
  125511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["SpotLight"]; });
  125512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGenerator"]; });
  125513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGeneratorSceneComponent"]; });
  125514. /* harmony import */ var _Loading_index__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Loading/index */ "./Loading/index.ts");
  125515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["DefaultLoadingScreen"]; });
  125516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderProgressEvent"]; });
  125517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoader"]; });
  125518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderFlags"]; });
  125519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["_BabylonLoaderRegistered"]; });
  125520. /* harmony import */ var _Materials_index__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Materials/index */ "./Materials/index.ts");
  125521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorCurves"]; });
  125522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectFallbacks"]; });
  125523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectCreationOptions"]; });
  125524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Effect"]; });
  125525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["FresnelParameters"]; });
  125526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfigurationDefines"]; });
  125527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfiguration"]; });
  125528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Material"]; });
  125529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialDefines"]; });
  125530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialHelper"]; });
  125531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiMaterial"]; });
  125532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PushMaterial"]; });
  125533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ShaderMaterial"]; });
  125534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterialDefines"]; });
  125535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterial"]; });
  125536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BaseTexture"]; });
  125537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CubeTexture"]; });
  125538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["HDRCubeTexture"]; });
  125539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["InternalTexture"]; });
  125540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DummyInternalTextureTracker"]; });
  125541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MirrorTexture"]; });
  125542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiRenderTarget"]; });
  125543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture"]; });
  125544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RenderTargetTexture"]; });
  125545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Texture"]; });
  125546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["UniformBuffer"]; });
  125547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialFlags"]; });
  125548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BackgroundMaterial"]; });
  125549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseMaterial"]; });
  125550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseSimpleMaterial"]; });
  125551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterial"]; });
  125552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMetallicRoughnessMaterial"]; });
  125553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRSpecularGlossinessMaterial"]; });
  125554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorGradingTexture"]; });
  125555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DynamicTexture"]; });
  125556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTexture"]; });
  125557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawCubeTexture"]; });
  125558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture3D"]; });
  125559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RefractionTexture"]; });
  125560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["VideoTexture"]; });
  125561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_DDSTextureLoader"]; });
  125562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_ENVTextureLoader"]; });
  125563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_KTXTextureLoader"]; });
  125564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_TGATextureLoader"]; });
  125565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CustomProceduralTexture"]; });
  125566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NoiseProceduralTexture"]; });
  125567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTextureSceneComponent"]; });
  125568. /* harmony import */ var _Maths_index__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Maths/index */ "./Maths/index.ts");
  125569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Scalar"]; });
  125570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToGammaSpace"]; });
  125571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToLinearSpace"]; });
  125572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Epsilon"]; });
  125573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color3"]; });
  125574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color4"]; });
  125575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector2"]; });
  125576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector3"]; });
  125577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector4"]; });
  125578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Size"]; });
  125579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Quaternion"]; });
  125580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Matrix"]; });
  125581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Plane"]; });
  125582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Viewport"]; });
  125583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Frustum"]; });
  125584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Space"]; });
  125585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Axis"]; });
  125586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["BezierCurve"]; });
  125587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Orientation"]; });
  125588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Angle"]; });
  125589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Arc2"]; });
  125590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path2"]; });
  125591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path3D"]; });
  125592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Curve3"]; });
  125593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalVertex"]; });
  125594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalTextureVertex"]; });
  125595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Tmp"]; });
  125596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalPolynomial"]; });
  125597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalHarmonics"]; });
  125598. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Meshes/index */ "./Meshes/index.ts");
  125599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["AbstractMesh"]; });
  125600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Buffer"]; });
  125601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexBuffer"]; });
  125602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CSG"]; });
  125603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Geometry"]; });
  125604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_PrimitiveGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_PrimitiveGeometry"]; });
  125605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["RibbonGeometry"]; });
  125606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BoxGeometry"]; });
  125607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SphereGeometry"]; });
  125608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DiscGeometry"]; });
  125609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CylinderGeometry"]; });
  125610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusGeometry"]; });
  125611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundGeometry"]; });
  125612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TiledGroundGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TiledGroundGeometry"]; });
  125613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PlaneGeometry"]; });
  125614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotGeometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusKnotGeometry"]; });
  125615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundMesh"]; });
  125616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedMesh"]; });
  125617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesMesh"]; });
  125618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedLinesMesh"]; });
  125619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshLODLevel"]; });
  125620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_CreationDataStorage"]; });
  125621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_InstancesBatch"]; });
  125622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Mesh"]; });
  125623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexData"]; });
  125624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshBuilder"]; });
  125625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationSettings"]; });
  125626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationQueue"]; });
  125627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationType"]; });
  125628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplicationQueueSceneComponent"]; });
  125629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Polygon"]; });
  125630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonMeshBuilder"]; });
  125631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BaseSubMesh"]; });
  125632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SubMesh"]; });
  125633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TransformNode"]; });
  125634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DracoCompression"]; });
  125635. /* harmony import */ var _Morph_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Morph/index */ "./Morph/index.ts");
  125636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTarget"]; });
  125637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTargetManager"]; });
  125638. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./node */ "./node.ts");
  125639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _node__WEBPACK_IMPORTED_MODULE_25__["Node"]; });
  125640. /* harmony import */ var _Offline_index__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Offline/index */ "./Offline/index.ts");
  125641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _Offline_index__WEBPACK_IMPORTED_MODULE_26__["Database"]; });
  125642. /* harmony import */ var _Particles_index__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Particles/index */ "./Particles/index.ts");
  125643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BaseParticleSystem"]; });
  125644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["GPUParticleSystem"]; });
  125645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["Particle"]; });
  125646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleHelper"]; });
  125647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystem"]; });
  125648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["_IDoNeedToBeInTheBuild"]; });
  125649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystemSet"]; });
  125650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticle"]; });
  125651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ModelShape"]; });
  125652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["DepthSortedParticle"]; });
  125653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticleSystem"]; });
  125654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitterType"]; });
  125655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitter"]; });
  125656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BoxParticleEmitter"]; });
  125657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ConeParticleEmitter"]; });
  125658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderParticleEmitter"]; });
  125659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderDirectedParticleEmitter"]; });
  125660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["HemisphericParticleEmitter"]; });
  125661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["PointParticleEmitter"]; });
  125662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereParticleEmitter"]; });
  125663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereDirectedParticleEmitter"]; });
  125664. /* harmony import */ var _Physics_index__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Physics/index */ "./Physics/index.ts");
  125665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngine"]; });
  125666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngineSceneComponent"]; });
  125667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsHelper"]; });
  125668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialExplosionEvent"]; });
  125669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsGravitationalFieldEvent"]; });
  125670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftEvent"]; });
  125671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsVortexEvent"]; });
  125672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialImpulseFalloff"]; });
  125673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftMode"]; });
  125674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsImpostor"]; });
  125675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsJoint"]; });
  125676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["DistanceJoint"]; });
  125677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["MotorEnabledJoint"]; });
  125678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["HingeJoint"]; });
  125679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["Hinge2Joint"]; });
  125680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["CannonJSPlugin"]; });
  125681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["AmmoJSPlugin"]; });
  125682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["OimoJSPlugin"]; });
  125683. /* harmony import */ var _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./PostProcesses/index */ "./PostProcesses/index.ts");
  125684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["AnaglyphPostProcess"]; });
  125685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlackAndWhitePostProcess"]; });
  125686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomEffect"]; });
  125687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomMergePostProcess"]; });
  125688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlurPostProcess"]; });
  125689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ChromaticAberrationPostProcess"]; });
  125690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["CircleOfConfusionPostProcess"]; });
  125691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ColorCorrectionPostProcess"]; });
  125692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ConvolutionPostProcess"]; });
  125693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldBlurPostProcess"]; });
  125694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffectBlurLevel"]; });
  125695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffect"]; });
  125696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcessOptions"]; });
  125697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcess"]; });
  125698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DisplayPassPostProcess"]; });
  125699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ExtractHighlightsPostProcess"]; });
  125700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FilterPostProcess"]; });
  125701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FxaaPostProcess"]; });
  125702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["GrainPostProcess"]; });
  125703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["HighlightsPostProcess"]; });
  125704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ImageProcessingPostProcess"]; });
  125705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["MotionBlurPostProcess"]; });
  125706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassPostProcess"]; });
  125707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassCubePostProcess"]; });
  125708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcess"]; });
  125709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessManager"]; });
  125710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["RefractionPostProcess"]; });
  125711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SharpenPostProcess"]; });
  125712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StereoscopicInterlacePostProcess"]; });
  125713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemappingOperator"]; });
  125714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemapPostProcess"]; });
  125715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VolumetricLightScatteringPostProcess"]; });
  125716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  125717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderEffect"]; });
  125718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipeline"]; });
  125719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManager"]; });
  125720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManagerSceneComponent"]; });
  125721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DefaultRenderingPipeline"]; });
  125722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["LensRenderingPipeline"]; });
  125723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAO2RenderingPipeline"]; });
  125724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAORenderingPipeline"]; });
  125725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StandardRenderingPipeline"]; });
  125726. /* harmony import */ var _Probes_index__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./Probes/index */ "./Probes/index.ts");
  125727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _Probes_index__WEBPACK_IMPORTED_MODULE_30__["ReflectionProbe"]; });
  125728. /* harmony import */ var _Rendering_index__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Rendering/index */ "./Rendering/index.ts");
  125729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["BoundingBoxRenderer"]; });
  125730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRenderer"]; });
  125731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRendererSceneComponent"]; });
  125732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["EdgesRenderer"]; });
  125733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["LineEdgesRenderer"]; });
  125734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRenderer"]; });
  125735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRendererSceneComponent"]; });
  125736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["OutlineRenderer"]; });
  125737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroup"]; });
  125738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroupInfo"]; });
  125739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingManager"]; });
  125740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["UtilityLayerRenderer"]; });
  125741. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./scene */ "./scene.ts");
  125742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _scene__WEBPACK_IMPORTED_MODULE_32__["Scene"]; });
  125743. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  125744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["SceneComponentConstants"]; });
  125745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["Stage"]; });
  125746. /* harmony import */ var _Sprites_index__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./Sprites/index */ "./Sprites/index.ts");
  125747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["Sprite"]; });
  125748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteManager"]; });
  125749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteSceneComponent"]; });
  125750. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./States/index */ "./States/index.ts");
  125751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_AlphaState"]; });
  125752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_DepthCullingState"]; });
  125753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_StencilState"]; });
  125754. /* harmony import */ var _Misc_index__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Misc/index */ "./Misc/index.ts");
  125755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AndOrNotEvaluator"]; });
  125756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetTaskState"]; });
  125757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AbstractAssetTask"]; });
  125758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsProgressEvent"]; });
  125759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshAssetTask"]; });
  125760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextFileAssetTask"]; });
  125761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["BinaryFileAssetTask"]; });
  125762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ImageAssetTask"]; });
  125763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureAssetTask"]; });
  125764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeTextureAssetTask"]; });
  125765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRCubeTextureAssetTask"]; });
  125766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsManager"]; });
  125767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DDSTools"]; });
  125768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["expandToProperty"]; });
  125769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serialize"]; });
  125770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsTexture"]; });
  125771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor3"]; });
  125772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsFresnelParameters"]; });
  125773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector2"]; });
  125774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector3"]; });
  125775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMeshReference"]; });
  125776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColorCurves"]; });
  125777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor4"]; });
  125778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsImageProcessingConfiguration"]; });
  125779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsQuaternion"]; });
  125780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsCameraReference"]; });
  125781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SerializationHelper"]; });
  125782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Deferred"]; });
  125783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EnvironmentTextureTools"]; });
  125784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInput"]; });
  125785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["KhronosTextureContainer"]; });
  125786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EventState"]; });
  125787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observer"]; });
  125788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MultiObserver"]; });
  125789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observable"]; });
  125790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerformanceMonitor"]; });
  125791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RollingAverage"]; });
  125792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PromisePolyfill"]; });
  125793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimization"]; });
  125794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureOptimization"]; });
  125795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HardwareScalingOptimization"]; });
  125796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ShadowsOptimization"]; });
  125797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PostProcessesOptimization"]; });
  125798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LensFlaresOptimization"]; });
  125799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CustomOptimization"]; });
  125800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ParticlesOptimization"]; });
  125801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RenderTargetsOptimization"]; });
  125802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MergeMeshesOptimization"]; });
  125803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizerOptions"]; });
  125804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizer"]; });
  125805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneSerializer"]; });
  125806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArray"]; });
  125807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArrayNoDuplicate"]; });
  125808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["StringDictionary"]; });
  125809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tags"]; });
  125810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureTools"]; });
  125811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TGATools"]; });
  125812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ColorGradient"]; });
  125813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Color3Gradient"]; });
  125814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FactorGradient"]; });
  125815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LoadFileError"]; });
  125816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RetryStrategy"]; });
  125817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tools"]; });
  125818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerfCounter"]; });
  125819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["className"]; });
  125820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AsyncLoop"]; });
  125821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VideoRecorder"]; });
  125822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["JoystickAxis"]; });
  125823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VirtualJoystick"]; });
  125824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WorkerPool"]; });
  125825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Logger"]; });
  125826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["_TypeStore"]; });
  125827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInputStore"]; });
  125828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DeepCopier"]; });
  125829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PivotTools"]; });
  125830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PrecisionDate"]; });
  125831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ScreenshotTools"]; });
  125832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeMapToSphericalPolynomialTools"]; });
  125833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRTools"]; });
  125834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PanoramaToCubeMapTools"]; });
  125835. /***/ }),
  125836. /***/ "./node.ts":
  125837. /*!*****************!*\
  125838. !*** ./node.ts ***!
  125839. \*****************/
  125840. /*! exports provided: Node */
  125841. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125842. "use strict";
  125843. __webpack_require__.r(__webpack_exports__);
  125844. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return Node; });
  125845. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125846. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  125847. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/decorators */ "./Misc/decorators.ts");
  125848. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  125849. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  125850. /**
  125851. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  125852. */
  125853. var Node = /** @class */ (function () {
  125854. /**
  125855. * Creates a new Node
  125856. * @param name the name and id to be given to this node
  125857. * @param scene the scene this node will be added to
  125858. * @param addToRootNodes the node will be added to scene.rootNodes
  125859. */
  125860. function Node(name, scene, addToRootNodes) {
  125861. if (scene === void 0) { scene = null; }
  125862. if (addToRootNodes === void 0) { addToRootNodes = true; }
  125863. /**
  125864. * Gets or sets a string used to store user defined state for the node
  125865. */
  125866. this.state = "";
  125867. /**
  125868. * Gets or sets an object used to store user defined information for the node
  125869. */
  125870. this.metadata = null;
  125871. /**
  125872. * For internal use only. Please do not use.
  125873. */
  125874. this.reservedDataStore = null;
  125875. /**
  125876. * Gets or sets a boolean used to define if the node must be serialized
  125877. */
  125878. this.doNotSerialize = false;
  125879. /** @hidden */
  125880. this._isDisposed = false;
  125881. /**
  125882. * Gets a list of Animations associated with the node
  125883. */
  125884. this.animations = new Array();
  125885. this._ranges = {};
  125886. this._isEnabled = true;
  125887. this._isParentEnabled = true;
  125888. this._isReady = true;
  125889. /** @hidden */
  125890. this._currentRenderId = -1;
  125891. this._parentRenderId = -1;
  125892. this._childRenderId = -1;
  125893. /** @hidden */
  125894. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  125895. /** @hidden */
  125896. this._worldMatrixDeterminant = 0;
  125897. /** @hidden */
  125898. this._sceneRootNodesIndex = -1;
  125899. this._animationPropertiesOverride = null;
  125900. /** @hidden */
  125901. this._isNode = true;
  125902. /**
  125903. * An event triggered when the mesh is disposed
  125904. */
  125905. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  125906. // Behaviors
  125907. this._behaviors = new Array();
  125908. this.name = name;
  125909. this.id = name;
  125910. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene);
  125911. this.uniqueId = this._scene.getUniqueId();
  125912. this._initCache();
  125913. if (addToRootNodes) {
  125914. this.addToSceneRootNodes();
  125915. }
  125916. }
  125917. /**
  125918. * Add a new node constructor
  125919. * @param type defines the type name of the node to construct
  125920. * @param constructorFunc defines the constructor function
  125921. */
  125922. Node.AddNodeConstructor = function (type, constructorFunc) {
  125923. this._NodeConstructors[type] = constructorFunc;
  125924. };
  125925. /**
  125926. * Returns a node constructor based on type name
  125927. * @param type defines the type name
  125928. * @param name defines the new node name
  125929. * @param scene defines the hosting scene
  125930. * @param options defines optional options to transmit to constructors
  125931. * @returns the new constructor or null
  125932. */
  125933. Node.Construct = function (type, name, scene, options) {
  125934. var constructorFunc = this._NodeConstructors[type];
  125935. if (!constructorFunc) {
  125936. return null;
  125937. }
  125938. return constructorFunc(name, scene, options);
  125939. };
  125940. /**
  125941. * Gets a boolean indicating if the node has been disposed
  125942. * @returns true if the node was disposed
  125943. */
  125944. Node.prototype.isDisposed = function () {
  125945. return this._isDisposed;
  125946. };
  125947. Object.defineProperty(Node.prototype, "parent", {
  125948. get: function () {
  125949. return this._parentNode;
  125950. },
  125951. /**
  125952. * Gets or sets the parent of the node
  125953. */
  125954. set: function (parent) {
  125955. if (this._parentNode === parent) {
  125956. return;
  125957. }
  125958. var previousParentNode = this._parentNode;
  125959. // Remove self from list of children of parent
  125960. if (this._parentNode && this._parentNode._children !== undefined && this._parentNode._children !== null) {
  125961. var index = this._parentNode._children.indexOf(this);
  125962. if (index !== -1) {
  125963. this._parentNode._children.splice(index, 1);
  125964. }
  125965. if (!parent && !this._isDisposed) {
  125966. this.addToSceneRootNodes();
  125967. }
  125968. }
  125969. // Store new parent
  125970. this._parentNode = parent;
  125971. // Add as child to new parent
  125972. if (this._parentNode) {
  125973. if (this._parentNode._children === undefined || this._parentNode._children === null) {
  125974. this._parentNode._children = new Array();
  125975. }
  125976. this._parentNode._children.push(this);
  125977. if (!previousParentNode) {
  125978. this.removeFromSceneRootNodes();
  125979. }
  125980. }
  125981. // Enabled state
  125982. this._syncParentEnabledState();
  125983. },
  125984. enumerable: true,
  125985. configurable: true
  125986. });
  125987. Node.prototype.addToSceneRootNodes = function () {
  125988. if (this._sceneRootNodesIndex === -1) {
  125989. this._sceneRootNodesIndex = this._scene.rootNodes.length;
  125990. this._scene.rootNodes.push(this);
  125991. }
  125992. };
  125993. Node.prototype.removeFromSceneRootNodes = function () {
  125994. if (this._sceneRootNodesIndex !== -1) {
  125995. var rootNodes = this._scene.rootNodes;
  125996. var lastIdx = rootNodes.length - 1;
  125997. rootNodes[this._sceneRootNodesIndex] = rootNodes[lastIdx];
  125998. rootNodes[this._sceneRootNodesIndex]._sceneRootNodesIndex = this._sceneRootNodesIndex;
  125999. this._scene.rootNodes.pop();
  126000. this._sceneRootNodesIndex = -1;
  126001. }
  126002. };
  126003. Object.defineProperty(Node.prototype, "animationPropertiesOverride", {
  126004. /**
  126005. * Gets or sets the animation properties override
  126006. */
  126007. get: function () {
  126008. if (!this._animationPropertiesOverride) {
  126009. return this._scene.animationPropertiesOverride;
  126010. }
  126011. return this._animationPropertiesOverride;
  126012. },
  126013. set: function (value) {
  126014. this._animationPropertiesOverride = value;
  126015. },
  126016. enumerable: true,
  126017. configurable: true
  126018. });
  126019. /**
  126020. * Gets a string idenfifying the name of the class
  126021. * @returns "Node" string
  126022. */
  126023. Node.prototype.getClassName = function () {
  126024. return "Node";
  126025. };
  126026. Object.defineProperty(Node.prototype, "onDispose", {
  126027. /**
  126028. * Sets a callback that will be raised when the node will be disposed
  126029. */
  126030. set: function (callback) {
  126031. if (this._onDisposeObserver) {
  126032. this.onDisposeObservable.remove(this._onDisposeObserver);
  126033. }
  126034. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  126035. },
  126036. enumerable: true,
  126037. configurable: true
  126038. });
  126039. /**
  126040. * Gets the scene of the node
  126041. * @returns a scene
  126042. */
  126043. Node.prototype.getScene = function () {
  126044. return this._scene;
  126045. };
  126046. /**
  126047. * Gets the engine of the node
  126048. * @returns a Engine
  126049. */
  126050. Node.prototype.getEngine = function () {
  126051. return this._scene.getEngine();
  126052. };
  126053. /**
  126054. * Attach a behavior to the node
  126055. * @see http://doc.babylonjs.com/features/behaviour
  126056. * @param behavior defines the behavior to attach
  126057. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  126058. * @returns the current Node
  126059. */
  126060. Node.prototype.addBehavior = function (behavior, attachImmediately) {
  126061. var _this = this;
  126062. if (attachImmediately === void 0) { attachImmediately = false; }
  126063. var index = this._behaviors.indexOf(behavior);
  126064. if (index !== -1) {
  126065. return this;
  126066. }
  126067. behavior.init();
  126068. if (this._scene.isLoading && !attachImmediately) {
  126069. // We defer the attach when the scene will be loaded
  126070. this._scene.onDataLoadedObservable.addOnce(function () {
  126071. behavior.attach(_this);
  126072. });
  126073. }
  126074. else {
  126075. behavior.attach(this);
  126076. }
  126077. this._behaviors.push(behavior);
  126078. return this;
  126079. };
  126080. /**
  126081. * Remove an attached behavior
  126082. * @see http://doc.babylonjs.com/features/behaviour
  126083. * @param behavior defines the behavior to attach
  126084. * @returns the current Node
  126085. */
  126086. Node.prototype.removeBehavior = function (behavior) {
  126087. var index = this._behaviors.indexOf(behavior);
  126088. if (index === -1) {
  126089. return this;
  126090. }
  126091. this._behaviors[index].detach();
  126092. this._behaviors.splice(index, 1);
  126093. return this;
  126094. };
  126095. Object.defineProperty(Node.prototype, "behaviors", {
  126096. /**
  126097. * Gets the list of attached behaviors
  126098. * @see http://doc.babylonjs.com/features/behaviour
  126099. */
  126100. get: function () {
  126101. return this._behaviors;
  126102. },
  126103. enumerable: true,
  126104. configurable: true
  126105. });
  126106. /**
  126107. * Gets an attached behavior by name
  126108. * @param name defines the name of the behavior to look for
  126109. * @see http://doc.babylonjs.com/features/behaviour
  126110. * @returns null if behavior was not found else the requested behavior
  126111. */
  126112. Node.prototype.getBehaviorByName = function (name) {
  126113. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  126114. var behavior = _a[_i];
  126115. if (behavior.name === name) {
  126116. return behavior;
  126117. }
  126118. }
  126119. return null;
  126120. };
  126121. /**
  126122. * Returns the latest update of the World matrix
  126123. * @returns a Matrix
  126124. */
  126125. Node.prototype.getWorldMatrix = function () {
  126126. if (this._currentRenderId !== this._scene.getRenderId()) {
  126127. this.computeWorldMatrix();
  126128. }
  126129. return this._worldMatrix;
  126130. };
  126131. /** @hidden */
  126132. Node.prototype._getWorldMatrixDeterminant = function () {
  126133. return this._worldMatrixDeterminant;
  126134. };
  126135. Object.defineProperty(Node.prototype, "worldMatrixFromCache", {
  126136. /**
  126137. * Returns directly the latest state of the mesh World matrix.
  126138. * A Matrix is returned.
  126139. */
  126140. get: function () {
  126141. return this._worldMatrix;
  126142. },
  126143. enumerable: true,
  126144. configurable: true
  126145. });
  126146. // override it in derived class if you add new variables to the cache
  126147. // and call the parent class method
  126148. /** @hidden */
  126149. Node.prototype._initCache = function () {
  126150. this._cache = {};
  126151. this._cache.parent = undefined;
  126152. };
  126153. /** @hidden */
  126154. Node.prototype.updateCache = function (force) {
  126155. if (!force && this.isSynchronized()) {
  126156. return;
  126157. }
  126158. this._cache.parent = this.parent;
  126159. this._updateCache();
  126160. };
  126161. // override it in derived class if you add new variables to the cache
  126162. // and call the parent class method if !ignoreParentClass
  126163. /** @hidden */
  126164. Node.prototype._updateCache = function (ignoreParentClass) {
  126165. };
  126166. // override it in derived class if you add new variables to the cache
  126167. /** @hidden */
  126168. Node.prototype._isSynchronized = function () {
  126169. return true;
  126170. };
  126171. /** @hidden */
  126172. Node.prototype._markSyncedWithParent = function () {
  126173. if (this._parentNode) {
  126174. this._parentRenderId = this._parentNode._childRenderId;
  126175. }
  126176. };
  126177. /** @hidden */
  126178. Node.prototype.isSynchronizedWithParent = function () {
  126179. if (!this._parentNode) {
  126180. return true;
  126181. }
  126182. if (this._parentRenderId !== this._parentNode._childRenderId) {
  126183. return false;
  126184. }
  126185. return this._parentNode.isSynchronized();
  126186. };
  126187. /** @hidden */
  126188. Node.prototype.isSynchronized = function () {
  126189. if (this._cache.parent != this._parentNode) {
  126190. this._cache.parent = this._parentNode;
  126191. return false;
  126192. }
  126193. if (this._parentNode && !this.isSynchronizedWithParent()) {
  126194. return false;
  126195. }
  126196. return this._isSynchronized();
  126197. };
  126198. /**
  126199. * Is this node ready to be used/rendered
  126200. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  126201. * @return true if the node is ready
  126202. */
  126203. Node.prototype.isReady = function (completeCheck) {
  126204. if (completeCheck === void 0) { completeCheck = false; }
  126205. return this._isReady;
  126206. };
  126207. /**
  126208. * Is this node enabled?
  126209. * 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
  126210. * @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
  126211. * @return whether this node (and its parent) is enabled
  126212. */
  126213. Node.prototype.isEnabled = function (checkAncestors) {
  126214. if (checkAncestors === void 0) { checkAncestors = true; }
  126215. if (checkAncestors === false) {
  126216. return this._isEnabled;
  126217. }
  126218. if (!this._isEnabled) {
  126219. return false;
  126220. }
  126221. return this._isParentEnabled;
  126222. };
  126223. /** @hidden */
  126224. Node.prototype._syncParentEnabledState = function () {
  126225. this._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : true;
  126226. if (this._children) {
  126227. this._children.forEach(function (c) {
  126228. c._syncParentEnabledState(); // Force children to update accordingly
  126229. });
  126230. }
  126231. };
  126232. /**
  126233. * Set the enabled state of this node
  126234. * @param value defines the new enabled state
  126235. */
  126236. Node.prototype.setEnabled = function (value) {
  126237. this._isEnabled = value;
  126238. this._syncParentEnabledState();
  126239. };
  126240. /**
  126241. * Is this node a descendant of the given node?
  126242. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  126243. * @param ancestor defines the parent node to inspect
  126244. * @returns a boolean indicating if this node is a descendant of the given node
  126245. */
  126246. Node.prototype.isDescendantOf = function (ancestor) {
  126247. if (this.parent) {
  126248. if (this.parent === ancestor) {
  126249. return true;
  126250. }
  126251. return this.parent.isDescendantOf(ancestor);
  126252. }
  126253. return false;
  126254. };
  126255. /** @hidden */
  126256. Node.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  126257. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  126258. if (!this._children) {
  126259. return;
  126260. }
  126261. for (var index = 0; index < this._children.length; index++) {
  126262. var item = this._children[index];
  126263. if (!predicate || predicate(item)) {
  126264. results.push(item);
  126265. }
  126266. if (!directDescendantsOnly) {
  126267. item._getDescendants(results, false, predicate);
  126268. }
  126269. }
  126270. };
  126271. /**
  126272. * Will return all nodes that have this node as ascendant
  126273. * @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
  126274. * @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
  126275. * @return all children nodes of all types
  126276. */
  126277. Node.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  126278. var results = new Array();
  126279. this._getDescendants(results, directDescendantsOnly, predicate);
  126280. return results;
  126281. };
  126282. /**
  126283. * Get all child-meshes of this node
  126284. * @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
  126285. * @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
  126286. * @returns an array of AbstractMesh
  126287. */
  126288. Node.prototype.getChildMeshes = function (directDescendantsOnly, predicate) {
  126289. var results = [];
  126290. this._getDescendants(results, directDescendantsOnly, function (node) {
  126291. return ((!predicate || predicate(node)) && (node.cullingStrategy !== undefined));
  126292. });
  126293. return results;
  126294. };
  126295. /**
  126296. * Get all direct children of this node
  126297. * @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
  126298. * @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)
  126299. * @returns an array of Node
  126300. */
  126301. Node.prototype.getChildren = function (predicate, directDescendantsOnly) {
  126302. if (directDescendantsOnly === void 0) { directDescendantsOnly = true; }
  126303. return this.getDescendants(directDescendantsOnly, predicate);
  126304. };
  126305. /** @hidden */
  126306. Node.prototype._setReady = function (state) {
  126307. if (state === this._isReady) {
  126308. return;
  126309. }
  126310. if (!state) {
  126311. this._isReady = false;
  126312. return;
  126313. }
  126314. if (this.onReady) {
  126315. this.onReady(this);
  126316. }
  126317. this._isReady = true;
  126318. };
  126319. /**
  126320. * Get an animation by name
  126321. * @param name defines the name of the animation to look for
  126322. * @returns null if not found else the requested animation
  126323. */
  126324. Node.prototype.getAnimationByName = function (name) {
  126325. for (var i = 0; i < this.animations.length; i++) {
  126326. var animation = this.animations[i];
  126327. if (animation.name === name) {
  126328. return animation;
  126329. }
  126330. }
  126331. return null;
  126332. };
  126333. /**
  126334. * Creates an animation range for this node
  126335. * @param name defines the name of the range
  126336. * @param from defines the starting key
  126337. * @param to defines the end key
  126338. */
  126339. Node.prototype.createAnimationRange = function (name, from, to) {
  126340. // check name not already in use
  126341. if (!this._ranges[name]) {
  126342. this._ranges[name] = Node._AnimationRangeFactory(name, from, to);
  126343. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  126344. if (this.animations[i]) {
  126345. this.animations[i].createRange(name, from, to);
  126346. }
  126347. }
  126348. }
  126349. };
  126350. /**
  126351. * Delete a specific animation range
  126352. * @param name defines the name of the range to delete
  126353. * @param deleteFrames defines if animation frames from the range must be deleted as well
  126354. */
  126355. Node.prototype.deleteAnimationRange = function (name, deleteFrames) {
  126356. if (deleteFrames === void 0) { deleteFrames = true; }
  126357. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  126358. if (this.animations[i]) {
  126359. this.animations[i].deleteRange(name, deleteFrames);
  126360. }
  126361. }
  126362. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  126363. };
  126364. /**
  126365. * Get an animation range by name
  126366. * @param name defines the name of the animation range to look for
  126367. * @returns null if not found else the requested animation range
  126368. */
  126369. Node.prototype.getAnimationRange = function (name) {
  126370. return this._ranges[name];
  126371. };
  126372. /**
  126373. * Will start the animation sequence
  126374. * @param name defines the range frames for animation sequence
  126375. * @param loop defines if the animation should loop (false by default)
  126376. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  126377. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  126378. * @returns the object created for this animation. If range does not exist, it will return null
  126379. */
  126380. Node.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  126381. var range = this.getAnimationRange(name);
  126382. if (!range) {
  126383. return null;
  126384. }
  126385. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  126386. };
  126387. /**
  126388. * Serialize animation ranges into a JSON compatible object
  126389. * @returns serialization object
  126390. */
  126391. Node.prototype.serializeAnimationRanges = function () {
  126392. var serializationRanges = [];
  126393. for (var name in this._ranges) {
  126394. var localRange = this._ranges[name];
  126395. if (!localRange) {
  126396. continue;
  126397. }
  126398. var range = {};
  126399. range.name = name;
  126400. range.from = localRange.from;
  126401. range.to = localRange.to;
  126402. serializationRanges.push(range);
  126403. }
  126404. return serializationRanges;
  126405. };
  126406. /**
  126407. * Computes the world matrix of the node
  126408. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  126409. * @returns the world matrix
  126410. */
  126411. Node.prototype.computeWorldMatrix = function (force) {
  126412. if (!this._worldMatrix) {
  126413. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  126414. }
  126415. return this._worldMatrix;
  126416. };
  126417. /**
  126418. * Releases resources associated with this node.
  126419. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  126420. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  126421. */
  126422. Node.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  126423. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  126424. this._isDisposed = true;
  126425. if (!doNotRecurse) {
  126426. var nodes = this.getDescendants(true);
  126427. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  126428. var node = nodes_1[_i];
  126429. node.dispose(doNotRecurse, disposeMaterialAndTextures);
  126430. }
  126431. }
  126432. if (!this.parent) {
  126433. this.removeFromSceneRootNodes();
  126434. }
  126435. else {
  126436. this.parent = null;
  126437. }
  126438. // Callback
  126439. this.onDisposeObservable.notifyObservers(this);
  126440. this.onDisposeObservable.clear();
  126441. // Behaviors
  126442. for (var _a = 0, _b = this._behaviors; _a < _b.length; _a++) {
  126443. var behavior = _b[_a];
  126444. behavior.detach();
  126445. }
  126446. this._behaviors = [];
  126447. };
  126448. /**
  126449. * Parse animation range data from a serialization object and store them into a given node
  126450. * @param node defines where to store the animation ranges
  126451. * @param parsedNode defines the serialization object to read data from
  126452. * @param scene defines the hosting scene
  126453. */
  126454. Node.ParseAnimationRanges = function (node, parsedNode, scene) {
  126455. if (parsedNode.ranges) {
  126456. for (var index = 0; index < parsedNode.ranges.length; index++) {
  126457. var data = parsedNode.ranges[index];
  126458. node.createAnimationRange(data.name, data.from, data.to);
  126459. }
  126460. }
  126461. };
  126462. /** @hidden */
  126463. Node._AnimationRangeFactory = function (name, from, to) {
  126464. throw "AnimationRange needs to be imported from animation before being created.";
  126465. };
  126466. Node._NodeConstructors = {};
  126467. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126468. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  126469. ], Node.prototype, "name", void 0);
  126470. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126471. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  126472. ], Node.prototype, "id", void 0);
  126473. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126474. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  126475. ], Node.prototype, "uniqueId", void 0);
  126476. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126477. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  126478. ], Node.prototype, "state", void 0);
  126479. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126480. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  126481. ], Node.prototype, "metadata", void 0);
  126482. return Node;
  126483. }());
  126484. /***/ }),
  126485. /***/ "./scene.ts":
  126486. /*!******************!*\
  126487. !*** ./scene.ts ***!
  126488. \******************/
  126489. /*! exports provided: Scene */
  126490. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126491. "use strict";
  126492. __webpack_require__.r(__webpack_exports__);
  126493. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return Scene; });
  126494. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  126495. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Misc/tools */ "./Misc/tools.ts");
  126496. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/precisionDate */ "./Misc/precisionDate.ts");
  126497. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  126498. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Misc/smartArray */ "./Misc/smartArray.ts");
  126499. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  126500. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Misc/tags */ "./Misc/tags.ts");
  126501. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  126502. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  126503. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Cameras/camera */ "./Cameras/camera.ts");
  126504. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  126505. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  126506. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  126507. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Animations/animation */ "./Animations/animation.ts");
  126508. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Animations/animatable */ "./Animations/animatable.ts");
  126509. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Lights/light */ "./Lights/light.ts");
  126510. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  126511. /* harmony import */ var _Collisions_collisionCoordinator__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Collisions/collisionCoordinator */ "./Collisions/collisionCoordinator.ts");
  126512. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./Events/pointerEvents */ "./Events/pointerEvents.ts");
  126513. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  126514. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Actions/actionEvent */ "./Actions/actionEvent.ts");
  126515. /* harmony import */ var _Actions_actionManager__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Actions/actionManager */ "./Actions/actionManager.ts");
  126516. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  126517. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  126518. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  126519. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./Culling/ray */ "./Culling/ray.ts");
  126520. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Engines/constants */ "./Engines/constants.ts");
  126521. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Misc/domManagement */ "./Misc/domManagement.ts");
  126522. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Misc/logger */ "./Misc/logger.ts");
  126523. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  126524. /** @hidden */
  126525. var ClickInfo = /** @class */ (function () {
  126526. function ClickInfo() {
  126527. this._singleClick = false;
  126528. this._doubleClick = false;
  126529. this._hasSwiped = false;
  126530. this._ignore = false;
  126531. }
  126532. Object.defineProperty(ClickInfo.prototype, "singleClick", {
  126533. get: function () {
  126534. return this._singleClick;
  126535. },
  126536. set: function (b) {
  126537. this._singleClick = b;
  126538. },
  126539. enumerable: true,
  126540. configurable: true
  126541. });
  126542. Object.defineProperty(ClickInfo.prototype, "doubleClick", {
  126543. get: function () {
  126544. return this._doubleClick;
  126545. },
  126546. set: function (b) {
  126547. this._doubleClick = b;
  126548. },
  126549. enumerable: true,
  126550. configurable: true
  126551. });
  126552. Object.defineProperty(ClickInfo.prototype, "hasSwiped", {
  126553. get: function () {
  126554. return this._hasSwiped;
  126555. },
  126556. set: function (b) {
  126557. this._hasSwiped = b;
  126558. },
  126559. enumerable: true,
  126560. configurable: true
  126561. });
  126562. Object.defineProperty(ClickInfo.prototype, "ignore", {
  126563. get: function () {
  126564. return this._ignore;
  126565. },
  126566. set: function (b) {
  126567. this._ignore = b;
  126568. },
  126569. enumerable: true,
  126570. configurable: true
  126571. });
  126572. return ClickInfo;
  126573. }());
  126574. /**
  126575. * Represents a scene to be rendered by the engine.
  126576. * @see http://doc.babylonjs.com/features/scene
  126577. */
  126578. var Scene = /** @class */ (function (_super) {
  126579. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Scene, _super);
  126580. /**
  126581. * Creates a new Scene
  126582. * @param engine defines the engine to use to render this scene
  126583. */
  126584. function Scene(engine, options) {
  126585. var _this = _super.call(this) || this;
  126586. // Members
  126587. /** @hidden */
  126588. _this._isScene = true;
  126589. /**
  126590. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  126591. */
  126592. _this.autoClear = true;
  126593. /**
  126594. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  126595. */
  126596. _this.autoClearDepthAndStencil = true;
  126597. /**
  126598. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  126599. */
  126600. _this.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color4"](0.2, 0.2, 0.3, 1.0);
  126601. /**
  126602. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  126603. */
  126604. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0, 0, 0);
  126605. _this._forceWireframe = false;
  126606. _this._forcePointsCloud = false;
  126607. /**
  126608. * Gets or sets a boolean indicating if animations are enabled
  126609. */
  126610. _this.animationsEnabled = true;
  126611. _this._animationPropertiesOverride = null;
  126612. /**
  126613. * Gets or sets a boolean indicating if a constant deltatime has to be used
  126614. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  126615. */
  126616. _this.useConstantAnimationDeltaTime = false;
  126617. /**
  126618. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  126619. * Please note that it requires to run a ray cast through the scene on every frame
  126620. */
  126621. _this.constantlyUpdateMeshUnderPointer = false;
  126622. /**
  126623. * Defines the HTML cursor to use when hovering over interactive elements
  126624. */
  126625. _this.hoverCursor = "pointer";
  126626. /**
  126627. * Defines the HTML default cursor to use (empty by default)
  126628. */
  126629. _this.defaultCursor = "";
  126630. /**
  126631. * This is used to call preventDefault() on pointer down
  126632. * in order to block unwanted artifacts like system double clicks
  126633. */
  126634. _this.preventDefaultOnPointerDown = true;
  126635. /**
  126636. * This is used to call preventDefault() on pointer up
  126637. * in order to block unwanted artifacts like system double clicks
  126638. */
  126639. _this.preventDefaultOnPointerUp = true;
  126640. // Metadata
  126641. /**
  126642. * Gets or sets user defined metadata
  126643. */
  126644. _this.metadata = null;
  126645. /**
  126646. * For internal use only. Please do not use.
  126647. */
  126648. _this.reservedDataStore = null;
  126649. /**
  126650. * Use this array to add regular expressions used to disable offline support for specific urls
  126651. */
  126652. _this.disableOfflineSupportExceptionRules = new Array();
  126653. /**
  126654. * An event triggered when the scene is disposed.
  126655. */
  126656. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126657. _this._onDisposeObserver = null;
  126658. /**
  126659. * An event triggered before rendering the scene (right after animations and physics)
  126660. */
  126661. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126662. _this._onBeforeRenderObserver = null;
  126663. /**
  126664. * An event triggered after rendering the scene
  126665. */
  126666. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126667. _this._onAfterRenderObserver = null;
  126668. /**
  126669. * An event triggered before animating the scene
  126670. */
  126671. _this.onBeforeAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126672. /**
  126673. * An event triggered after animations processing
  126674. */
  126675. _this.onAfterAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126676. /**
  126677. * An event triggered before draw calls are ready to be sent
  126678. */
  126679. _this.onBeforeDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126680. /**
  126681. * An event triggered after draw calls have been sent
  126682. */
  126683. _this.onAfterDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126684. /**
  126685. * An event triggered when the scene is ready
  126686. */
  126687. _this.onReadyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126688. /**
  126689. * An event triggered before rendering a camera
  126690. */
  126691. _this.onBeforeCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126692. _this._onBeforeCameraRenderObserver = null;
  126693. /**
  126694. * An event triggered after rendering a camera
  126695. */
  126696. _this.onAfterCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126697. _this._onAfterCameraRenderObserver = null;
  126698. /**
  126699. * An event triggered when active meshes evaluation is about to start
  126700. */
  126701. _this.onBeforeActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126702. /**
  126703. * An event triggered when active meshes evaluation is done
  126704. */
  126705. _this.onAfterActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126706. /**
  126707. * An event triggered when particles rendering is about to start
  126708. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  126709. */
  126710. _this.onBeforeParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126711. /**
  126712. * An event triggered when particles rendering is done
  126713. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  126714. */
  126715. _this.onAfterParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126716. /**
  126717. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  126718. */
  126719. _this.onDataLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126720. /**
  126721. * An event triggered when a camera is created
  126722. */
  126723. _this.onNewCameraAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126724. /**
  126725. * An event triggered when a camera is removed
  126726. */
  126727. _this.onCameraRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126728. /**
  126729. * An event triggered when a light is created
  126730. */
  126731. _this.onNewLightAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126732. /**
  126733. * An event triggered when a light is removed
  126734. */
  126735. _this.onLightRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126736. /**
  126737. * An event triggered when a geometry is created
  126738. */
  126739. _this.onNewGeometryAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126740. /**
  126741. * An event triggered when a geometry is removed
  126742. */
  126743. _this.onGeometryRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126744. /**
  126745. * An event triggered when a transform node is created
  126746. */
  126747. _this.onNewTransformNodeAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126748. /**
  126749. * An event triggered when a transform node is removed
  126750. */
  126751. _this.onTransformNodeRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126752. /**
  126753. * An event triggered when a mesh is created
  126754. */
  126755. _this.onNewMeshAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126756. /**
  126757. * An event triggered when a mesh is removed
  126758. */
  126759. _this.onMeshRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126760. /**
  126761. * An event triggered when a material is created
  126762. */
  126763. _this.onNewMaterialAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126764. /**
  126765. * An event triggered when a material is removed
  126766. */
  126767. _this.onMaterialRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126768. /**
  126769. * An event triggered when a texture is created
  126770. */
  126771. _this.onNewTextureAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126772. /**
  126773. * An event triggered when a texture is removed
  126774. */
  126775. _this.onTextureRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126776. /**
  126777. * An event triggered when render targets are about to be rendered
  126778. * Can happen multiple times per frame.
  126779. */
  126780. _this.onBeforeRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126781. /**
  126782. * An event triggered when render targets were rendered.
  126783. * Can happen multiple times per frame.
  126784. */
  126785. _this.onAfterRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126786. /**
  126787. * An event triggered before calculating deterministic simulation step
  126788. */
  126789. _this.onBeforeStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126790. /**
  126791. * An event triggered after calculating deterministic simulation step
  126792. */
  126793. _this.onAfterStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126794. /**
  126795. * An event triggered when the activeCamera property is updated
  126796. */
  126797. _this.onActiveCameraChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126798. /**
  126799. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  126800. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  126801. * 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)
  126802. */
  126803. _this.onBeforeRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126804. /**
  126805. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  126806. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  126807. * 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)
  126808. */
  126809. _this.onAfterRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126810. /**
  126811. * This Observable will when a mesh has been imported into the scene.
  126812. */
  126813. _this.onMeshImportedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126814. // Animations
  126815. _this._registeredForLateAnimationBindings = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  126816. /**
  126817. * 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).
  126818. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  126819. */
  126820. _this.onPrePointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126821. /**
  126822. * Observable event triggered each time an input event is received from the rendering canvas
  126823. */
  126824. _this.onPointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126825. _this._meshPickProceed = false;
  126826. _this._currentPickResult = null;
  126827. _this._previousPickResult = null;
  126828. _this._totalPointersPressed = 0;
  126829. _this._doubleClickOccured = false;
  126830. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  126831. _this.cameraToUseForPointers = null;
  126832. _this._pointerX = 0;
  126833. _this._pointerY = 0;
  126834. _this._startingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  126835. _this._previousStartingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  126836. _this._startingPointerTime = 0;
  126837. _this._previousStartingPointerTime = 0;
  126838. _this._pointerCaptures = {};
  126839. // Deterministic lockstep
  126840. _this._timeAccumulator = 0;
  126841. _this._currentStepId = 0;
  126842. _this._currentInternalStep = 0;
  126843. // Keyboard
  126844. /**
  126845. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  126846. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  126847. */
  126848. _this.onPreKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126849. /**
  126850. * Observable event triggered each time an keyboard event is received from the hosting window
  126851. */
  126852. _this.onKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  126853. // Coordinates system
  126854. _this._useRightHandedSystem = false;
  126855. // Fog
  126856. _this._fogEnabled = true;
  126857. _this._fogMode = Scene.FOGMODE_NONE;
  126858. /**
  126859. * Gets or sets the fog color to use
  126860. * @see http://doc.babylonjs.com/babylon101/environment#fog
  126861. * (Default is Color3(0.2, 0.2, 0.3))
  126862. */
  126863. _this.fogColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0.2, 0.2, 0.3);
  126864. /**
  126865. * Gets or sets the fog density to use
  126866. * @see http://doc.babylonjs.com/babylon101/environment#fog
  126867. * (Default is 0.1)
  126868. */
  126869. _this.fogDensity = 0.1;
  126870. /**
  126871. * Gets or sets the fog start distance to use
  126872. * @see http://doc.babylonjs.com/babylon101/environment#fog
  126873. * (Default is 0)
  126874. */
  126875. _this.fogStart = 0;
  126876. /**
  126877. * Gets or sets the fog end distance to use
  126878. * @see http://doc.babylonjs.com/babylon101/environment#fog
  126879. * (Default is 1000)
  126880. */
  126881. _this.fogEnd = 1000.0;
  126882. // Lights
  126883. _this._shadowsEnabled = true;
  126884. _this._lightsEnabled = true;
  126885. /** All of the active cameras added to this scene. */
  126886. _this.activeCameras = new Array();
  126887. // Textures
  126888. _this._texturesEnabled = true;
  126889. // Particles
  126890. /**
  126891. * Gets or sets a boolean indicating if particles are enabled on this scene
  126892. */
  126893. _this.particlesEnabled = true;
  126894. // Sprites
  126895. /**
  126896. * Gets or sets a boolean indicating if sprites are enabled on this scene
  126897. */
  126898. _this.spritesEnabled = true;
  126899. // Skeletons
  126900. _this._skeletonsEnabled = true;
  126901. // Lens flares
  126902. /**
  126903. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  126904. */
  126905. _this.lensFlaresEnabled = true;
  126906. // Collisions
  126907. /**
  126908. * Gets or sets a boolean indicating if collisions are enabled on this scene
  126909. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  126910. */
  126911. _this.collisionsEnabled = true;
  126912. /**
  126913. * Defines the gravity applied to this scene (used only for collisions)
  126914. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  126915. */
  126916. _this.gravity = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](0, -9.807, 0);
  126917. // Postprocesses
  126918. /**
  126919. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  126920. */
  126921. _this.postProcessesEnabled = true;
  126922. /**
  126923. * The list of postprocesses added to the scene
  126924. */
  126925. _this.postProcesses = new Array();
  126926. // Customs render targets
  126927. /**
  126928. * Gets or sets a boolean indicating if render targets are enabled on this scene
  126929. */
  126930. _this.renderTargetsEnabled = true;
  126931. /**
  126932. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  126933. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  126934. */
  126935. _this.dumpNextRenderTargets = false;
  126936. /**
  126937. * The list of user defined render targets added to the scene
  126938. */
  126939. _this.customRenderTargets = new Array();
  126940. /**
  126941. * Gets the list of meshes imported to the scene through SceneLoader
  126942. */
  126943. _this.importedMeshesFiles = new Array();
  126944. // Probes
  126945. /**
  126946. * Gets or sets a boolean indicating if probes are enabled on this scene
  126947. */
  126948. _this.probesEnabled = true;
  126949. _this._meshesForIntersections = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  126950. // Procedural textures
  126951. /**
  126952. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  126953. */
  126954. _this.proceduralTexturesEnabled = true;
  126955. // Performance counters
  126956. _this._totalVertices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  126957. /** @hidden */
  126958. _this._activeIndices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  126959. /** @hidden */
  126960. _this._activeParticles = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  126961. /** @hidden */
  126962. _this._activeBones = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  126963. _this._animationTime = 0;
  126964. /**
  126965. * Gets or sets a general scale for animation speed
  126966. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  126967. */
  126968. _this.animationTimeScale = 1;
  126969. _this._renderId = 0;
  126970. _this._frameId = 0;
  126971. _this._executeWhenReadyTimeoutId = -1;
  126972. _this._intermediateRendering = false;
  126973. _this._viewUpdateFlag = -1;
  126974. _this._projectionUpdateFlag = -1;
  126975. _this._alternateViewUpdateFlag = -1;
  126976. _this._alternateProjectionUpdateFlag = -1;
  126977. /** @hidden */
  126978. _this._toBeDisposed = new Array(256);
  126979. _this._activeRequests = new Array();
  126980. _this._pendingData = new Array();
  126981. _this._isDisposed = false;
  126982. /**
  126983. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  126984. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  126985. */
  126986. _this.dispatchAllSubMeshesOfActiveMeshes = false;
  126987. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  126988. _this._processedMaterials = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  126989. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  126990. /** @hidden */
  126991. _this._activeParticleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  126992. _this._activeSkeletons = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  126993. _this._softwareSkinnedMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  126994. /** @hidden */
  126995. _this._activeAnimatables = new Array();
  126996. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  126997. _this._useAlternateCameraConfiguration = false;
  126998. _this._alternateRendering = false;
  126999. _this._wheelEventName = "";
  127000. /**
  127001. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  127002. * This is useful if there are more lights that the maximum simulteanous authorized
  127003. */
  127004. _this.requireLightSorting = false;
  127005. /**
  127006. * @hidden
  127007. * Backing store of defined scene components.
  127008. */
  127009. _this._components = [];
  127010. /**
  127011. * @hidden
  127012. * Backing store of defined scene components.
  127013. */
  127014. _this._serializableComponents = [];
  127015. /**
  127016. * List of components to register on the next registration step.
  127017. */
  127018. _this._transientComponents = [];
  127019. /**
  127020. * @hidden
  127021. * Defines the actions happening before camera updates.
  127022. */
  127023. _this._beforeCameraUpdateStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127024. /**
  127025. * @hidden
  127026. * Defines the actions happening before clear the canvas.
  127027. */
  127028. _this._beforeClearStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127029. /**
  127030. * @hidden
  127031. * Defines the actions when collecting render targets for the frame.
  127032. */
  127033. _this._gatherRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127034. /**
  127035. * @hidden
  127036. * Defines the actions happening for one camera in the frame.
  127037. */
  127038. _this._gatherActiveCameraRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127039. /**
  127040. * @hidden
  127041. * Defines the actions happening during the per mesh ready checks.
  127042. */
  127043. _this._isReadyForMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127044. /**
  127045. * @hidden
  127046. * Defines the actions happening before evaluate active mesh checks.
  127047. */
  127048. _this._beforeEvaluateActiveMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127049. /**
  127050. * @hidden
  127051. * Defines the actions happening during the evaluate sub mesh checks.
  127052. */
  127053. _this._evaluateSubMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127054. /**
  127055. * @hidden
  127056. * Defines the actions happening during the active mesh stage.
  127057. */
  127058. _this._activeMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127059. /**
  127060. * @hidden
  127061. * Defines the actions happening during the per camera render target step.
  127062. */
  127063. _this._cameraDrawRenderTargetStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127064. /**
  127065. * @hidden
  127066. * Defines the actions happening just before the active camera is drawing.
  127067. */
  127068. _this._beforeCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127069. /**
  127070. * @hidden
  127071. * Defines the actions happening just before a render target is drawing.
  127072. */
  127073. _this._beforeRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127074. /**
  127075. * @hidden
  127076. * Defines the actions happening just before a rendering group is drawing.
  127077. */
  127078. _this._beforeRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127079. /**
  127080. * @hidden
  127081. * Defines the actions happening just before a mesh is drawing.
  127082. */
  127083. _this._beforeRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127084. /**
  127085. * @hidden
  127086. * Defines the actions happening just after a mesh has been drawn.
  127087. */
  127088. _this._afterRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127089. /**
  127090. * @hidden
  127091. * Defines the actions happening just after a rendering group has been drawn.
  127092. */
  127093. _this._afterRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127094. /**
  127095. * @hidden
  127096. * Defines the actions happening just after the active camera has been drawn.
  127097. */
  127098. _this._afterCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127099. /**
  127100. * @hidden
  127101. * Defines the actions happening just after a render target has been drawn.
  127102. */
  127103. _this._afterRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127104. /**
  127105. * @hidden
  127106. * Defines the actions happening just after rendering all cameras and computing intersections.
  127107. */
  127108. _this._afterRenderStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127109. /**
  127110. * @hidden
  127111. * Defines the actions happening when a pointer move event happens.
  127112. */
  127113. _this._pointerMoveStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127114. /**
  127115. * @hidden
  127116. * Defines the actions happening when a pointer down event happens.
  127117. */
  127118. _this._pointerDownStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127119. /**
  127120. * @hidden
  127121. * Defines the actions happening when a pointer up event happens.
  127122. */
  127123. _this._pointerUpStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_24__["Stage"].Create();
  127124. /**
  127125. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  127126. */
  127127. _this.geometriesByUniqueId = null;
  127128. _this._defaultMeshCandidates = {
  127129. data: [],
  127130. length: 0
  127131. };
  127132. _this._defaultSubMeshCandidates = {
  127133. data: [],
  127134. length: 0
  127135. };
  127136. _this._preventFreeActiveMeshesAndRenderingGroups = false;
  127137. _this._activeMeshesFrozen = false;
  127138. /** @hidden */
  127139. _this._allowPostProcessClearColor = true;
  127140. /**
  127141. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  127142. */
  127143. _this.getDeterministicFrameTime = function () {
  127144. return 1000.0 / 60.0; // frame time in ms
  127145. };
  127146. _this._tempPickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"].Zero() : null;
  127147. _this._blockMaterialDirtyMechanism = false;
  127148. _this._engine = engine || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_29__["EngineStore"].LastCreatedEngine;
  127149. _this._engine.scenes.push(_this);
  127150. _this._uid = null;
  127151. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_23__["RenderingManager"](_this);
  127152. if (_PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"]) {
  127153. _this.postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"](_this);
  127154. }
  127155. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_27__["DomManagement"].IsWindowObjectExist()) {
  127156. _this.attachControl();
  127157. }
  127158. //collision coordinator initialization. For now legacy per default.
  127159. _this.workerCollisions = false; //(!!Worker && (!!CollisionWorker || WorkerIncluded));
  127160. // Uniform Buffer
  127161. _this._createUbo();
  127162. // Default Image processing definition
  127163. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]) {
  127164. _this._imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]();
  127165. }
  127166. _this.setDefaultCandidateProviders();
  127167. if (options && options.useGeometryUniqueIdsMap === true) {
  127168. _this.geometriesByUniqueId = {};
  127169. }
  127170. _this.useMaterialMeshMap = options && options.useGeometryUniqueIdsMap || false;
  127171. _this.useClonedMeshhMap = options && options.useClonedMeshhMap || false;
  127172. _this._engine.onNewSceneAddedObservable.notifyObservers(_this);
  127173. return _this;
  127174. }
  127175. /**
  127176. * Factory used to create the default material.
  127177. * @param name The name of the material to create
  127178. * @param scene The scene to create the material for
  127179. * @returns The default material
  127180. */
  127181. Scene.DefaultMaterialFactory = function (scene) {
  127182. throw "Import StandardMaterial or Fill DefaultMaterialFactory static property on scene before relying on default material creation.";
  127183. };
  127184. Object.defineProperty(Scene.prototype, "environmentTexture", {
  127185. /**
  127186. * Texture used in all pbr material as the reflection texture.
  127187. * As in the majority of the scene they are the same (exception for multi room and so on),
  127188. * this is easier to reference from here than from all the materials.
  127189. */
  127190. get: function () {
  127191. return this._environmentTexture;
  127192. },
  127193. /**
  127194. * Texture used in all pbr material as the reflection texture.
  127195. * As in the majority of the scene they are the same (exception for multi room and so on),
  127196. * this is easier to set here than in all the materials.
  127197. */
  127198. set: function (value) {
  127199. if (this._environmentTexture === value) {
  127200. return;
  127201. }
  127202. this._environmentTexture = value;
  127203. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_TextureDirtyFlag);
  127204. },
  127205. enumerable: true,
  127206. configurable: true
  127207. });
  127208. Object.defineProperty(Scene.prototype, "imageProcessingConfiguration", {
  127209. /**
  127210. * Default image processing configuration used either in the rendering
  127211. * Forward main pass or through the imageProcessingPostProcess if present.
  127212. * As in the majority of the scene they are the same (exception for multi camera),
  127213. * this is easier to reference from here than from all the materials and post process.
  127214. *
  127215. * No setter as we it is a shared configuration, you can set the values instead.
  127216. */
  127217. get: function () {
  127218. return this._imageProcessingConfiguration;
  127219. },
  127220. enumerable: true,
  127221. configurable: true
  127222. });
  127223. Object.defineProperty(Scene.prototype, "forceWireframe", {
  127224. get: function () {
  127225. return this._forceWireframe;
  127226. },
  127227. /**
  127228. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  127229. */
  127230. set: function (value) {
  127231. if (this._forceWireframe === value) {
  127232. return;
  127233. }
  127234. this._forceWireframe = value;
  127235. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_MiscDirtyFlag);
  127236. },
  127237. enumerable: true,
  127238. configurable: true
  127239. });
  127240. Object.defineProperty(Scene.prototype, "forcePointsCloud", {
  127241. get: function () {
  127242. return this._forcePointsCloud;
  127243. },
  127244. /**
  127245. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  127246. */
  127247. set: function (value) {
  127248. if (this._forcePointsCloud === value) {
  127249. return;
  127250. }
  127251. this._forcePointsCloud = value;
  127252. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_MiscDirtyFlag);
  127253. },
  127254. enumerable: true,
  127255. configurable: true
  127256. });
  127257. Object.defineProperty(Scene.prototype, "animationPropertiesOverride", {
  127258. /**
  127259. * Gets or sets the animation properties override
  127260. */
  127261. get: function () {
  127262. return this._animationPropertiesOverride;
  127263. },
  127264. set: function (value) {
  127265. this._animationPropertiesOverride = value;
  127266. },
  127267. enumerable: true,
  127268. configurable: true
  127269. });
  127270. Object.defineProperty(Scene.prototype, "onDispose", {
  127271. /** Sets a function to be executed when this scene is disposed. */
  127272. set: function (callback) {
  127273. if (this._onDisposeObserver) {
  127274. this.onDisposeObservable.remove(this._onDisposeObserver);
  127275. }
  127276. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  127277. },
  127278. enumerable: true,
  127279. configurable: true
  127280. });
  127281. Object.defineProperty(Scene.prototype, "beforeRender", {
  127282. /** Sets a function to be executed before rendering this scene */
  127283. set: function (callback) {
  127284. if (this._onBeforeRenderObserver) {
  127285. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  127286. }
  127287. if (callback) {
  127288. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  127289. }
  127290. },
  127291. enumerable: true,
  127292. configurable: true
  127293. });
  127294. Object.defineProperty(Scene.prototype, "afterRender", {
  127295. /** Sets a function to be executed after rendering this scene */
  127296. set: function (callback) {
  127297. if (this._onAfterRenderObserver) {
  127298. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  127299. }
  127300. if (callback) {
  127301. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  127302. }
  127303. },
  127304. enumerable: true,
  127305. configurable: true
  127306. });
  127307. Object.defineProperty(Scene.prototype, "beforeCameraRender", {
  127308. /** Sets a function to be executed before rendering a camera*/
  127309. set: function (callback) {
  127310. if (this._onBeforeCameraRenderObserver) {
  127311. this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  127312. }
  127313. this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(callback);
  127314. },
  127315. enumerable: true,
  127316. configurable: true
  127317. });
  127318. Object.defineProperty(Scene.prototype, "afterCameraRender", {
  127319. /** Sets a function to be executed after rendering a camera*/
  127320. set: function (callback) {
  127321. if (this._onAfterCameraRenderObserver) {
  127322. this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  127323. }
  127324. this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(callback);
  127325. },
  127326. enumerable: true,
  127327. configurable: true
  127328. });
  127329. Object.defineProperty(Scene.prototype, "unTranslatedPointer", {
  127330. /**
  127331. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  127332. */
  127333. get: function () {
  127334. return new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](this._unTranslatedPointerX, this._unTranslatedPointerY);
  127335. },
  127336. enumerable: true,
  127337. configurable: true
  127338. });
  127339. Object.defineProperty(Scene.prototype, "useRightHandedSystem", {
  127340. get: function () {
  127341. return this._useRightHandedSystem;
  127342. },
  127343. /**
  127344. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  127345. */
  127346. set: function (value) {
  127347. if (this._useRightHandedSystem === value) {
  127348. return;
  127349. }
  127350. this._useRightHandedSystem = value;
  127351. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_MiscDirtyFlag);
  127352. },
  127353. enumerable: true,
  127354. configurable: true
  127355. });
  127356. /**
  127357. * Sets the step Id used by deterministic lock step
  127358. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127359. * @param newStepId defines the step Id
  127360. */
  127361. Scene.prototype.setStepId = function (newStepId) {
  127362. this._currentStepId = newStepId;
  127363. };
  127364. /**
  127365. * Gets the step Id used by deterministic lock step
  127366. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127367. * @returns the step Id
  127368. */
  127369. Scene.prototype.getStepId = function () {
  127370. return this._currentStepId;
  127371. };
  127372. /**
  127373. * Gets the internal step used by deterministic lock step
  127374. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127375. * @returns the internal step
  127376. */
  127377. Scene.prototype.getInternalStep = function () {
  127378. return this._currentInternalStep;
  127379. };
  127380. Object.defineProperty(Scene.prototype, "fogEnabled", {
  127381. get: function () {
  127382. return this._fogEnabled;
  127383. },
  127384. /**
  127385. * Gets or sets a boolean indicating if fog is enabled on this scene
  127386. * @see http://doc.babylonjs.com/babylon101/environment#fog
  127387. * (Default is true)
  127388. */
  127389. set: function (value) {
  127390. if (this._fogEnabled === value) {
  127391. return;
  127392. }
  127393. this._fogEnabled = value;
  127394. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_MiscDirtyFlag);
  127395. },
  127396. enumerable: true,
  127397. configurable: true
  127398. });
  127399. Object.defineProperty(Scene.prototype, "fogMode", {
  127400. get: function () {
  127401. return this._fogMode;
  127402. },
  127403. /**
  127404. * Gets or sets the fog mode to use
  127405. * @see http://doc.babylonjs.com/babylon101/environment#fog
  127406. * | mode | value |
  127407. * | --- | --- |
  127408. * | FOGMODE_NONE | 0 |
  127409. * | FOGMODE_EXP | 1 |
  127410. * | FOGMODE_EXP2 | 2 |
  127411. * | FOGMODE_LINEAR | 3 |
  127412. */
  127413. set: function (value) {
  127414. if (this._fogMode === value) {
  127415. return;
  127416. }
  127417. this._fogMode = value;
  127418. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_MiscDirtyFlag);
  127419. },
  127420. enumerable: true,
  127421. configurable: true
  127422. });
  127423. Object.defineProperty(Scene.prototype, "shadowsEnabled", {
  127424. get: function () {
  127425. return this._shadowsEnabled;
  127426. },
  127427. /**
  127428. * Gets or sets a boolean indicating if shadows are enabled on this scene
  127429. */
  127430. set: function (value) {
  127431. if (this._shadowsEnabled === value) {
  127432. return;
  127433. }
  127434. this._shadowsEnabled = value;
  127435. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_LightDirtyFlag);
  127436. },
  127437. enumerable: true,
  127438. configurable: true
  127439. });
  127440. Object.defineProperty(Scene.prototype, "lightsEnabled", {
  127441. get: function () {
  127442. return this._lightsEnabled;
  127443. },
  127444. /**
  127445. * Gets or sets a boolean indicating if lights are enabled on this scene
  127446. */
  127447. set: function (value) {
  127448. if (this._lightsEnabled === value) {
  127449. return;
  127450. }
  127451. this._lightsEnabled = value;
  127452. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_LightDirtyFlag);
  127453. },
  127454. enumerable: true,
  127455. configurable: true
  127456. });
  127457. Object.defineProperty(Scene.prototype, "activeCamera", {
  127458. /** Gets or sets the current active camera */
  127459. get: function () {
  127460. return this._activeCamera;
  127461. },
  127462. set: function (value) {
  127463. if (value === this._activeCamera) {
  127464. return;
  127465. }
  127466. this._activeCamera = value;
  127467. this.onActiveCameraChanged.notifyObservers(this);
  127468. },
  127469. enumerable: true,
  127470. configurable: true
  127471. });
  127472. Object.defineProperty(Scene.prototype, "defaultMaterial", {
  127473. /** The default material used on meshes when no material is affected */
  127474. get: function () {
  127475. if (!this._defaultMaterial) {
  127476. this._defaultMaterial = Scene.DefaultMaterialFactory(this);
  127477. }
  127478. return this._defaultMaterial;
  127479. },
  127480. /** The default material used on meshes when no material is affected */
  127481. set: function (value) {
  127482. this._defaultMaterial = value;
  127483. },
  127484. enumerable: true,
  127485. configurable: true
  127486. });
  127487. Object.defineProperty(Scene.prototype, "texturesEnabled", {
  127488. get: function () {
  127489. return this._texturesEnabled;
  127490. },
  127491. /**
  127492. * Gets or sets a boolean indicating if textures are enabled on this scene
  127493. */
  127494. set: function (value) {
  127495. if (this._texturesEnabled === value) {
  127496. return;
  127497. }
  127498. this._texturesEnabled = value;
  127499. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_TextureDirtyFlag);
  127500. },
  127501. enumerable: true,
  127502. configurable: true
  127503. });
  127504. Object.defineProperty(Scene.prototype, "skeletonsEnabled", {
  127505. get: function () {
  127506. return this._skeletonsEnabled;
  127507. },
  127508. /**
  127509. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  127510. */
  127511. set: function (value) {
  127512. if (this._skeletonsEnabled === value) {
  127513. return;
  127514. }
  127515. this._skeletonsEnabled = value;
  127516. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_AttributesDirtyFlag);
  127517. },
  127518. enumerable: true,
  127519. configurable: true
  127520. });
  127521. Object.defineProperty(Scene.prototype, "_isAlternateRenderingEnabled", {
  127522. /** @hidden */
  127523. get: function () {
  127524. return this._alternateRendering;
  127525. },
  127526. enumerable: true,
  127527. configurable: true
  127528. });
  127529. Object.defineProperty(Scene.prototype, "frustumPlanes", {
  127530. /**
  127531. * Gets the list of frustum planes (built from the active camera)
  127532. */
  127533. get: function () {
  127534. return this._frustumPlanes;
  127535. },
  127536. enumerable: true,
  127537. configurable: true
  127538. });
  127539. /**
  127540. * Registers the transient components if needed.
  127541. */
  127542. Scene.prototype._registerTransientComponents = function () {
  127543. // Register components that have been associated lately to the scene.
  127544. if (this._transientComponents.length > 0) {
  127545. for (var _i = 0, _a = this._transientComponents; _i < _a.length; _i++) {
  127546. var component = _a[_i];
  127547. component.register();
  127548. }
  127549. this._transientComponents = [];
  127550. }
  127551. };
  127552. /**
  127553. * @hidden
  127554. * Add a component to the scene.
  127555. * Note that the ccomponent could be registered on th next frame if this is called after
  127556. * the register component stage.
  127557. * @param component Defines the component to add to the scene
  127558. */
  127559. Scene.prototype._addComponent = function (component) {
  127560. this._components.push(component);
  127561. this._transientComponents.push(component);
  127562. var serializableComponent = component;
  127563. if (serializableComponent.addFromContainer) {
  127564. this._serializableComponents.push(serializableComponent);
  127565. }
  127566. };
  127567. /**
  127568. * @hidden
  127569. * Gets a component from the scene.
  127570. * @param name defines the name of the component to retrieve
  127571. * @returns the component or null if not present
  127572. */
  127573. Scene.prototype._getComponent = function (name) {
  127574. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  127575. var component = _a[_i];
  127576. if (component.name === name) {
  127577. return component;
  127578. }
  127579. }
  127580. return null;
  127581. };
  127582. /**
  127583. * @hidden
  127584. */
  127585. Scene.prototype._getDefaultMeshCandidates = function () {
  127586. this._defaultMeshCandidates.data = this.meshes;
  127587. this._defaultMeshCandidates.length = this.meshes.length;
  127588. return this._defaultMeshCandidates;
  127589. };
  127590. /**
  127591. * @hidden
  127592. */
  127593. Scene.prototype._getDefaultSubMeshCandidates = function (mesh) {
  127594. this._defaultSubMeshCandidates.data = mesh.subMeshes;
  127595. this._defaultSubMeshCandidates.length = mesh.subMeshes.length;
  127596. return this._defaultSubMeshCandidates;
  127597. };
  127598. /**
  127599. * Sets the default candidate providers for the scene.
  127600. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  127601. * and getCollidingSubMeshCandidates to their default function
  127602. */
  127603. Scene.prototype.setDefaultCandidateProviders = function () {
  127604. this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this);
  127605. this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  127606. this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  127607. this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  127608. };
  127609. Object.defineProperty(Scene.prototype, "workerCollisions", {
  127610. /**
  127611. * Gets a boolean indicating if collisions are processed on a web worker
  127612. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  127613. */
  127614. get: function () {
  127615. // Worker has been deprecated.
  127616. // Keep for back compat.
  127617. return false;
  127618. },
  127619. set: function (enabled) {
  127620. if (!_Collisions_collisionCoordinator__WEBPACK_IMPORTED_MODULE_17__["CollisionCoordinatorLegacy"]) {
  127621. return;
  127622. }
  127623. if (this.collisionCoordinator) {
  127624. this.collisionCoordinator.destroy();
  127625. }
  127626. this.collisionCoordinator = new _Collisions_collisionCoordinator__WEBPACK_IMPORTED_MODULE_17__["CollisionCoordinatorLegacy"]();
  127627. this.collisionCoordinator.init(this);
  127628. },
  127629. enumerable: true,
  127630. configurable: true
  127631. });
  127632. Object.defineProperty(Scene.prototype, "meshUnderPointer", {
  127633. /**
  127634. * Gets the mesh that is currently under the pointer
  127635. */
  127636. get: function () {
  127637. return this._pointerOverMesh;
  127638. },
  127639. enumerable: true,
  127640. configurable: true
  127641. });
  127642. Object.defineProperty(Scene.prototype, "pointerX", {
  127643. /**
  127644. * Gets or sets the current on-screen X position of the pointer
  127645. */
  127646. get: function () {
  127647. return this._pointerX;
  127648. },
  127649. set: function (value) {
  127650. this._pointerX = value;
  127651. },
  127652. enumerable: true,
  127653. configurable: true
  127654. });
  127655. Object.defineProperty(Scene.prototype, "pointerY", {
  127656. /**
  127657. * Gets or sets the current on-screen Y position of the pointer
  127658. */
  127659. get: function () {
  127660. return this._pointerY;
  127661. },
  127662. set: function (value) {
  127663. this._pointerY = value;
  127664. },
  127665. enumerable: true,
  127666. configurable: true
  127667. });
  127668. /**
  127669. * Gets the cached material (ie. the latest rendered one)
  127670. * @returns the cached material
  127671. */
  127672. Scene.prototype.getCachedMaterial = function () {
  127673. return this._cachedMaterial;
  127674. };
  127675. /**
  127676. * Gets the cached effect (ie. the latest rendered one)
  127677. * @returns the cached effect
  127678. */
  127679. Scene.prototype.getCachedEffect = function () {
  127680. return this._cachedEffect;
  127681. };
  127682. /**
  127683. * Gets the cached visibility state (ie. the latest rendered one)
  127684. * @returns the cached visibility state
  127685. */
  127686. Scene.prototype.getCachedVisibility = function () {
  127687. return this._cachedVisibility;
  127688. };
  127689. /**
  127690. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  127691. * @param material defines the current material
  127692. * @param effect defines the current effect
  127693. * @param visibility defines the current visibility state
  127694. * @returns true if one parameter is not cached
  127695. */
  127696. Scene.prototype.isCachedMaterialInvalid = function (material, effect, visibility) {
  127697. if (visibility === void 0) { visibility = 1; }
  127698. return this._cachedEffect !== effect || this._cachedMaterial !== material || this._cachedVisibility !== visibility;
  127699. };
  127700. /**
  127701. * Gets the engine associated with the scene
  127702. * @returns an Engine
  127703. */
  127704. Scene.prototype.getEngine = function () {
  127705. return this._engine;
  127706. };
  127707. /**
  127708. * Gets the total number of vertices rendered per frame
  127709. * @returns the total number of vertices rendered per frame
  127710. */
  127711. Scene.prototype.getTotalVertices = function () {
  127712. return this._totalVertices.current;
  127713. };
  127714. Object.defineProperty(Scene.prototype, "totalVerticesPerfCounter", {
  127715. /**
  127716. * Gets the performance counter for total vertices
  127717. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  127718. */
  127719. get: function () {
  127720. return this._totalVertices;
  127721. },
  127722. enumerable: true,
  127723. configurable: true
  127724. });
  127725. /**
  127726. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  127727. * @returns the total number of active indices rendered per frame
  127728. */
  127729. Scene.prototype.getActiveIndices = function () {
  127730. return this._activeIndices.current;
  127731. };
  127732. Object.defineProperty(Scene.prototype, "totalActiveIndicesPerfCounter", {
  127733. /**
  127734. * Gets the performance counter for active indices
  127735. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  127736. */
  127737. get: function () {
  127738. return this._activeIndices;
  127739. },
  127740. enumerable: true,
  127741. configurable: true
  127742. });
  127743. /**
  127744. * Gets the total number of active particles rendered per frame
  127745. * @returns the total number of active particles rendered per frame
  127746. */
  127747. Scene.prototype.getActiveParticles = function () {
  127748. return this._activeParticles.current;
  127749. };
  127750. Object.defineProperty(Scene.prototype, "activeParticlesPerfCounter", {
  127751. /**
  127752. * Gets the performance counter for active particles
  127753. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  127754. */
  127755. get: function () {
  127756. return this._activeParticles;
  127757. },
  127758. enumerable: true,
  127759. configurable: true
  127760. });
  127761. /**
  127762. * Gets the total number of active bones rendered per frame
  127763. * @returns the total number of active bones rendered per frame
  127764. */
  127765. Scene.prototype.getActiveBones = function () {
  127766. return this._activeBones.current;
  127767. };
  127768. Object.defineProperty(Scene.prototype, "activeBonesPerfCounter", {
  127769. /**
  127770. * Gets the performance counter for active bones
  127771. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  127772. */
  127773. get: function () {
  127774. return this._activeBones;
  127775. },
  127776. enumerable: true,
  127777. configurable: true
  127778. });
  127779. /**
  127780. * Gets the array of active meshes
  127781. * @returns an array of AbstractMesh
  127782. */
  127783. Scene.prototype.getActiveMeshes = function () {
  127784. return this._activeMeshes;
  127785. };
  127786. /**
  127787. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  127788. * @returns a number
  127789. */
  127790. Scene.prototype.getAnimationRatio = function () {
  127791. return this._animationRatio !== undefined ? this._animationRatio : 1;
  127792. };
  127793. /**
  127794. * Gets an unique Id for the current render phase
  127795. * @returns a number
  127796. */
  127797. Scene.prototype.getRenderId = function () {
  127798. return this._renderId;
  127799. };
  127800. /**
  127801. * Gets an unique Id for the current frame
  127802. * @returns a number
  127803. */
  127804. Scene.prototype.getFrameId = function () {
  127805. return this._frameId;
  127806. };
  127807. /** Call this function if you want to manually increment the render Id*/
  127808. Scene.prototype.incrementRenderId = function () {
  127809. this._renderId++;
  127810. };
  127811. Scene.prototype._updatePointerPosition = function (evt) {
  127812. var canvasRect = this._engine.getRenderingCanvasClientRect();
  127813. if (!canvasRect) {
  127814. return;
  127815. }
  127816. this._pointerX = evt.clientX - canvasRect.left;
  127817. this._pointerY = evt.clientY - canvasRect.top;
  127818. this._unTranslatedPointerX = this._pointerX;
  127819. this._unTranslatedPointerY = this._pointerY;
  127820. };
  127821. Scene.prototype._createUbo = function () {
  127822. this._sceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  127823. this._sceneUbo.addUniform("viewProjection", 16);
  127824. this._sceneUbo.addUniform("view", 16);
  127825. };
  127826. Scene.prototype._createAlternateUbo = function () {
  127827. this._alternateSceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  127828. this._alternateSceneUbo.addUniform("viewProjection", 16);
  127829. this._alternateSceneUbo.addUniform("view", 16);
  127830. };
  127831. // Pointers handling
  127832. Scene.prototype._setRayOnPointerInfo = function (pointerInfo) {
  127833. if (pointerInfo.pickInfo) {
  127834. if (!pointerInfo.pickInfo.ray) {
  127835. pointerInfo.pickInfo.ray = this.createPickingRay(pointerInfo.event.offsetX, pointerInfo.event.offsetY, _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity(), this.activeCamera);
  127836. }
  127837. }
  127838. };
  127839. /**
  127840. * Use this method to simulate a pointer move on a mesh
  127841. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  127842. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  127843. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  127844. * @returns the current scene
  127845. */
  127846. Scene.prototype.simulatePointerMove = function (pickResult, pointerEventInit) {
  127847. var evt = new PointerEvent("pointermove", pointerEventInit);
  127848. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERMOVE)) {
  127849. return this;
  127850. }
  127851. return this._processPointerMove(pickResult, evt);
  127852. };
  127853. Scene.prototype._processPointerMove = function (pickResult, evt) {
  127854. var canvas = this._engine.getRenderingCanvas();
  127855. if (!canvas) {
  127856. return this;
  127857. }
  127858. // Restore pointer
  127859. canvas.style.cursor = this.defaultCursor;
  127860. var isMeshPicked = (pickResult && pickResult.hit && pickResult.pickedMesh) ? true : false;
  127861. if (isMeshPicked) {
  127862. this.setPointerOverMesh(pickResult.pickedMesh);
  127863. if (this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers) {
  127864. if (this._pointerOverMesh.actionManager.hoverCursor) {
  127865. canvas.style.cursor = this._pointerOverMesh.actionManager.hoverCursor;
  127866. }
  127867. else {
  127868. canvas.style.cursor = this.hoverCursor;
  127869. }
  127870. }
  127871. }
  127872. else {
  127873. this.setPointerOverMesh(null);
  127874. }
  127875. for (var _i = 0, _a = this._pointerMoveStage; _i < _a.length; _i++) {
  127876. var step = _a[_i];
  127877. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, isMeshPicked, canvas);
  127878. }
  127879. if (pickResult) {
  127880. var type = evt.type === this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERMOVE;
  127881. if (this.onPointerMove) {
  127882. this.onPointerMove(evt, pickResult, type);
  127883. }
  127884. if (this.onPointerObservable.hasObservers()) {
  127885. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerInfo"](type, evt, pickResult);
  127886. this._setRayOnPointerInfo(pi);
  127887. this.onPointerObservable.notifyObservers(pi, type);
  127888. }
  127889. }
  127890. return this;
  127891. };
  127892. Scene.prototype._checkPrePointerObservable = function (pickResult, evt, type) {
  127893. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerInfoPre"](type, evt, this._unTranslatedPointerX, this._unTranslatedPointerY);
  127894. if (pickResult) {
  127895. pi.ray = pickResult.ray;
  127896. }
  127897. this.onPrePointerObservable.notifyObservers(pi, type);
  127898. if (pi.skipOnPointerObservable) {
  127899. return true;
  127900. }
  127901. else {
  127902. return false;
  127903. }
  127904. };
  127905. /**
  127906. * Use this method to simulate a pointer down on a mesh
  127907. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  127908. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  127909. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  127910. * @returns the current scene
  127911. */
  127912. Scene.prototype.simulatePointerDown = function (pickResult, pointerEventInit) {
  127913. var evt = new PointerEvent("pointerdown", pointerEventInit);
  127914. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOWN)) {
  127915. return this;
  127916. }
  127917. return this._processPointerDown(pickResult, evt);
  127918. };
  127919. Scene.prototype._processPointerDown = function (pickResult, evt) {
  127920. var _this = this;
  127921. if (pickResult && pickResult.hit && pickResult.pickedMesh) {
  127922. this._pickedDownMesh = pickResult.pickedMesh;
  127923. var actionManager = pickResult.pickedMesh.actionManager;
  127924. if (actionManager) {
  127925. if (actionManager.hasPickTriggers) {
  127926. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnPickDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  127927. switch (evt.button) {
  127928. case 0:
  127929. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnLeftPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  127930. break;
  127931. case 1:
  127932. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnCenterPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  127933. break;
  127934. case 2:
  127935. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnRightPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  127936. break;
  127937. }
  127938. }
  127939. if (actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnLongPressTrigger)) {
  127940. window.setTimeout(function () {
  127941. 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_26__["Constants"].ACTION_OnLongPressTrigger) && mesh == _this._pickedDownMesh); }, false, _this.cameraToUseForPointers);
  127942. if (pickResult && pickResult.hit && pickResult.pickedMesh && actionManager) {
  127943. if (_this._totalPointersPressed !== 0 &&
  127944. ((Date.now() - _this._startingPointerTime) > Scene.LongPressDelay) &&
  127945. !_this._isPointerSwiping()) {
  127946. _this._startingPointerTime = 0;
  127947. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnLongPressTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  127948. }
  127949. }
  127950. }, Scene.LongPressDelay);
  127951. }
  127952. }
  127953. }
  127954. else {
  127955. for (var _i = 0, _a = this._pointerDownStage; _i < _a.length; _i++) {
  127956. var step = _a[_i];
  127957. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  127958. }
  127959. }
  127960. if (pickResult) {
  127961. var type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOWN;
  127962. if (this.onPointerDown) {
  127963. this.onPointerDown(evt, pickResult, type);
  127964. }
  127965. if (this.onPointerObservable.hasObservers()) {
  127966. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerInfo"](type, evt, pickResult);
  127967. this._setRayOnPointerInfo(pi);
  127968. this.onPointerObservable.notifyObservers(pi, type);
  127969. }
  127970. }
  127971. return this;
  127972. };
  127973. /**
  127974. * Use this method to simulate a pointer up on a mesh
  127975. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  127976. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  127977. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  127978. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  127979. * @returns the current scene
  127980. */
  127981. Scene.prototype.simulatePointerUp = function (pickResult, pointerEventInit, doubleTap) {
  127982. var evt = new PointerEvent("pointerup", pointerEventInit);
  127983. var clickInfo = new ClickInfo();
  127984. if (doubleTap) {
  127985. clickInfo.doubleClick = true;
  127986. }
  127987. else {
  127988. clickInfo.singleClick = true;
  127989. }
  127990. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERUP)) {
  127991. return this;
  127992. }
  127993. return this._processPointerUp(pickResult, evt, clickInfo);
  127994. };
  127995. Scene.prototype._processPointerUp = function (pickResult, evt, clickInfo) {
  127996. if (pickResult && pickResult && pickResult.pickedMesh) {
  127997. this._pickedUpMesh = pickResult.pickedMesh;
  127998. if (this._pickedDownMesh === this._pickedUpMesh) {
  127999. if (this.onPointerPick) {
  128000. this.onPointerPick(evt, pickResult);
  128001. }
  128002. if (clickInfo.singleClick && !clickInfo.ignore && this.onPointerObservable.hasObservers()) {
  128003. var type_1 = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERPICK;
  128004. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerInfo"](type_1, evt, pickResult);
  128005. this._setRayOnPointerInfo(pi);
  128006. this.onPointerObservable.notifyObservers(pi, type_1);
  128007. }
  128008. }
  128009. if (pickResult.pickedMesh.actionManager && !clickInfo.ignore) {
  128010. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnPickUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128011. if (!clickInfo.hasSwiped && clickInfo.singleClick) {
  128012. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128013. }
  128014. if (clickInfo.doubleClick && pickResult.pickedMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnDoublePickTrigger)) {
  128015. pickResult.pickedMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnDoublePickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  128016. }
  128017. }
  128018. }
  128019. else {
  128020. if (!clickInfo.ignore) {
  128021. for (var _i = 0, _a = this._pointerUpStage; _i < _a.length; _i++) {
  128022. var step = _a[_i];
  128023. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  128024. }
  128025. }
  128026. }
  128027. if (this._pickedDownMesh &&
  128028. this._pickedDownMesh.actionManager &&
  128029. this._pickedDownMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnPickOutTrigger) &&
  128030. this._pickedDownMesh !== this._pickedUpMesh) {
  128031. this._pickedDownMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnPickOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(this._pickedDownMesh, evt));
  128032. }
  128033. var type = 0;
  128034. if (this.onPointerObservable.hasObservers()) {
  128035. if (!clickInfo.ignore && !clickInfo.hasSwiped) {
  128036. if (clickInfo.singleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERTAP)) {
  128037. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERTAP;
  128038. }
  128039. else if (clickInfo.doubleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP)) {
  128040. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP;
  128041. }
  128042. if (type) {
  128043. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerInfo"](type, evt, pickResult);
  128044. this._setRayOnPointerInfo(pi);
  128045. this.onPointerObservable.notifyObservers(pi, type);
  128046. }
  128047. }
  128048. if (!clickInfo.ignore) {
  128049. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERUP;
  128050. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerInfo"](type, evt, pickResult);
  128051. this._setRayOnPointerInfo(pi);
  128052. this.onPointerObservable.notifyObservers(pi, type);
  128053. }
  128054. }
  128055. if (this.onPointerUp && !clickInfo.ignore) {
  128056. this.onPointerUp(evt, pickResult, type);
  128057. }
  128058. return this;
  128059. };
  128060. /**
  128061. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  128062. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  128063. * @returns true if the pointer was captured
  128064. */
  128065. Scene.prototype.isPointerCaptured = function (pointerId) {
  128066. if (pointerId === void 0) { pointerId = 0; }
  128067. return this._pointerCaptures[pointerId];
  128068. };
  128069. /** @hidden */
  128070. Scene.prototype._isPointerSwiping = function () {
  128071. return Math.abs(this._startingPointerPosition.x - this._pointerX) > Scene.DragMovementThreshold ||
  128072. Math.abs(this._startingPointerPosition.y - this._pointerY) > Scene.DragMovementThreshold;
  128073. };
  128074. /**
  128075. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  128076. * @param attachUp defines if you want to attach events to pointerup
  128077. * @param attachDown defines if you want to attach events to pointerdown
  128078. * @param attachMove defines if you want to attach events to pointermove
  128079. */
  128080. Scene.prototype.attachControl = function (attachUp, attachDown, attachMove) {
  128081. var _this = this;
  128082. if (attachUp === void 0) { attachUp = true; }
  128083. if (attachDown === void 0) { attachDown = true; }
  128084. if (attachMove === void 0) { attachMove = true; }
  128085. this._initActionManager = function (act, clickInfo) {
  128086. if (!_this._meshPickProceed) {
  128087. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  128088. _this._currentPickResult = pickResult;
  128089. if (pickResult) {
  128090. act = (pickResult.hit && pickResult.pickedMesh) ? pickResult.pickedMesh.actionManager : null;
  128091. }
  128092. _this._meshPickProceed = true;
  128093. }
  128094. return act;
  128095. };
  128096. this._delayedSimpleClick = function (btn, clickInfo, cb) {
  128097. // double click delay is over and that no double click has been raised since, or the 2 consecutive keys pressed are different
  128098. if ((Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay && !_this._doubleClickOccured) ||
  128099. btn !== _this._previousButtonPressed) {
  128100. _this._doubleClickOccured = false;
  128101. clickInfo.singleClick = true;
  128102. clickInfo.ignore = false;
  128103. cb(clickInfo, _this._currentPickResult);
  128104. }
  128105. };
  128106. this._initClickEvent = function (obs1, obs2, evt, cb) {
  128107. var clickInfo = new ClickInfo();
  128108. _this._currentPickResult = null;
  128109. var act = null;
  128110. var checkPicking = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERPICK) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERPICK)
  128111. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERTAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERTAP)
  128112. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP);
  128113. if (!checkPicking && _Actions_actionManager__WEBPACK_IMPORTED_MODULE_21__["ActionManager"]) {
  128114. act = _this._initActionManager(act, clickInfo);
  128115. if (act) {
  128116. checkPicking = act.hasPickTriggers;
  128117. }
  128118. }
  128119. var needToIgnoreNext = false;
  128120. if (checkPicking) {
  128121. var btn = evt.button;
  128122. clickInfo.hasSwiped = _this._isPointerSwiping();
  128123. if (!clickInfo.hasSwiped) {
  128124. var checkSingleClickImmediately = !Scene.ExclusiveDoubleClickMode;
  128125. if (!checkSingleClickImmediately) {
  128126. checkSingleClickImmediately = !obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP) &&
  128127. !obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP);
  128128. if (checkSingleClickImmediately && !_Actions_actionManager__WEBPACK_IMPORTED_MODULE_21__["ActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnDoublePickTrigger)) {
  128129. act = _this._initActionManager(act, clickInfo);
  128130. if (act) {
  128131. checkSingleClickImmediately = !act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnDoublePickTrigger);
  128132. }
  128133. }
  128134. }
  128135. if (checkSingleClickImmediately) {
  128136. // single click detected if double click delay is over or two different successive keys pressed without exclusive double click or no double click required
  128137. if (Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay ||
  128138. btn !== _this._previousButtonPressed) {
  128139. clickInfo.singleClick = true;
  128140. cb(clickInfo, _this._currentPickResult);
  128141. needToIgnoreNext = true;
  128142. }
  128143. }
  128144. // at least one double click is required to be check and exclusive double click is enabled
  128145. else {
  128146. // wait that no double click has been raised during the double click delay
  128147. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  128148. _this._delayedSimpleClickTimeout = window.setTimeout(_this._delayedSimpleClick.bind(_this, btn, clickInfo, cb), Scene.DoubleClickDelay);
  128149. }
  128150. var checkDoubleClick = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP) ||
  128151. obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP);
  128152. if (!checkDoubleClick && _Actions_actionManager__WEBPACK_IMPORTED_MODULE_21__["ActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnDoublePickTrigger)) {
  128153. act = _this._initActionManager(act, clickInfo);
  128154. if (act) {
  128155. checkDoubleClick = act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnDoublePickTrigger);
  128156. }
  128157. }
  128158. if (checkDoubleClick) {
  128159. // two successive keys pressed are equal, double click delay is not over and double click has not just occurred
  128160. if (btn === _this._previousButtonPressed &&
  128161. Date.now() - _this._previousStartingPointerTime < Scene.DoubleClickDelay &&
  128162. !_this._doubleClickOccured) {
  128163. // pointer has not moved for 2 clicks, it's a double click
  128164. if (!clickInfo.hasSwiped &&
  128165. !_this._isPointerSwiping()) {
  128166. _this._previousStartingPointerTime = 0;
  128167. _this._doubleClickOccured = true;
  128168. clickInfo.doubleClick = true;
  128169. clickInfo.ignore = false;
  128170. if (Scene.ExclusiveDoubleClickMode && _this._previousDelayedSimpleClickTimeout) {
  128171. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  128172. }
  128173. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  128174. cb(clickInfo, _this._currentPickResult);
  128175. }
  128176. // if the two successive clicks are too far, it's just two simple clicks
  128177. else {
  128178. _this._doubleClickOccured = false;
  128179. _this._previousStartingPointerTime = _this._startingPointerTime;
  128180. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  128181. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  128182. _this._previousButtonPressed = btn;
  128183. if (Scene.ExclusiveDoubleClickMode) {
  128184. if (_this._previousDelayedSimpleClickTimeout) {
  128185. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  128186. }
  128187. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  128188. cb(clickInfo, _this._previousPickResult);
  128189. }
  128190. else {
  128191. cb(clickInfo, _this._currentPickResult);
  128192. }
  128193. }
  128194. needToIgnoreNext = true;
  128195. }
  128196. // just the first click of the double has been raised
  128197. else {
  128198. _this._doubleClickOccured = false;
  128199. _this._previousStartingPointerTime = _this._startingPointerTime;
  128200. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  128201. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  128202. _this._previousButtonPressed = btn;
  128203. }
  128204. }
  128205. }
  128206. }
  128207. if (!needToIgnoreNext) {
  128208. cb(clickInfo, _this._currentPickResult);
  128209. }
  128210. };
  128211. this._onPointerMove = function (evt) {
  128212. _this._updatePointerPosition(evt);
  128213. // PreObservable support
  128214. if (_this._checkPrePointerObservable(null, evt, evt.type === _this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERMOVE)) {
  128215. return;
  128216. }
  128217. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  128218. return;
  128219. }
  128220. if (!_this.pointerMovePredicate) {
  128221. _this.pointerMovePredicate = function (mesh) { return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (mesh.enablePointerMoveEvents || _this.constantlyUpdateMeshUnderPointer || (mesh.actionManager !== null && mesh.actionManager !== undefined)); };
  128222. }
  128223. // Meshes
  128224. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerMovePredicate, false, _this.cameraToUseForPointers);
  128225. _this._processPointerMove(pickResult, evt);
  128226. };
  128227. this._onPointerDown = function (evt) {
  128228. _this._totalPointersPressed++;
  128229. _this._pickedDownMesh = null;
  128230. _this._meshPickProceed = false;
  128231. _this._updatePointerPosition(evt);
  128232. if (_this.preventDefaultOnPointerDown && canvas) {
  128233. evt.preventDefault();
  128234. canvas.focus();
  128235. }
  128236. _this._startingPointerPosition.x = _this._pointerX;
  128237. _this._startingPointerPosition.y = _this._pointerY;
  128238. _this._startingPointerTime = Date.now();
  128239. // PreObservable support
  128240. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOWN)) {
  128241. return;
  128242. }
  128243. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  128244. return;
  128245. }
  128246. _this._pointerCaptures[evt.pointerId] = true;
  128247. if (!_this.pointerDownPredicate) {
  128248. _this.pointerDownPredicate = function (mesh) {
  128249. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
  128250. };
  128251. }
  128252. // Meshes
  128253. _this._pickedDownMesh = null;
  128254. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  128255. _this._processPointerDown(pickResult, evt);
  128256. };
  128257. this._onPointerUp = function (evt) {
  128258. if (_this._totalPointersPressed === 0) { // We are attaching the pointer up to windows because of a bug in FF
  128259. return; // So we need to test it the pointer down was pressed before.
  128260. }
  128261. _this._totalPointersPressed--;
  128262. _this._pickedUpMesh = null;
  128263. _this._meshPickProceed = false;
  128264. _this._updatePointerPosition(evt);
  128265. if (_this.preventDefaultOnPointerUp && canvas) {
  128266. evt.preventDefault();
  128267. canvas.focus();
  128268. }
  128269. _this._initClickEvent(_this.onPrePointerObservable, _this.onPointerObservable, evt, function (clickInfo, pickResult) {
  128270. _this._pointerCaptures[evt.pointerId] = false;
  128271. // PreObservable support
  128272. if (_this.onPrePointerObservable.hasObservers()) {
  128273. if (!clickInfo.ignore) {
  128274. if (!clickInfo.hasSwiped) {
  128275. if (clickInfo.singleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERTAP)) {
  128276. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERTAP)) {
  128277. return;
  128278. }
  128279. }
  128280. if (clickInfo.doubleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP)) {
  128281. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERDOUBLETAP)) {
  128282. return;
  128283. }
  128284. }
  128285. }
  128286. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_18__["PointerEventTypes"].POINTERUP)) {
  128287. return;
  128288. }
  128289. }
  128290. }
  128291. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  128292. return;
  128293. }
  128294. if (!_this.pointerUpPredicate) {
  128295. _this.pointerUpPredicate = function (mesh) {
  128296. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
  128297. };
  128298. }
  128299. // Meshes
  128300. if (!_this._meshPickProceed && (_Actions_actionManager__WEBPACK_IMPORTED_MODULE_21__["ActionManager"] && _Actions_actionManager__WEBPACK_IMPORTED_MODULE_21__["ActionManager"].HasTriggers || _this.onPointerObservable.hasObservers())) {
  128301. _this._initActionManager(null, clickInfo);
  128302. }
  128303. if (!pickResult) {
  128304. pickResult = _this._currentPickResult;
  128305. }
  128306. _this._processPointerUp(pickResult, evt, clickInfo);
  128307. _this._previousPickResult = _this._currentPickResult;
  128308. });
  128309. };
  128310. this._onKeyDown = function (evt) {
  128311. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_19__["KeyboardEventTypes"].KEYDOWN;
  128312. if (_this.onPreKeyboardObservable.hasObservers()) {
  128313. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_19__["KeyboardInfoPre"](type, evt);
  128314. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  128315. if (pi.skipOnPointerObservable) {
  128316. return;
  128317. }
  128318. }
  128319. if (_this.onKeyboardObservable.hasObservers()) {
  128320. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_19__["KeyboardInfo"](type, evt);
  128321. _this.onKeyboardObservable.notifyObservers(pi, type);
  128322. }
  128323. if (_this.actionManager) {
  128324. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnKeyDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNewFromScene(_this, evt));
  128325. }
  128326. };
  128327. this._onKeyUp = function (evt) {
  128328. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_19__["KeyboardEventTypes"].KEYUP;
  128329. if (_this.onPreKeyboardObservable.hasObservers()) {
  128330. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_19__["KeyboardInfoPre"](type, evt);
  128331. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  128332. if (pi.skipOnPointerObservable) {
  128333. return;
  128334. }
  128335. }
  128336. if (_this.onKeyboardObservable.hasObservers()) {
  128337. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_19__["KeyboardInfo"](type, evt);
  128338. _this.onKeyboardObservable.notifyObservers(pi, type);
  128339. }
  128340. if (_this.actionManager) {
  128341. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnKeyUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNewFromScene(_this, evt));
  128342. }
  128343. };
  128344. var engine = this.getEngine();
  128345. this._onCanvasFocusObserver = engine.onCanvasFocusObservable.add(function () {
  128346. if (!canvas) {
  128347. return;
  128348. }
  128349. canvas.addEventListener("keydown", _this._onKeyDown, false);
  128350. canvas.addEventListener("keyup", _this._onKeyUp, false);
  128351. });
  128352. this._onCanvasBlurObserver = engine.onCanvasBlurObservable.add(function () {
  128353. if (!canvas) {
  128354. return;
  128355. }
  128356. canvas.removeEventListener("keydown", _this._onKeyDown);
  128357. canvas.removeEventListener("keyup", _this._onKeyUp);
  128358. });
  128359. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  128360. var canvas = this._engine.getRenderingCanvas();
  128361. if (!canvas) {
  128362. return;
  128363. }
  128364. if (attachMove) {
  128365. canvas.addEventListener(eventPrefix + "move", this._onPointerMove, false);
  128366. // Wheel
  128367. this._wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : // Modern browsers support "wheel"
  128368. document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
  128369. "DOMMouseScroll"; // let's assume that remaining browsers are older Firefox
  128370. canvas.addEventListener(this._wheelEventName, this._onPointerMove, false);
  128371. }
  128372. if (attachDown) {
  128373. canvas.addEventListener(eventPrefix + "down", this._onPointerDown, false);
  128374. }
  128375. if (attachUp) {
  128376. window.addEventListener(eventPrefix + "up", this._onPointerUp, false);
  128377. }
  128378. canvas.tabIndex = 1;
  128379. };
  128380. /** Detaches all event handlers*/
  128381. Scene.prototype.detachControl = function () {
  128382. var engine = this.getEngine();
  128383. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  128384. var canvas = engine.getRenderingCanvas();
  128385. if (!canvas) {
  128386. return;
  128387. }
  128388. canvas.removeEventListener(eventPrefix + "move", this._onPointerMove);
  128389. canvas.removeEventListener(eventPrefix + "down", this._onPointerDown);
  128390. window.removeEventListener(eventPrefix + "up", this._onPointerUp);
  128391. if (this._onCanvasBlurObserver) {
  128392. engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  128393. }
  128394. if (this._onCanvasFocusObserver) {
  128395. engine.onCanvasFocusObservable.remove(this._onCanvasFocusObserver);
  128396. }
  128397. // Wheel
  128398. canvas.removeEventListener(this._wheelEventName, this._onPointerMove);
  128399. // Keyboard
  128400. canvas.removeEventListener("keydown", this._onKeyDown);
  128401. canvas.removeEventListener("keyup", this._onKeyUp);
  128402. // Observables
  128403. this.onKeyboardObservable.clear();
  128404. this.onPreKeyboardObservable.clear();
  128405. this.onPointerObservable.clear();
  128406. this.onPrePointerObservable.clear();
  128407. };
  128408. /**
  128409. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  128410. * Delay loaded resources are not taking in account
  128411. * @return true if all required resources are ready
  128412. */
  128413. Scene.prototype.isReady = function () {
  128414. if (this._isDisposed) {
  128415. return false;
  128416. }
  128417. var index;
  128418. var engine = this.getEngine();
  128419. // Effects
  128420. if (!engine.areAllEffectsReady()) {
  128421. return false;
  128422. }
  128423. // Pending data
  128424. if (this._pendingData.length > 0) {
  128425. return false;
  128426. }
  128427. // Meshes
  128428. for (index = 0; index < this.meshes.length; index++) {
  128429. var mesh = this.meshes[index];
  128430. if (!mesh.isEnabled()) {
  128431. continue;
  128432. }
  128433. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  128434. continue;
  128435. }
  128436. if (!mesh.isReady(true)) {
  128437. return false;
  128438. }
  128439. var hardwareInstancedRendering = mesh.getClassName() === "InstancedMesh" || mesh.getClassName() === "InstancedLinesMesh" || engine.getCaps().instancedArrays && mesh.instances.length > 0;
  128440. // Is Ready For Mesh
  128441. for (var _i = 0, _a = this._isReadyForMeshStage; _i < _a.length; _i++) {
  128442. var step = _a[_i];
  128443. if (!step.action(mesh, hardwareInstancedRendering)) {
  128444. return false;
  128445. }
  128446. }
  128447. }
  128448. // Geometries
  128449. for (index = 0; index < this.geometries.length; index++) {
  128450. var geometry = this.geometries[index];
  128451. if (geometry.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].DELAYLOADSTATE_LOADING) {
  128452. return false;
  128453. }
  128454. }
  128455. // Post-processes
  128456. if (this.activeCameras && this.activeCameras.length > 0) {
  128457. for (var _b = 0, _c = this.activeCameras; _b < _c.length; _b++) {
  128458. var camera = _c[_b];
  128459. if (!camera.isReady(true)) {
  128460. return false;
  128461. }
  128462. }
  128463. }
  128464. else if (this.activeCamera) {
  128465. if (!this.activeCamera.isReady(true)) {
  128466. return false;
  128467. }
  128468. }
  128469. // Particles
  128470. for (var _d = 0, _e = this.particleSystems; _d < _e.length; _d++) {
  128471. var particleSystem = _e[_d];
  128472. if (!particleSystem.isReady()) {
  128473. return false;
  128474. }
  128475. }
  128476. return true;
  128477. };
  128478. /** Resets all cached information relative to material (including effect and visibility) */
  128479. Scene.prototype.resetCachedMaterial = function () {
  128480. this._cachedMaterial = null;
  128481. this._cachedEffect = null;
  128482. this._cachedVisibility = null;
  128483. };
  128484. /**
  128485. * Registers a function to be called before every frame render
  128486. * @param func defines the function to register
  128487. */
  128488. Scene.prototype.registerBeforeRender = function (func) {
  128489. this.onBeforeRenderObservable.add(func);
  128490. };
  128491. /**
  128492. * Unregisters a function called before every frame render
  128493. * @param func defines the function to unregister
  128494. */
  128495. Scene.prototype.unregisterBeforeRender = function (func) {
  128496. this.onBeforeRenderObservable.removeCallback(func);
  128497. };
  128498. /**
  128499. * Registers a function to be called after every frame render
  128500. * @param func defines the function to register
  128501. */
  128502. Scene.prototype.registerAfterRender = function (func) {
  128503. this.onAfterRenderObservable.add(func);
  128504. };
  128505. /**
  128506. * Unregisters a function called after every frame render
  128507. * @param func defines the function to unregister
  128508. */
  128509. Scene.prototype.unregisterAfterRender = function (func) {
  128510. this.onAfterRenderObservable.removeCallback(func);
  128511. };
  128512. Scene.prototype._executeOnceBeforeRender = function (func) {
  128513. var _this = this;
  128514. var execFunc = function () {
  128515. func();
  128516. setTimeout(function () {
  128517. _this.unregisterBeforeRender(execFunc);
  128518. });
  128519. };
  128520. this.registerBeforeRender(execFunc);
  128521. };
  128522. /**
  128523. * The provided function will run before render once and will be disposed afterwards.
  128524. * A timeout delay can be provided so that the function will be executed in N ms.
  128525. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  128526. * @param func The function to be executed.
  128527. * @param timeout optional delay in ms
  128528. */
  128529. Scene.prototype.executeOnceBeforeRender = function (func, timeout) {
  128530. var _this = this;
  128531. if (timeout !== undefined) {
  128532. setTimeout(function () {
  128533. _this._executeOnceBeforeRender(func);
  128534. }, timeout);
  128535. }
  128536. else {
  128537. this._executeOnceBeforeRender(func);
  128538. }
  128539. };
  128540. /** @hidden */
  128541. Scene.prototype._addPendingData = function (data) {
  128542. this._pendingData.push(data);
  128543. };
  128544. /** @hidden */
  128545. Scene.prototype._removePendingData = function (data) {
  128546. var wasLoading = this.isLoading;
  128547. var index = this._pendingData.indexOf(data);
  128548. if (index !== -1) {
  128549. this._pendingData.splice(index, 1);
  128550. }
  128551. if (wasLoading && !this.isLoading) {
  128552. this.onDataLoadedObservable.notifyObservers(this);
  128553. }
  128554. };
  128555. /**
  128556. * Returns the number of items waiting to be loaded
  128557. * @returns the number of items waiting to be loaded
  128558. */
  128559. Scene.prototype.getWaitingItemsCount = function () {
  128560. return this._pendingData.length;
  128561. };
  128562. Object.defineProperty(Scene.prototype, "isLoading", {
  128563. /**
  128564. * Returns a boolean indicating if the scene is still loading data
  128565. */
  128566. get: function () {
  128567. return this._pendingData.length > 0;
  128568. },
  128569. enumerable: true,
  128570. configurable: true
  128571. });
  128572. /**
  128573. * Registers a function to be executed when the scene is ready
  128574. * @param {Function} func - the function to be executed
  128575. */
  128576. Scene.prototype.executeWhenReady = function (func) {
  128577. var _this = this;
  128578. this.onReadyObservable.add(func);
  128579. if (this._executeWhenReadyTimeoutId !== -1) {
  128580. return;
  128581. }
  128582. this._executeWhenReadyTimeoutId = setTimeout(function () {
  128583. _this._checkIsReady();
  128584. }, 150);
  128585. };
  128586. /**
  128587. * Returns a promise that resolves when the scene is ready
  128588. * @returns A promise that resolves when the scene is ready
  128589. */
  128590. Scene.prototype.whenReadyAsync = function () {
  128591. var _this = this;
  128592. return new Promise(function (resolve) {
  128593. _this.executeWhenReady(function () {
  128594. resolve();
  128595. });
  128596. });
  128597. };
  128598. /** @hidden */
  128599. Scene.prototype._checkIsReady = function () {
  128600. var _this = this;
  128601. this._registerTransientComponents();
  128602. if (this.isReady()) {
  128603. this.onReadyObservable.notifyObservers(this);
  128604. this.onReadyObservable.clear();
  128605. this._executeWhenReadyTimeoutId = -1;
  128606. return;
  128607. }
  128608. this._executeWhenReadyTimeoutId = setTimeout(function () {
  128609. _this._checkIsReady();
  128610. }, 150);
  128611. };
  128612. // Animations
  128613. /**
  128614. * Will start the animation sequence of a given target
  128615. * @param target defines the target
  128616. * @param from defines from which frame should animation start
  128617. * @param to defines until which frame should animation run.
  128618. * @param weight defines the weight to apply to the animation (1.0 by default)
  128619. * @param loop defines if the animation loops
  128620. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  128621. * @param onAnimationEnd defines the function to be executed when the animation ends
  128622. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  128623. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  128624. * @param onAnimationLoop defines the callback to call when an animation loops
  128625. * @returns the animatable object created for this animation
  128626. */
  128627. Scene.prototype.beginWeightedAnimation = function (target, from, to, weight, loop, speedRatio, onAnimationEnd, animatable, targetMask, onAnimationLoop) {
  128628. if (weight === void 0) { weight = 1.0; }
  128629. if (speedRatio === void 0) { speedRatio = 1.0; }
  128630. var returnedAnimatable = this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, false, targetMask, onAnimationLoop);
  128631. returnedAnimatable.weight = weight;
  128632. return returnedAnimatable;
  128633. };
  128634. /**
  128635. * Will start the animation sequence of a given target
  128636. * @param target defines the target
  128637. * @param from defines from which frame should animation start
  128638. * @param to defines until which frame should animation run.
  128639. * @param loop defines if the animation loops
  128640. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  128641. * @param onAnimationEnd defines the function to be executed when the animation ends
  128642. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  128643. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  128644. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  128645. * @param onAnimationLoop defines the callback to call when an animation loops
  128646. * @returns the animatable object created for this animation
  128647. */
  128648. Scene.prototype.beginAnimation = function (target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  128649. if (speedRatio === void 0) { speedRatio = 1.0; }
  128650. if (stopCurrent === void 0) { stopCurrent = true; }
  128651. if (from > to && speedRatio > 0) {
  128652. speedRatio *= -1;
  128653. }
  128654. if (stopCurrent) {
  128655. this.stopAnimation(target, undefined, targetMask);
  128656. }
  128657. if (!animatable) {
  128658. animatable = new _Animations_animatable__WEBPACK_IMPORTED_MODULE_14__["Animatable"](this, target, from, to, loop, speedRatio, onAnimationEnd, undefined, onAnimationLoop);
  128659. }
  128660. var shouldRunTargetAnimations = targetMask ? targetMask(target) : true;
  128661. // Local animations
  128662. if (target.animations && shouldRunTargetAnimations) {
  128663. animatable.appendAnimations(target, target.animations);
  128664. }
  128665. // Children animations
  128666. if (target.getAnimatables) {
  128667. var animatables = target.getAnimatables();
  128668. for (var index = 0; index < animatables.length; index++) {
  128669. this.beginAnimation(animatables[index], from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop);
  128670. }
  128671. }
  128672. animatable.reset();
  128673. return animatable;
  128674. };
  128675. /**
  128676. * Will start the animation sequence of a given target and its hierarchy
  128677. * @param target defines the target
  128678. * @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.
  128679. * @param from defines from which frame should animation start
  128680. * @param to defines until which frame should animation run.
  128681. * @param loop defines if the animation loops
  128682. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  128683. * @param onAnimationEnd defines the function to be executed when the animation ends
  128684. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  128685. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  128686. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  128687. * @param onAnimationLoop defines the callback to call when an animation loops
  128688. * @returns the list of created animatables
  128689. */
  128690. Scene.prototype.beginHierarchyAnimation = function (target, directDescendantsOnly, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  128691. if (speedRatio === void 0) { speedRatio = 1.0; }
  128692. if (stopCurrent === void 0) { stopCurrent = true; }
  128693. var children = target.getDescendants(directDescendantsOnly);
  128694. var result = [];
  128695. result.push(this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  128696. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  128697. var child = children_1[_i];
  128698. result.push(this.beginAnimation(child, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  128699. }
  128700. return result;
  128701. };
  128702. /**
  128703. * Begin a new animation on a given node
  128704. * @param target defines the target where the animation will take place
  128705. * @param animations defines the list of animations to start
  128706. * @param from defines the initial value
  128707. * @param to defines the final value
  128708. * @param loop defines if you want animation to loop (off by default)
  128709. * @param speedRatio defines the speed ratio to apply to all animations
  128710. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  128711. * @param onAnimationLoop defines the callback to call when an animation loops
  128712. * @returns the list of created animatables
  128713. */
  128714. Scene.prototype.beginDirectAnimation = function (target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  128715. if (speedRatio === undefined) {
  128716. speedRatio = 1.0;
  128717. }
  128718. var animatable = new _Animations_animatable__WEBPACK_IMPORTED_MODULE_14__["Animatable"](this, target, from, to, loop, speedRatio, onAnimationEnd, animations, onAnimationLoop);
  128719. return animatable;
  128720. };
  128721. /**
  128722. * Begin a new animation on a given node and its hierarchy
  128723. * @param target defines the root node where the animation will take place
  128724. * @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.
  128725. * @param animations defines the list of animations to start
  128726. * @param from defines the initial value
  128727. * @param to defines the final value
  128728. * @param loop defines if you want animation to loop (off by default)
  128729. * @param speedRatio defines the speed ratio to apply to all animations
  128730. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  128731. * @param onAnimationLoop defines the callback to call when an animation loops
  128732. * @returns the list of animatables created for all nodes
  128733. */
  128734. Scene.prototype.beginDirectHierarchyAnimation = function (target, directDescendantsOnly, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  128735. var children = target.getDescendants(directDescendantsOnly);
  128736. var result = [];
  128737. result.push(this.beginDirectAnimation(target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  128738. for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
  128739. var child = children_2[_i];
  128740. result.push(this.beginDirectAnimation(child, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  128741. }
  128742. return result;
  128743. };
  128744. /**
  128745. * Gets the animatable associated with a specific target
  128746. * @param target defines the target of the animatable
  128747. * @returns the required animatable if found
  128748. */
  128749. Scene.prototype.getAnimatableByTarget = function (target) {
  128750. for (var index = 0; index < this._activeAnimatables.length; index++) {
  128751. if (this._activeAnimatables[index].target === target) {
  128752. return this._activeAnimatables[index];
  128753. }
  128754. }
  128755. return null;
  128756. };
  128757. /**
  128758. * Gets all animatables associated with a given target
  128759. * @param target defines the target to look animatables for
  128760. * @returns an array of Animatables
  128761. */
  128762. Scene.prototype.getAllAnimatablesByTarget = function (target) {
  128763. var result = [];
  128764. for (var index = 0; index < this._activeAnimatables.length; index++) {
  128765. if (this._activeAnimatables[index].target === target) {
  128766. result.push(this._activeAnimatables[index]);
  128767. }
  128768. }
  128769. return result;
  128770. };
  128771. Object.defineProperty(Scene.prototype, "animatables", {
  128772. /**
  128773. * Gets all animatable attached to the scene
  128774. */
  128775. get: function () {
  128776. return this._activeAnimatables;
  128777. },
  128778. enumerable: true,
  128779. configurable: true
  128780. });
  128781. /**
  128782. * Will stop the animation of the given target
  128783. * @param target - the target
  128784. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  128785. * @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)
  128786. */
  128787. Scene.prototype.stopAnimation = function (target, animationName, targetMask) {
  128788. var animatables = this.getAllAnimatablesByTarget(target);
  128789. for (var _i = 0, animatables_1 = animatables; _i < animatables_1.length; _i++) {
  128790. var animatable = animatables_1[_i];
  128791. animatable.stop(animationName, targetMask);
  128792. }
  128793. };
  128794. /**
  128795. * Stops and removes all animations that have been applied to the scene
  128796. */
  128797. Scene.prototype.stopAllAnimations = function () {
  128798. if (this._activeAnimatables) {
  128799. for (var i = 0; i < this._activeAnimatables.length; i++) {
  128800. this._activeAnimatables[i].stop();
  128801. }
  128802. this._activeAnimatables = [];
  128803. }
  128804. for (var _i = 0, _a = this.animationGroups; _i < _a.length; _i++) {
  128805. var group = _a[_i];
  128806. group.stop();
  128807. }
  128808. };
  128809. /**
  128810. * Resets the last animation time frame.
  128811. * Useful to override when animations start running when loading a scene for the first time.
  128812. */
  128813. Scene.prototype.resetLastAnimationTimeFrame = function () {
  128814. this._animationTimeLast = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  128815. };
  128816. Scene.prototype._animate = function () {
  128817. if (!this.animationsEnabled || this._activeAnimatables.length === 0) {
  128818. return;
  128819. }
  128820. // Getting time
  128821. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  128822. if (!this._animationTimeLast) {
  128823. if (this._pendingData.length > 0) {
  128824. return;
  128825. }
  128826. this._animationTimeLast = now;
  128827. }
  128828. var deltaTime = this.useConstantAnimationDeltaTime ? 16.0 : (now - this._animationTimeLast) * this.animationTimeScale;
  128829. this._animationTime += deltaTime;
  128830. this._animationTimeLast = now;
  128831. for (var index = 0; index < this._activeAnimatables.length; index++) {
  128832. this._activeAnimatables[index]._animate(this._animationTime);
  128833. }
  128834. // Late animation bindings
  128835. this._processLateAnimationBindings();
  128836. };
  128837. /** @hidden */
  128838. Scene.prototype._registerTargetForLateAnimationBinding = function (runtimeAnimation, originalValue) {
  128839. var target = runtimeAnimation.target;
  128840. this._registeredForLateAnimationBindings.pushNoDuplicate(target);
  128841. if (!target._lateAnimationHolders) {
  128842. target._lateAnimationHolders = {};
  128843. }
  128844. if (!target._lateAnimationHolders[runtimeAnimation.targetPath]) {
  128845. target._lateAnimationHolders[runtimeAnimation.targetPath] = {
  128846. totalWeight: 0,
  128847. animations: [],
  128848. originalValue: originalValue
  128849. };
  128850. }
  128851. target._lateAnimationHolders[runtimeAnimation.targetPath].animations.push(runtimeAnimation);
  128852. target._lateAnimationHolders[runtimeAnimation.targetPath].totalWeight += runtimeAnimation.weight;
  128853. };
  128854. Scene.prototype._processLateAnimationBindingsForMatrices = function (holder) {
  128855. var normalizer = 1.0;
  128856. var finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Vector3[0];
  128857. var finalScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Vector3[1];
  128858. var finalQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Quaternion[0];
  128859. var startIndex = 0;
  128860. var originalAnimation = holder.animations[0];
  128861. var originalValue = holder.originalValue;
  128862. var scale = 1;
  128863. if (holder.totalWeight < 1.0) {
  128864. // We need to mix the original value in
  128865. originalValue.decompose(finalScaling, finalQuaternion, finalPosition);
  128866. scale = 1.0 - holder.totalWeight;
  128867. }
  128868. else {
  128869. startIndex = 1;
  128870. // We need to normalize the weights
  128871. normalizer = holder.totalWeight;
  128872. originalAnimation.currentValue.decompose(finalScaling, finalQuaternion, finalPosition);
  128873. scale = originalAnimation.weight / normalizer;
  128874. if (scale == 1) {
  128875. return originalAnimation.currentValue;
  128876. }
  128877. }
  128878. finalScaling.scaleInPlace(scale);
  128879. finalPosition.scaleInPlace(scale);
  128880. finalQuaternion.scaleInPlace(scale);
  128881. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  128882. var runtimeAnimation = holder.animations[animIndex];
  128883. var scale = runtimeAnimation.weight / normalizer;
  128884. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Vector3[2];
  128885. var currentScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Vector3[3];
  128886. var currentQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Quaternion[1];
  128887. runtimeAnimation.currentValue.decompose(currentScaling, currentQuaternion, currentPosition);
  128888. currentScaling.scaleAndAddToRef(scale, finalScaling);
  128889. currentQuaternion.scaleAndAddToRef(scale, finalQuaternion);
  128890. currentPosition.scaleAndAddToRef(scale, finalPosition);
  128891. }
  128892. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].ComposeToRef(finalScaling, finalQuaternion, finalPosition, originalAnimation._workValue);
  128893. return originalAnimation._workValue;
  128894. };
  128895. Scene.prototype._processLateAnimationBindingsForQuaternions = function (holder, refQuaternion) {
  128896. var originalAnimation = holder.animations[0];
  128897. var originalValue = holder.originalValue;
  128898. if (holder.animations.length === 1) {
  128899. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Quaternion"].SlerpToRef(originalValue, originalAnimation.currentValue, Math.min(1.0, holder.totalWeight), refQuaternion);
  128900. return refQuaternion;
  128901. }
  128902. var normalizer = 1.0;
  128903. var quaternions;
  128904. var weights;
  128905. if (holder.totalWeight < 1.0) {
  128906. var scale = 1.0 - holder.totalWeight;
  128907. quaternions = [];
  128908. weights = [];
  128909. quaternions.push(originalValue);
  128910. weights.push(scale);
  128911. }
  128912. else {
  128913. if (holder.animations.length === 2) { // Slerp as soon as we can
  128914. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Quaternion"].SlerpToRef(holder.animations[0].currentValue, holder.animations[1].currentValue, holder.animations[1].weight / holder.totalWeight, refQuaternion);
  128915. return refQuaternion;
  128916. }
  128917. quaternions = [];
  128918. weights = [];
  128919. normalizer = holder.totalWeight;
  128920. }
  128921. for (var animIndex = 0; animIndex < holder.animations.length; animIndex++) {
  128922. var runtimeAnimation = holder.animations[animIndex];
  128923. quaternions.push(runtimeAnimation.currentValue);
  128924. weights.push(runtimeAnimation.weight / normalizer);
  128925. }
  128926. // https://gamedev.stackexchange.com/questions/62354/method-for-interpolation-between-3-quaternions
  128927. var cumulativeAmount = 0;
  128928. var cumulativeQuaternion = null;
  128929. for (var index = 0; index < quaternions.length;) {
  128930. if (!cumulativeQuaternion) {
  128931. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Quaternion"].SlerpToRef(quaternions[index], quaternions[index + 1], weights[index + 1] / (weights[index] + weights[index + 1]), refQuaternion);
  128932. cumulativeQuaternion = refQuaternion;
  128933. cumulativeAmount = weights[index] + weights[index + 1];
  128934. index += 2;
  128935. continue;
  128936. }
  128937. cumulativeAmount += weights[index];
  128938. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Quaternion"].SlerpToRef(cumulativeQuaternion, quaternions[index], weights[index] / cumulativeAmount, cumulativeQuaternion);
  128939. index++;
  128940. }
  128941. return cumulativeQuaternion;
  128942. };
  128943. Scene.prototype._processLateAnimationBindings = function () {
  128944. if (!this._registeredForLateAnimationBindings.length) {
  128945. return;
  128946. }
  128947. for (var index = 0; index < this._registeredForLateAnimationBindings.length; index++) {
  128948. var target = this._registeredForLateAnimationBindings.data[index];
  128949. for (var path in target._lateAnimationHolders) {
  128950. var holder = target._lateAnimationHolders[path];
  128951. var originalAnimation = holder.animations[0];
  128952. var originalValue = holder.originalValue;
  128953. var matrixDecomposeMode = _Animations_animation__WEBPACK_IMPORTED_MODULE_13__["Animation"].AllowMatrixDecomposeForInterpolation && originalValue.m; // ie. data is matrix
  128954. var finalValue = target[path];
  128955. if (matrixDecomposeMode) {
  128956. finalValue = this._processLateAnimationBindingsForMatrices(holder);
  128957. }
  128958. else {
  128959. var quaternionMode = originalValue.w !== undefined;
  128960. if (quaternionMode) {
  128961. finalValue = this._processLateAnimationBindingsForQuaternions(holder, finalValue || _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Quaternion"].Identity());
  128962. }
  128963. else {
  128964. var startIndex = 0;
  128965. var normalizer = 1.0;
  128966. if (holder.totalWeight < 1.0) {
  128967. // We need to mix the original value in
  128968. if (originalValue.scale) {
  128969. finalValue = originalValue.scale(1.0 - holder.totalWeight);
  128970. }
  128971. else {
  128972. finalValue = originalValue * (1.0 - holder.totalWeight);
  128973. }
  128974. }
  128975. else {
  128976. // We need to normalize the weights
  128977. normalizer = holder.totalWeight;
  128978. var scale_1 = originalAnimation.weight / normalizer;
  128979. if (scale_1 !== 1) {
  128980. if (originalAnimation.currentValue.scale) {
  128981. finalValue = originalAnimation.currentValue.scale(scale_1);
  128982. }
  128983. else {
  128984. finalValue = originalAnimation.currentValue * scale_1;
  128985. }
  128986. }
  128987. else {
  128988. finalValue = originalAnimation.currentValue;
  128989. }
  128990. startIndex = 1;
  128991. }
  128992. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  128993. var runtimeAnimation = holder.animations[animIndex];
  128994. var scale = runtimeAnimation.weight / normalizer;
  128995. if (runtimeAnimation.currentValue.scaleAndAddToRef) {
  128996. runtimeAnimation.currentValue.scaleAndAddToRef(scale, finalValue);
  128997. }
  128998. else {
  128999. finalValue += runtimeAnimation.currentValue * scale;
  129000. }
  129001. }
  129002. }
  129003. }
  129004. target[path] = finalValue;
  129005. }
  129006. target._lateAnimationHolders = {};
  129007. }
  129008. this._registeredForLateAnimationBindings.reset();
  129009. };
  129010. // Matrix
  129011. /** @hidden */
  129012. Scene.prototype._switchToAlternateCameraConfiguration = function (active) {
  129013. this._useAlternateCameraConfiguration = active;
  129014. };
  129015. /**
  129016. * Gets the current view matrix
  129017. * @returns a Matrix
  129018. */
  129019. Scene.prototype.getViewMatrix = function () {
  129020. return this._useAlternateCameraConfiguration ? this._alternateViewMatrix : this._viewMatrix;
  129021. };
  129022. /**
  129023. * Gets the current projection matrix
  129024. * @returns a Matrix
  129025. */
  129026. Scene.prototype.getProjectionMatrix = function () {
  129027. return this._useAlternateCameraConfiguration ? this._alternateProjectionMatrix : this._projectionMatrix;
  129028. };
  129029. /**
  129030. * Gets the current transform matrix
  129031. * @returns a Matrix made of View * Projection
  129032. */
  129033. Scene.prototype.getTransformMatrix = function () {
  129034. return this._useAlternateCameraConfiguration ? this._alternateTransformMatrix : this._transformMatrix;
  129035. };
  129036. /**
  129037. * Sets the current transform matrix
  129038. * @param view defines the View matrix to use
  129039. * @param projection defines the Projection matrix to use
  129040. */
  129041. Scene.prototype.setTransformMatrix = function (view, projection) {
  129042. if (this._viewUpdateFlag === view.updateFlag && this._projectionUpdateFlag === projection.updateFlag) {
  129043. return;
  129044. }
  129045. this._viewUpdateFlag = view.updateFlag;
  129046. this._projectionUpdateFlag = projection.updateFlag;
  129047. this._viewMatrix = view;
  129048. this._projectionMatrix = projection;
  129049. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  129050. // Update frustum
  129051. if (!this._frustumPlanes) {
  129052. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanes(this._transformMatrix);
  129053. }
  129054. else {
  129055. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  129056. }
  129057. if (this.activeCamera && this.activeCamera._alternateCamera) {
  129058. var otherCamera = this.activeCamera._alternateCamera;
  129059. otherCamera.getViewMatrix().multiplyToRef(otherCamera.getProjectionMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Matrix[0]);
  129060. _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
  129061. }
  129062. if (this._sceneUbo.useUbo) {
  129063. this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix);
  129064. this._sceneUbo.updateMatrix("view", this._viewMatrix);
  129065. this._sceneUbo.update();
  129066. }
  129067. };
  129068. /** @hidden */
  129069. Scene.prototype._setAlternateTransformMatrix = function (view, projection) {
  129070. if (this._alternateViewUpdateFlag === view.updateFlag && this._alternateProjectionUpdateFlag === projection.updateFlag) {
  129071. return;
  129072. }
  129073. this._alternateViewUpdateFlag = view.updateFlag;
  129074. this._alternateProjectionUpdateFlag = projection.updateFlag;
  129075. this._alternateViewMatrix = view;
  129076. this._alternateProjectionMatrix = projection;
  129077. if (!this._alternateTransformMatrix) {
  129078. this._alternateTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  129079. }
  129080. this._alternateViewMatrix.multiplyToRef(this._alternateProjectionMatrix, this._alternateTransformMatrix);
  129081. if (!this._alternateSceneUbo) {
  129082. this._createAlternateUbo();
  129083. }
  129084. if (this._alternateSceneUbo.useUbo) {
  129085. this._alternateSceneUbo.updateMatrix("viewProjection", this._alternateTransformMatrix);
  129086. this._alternateSceneUbo.updateMatrix("view", this._alternateViewMatrix);
  129087. this._alternateSceneUbo.update();
  129088. }
  129089. };
  129090. /**
  129091. * Gets the uniform buffer used to store scene data
  129092. * @returns a UniformBuffer
  129093. */
  129094. Scene.prototype.getSceneUniformBuffer = function () {
  129095. return this._useAlternateCameraConfiguration ? this._alternateSceneUbo : this._sceneUbo;
  129096. };
  129097. /**
  129098. * Gets an unique (relatively to the current scene) Id
  129099. * @returns an unique number for the scene
  129100. */
  129101. Scene.prototype.getUniqueId = function () {
  129102. var result = Scene._uniqueIdCounter;
  129103. Scene._uniqueIdCounter++;
  129104. return result;
  129105. };
  129106. /**
  129107. * Add a mesh to the list of scene's meshes
  129108. * @param newMesh defines the mesh to add
  129109. * @param recursive if all child meshes should also be added to the scene
  129110. */
  129111. Scene.prototype.addMesh = function (newMesh, recursive) {
  129112. var _this = this;
  129113. if (recursive === void 0) { recursive = false; }
  129114. this.meshes.push(newMesh);
  129115. //notify the collision coordinator
  129116. if (this.collisionCoordinator) {
  129117. this.collisionCoordinator.onMeshAdded(newMesh);
  129118. }
  129119. newMesh._resyncLightSources();
  129120. this.onNewMeshAddedObservable.notifyObservers(newMesh);
  129121. if (recursive) {
  129122. newMesh.getChildMeshes().forEach(function (m) {
  129123. _this.addMesh(m);
  129124. });
  129125. }
  129126. };
  129127. /**
  129128. * Remove a mesh for the list of scene's meshes
  129129. * @param toRemove defines the mesh to remove
  129130. * @param recursive if all child meshes should also be removed from the scene
  129131. * @returns the index where the mesh was in the mesh list
  129132. */
  129133. Scene.prototype.removeMesh = function (toRemove, recursive) {
  129134. var _this = this;
  129135. if (recursive === void 0) { recursive = false; }
  129136. var index = this.meshes.indexOf(toRemove);
  129137. if (index !== -1) {
  129138. // Remove from the scene if mesh found
  129139. this.meshes[index] = this.meshes[this.meshes.length - 1];
  129140. this.meshes.pop();
  129141. }
  129142. this.onMeshRemovedObservable.notifyObservers(toRemove);
  129143. if (recursive) {
  129144. toRemove.getChildMeshes().forEach(function (m) {
  129145. _this.removeMesh(m);
  129146. });
  129147. }
  129148. return index;
  129149. };
  129150. /**
  129151. * Add a transform node to the list of scene's transform nodes
  129152. * @param newTransformNode defines the transform node to add
  129153. */
  129154. Scene.prototype.addTransformNode = function (newTransformNode) {
  129155. newTransformNode._indexInSceneTransformNodesArray = this.transformNodes.length;
  129156. this.transformNodes.push(newTransformNode);
  129157. this.onNewTransformNodeAddedObservable.notifyObservers(newTransformNode);
  129158. };
  129159. /**
  129160. * Remove a transform node for the list of scene's transform nodes
  129161. * @param toRemove defines the transform node to remove
  129162. * @returns the index where the transform node was in the transform node list
  129163. */
  129164. Scene.prototype.removeTransformNode = function (toRemove) {
  129165. var index = toRemove._indexInSceneTransformNodesArray;
  129166. if (index !== -1) {
  129167. if (index !== this.transformNodes.length - 1) {
  129168. var lastNode = this.transformNodes[this.transformNodes.length - 1];
  129169. this.transformNodes[index] = lastNode;
  129170. lastNode._indexInSceneTransformNodesArray = index;
  129171. }
  129172. toRemove._indexInSceneTransformNodesArray = -1;
  129173. this.transformNodes.pop();
  129174. }
  129175. this.onTransformNodeRemovedObservable.notifyObservers(toRemove);
  129176. return index;
  129177. };
  129178. /**
  129179. * Remove a skeleton for the list of scene's skeletons
  129180. * @param toRemove defines the skeleton to remove
  129181. * @returns the index where the skeleton was in the skeleton list
  129182. */
  129183. Scene.prototype.removeSkeleton = function (toRemove) {
  129184. var index = this.skeletons.indexOf(toRemove);
  129185. if (index !== -1) {
  129186. // Remove from the scene if found
  129187. this.skeletons.splice(index, 1);
  129188. }
  129189. return index;
  129190. };
  129191. /**
  129192. * Remove a morph target for the list of scene's morph targets
  129193. * @param toRemove defines the morph target to remove
  129194. * @returns the index where the morph target was in the morph target list
  129195. */
  129196. Scene.prototype.removeMorphTargetManager = function (toRemove) {
  129197. var index = this.morphTargetManagers.indexOf(toRemove);
  129198. if (index !== -1) {
  129199. // Remove from the scene if found
  129200. this.morphTargetManagers.splice(index, 1);
  129201. }
  129202. return index;
  129203. };
  129204. /**
  129205. * Remove a light for the list of scene's lights
  129206. * @param toRemove defines the light to remove
  129207. * @returns the index where the light was in the light list
  129208. */
  129209. Scene.prototype.removeLight = function (toRemove) {
  129210. var index = this.lights.indexOf(toRemove);
  129211. if (index !== -1) {
  129212. // Remove from meshes
  129213. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  129214. var mesh = _a[_i];
  129215. mesh._removeLightSource(toRemove);
  129216. }
  129217. // Remove from the scene if mesh found
  129218. this.lights.splice(index, 1);
  129219. this.sortLightsByPriority();
  129220. }
  129221. this.onLightRemovedObservable.notifyObservers(toRemove);
  129222. return index;
  129223. };
  129224. /**
  129225. * Remove a camera for the list of scene's cameras
  129226. * @param toRemove defines the camera to remove
  129227. * @returns the index where the camera was in the camera list
  129228. */
  129229. Scene.prototype.removeCamera = function (toRemove) {
  129230. var index = this.cameras.indexOf(toRemove);
  129231. if (index !== -1) {
  129232. // Remove from the scene if mesh found
  129233. this.cameras.splice(index, 1);
  129234. }
  129235. // Remove from activeCameras
  129236. var index2 = this.activeCameras.indexOf(toRemove);
  129237. if (index2 !== -1) {
  129238. // Remove from the scene if mesh found
  129239. this.activeCameras.splice(index2, 1);
  129240. }
  129241. // Reset the activeCamera
  129242. if (this.activeCamera === toRemove) {
  129243. if (this.cameras.length > 0) {
  129244. this.activeCamera = this.cameras[0];
  129245. }
  129246. else {
  129247. this.activeCamera = null;
  129248. }
  129249. }
  129250. this.onCameraRemovedObservable.notifyObservers(toRemove);
  129251. return index;
  129252. };
  129253. /**
  129254. * Remove a particle system for the list of scene's particle systems
  129255. * @param toRemove defines the particle system to remove
  129256. * @returns the index where the particle system was in the particle system list
  129257. */
  129258. Scene.prototype.removeParticleSystem = function (toRemove) {
  129259. var index = this.particleSystems.indexOf(toRemove);
  129260. if (index !== -1) {
  129261. this.particleSystems.splice(index, 1);
  129262. }
  129263. return index;
  129264. };
  129265. /**
  129266. * Remove a animation for the list of scene's animations
  129267. * @param toRemove defines the animation to remove
  129268. * @returns the index where the animation was in the animation list
  129269. */
  129270. Scene.prototype.removeAnimation = function (toRemove) {
  129271. var index = this.animations.indexOf(toRemove);
  129272. if (index !== -1) {
  129273. this.animations.splice(index, 1);
  129274. }
  129275. return index;
  129276. };
  129277. /**
  129278. * Removes the given animation group from this scene.
  129279. * @param toRemove The animation group to remove
  129280. * @returns The index of the removed animation group
  129281. */
  129282. Scene.prototype.removeAnimationGroup = function (toRemove) {
  129283. var index = this.animationGroups.indexOf(toRemove);
  129284. if (index !== -1) {
  129285. this.animationGroups.splice(index, 1);
  129286. }
  129287. return index;
  129288. };
  129289. /**
  129290. * Removes the given multi-material from this scene.
  129291. * @param toRemove The multi-material to remove
  129292. * @returns The index of the removed multi-material
  129293. */
  129294. Scene.prototype.removeMultiMaterial = function (toRemove) {
  129295. var index = this.multiMaterials.indexOf(toRemove);
  129296. if (index !== -1) {
  129297. this.multiMaterials.splice(index, 1);
  129298. }
  129299. return index;
  129300. };
  129301. /**
  129302. * Removes the given material from this scene.
  129303. * @param toRemove The material to remove
  129304. * @returns The index of the removed material
  129305. */
  129306. Scene.prototype.removeMaterial = function (toRemove) {
  129307. var index = toRemove._indexInSceneMaterialArray;
  129308. if (index !== -1 && index < this.materials.length) {
  129309. if (index !== this.materials.length - 1) {
  129310. var lastMaterial = this.materials[this.materials.length - 1];
  129311. this.materials[index] = lastMaterial;
  129312. lastMaterial._indexInSceneMaterialArray = index;
  129313. }
  129314. toRemove._indexInSceneMaterialArray = -1;
  129315. this.materials.pop();
  129316. }
  129317. this.onMaterialRemovedObservable.notifyObservers(toRemove);
  129318. return index;
  129319. };
  129320. /**
  129321. * Removes the given action manager from this scene.
  129322. * @param toRemove The action manager to remove
  129323. * @returns The index of the removed action manager
  129324. */
  129325. Scene.prototype.removeActionManager = function (toRemove) {
  129326. var index = this.actionManagers.indexOf(toRemove);
  129327. if (index !== -1) {
  129328. this.actionManagers.splice(index, 1);
  129329. }
  129330. return index;
  129331. };
  129332. /**
  129333. * Removes the given texture from this scene.
  129334. * @param toRemove The texture to remove
  129335. * @returns The index of the removed texture
  129336. */
  129337. Scene.prototype.removeTexture = function (toRemove) {
  129338. var index = this.textures.indexOf(toRemove);
  129339. if (index !== -1) {
  129340. this.textures.splice(index, 1);
  129341. }
  129342. this.onTextureRemovedObservable.notifyObservers(toRemove);
  129343. return index;
  129344. };
  129345. /**
  129346. * Adds the given light to this scene
  129347. * @param newLight The light to add
  129348. */
  129349. Scene.prototype.addLight = function (newLight) {
  129350. this.lights.push(newLight);
  129351. this.sortLightsByPriority();
  129352. // Add light to all meshes (To support if the light is removed and then readded)
  129353. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  129354. var mesh = _a[_i];
  129355. if (mesh._lightSources.indexOf(newLight) === -1) {
  129356. mesh._lightSources.push(newLight);
  129357. mesh._resyncLightSources();
  129358. }
  129359. }
  129360. this.onNewLightAddedObservable.notifyObservers(newLight);
  129361. };
  129362. /**
  129363. * Sorts the list list based on light priorities
  129364. */
  129365. Scene.prototype.sortLightsByPriority = function () {
  129366. if (this.requireLightSorting) {
  129367. this.lights.sort(_Lights_light__WEBPACK_IMPORTED_MODULE_15__["Light"].CompareLightsPriority);
  129368. }
  129369. };
  129370. /**
  129371. * Adds the given camera to this scene
  129372. * @param newCamera The camera to add
  129373. */
  129374. Scene.prototype.addCamera = function (newCamera) {
  129375. this.cameras.push(newCamera);
  129376. this.onNewCameraAddedObservable.notifyObservers(newCamera);
  129377. };
  129378. /**
  129379. * Adds the given skeleton to this scene
  129380. * @param newSkeleton The skeleton to add
  129381. */
  129382. Scene.prototype.addSkeleton = function (newSkeleton) {
  129383. this.skeletons.push(newSkeleton);
  129384. };
  129385. /**
  129386. * Adds the given particle system to this scene
  129387. * @param newParticleSystem The particle system to add
  129388. */
  129389. Scene.prototype.addParticleSystem = function (newParticleSystem) {
  129390. this.particleSystems.push(newParticleSystem);
  129391. };
  129392. /**
  129393. * Adds the given animation to this scene
  129394. * @param newAnimation The animation to add
  129395. */
  129396. Scene.prototype.addAnimation = function (newAnimation) {
  129397. this.animations.push(newAnimation);
  129398. };
  129399. /**
  129400. * Adds the given animation group to this scene.
  129401. * @param newAnimationGroup The animation group to add
  129402. */
  129403. Scene.prototype.addAnimationGroup = function (newAnimationGroup) {
  129404. this.animationGroups.push(newAnimationGroup);
  129405. };
  129406. /**
  129407. * Adds the given multi-material to this scene
  129408. * @param newMultiMaterial The multi-material to add
  129409. */
  129410. Scene.prototype.addMultiMaterial = function (newMultiMaterial) {
  129411. this.multiMaterials.push(newMultiMaterial);
  129412. };
  129413. /**
  129414. * Adds the given material to this scene
  129415. * @param newMaterial The material to add
  129416. */
  129417. Scene.prototype.addMaterial = function (newMaterial) {
  129418. newMaterial._indexInSceneMaterialArray = this.materials.length;
  129419. this.materials.push(newMaterial);
  129420. this.onNewMaterialAddedObservable.notifyObservers(newMaterial);
  129421. };
  129422. /**
  129423. * Adds the given morph target to this scene
  129424. * @param newMorphTargetManager The morph target to add
  129425. */
  129426. Scene.prototype.addMorphTargetManager = function (newMorphTargetManager) {
  129427. this.morphTargetManagers.push(newMorphTargetManager);
  129428. };
  129429. /**
  129430. * Adds the given geometry to this scene
  129431. * @param newGeometry The geometry to add
  129432. */
  129433. Scene.prototype.addGeometry = function (newGeometry) {
  129434. if (this.geometriesByUniqueId) {
  129435. this.geometriesByUniqueId[newGeometry.uniqueId] = this.geometries.length;
  129436. }
  129437. this.geometries.push(newGeometry);
  129438. };
  129439. /**
  129440. * Adds the given action manager to this scene
  129441. * @param newActionManager The action manager to add
  129442. */
  129443. Scene.prototype.addActionManager = function (newActionManager) {
  129444. this.actionManagers.push(newActionManager);
  129445. };
  129446. /**
  129447. * Adds the given texture to this scene.
  129448. * @param newTexture The texture to add
  129449. */
  129450. Scene.prototype.addTexture = function (newTexture) {
  129451. this.textures.push(newTexture);
  129452. this.onNewTextureAddedObservable.notifyObservers(newTexture);
  129453. };
  129454. /**
  129455. * Switch active camera
  129456. * @param newCamera defines the new active camera
  129457. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  129458. */
  129459. Scene.prototype.switchActiveCamera = function (newCamera, attachControl) {
  129460. if (attachControl === void 0) { attachControl = true; }
  129461. var canvas = this._engine.getRenderingCanvas();
  129462. if (!canvas) {
  129463. return;
  129464. }
  129465. if (this.activeCamera) {
  129466. this.activeCamera.detachControl(canvas);
  129467. }
  129468. this.activeCamera = newCamera;
  129469. if (attachControl) {
  129470. newCamera.attachControl(canvas);
  129471. }
  129472. };
  129473. /**
  129474. * sets the active camera of the scene using its ID
  129475. * @param id defines the camera's ID
  129476. * @return the new active camera or null if none found.
  129477. */
  129478. Scene.prototype.setActiveCameraByID = function (id) {
  129479. var camera = this.getCameraByID(id);
  129480. if (camera) {
  129481. this.activeCamera = camera;
  129482. return camera;
  129483. }
  129484. return null;
  129485. };
  129486. /**
  129487. * sets the active camera of the scene using its name
  129488. * @param name defines the camera's name
  129489. * @returns the new active camera or null if none found.
  129490. */
  129491. Scene.prototype.setActiveCameraByName = function (name) {
  129492. var camera = this.getCameraByName(name);
  129493. if (camera) {
  129494. this.activeCamera = camera;
  129495. return camera;
  129496. }
  129497. return null;
  129498. };
  129499. /**
  129500. * get an animation group using its name
  129501. * @param name defines the material's name
  129502. * @return the animation group or null if none found.
  129503. */
  129504. Scene.prototype.getAnimationGroupByName = function (name) {
  129505. for (var index = 0; index < this.animationGroups.length; index++) {
  129506. if (this.animationGroups[index].name === name) {
  129507. return this.animationGroups[index];
  129508. }
  129509. }
  129510. return null;
  129511. };
  129512. /**
  129513. * get a material using its id
  129514. * @param id defines the material's ID
  129515. * @return the material or null if none found.
  129516. */
  129517. Scene.prototype.getMaterialByID = function (id) {
  129518. for (var index = 0; index < this.materials.length; index++) {
  129519. if (this.materials[index].id === id) {
  129520. return this.materials[index];
  129521. }
  129522. }
  129523. return null;
  129524. };
  129525. /**
  129526. * Gets a material using its name
  129527. * @param name defines the material's name
  129528. * @return the material or null if none found.
  129529. */
  129530. Scene.prototype.getMaterialByName = function (name) {
  129531. for (var index = 0; index < this.materials.length; index++) {
  129532. if (this.materials[index].name === name) {
  129533. return this.materials[index];
  129534. }
  129535. }
  129536. return null;
  129537. };
  129538. /**
  129539. * Gets a camera using its id
  129540. * @param id defines the id to look for
  129541. * @returns the camera or null if not found
  129542. */
  129543. Scene.prototype.getCameraByID = function (id) {
  129544. for (var index = 0; index < this.cameras.length; index++) {
  129545. if (this.cameras[index].id === id) {
  129546. return this.cameras[index];
  129547. }
  129548. }
  129549. return null;
  129550. };
  129551. /**
  129552. * Gets a camera using its unique id
  129553. * @param uniqueId defines the unique id to look for
  129554. * @returns the camera or null if not found
  129555. */
  129556. Scene.prototype.getCameraByUniqueID = function (uniqueId) {
  129557. for (var index = 0; index < this.cameras.length; index++) {
  129558. if (this.cameras[index].uniqueId === uniqueId) {
  129559. return this.cameras[index];
  129560. }
  129561. }
  129562. return null;
  129563. };
  129564. /**
  129565. * Gets a camera using its name
  129566. * @param name defines the camera's name
  129567. * @return the camera or null if none found.
  129568. */
  129569. Scene.prototype.getCameraByName = function (name) {
  129570. for (var index = 0; index < this.cameras.length; index++) {
  129571. if (this.cameras[index].name === name) {
  129572. return this.cameras[index];
  129573. }
  129574. }
  129575. return null;
  129576. };
  129577. /**
  129578. * Gets a bone using its id
  129579. * @param id defines the bone's id
  129580. * @return the bone or null if not found
  129581. */
  129582. Scene.prototype.getBoneByID = function (id) {
  129583. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  129584. var skeleton = this.skeletons[skeletonIndex];
  129585. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  129586. if (skeleton.bones[boneIndex].id === id) {
  129587. return skeleton.bones[boneIndex];
  129588. }
  129589. }
  129590. }
  129591. return null;
  129592. };
  129593. /**
  129594. * Gets a bone using its id
  129595. * @param name defines the bone's name
  129596. * @return the bone or null if not found
  129597. */
  129598. Scene.prototype.getBoneByName = function (name) {
  129599. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  129600. var skeleton = this.skeletons[skeletonIndex];
  129601. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  129602. if (skeleton.bones[boneIndex].name === name) {
  129603. return skeleton.bones[boneIndex];
  129604. }
  129605. }
  129606. }
  129607. return null;
  129608. };
  129609. /**
  129610. * Gets a light node using its name
  129611. * @param name defines the the light's name
  129612. * @return the light or null if none found.
  129613. */
  129614. Scene.prototype.getLightByName = function (name) {
  129615. for (var index = 0; index < this.lights.length; index++) {
  129616. if (this.lights[index].name === name) {
  129617. return this.lights[index];
  129618. }
  129619. }
  129620. return null;
  129621. };
  129622. /**
  129623. * Gets a light node using its id
  129624. * @param id defines the light's id
  129625. * @return the light or null if none found.
  129626. */
  129627. Scene.prototype.getLightByID = function (id) {
  129628. for (var index = 0; index < this.lights.length; index++) {
  129629. if (this.lights[index].id === id) {
  129630. return this.lights[index];
  129631. }
  129632. }
  129633. return null;
  129634. };
  129635. /**
  129636. * Gets a light node using its scene-generated unique ID
  129637. * @param uniqueId defines the light's unique id
  129638. * @return the light or null if none found.
  129639. */
  129640. Scene.prototype.getLightByUniqueID = function (uniqueId) {
  129641. for (var index = 0; index < this.lights.length; index++) {
  129642. if (this.lights[index].uniqueId === uniqueId) {
  129643. return this.lights[index];
  129644. }
  129645. }
  129646. return null;
  129647. };
  129648. /**
  129649. * Gets a particle system by id
  129650. * @param id defines the particle system id
  129651. * @return the corresponding system or null if none found
  129652. */
  129653. Scene.prototype.getParticleSystemByID = function (id) {
  129654. for (var index = 0; index < this.particleSystems.length; index++) {
  129655. if (this.particleSystems[index].id === id) {
  129656. return this.particleSystems[index];
  129657. }
  129658. }
  129659. return null;
  129660. };
  129661. /**
  129662. * Gets a geometry using its ID
  129663. * @param id defines the geometry's id
  129664. * @return the geometry or null if none found.
  129665. */
  129666. Scene.prototype.getGeometryByID = function (id) {
  129667. for (var index = 0; index < this.geometries.length; index++) {
  129668. if (this.geometries[index].id === id) {
  129669. return this.geometries[index];
  129670. }
  129671. }
  129672. return null;
  129673. };
  129674. Scene.prototype._getGeometryByUniqueID = function (uniqueId) {
  129675. if (this.geometriesByUniqueId) {
  129676. var index_1 = this.geometriesByUniqueId[uniqueId];
  129677. if (index_1 !== undefined) {
  129678. return this.geometries[index_1];
  129679. }
  129680. }
  129681. else {
  129682. for (var index = 0; index < this.geometries.length; index++) {
  129683. if (this.geometries[index].uniqueId === uniqueId) {
  129684. return this.geometries[index];
  129685. }
  129686. }
  129687. }
  129688. return null;
  129689. };
  129690. /**
  129691. * Add a new geometry to this scene
  129692. * @param geometry defines the geometry to be added to the scene.
  129693. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  129694. * @return a boolean defining if the geometry was added or not
  129695. */
  129696. Scene.prototype.pushGeometry = function (geometry, force) {
  129697. if (!force && this._getGeometryByUniqueID(geometry.uniqueId)) {
  129698. return false;
  129699. }
  129700. this.addGeometry(geometry);
  129701. //notify the collision coordinator
  129702. if (this.collisionCoordinator) {
  129703. this.collisionCoordinator.onGeometryAdded(geometry);
  129704. }
  129705. this.onNewGeometryAddedObservable.notifyObservers(geometry);
  129706. return true;
  129707. };
  129708. /**
  129709. * Removes an existing geometry
  129710. * @param geometry defines the geometry to be removed from the scene
  129711. * @return a boolean defining if the geometry was removed or not
  129712. */
  129713. Scene.prototype.removeGeometry = function (geometry) {
  129714. var index;
  129715. if (this.geometriesByUniqueId) {
  129716. index = this.geometriesByUniqueId[geometry.uniqueId];
  129717. if (index === undefined) {
  129718. return false;
  129719. }
  129720. }
  129721. else {
  129722. index = this.geometries.indexOf(geometry);
  129723. if (index < 0) {
  129724. return false;
  129725. }
  129726. }
  129727. if (index !== this.geometries.length - 1) {
  129728. var lastGeometry = this.geometries[this.geometries.length - 1];
  129729. this.geometries[index] = lastGeometry;
  129730. if (this.geometriesByUniqueId) {
  129731. this.geometriesByUniqueId[lastGeometry.uniqueId] = index;
  129732. this.geometriesByUniqueId[geometry.uniqueId] = undefined;
  129733. }
  129734. }
  129735. this.geometries.pop();
  129736. //notify the collision coordinator
  129737. if (this.collisionCoordinator) {
  129738. this.collisionCoordinator.onGeometryDeleted(geometry);
  129739. }
  129740. this.onGeometryRemovedObservable.notifyObservers(geometry);
  129741. return true;
  129742. };
  129743. /**
  129744. * Gets the list of geometries attached to the scene
  129745. * @returns an array of Geometry
  129746. */
  129747. Scene.prototype.getGeometries = function () {
  129748. return this.geometries;
  129749. };
  129750. /**
  129751. * Gets the first added mesh found of a given ID
  129752. * @param id defines the id to search for
  129753. * @return the mesh found or null if not found at all
  129754. */
  129755. Scene.prototype.getMeshByID = function (id) {
  129756. for (var index = 0; index < this.meshes.length; index++) {
  129757. if (this.meshes[index].id === id) {
  129758. return this.meshes[index];
  129759. }
  129760. }
  129761. return null;
  129762. };
  129763. /**
  129764. * Gets a list of meshes using their id
  129765. * @param id defines the id to search for
  129766. * @returns a list of meshes
  129767. */
  129768. Scene.prototype.getMeshesByID = function (id) {
  129769. return this.meshes.filter(function (m) {
  129770. return m.id === id;
  129771. });
  129772. };
  129773. /**
  129774. * Gets the first added transform node found of a given ID
  129775. * @param id defines the id to search for
  129776. * @return the found transform node or null if not found at all.
  129777. */
  129778. Scene.prototype.getTransformNodeByID = function (id) {
  129779. for (var index = 0; index < this.transformNodes.length; index++) {
  129780. if (this.transformNodes[index].id === id) {
  129781. return this.transformNodes[index];
  129782. }
  129783. }
  129784. return null;
  129785. };
  129786. /**
  129787. * Gets a list of transform nodes using their id
  129788. * @param id defines the id to search for
  129789. * @returns a list of transform nodes
  129790. */
  129791. Scene.prototype.getTransformNodesByID = function (id) {
  129792. return this.transformNodes.filter(function (m) {
  129793. return m.id === id;
  129794. });
  129795. };
  129796. /**
  129797. * Gets a mesh with its auto-generated unique id
  129798. * @param uniqueId defines the unique id to search for
  129799. * @return the found mesh or null if not found at all.
  129800. */
  129801. Scene.prototype.getMeshByUniqueID = function (uniqueId) {
  129802. for (var index = 0; index < this.meshes.length; index++) {
  129803. if (this.meshes[index].uniqueId === uniqueId) {
  129804. return this.meshes[index];
  129805. }
  129806. }
  129807. return null;
  129808. };
  129809. /**
  129810. * Gets a the last added mesh using a given id
  129811. * @param id defines the id to search for
  129812. * @return the found mesh or null if not found at all.
  129813. */
  129814. Scene.prototype.getLastMeshByID = function (id) {
  129815. for (var index = this.meshes.length - 1; index >= 0; index--) {
  129816. if (this.meshes[index].id === id) {
  129817. return this.meshes[index];
  129818. }
  129819. }
  129820. return null;
  129821. };
  129822. /**
  129823. * Gets a the last added node (Mesh, Camera, Light) using a given id
  129824. * @param id defines the id to search for
  129825. * @return the found node or null if not found at all
  129826. */
  129827. Scene.prototype.getLastEntryByID = function (id) {
  129828. var index;
  129829. for (index = this.meshes.length - 1; index >= 0; index--) {
  129830. if (this.meshes[index].id === id) {
  129831. return this.meshes[index];
  129832. }
  129833. }
  129834. for (index = this.transformNodes.length - 1; index >= 0; index--) {
  129835. if (this.transformNodes[index].id === id) {
  129836. return this.transformNodes[index];
  129837. }
  129838. }
  129839. for (index = this.cameras.length - 1; index >= 0; index--) {
  129840. if (this.cameras[index].id === id) {
  129841. return this.cameras[index];
  129842. }
  129843. }
  129844. for (index = this.lights.length - 1; index >= 0; index--) {
  129845. if (this.lights[index].id === id) {
  129846. return this.lights[index];
  129847. }
  129848. }
  129849. return null;
  129850. };
  129851. /**
  129852. * Gets a node (Mesh, Camera, Light) using a given id
  129853. * @param id defines the id to search for
  129854. * @return the found node or null if not found at all
  129855. */
  129856. Scene.prototype.getNodeByID = function (id) {
  129857. var mesh = this.getMeshByID(id);
  129858. if (mesh) {
  129859. return mesh;
  129860. }
  129861. var transformNode = this.getTransformNodeByID(id);
  129862. if (transformNode) {
  129863. return transformNode;
  129864. }
  129865. var light = this.getLightByID(id);
  129866. if (light) {
  129867. return light;
  129868. }
  129869. var camera = this.getCameraByID(id);
  129870. if (camera) {
  129871. return camera;
  129872. }
  129873. var bone = this.getBoneByID(id);
  129874. if (bone) {
  129875. return bone;
  129876. }
  129877. return null;
  129878. };
  129879. /**
  129880. * Gets a node (Mesh, Camera, Light) using a given name
  129881. * @param name defines the name to search for
  129882. * @return the found node or null if not found at all.
  129883. */
  129884. Scene.prototype.getNodeByName = function (name) {
  129885. var mesh = this.getMeshByName(name);
  129886. if (mesh) {
  129887. return mesh;
  129888. }
  129889. var transformNode = this.getTransformNodeByName(name);
  129890. if (transformNode) {
  129891. return transformNode;
  129892. }
  129893. var light = this.getLightByName(name);
  129894. if (light) {
  129895. return light;
  129896. }
  129897. var camera = this.getCameraByName(name);
  129898. if (camera) {
  129899. return camera;
  129900. }
  129901. var bone = this.getBoneByName(name);
  129902. if (bone) {
  129903. return bone;
  129904. }
  129905. return null;
  129906. };
  129907. /**
  129908. * Gets a mesh using a given name
  129909. * @param name defines the name to search for
  129910. * @return the found mesh or null if not found at all.
  129911. */
  129912. Scene.prototype.getMeshByName = function (name) {
  129913. for (var index = 0; index < this.meshes.length; index++) {
  129914. if (this.meshes[index].name === name) {
  129915. return this.meshes[index];
  129916. }
  129917. }
  129918. return null;
  129919. };
  129920. /**
  129921. * Gets a transform node using a given name
  129922. * @param name defines the name to search for
  129923. * @return the found transform node or null if not found at all.
  129924. */
  129925. Scene.prototype.getTransformNodeByName = function (name) {
  129926. for (var index = 0; index < this.transformNodes.length; index++) {
  129927. if (this.transformNodes[index].name === name) {
  129928. return this.transformNodes[index];
  129929. }
  129930. }
  129931. return null;
  129932. };
  129933. /**
  129934. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  129935. * @param id defines the id to search for
  129936. * @return the found skeleton or null if not found at all.
  129937. */
  129938. Scene.prototype.getLastSkeletonByID = function (id) {
  129939. for (var index = this.skeletons.length - 1; index >= 0; index--) {
  129940. if (this.skeletons[index].id === id) {
  129941. return this.skeletons[index];
  129942. }
  129943. }
  129944. return null;
  129945. };
  129946. /**
  129947. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  129948. * @param id defines the id to search for
  129949. * @return the found skeleton or null if not found at all.
  129950. */
  129951. Scene.prototype.getSkeletonById = function (id) {
  129952. for (var index = 0; index < this.skeletons.length; index++) {
  129953. if (this.skeletons[index].id === id) {
  129954. return this.skeletons[index];
  129955. }
  129956. }
  129957. return null;
  129958. };
  129959. /**
  129960. * Gets a skeleton using a given name
  129961. * @param name defines the name to search for
  129962. * @return the found skeleton or null if not found at all.
  129963. */
  129964. Scene.prototype.getSkeletonByName = function (name) {
  129965. for (var index = 0; index < this.skeletons.length; index++) {
  129966. if (this.skeletons[index].name === name) {
  129967. return this.skeletons[index];
  129968. }
  129969. }
  129970. return null;
  129971. };
  129972. /**
  129973. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  129974. * @param id defines the id to search for
  129975. * @return the found morph target manager or null if not found at all.
  129976. */
  129977. Scene.prototype.getMorphTargetManagerById = function (id) {
  129978. for (var index = 0; index < this.morphTargetManagers.length; index++) {
  129979. if (this.morphTargetManagers[index].uniqueId === id) {
  129980. return this.morphTargetManagers[index];
  129981. }
  129982. }
  129983. return null;
  129984. };
  129985. /**
  129986. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  129987. * @param id defines the id to search for
  129988. * @return the found morph target or null if not found at all.
  129989. */
  129990. Scene.prototype.getMorphTargetById = function (id) {
  129991. for (var managerIndex = 0; managerIndex < this.morphTargetManagers.length; ++managerIndex) {
  129992. var morphTargetManager = this.morphTargetManagers[managerIndex];
  129993. for (var index = 0; index < morphTargetManager.numTargets; ++index) {
  129994. var target = morphTargetManager.getTarget(index);
  129995. if (target.id === id) {
  129996. return target;
  129997. }
  129998. }
  129999. }
  130000. return null;
  130001. };
  130002. /**
  130003. * Gets a boolean indicating if the given mesh is active
  130004. * @param mesh defines the mesh to look for
  130005. * @returns true if the mesh is in the active list
  130006. */
  130007. Scene.prototype.isActiveMesh = function (mesh) {
  130008. return (this._activeMeshes.indexOf(mesh) !== -1);
  130009. };
  130010. Object.defineProperty(Scene.prototype, "uid", {
  130011. /**
  130012. * Return a unique id as a string which can serve as an identifier for the scene
  130013. */
  130014. get: function () {
  130015. if (!this._uid) {
  130016. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].RandomId();
  130017. }
  130018. return this._uid;
  130019. },
  130020. enumerable: true,
  130021. configurable: true
  130022. });
  130023. /**
  130024. * Add an externaly attached data from its key.
  130025. * This method call will fail and return false, if such key already exists.
  130026. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  130027. * @param key the unique key that identifies the data
  130028. * @param data the data object to associate to the key for this Engine instance
  130029. * @return true if no such key were already present and the data was added successfully, false otherwise
  130030. */
  130031. Scene.prototype.addExternalData = function (key, data) {
  130032. if (!this._externalData) {
  130033. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  130034. }
  130035. return this._externalData.add(key, data);
  130036. };
  130037. /**
  130038. * Get an externaly attached data from its key
  130039. * @param key the unique key that identifies the data
  130040. * @return the associated data, if present (can be null), or undefined if not present
  130041. */
  130042. Scene.prototype.getExternalData = function (key) {
  130043. if (!this._externalData) {
  130044. return null;
  130045. }
  130046. return this._externalData.get(key);
  130047. };
  130048. /**
  130049. * Get an externaly attached data from its key, create it using a factory if it's not already present
  130050. * @param key the unique key that identifies the data
  130051. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  130052. * @return the associated data, can be null if the factory returned null.
  130053. */
  130054. Scene.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  130055. if (!this._externalData) {
  130056. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  130057. }
  130058. return this._externalData.getOrAddWithFactory(key, factory);
  130059. };
  130060. /**
  130061. * Remove an externaly attached data from the Engine instance
  130062. * @param key the unique key that identifies the data
  130063. * @return true if the data was successfully removed, false if it doesn't exist
  130064. */
  130065. Scene.prototype.removeExternalData = function (key) {
  130066. return this._externalData.remove(key);
  130067. };
  130068. Scene.prototype._evaluateSubMesh = function (subMesh, mesh) {
  130069. if (this.dispatchAllSubMeshesOfActiveMeshes || mesh.alwaysSelectAsActiveMesh || mesh.subMeshes.length === 1 || subMesh.isInFrustum(this._frustumPlanes)) {
  130070. for (var _i = 0, _a = this._evaluateSubMeshStage; _i < _a.length; _i++) {
  130071. var step = _a[_i];
  130072. step.action(mesh, subMesh);
  130073. }
  130074. var material = subMesh.getMaterial();
  130075. if (material !== null && material !== undefined) {
  130076. // Render targets
  130077. if (material.hasRenderTargetTextures && material.getRenderTargetTextures !== undefined) {
  130078. if (this._processedMaterials.indexOf(material) === -1) {
  130079. this._processedMaterials.push(material);
  130080. this._renderTargets.concatWithNoDuplicate(material.getRenderTargetTextures());
  130081. }
  130082. }
  130083. // Dispatch
  130084. this._activeIndices.addCount(subMesh.indexCount, false);
  130085. this._renderingManager.dispatch(subMesh, mesh, material);
  130086. }
  130087. }
  130088. };
  130089. /**
  130090. * Clear the processed materials smart array preventing retention point in material dispose.
  130091. */
  130092. Scene.prototype.freeProcessedMaterials = function () {
  130093. this._processedMaterials.dispose();
  130094. };
  130095. Object.defineProperty(Scene.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
  130096. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  130097. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  130098. * when disposing several meshes in a row or a hierarchy of meshes.
  130099. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  130100. */
  130101. get: function () {
  130102. return this._preventFreeActiveMeshesAndRenderingGroups;
  130103. },
  130104. set: function (value) {
  130105. if (this._preventFreeActiveMeshesAndRenderingGroups === value) {
  130106. return;
  130107. }
  130108. if (value) {
  130109. this.freeActiveMeshes();
  130110. this.freeRenderingGroups();
  130111. }
  130112. this._preventFreeActiveMeshesAndRenderingGroups = value;
  130113. },
  130114. enumerable: true,
  130115. configurable: true
  130116. });
  130117. /**
  130118. * Clear the active meshes smart array preventing retention point in mesh dispose.
  130119. */
  130120. Scene.prototype.freeActiveMeshes = function () {
  130121. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  130122. return;
  130123. }
  130124. this._activeMeshes.dispose();
  130125. if (this.activeCamera && this.activeCamera._activeMeshes) {
  130126. this.activeCamera._activeMeshes.dispose();
  130127. }
  130128. if (this.activeCameras) {
  130129. for (var i = 0; i < this.activeCameras.length; i++) {
  130130. var activeCamera = this.activeCameras[i];
  130131. if (activeCamera && activeCamera._activeMeshes) {
  130132. activeCamera._activeMeshes.dispose();
  130133. }
  130134. }
  130135. }
  130136. };
  130137. /**
  130138. * Clear the info related to rendering groups preventing retention points during dispose.
  130139. */
  130140. Scene.prototype.freeRenderingGroups = function () {
  130141. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  130142. return;
  130143. }
  130144. if (this._renderingManager) {
  130145. this._renderingManager.freeRenderingGroups();
  130146. }
  130147. if (this.textures) {
  130148. for (var i = 0; i < this.textures.length; i++) {
  130149. var texture = this.textures[i];
  130150. if (texture && texture.renderList) {
  130151. texture.freeRenderingGroups();
  130152. }
  130153. }
  130154. }
  130155. };
  130156. /** @hidden */
  130157. Scene.prototype._isInIntermediateRendering = function () {
  130158. return this._intermediateRendering;
  130159. };
  130160. /**
  130161. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  130162. * @returns the current scene
  130163. */
  130164. Scene.prototype.freezeActiveMeshes = function () {
  130165. if (!this.activeCamera) {
  130166. return this;
  130167. }
  130168. if (!this._frustumPlanes) {
  130169. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  130170. }
  130171. this._evaluateActiveMeshes();
  130172. this._activeMeshesFrozen = true;
  130173. return this;
  130174. };
  130175. /**
  130176. * Use this function to restart evaluating active meshes on every frame
  130177. * @returns the current scene
  130178. */
  130179. Scene.prototype.unfreezeActiveMeshes = function () {
  130180. this._activeMeshesFrozen = false;
  130181. return this;
  130182. };
  130183. Scene.prototype._evaluateActiveMeshes = function () {
  130184. if (this._activeMeshesFrozen && this._activeMeshes.length) {
  130185. return;
  130186. }
  130187. if (!this.activeCamera) {
  130188. return;
  130189. }
  130190. this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this);
  130191. this.activeCamera._activeMeshes.reset();
  130192. this._activeMeshes.reset();
  130193. this._renderingManager.reset();
  130194. this._processedMaterials.reset();
  130195. this._activeParticleSystems.reset();
  130196. this._activeSkeletons.reset();
  130197. this._softwareSkinnedMeshes.reset();
  130198. for (var _i = 0, _a = this._beforeEvaluateActiveMeshStage; _i < _a.length; _i++) {
  130199. var step = _a[_i];
  130200. step.action();
  130201. }
  130202. // Determine mesh candidates
  130203. var meshes = this.getActiveMeshCandidates();
  130204. // Check each mesh
  130205. var len = meshes.length;
  130206. for (var i = 0; i < len; i++) {
  130207. var mesh = meshes.data[i];
  130208. if (mesh.isBlocked) {
  130209. continue;
  130210. }
  130211. this._totalVertices.addCount(mesh.getTotalVertices(), false);
  130212. if (!mesh.isReady() || !mesh.isEnabled()) {
  130213. continue;
  130214. }
  130215. mesh.computeWorldMatrix();
  130216. // Intersections
  130217. if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionEnterTrigger, _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionExitTrigger)) {
  130218. this._meshesForIntersections.pushNoDuplicate(mesh);
  130219. }
  130220. // Switch to current LOD
  130221. var meshLOD = mesh.getLOD(this.activeCamera);
  130222. if (meshLOD === undefined || meshLOD === null) {
  130223. continue;
  130224. }
  130225. mesh._preActivate();
  130226. if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
  130227. this._activeMeshes.push(mesh);
  130228. this.activeCamera._activeMeshes.push(mesh);
  130229. mesh._activate(this._renderId);
  130230. if (meshLOD !== mesh) {
  130231. meshLOD._activate(this._renderId);
  130232. }
  130233. this._activeMesh(mesh, meshLOD);
  130234. }
  130235. }
  130236. this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this);
  130237. // Particle systems
  130238. if (this.particlesEnabled) {
  130239. this.onBeforeParticlesRenderingObservable.notifyObservers(this);
  130240. for (var particleIndex = 0; particleIndex < this.particleSystems.length; particleIndex++) {
  130241. var particleSystem = this.particleSystems[particleIndex];
  130242. if (!particleSystem.isStarted() || !particleSystem.emitter) {
  130243. continue;
  130244. }
  130245. var emitter = particleSystem.emitter;
  130246. if (!emitter.position || emitter.isEnabled()) {
  130247. this._activeParticleSystems.push(particleSystem);
  130248. particleSystem.animate();
  130249. this._renderingManager.dispatchParticles(particleSystem);
  130250. }
  130251. }
  130252. this.onAfterParticlesRenderingObservable.notifyObservers(this);
  130253. }
  130254. };
  130255. Scene.prototype._activeMesh = function (sourceMesh, mesh) {
  130256. if (this._skeletonsEnabled && mesh.skeleton !== null && mesh.skeleton !== undefined) {
  130257. if (this._activeSkeletons.pushNoDuplicate(mesh.skeleton)) {
  130258. mesh.skeleton.prepare();
  130259. }
  130260. if (!mesh.computeBonesUsingShaders) {
  130261. this._softwareSkinnedMeshes.pushNoDuplicate(mesh);
  130262. }
  130263. }
  130264. for (var _i = 0, _a = this._activeMeshStage; _i < _a.length; _i++) {
  130265. var step = _a[_i];
  130266. step.action(sourceMesh, mesh);
  130267. }
  130268. if (mesh !== undefined && mesh !== null
  130269. && mesh.subMeshes !== undefined && mesh.subMeshes !== null && mesh.subMeshes.length > 0) {
  130270. var subMeshes = this.getActiveSubMeshCandidates(mesh);
  130271. var len = subMeshes.length;
  130272. for (var i = 0; i < len; i++) {
  130273. var subMesh = subMeshes.data[i];
  130274. this._evaluateSubMesh(subMesh, mesh);
  130275. }
  130276. }
  130277. };
  130278. /**
  130279. * Update the transform matrix to update from the current active camera
  130280. * @param force defines a boolean used to force the update even if cache is up to date
  130281. */
  130282. Scene.prototype.updateTransformMatrix = function (force) {
  130283. if (!this.activeCamera) {
  130284. return;
  130285. }
  130286. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(force));
  130287. };
  130288. /**
  130289. * 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)
  130290. * @param alternateCamera defines the camera to use
  130291. */
  130292. Scene.prototype.updateAlternateTransformMatrix = function (alternateCamera) {
  130293. this._setAlternateTransformMatrix(alternateCamera.getViewMatrix(), alternateCamera.getProjectionMatrix());
  130294. };
  130295. Scene.prototype._renderForCamera = function (camera, rigParent) {
  130296. if (camera && camera._skipRendering) {
  130297. return;
  130298. }
  130299. var engine = this._engine;
  130300. this.activeCamera = camera;
  130301. if (!this.activeCamera) {
  130302. throw new Error("Active camera not set");
  130303. }
  130304. // Viewport
  130305. engine.setViewport(this.activeCamera.viewport);
  130306. // Camera
  130307. this.resetCachedMaterial();
  130308. this._renderId++;
  130309. this.updateTransformMatrix();
  130310. if (camera._alternateCamera) {
  130311. this.updateAlternateTransformMatrix(camera._alternateCamera);
  130312. this._alternateRendering = true;
  130313. }
  130314. this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera);
  130315. // Meshes
  130316. this._evaluateActiveMeshes();
  130317. // Software skinning
  130318. for (var softwareSkinnedMeshIndex = 0; softwareSkinnedMeshIndex < this._softwareSkinnedMeshes.length; softwareSkinnedMeshIndex++) {
  130319. var mesh = this._softwareSkinnedMeshes.data[softwareSkinnedMeshIndex];
  130320. mesh.applySkeleton(mesh.skeleton);
  130321. }
  130322. // Render targets
  130323. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  130324. if (camera.customRenderTargets && camera.customRenderTargets.length > 0) {
  130325. this._renderTargets.concatWithNoDuplicate(camera.customRenderTargets);
  130326. }
  130327. if (rigParent && rigParent.customRenderTargets && rigParent.customRenderTargets.length > 0) {
  130328. this._renderTargets.concatWithNoDuplicate(rigParent.customRenderTargets);
  130329. }
  130330. // Collects render targets from external components.
  130331. for (var _i = 0, _a = this._gatherActiveCameraRenderTargetsStage; _i < _a.length; _i++) {
  130332. var step = _a[_i];
  130333. step.action(this._renderTargets);
  130334. }
  130335. if (this.renderTargetsEnabled) {
  130336. this._intermediateRendering = true;
  130337. if (this._renderTargets.length > 0) {
  130338. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
  130339. for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
  130340. var renderTarget = this._renderTargets.data[renderIndex];
  130341. if (renderTarget._shouldRender()) {
  130342. this._renderId++;
  130343. var hasSpecialRenderTargetCamera = renderTarget.activeCamera && renderTarget.activeCamera !== this.activeCamera;
  130344. renderTarget.render(hasSpecialRenderTargetCamera, this.dumpNextRenderTargets);
  130345. }
  130346. }
  130347. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Render targets", this._renderTargets.length > 0);
  130348. this._renderId++;
  130349. }
  130350. for (var _b = 0, _c = this._cameraDrawRenderTargetStage; _b < _c.length; _b++) {
  130351. var step = _c[_b];
  130352. step.action(this.activeCamera);
  130353. }
  130354. this._intermediateRendering = false;
  130355. if (this.activeCamera.outputRenderTarget) {
  130356. var internalTexture = this.activeCamera.outputRenderTarget.getInternalTexture();
  130357. if (internalTexture) {
  130358. engine.bindFramebuffer(internalTexture);
  130359. }
  130360. else {
  130361. _Misc_logger__WEBPACK_IMPORTED_MODULE_28__["Logger"].Error("Camera contains invalid customDefaultRenderTarget");
  130362. }
  130363. }
  130364. else {
  130365. engine.restoreDefaultFramebuffer(); // Restore back buffer if needed
  130366. }
  130367. }
  130368. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  130369. // Prepare Frame
  130370. if (this.postProcessManager) {
  130371. this.postProcessManager._prepareFrame();
  130372. }
  130373. // Before Camera Draw
  130374. for (var _d = 0, _e = this._beforeCameraDrawStage; _d < _e.length; _d++) {
  130375. var step = _e[_d];
  130376. step.action(this.activeCamera);
  130377. }
  130378. // Render
  130379. this.onBeforeDrawPhaseObservable.notifyObservers(this);
  130380. this._renderingManager.render(null, null, true, true);
  130381. this.onAfterDrawPhaseObservable.notifyObservers(this);
  130382. // After Camera Draw
  130383. for (var _f = 0, _g = this._afterCameraDrawStage; _f < _g.length; _f++) {
  130384. var step = _g[_f];
  130385. step.action(this.activeCamera);
  130386. }
  130387. // Finalize frame
  130388. if (this.postProcessManager) {
  130389. this.postProcessManager._finalizeFrame(camera.isIntermediate);
  130390. }
  130391. // Reset some special arrays
  130392. this._renderTargets.reset();
  130393. this._alternateRendering = false;
  130394. this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
  130395. };
  130396. Scene.prototype._processSubCameras = function (camera) {
  130397. if (camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  130398. this._renderForCamera(camera);
  130399. return;
  130400. }
  130401. // rig cameras
  130402. for (var index = 0; index < camera._rigCameras.length; index++) {
  130403. this._renderForCamera(camera._rigCameras[index], camera);
  130404. }
  130405. this.activeCamera = camera;
  130406. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  130407. };
  130408. Scene.prototype._checkIntersections = function () {
  130409. for (var index = 0; index < this._meshesForIntersections.length; index++) {
  130410. var sourceMesh = this._meshesForIntersections.data[index];
  130411. if (!sourceMesh.actionManager) {
  130412. continue;
  130413. }
  130414. for (var actionIndex = 0; actionIndex < sourceMesh.actionManager.actions.length; actionIndex++) {
  130415. var action = sourceMesh.actionManager.actions[actionIndex];
  130416. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionEnterTrigger || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionExitTrigger) {
  130417. var parameters = action.getTriggerParameter();
  130418. var otherMesh = parameters instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameters : parameters.mesh;
  130419. var areIntersecting = otherMesh.intersectsMesh(sourceMesh, parameters.usePreciseIntersection);
  130420. var currentIntersectionInProgress = sourceMesh._intersectionsInProgress.indexOf(otherMesh);
  130421. if (areIntersecting && currentIntersectionInProgress === -1) {
  130422. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionEnterTrigger) {
  130423. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  130424. sourceMesh._intersectionsInProgress.push(otherMesh);
  130425. }
  130426. else if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionExitTrigger) {
  130427. sourceMesh._intersectionsInProgress.push(otherMesh);
  130428. }
  130429. }
  130430. else if (!areIntersecting && currentIntersectionInProgress > -1) {
  130431. //They intersected, and now they don't.
  130432. //is this trigger an exit trigger? execute an event.
  130433. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionExitTrigger) {
  130434. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  130435. }
  130436. //if this is an exit trigger, or no exit trigger exists, remove the id from the intersection in progress array.
  130437. if (!sourceMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionExitTrigger, function (parameter) {
  130438. var parameterMesh = parameter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameter : parameter.mesh;
  130439. return otherMesh === parameterMesh;
  130440. }) || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnIntersectionExitTrigger) {
  130441. sourceMesh._intersectionsInProgress.splice(currentIntersectionInProgress, 1);
  130442. }
  130443. }
  130444. }
  130445. }
  130446. }
  130447. };
  130448. /** @hidden */
  130449. Scene.prototype._advancePhysicsEngineStep = function (step) {
  130450. // Do nothing. Code will be replaced if physics engine component is referenced
  130451. };
  130452. /**
  130453. * Render the scene
  130454. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  130455. */
  130456. Scene.prototype.render = function (updateCameras) {
  130457. if (updateCameras === void 0) { updateCameras = true; }
  130458. if (this.isDisposed) {
  130459. return;
  130460. }
  130461. this._frameId++;
  130462. // Register components that have been associated lately to the scene.
  130463. this._registerTransientComponents();
  130464. this._activeParticles.fetchNewFrame();
  130465. this._totalVertices.fetchNewFrame();
  130466. this._activeIndices.fetchNewFrame();
  130467. this._activeBones.fetchNewFrame();
  130468. this._meshesForIntersections.reset();
  130469. this.resetCachedMaterial();
  130470. this.onBeforeAnimationsObservable.notifyObservers(this);
  130471. // Actions
  130472. if (this.actionManager) {
  130473. this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnEveryFrameTrigger);
  130474. }
  130475. if (this._engine.isDeterministicLockStep()) {
  130476. var deltaTime = Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime)) + this._timeAccumulator;
  130477. var defaultFPS = (60.0 / 1000.0);
  130478. var defaultFrameTime = this.getDeterministicFrameTime();
  130479. var stepsTaken = 0;
  130480. var maxSubSteps = this._engine.getLockstepMaxSteps();
  130481. var internalSteps = Math.floor(deltaTime / (1000 * defaultFPS));
  130482. internalSteps = Math.min(internalSteps, maxSubSteps);
  130483. do {
  130484. this.onBeforeStepObservable.notifyObservers(this);
  130485. // Animations
  130486. this._animationRatio = defaultFrameTime * defaultFPS;
  130487. this._animate();
  130488. this.onAfterAnimationsObservable.notifyObservers(this);
  130489. // Physics
  130490. this._advancePhysicsEngineStep(defaultFrameTime);
  130491. this.onAfterStepObservable.notifyObservers(this);
  130492. this._currentStepId++;
  130493. stepsTaken++;
  130494. deltaTime -= defaultFrameTime;
  130495. } while (deltaTime > 0 && stepsTaken < internalSteps);
  130496. this._timeAccumulator = deltaTime < 0 ? 0 : deltaTime;
  130497. }
  130498. else {
  130499. // Animations
  130500. var deltaTime = this.useConstantAnimationDeltaTime ? 16 : Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime));
  130501. this._animationRatio = deltaTime * (60.0 / 1000.0);
  130502. this._animate();
  130503. this.onAfterAnimationsObservable.notifyObservers(this);
  130504. // Physics
  130505. this._advancePhysicsEngineStep(deltaTime);
  130506. }
  130507. // Before camera update steps
  130508. for (var _i = 0, _a = this._beforeCameraUpdateStage; _i < _a.length; _i++) {
  130509. var step = _a[_i];
  130510. step.action();
  130511. }
  130512. // Update Cameras
  130513. if (updateCameras) {
  130514. if (this.activeCameras.length > 0) {
  130515. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  130516. var camera = this.activeCameras[cameraIndex];
  130517. camera.update();
  130518. if (camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  130519. // rig cameras
  130520. for (var index = 0; index < camera._rigCameras.length; index++) {
  130521. camera._rigCameras[index].update();
  130522. }
  130523. }
  130524. }
  130525. }
  130526. else if (this.activeCamera) {
  130527. this.activeCamera.update();
  130528. if (this.activeCamera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  130529. // rig cameras
  130530. for (var index = 0; index < this.activeCamera._rigCameras.length; index++) {
  130531. this.activeCamera._rigCameras[index].update();
  130532. }
  130533. }
  130534. }
  130535. }
  130536. // Before render
  130537. this.onBeforeRenderObservable.notifyObservers(this);
  130538. // Customs render targets
  130539. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  130540. var engine = this.getEngine();
  130541. var currentActiveCamera = this.activeCamera;
  130542. if (this.renderTargetsEnabled) {
  130543. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  130544. this._intermediateRendering = true;
  130545. for (var customIndex = 0; customIndex < this.customRenderTargets.length; customIndex++) {
  130546. var renderTarget = this.customRenderTargets[customIndex];
  130547. if (renderTarget._shouldRender()) {
  130548. this._renderId++;
  130549. this.activeCamera = renderTarget.activeCamera || this.activeCamera;
  130550. if (!this.activeCamera) {
  130551. throw new Error("Active camera not set");
  130552. }
  130553. // Viewport
  130554. engine.setViewport(this.activeCamera.viewport);
  130555. // Camera
  130556. this.updateTransformMatrix();
  130557. renderTarget.render(currentActiveCamera !== this.activeCamera, this.dumpNextRenderTargets);
  130558. }
  130559. }
  130560. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  130561. this._intermediateRendering = false;
  130562. this._renderId++;
  130563. }
  130564. // Restore back buffer
  130565. if (this.customRenderTargets.length > 0) {
  130566. engine.restoreDefaultFramebuffer();
  130567. }
  130568. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  130569. this.activeCamera = currentActiveCamera;
  130570. for (var _b = 0, _c = this._beforeClearStage; _b < _c.length; _b++) {
  130571. var step = _c[_b];
  130572. step.action();
  130573. }
  130574. // Clear
  130575. if (this.autoClearDepthAndStencil || this.autoClear) {
  130576. this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
  130577. }
  130578. // Collects render targets from external components.
  130579. for (var _d = 0, _e = this._gatherRenderTargetsStage; _d < _e.length; _d++) {
  130580. var step = _e[_d];
  130581. step.action(this._renderTargets);
  130582. }
  130583. // Multi-cameras?
  130584. if (this.activeCameras.length > 0) {
  130585. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  130586. if (cameraIndex > 0) {
  130587. this._engine.clear(null, false, true, true);
  130588. }
  130589. this._processSubCameras(this.activeCameras[cameraIndex]);
  130590. }
  130591. }
  130592. else {
  130593. if (!this.activeCamera) {
  130594. throw new Error("No camera defined");
  130595. }
  130596. this._processSubCameras(this.activeCamera);
  130597. }
  130598. // Intersection checks
  130599. this._checkIntersections();
  130600. // Executes the after render stage actions.
  130601. for (var _f = 0, _g = this._afterRenderStage; _f < _g.length; _f++) {
  130602. var step = _g[_f];
  130603. step.action();
  130604. }
  130605. // After render
  130606. if (this.afterRender) {
  130607. this.afterRender();
  130608. }
  130609. this.onAfterRenderObservable.notifyObservers(this);
  130610. // Cleaning
  130611. if (this._toBeDisposed.length) {
  130612. for (var index = 0; index < this._toBeDisposed.length; index++) {
  130613. var data = this._toBeDisposed[index];
  130614. if (data) {
  130615. data.dispose();
  130616. }
  130617. }
  130618. this._toBeDisposed = [];
  130619. }
  130620. if (this.dumpNextRenderTargets) {
  130621. this.dumpNextRenderTargets = false;
  130622. }
  130623. this._activeBones.addCount(0, true);
  130624. this._activeIndices.addCount(0, true);
  130625. this._activeParticles.addCount(0, true);
  130626. };
  130627. /**
  130628. * Freeze all materials
  130629. * A frozen material will not be updatable but should be faster to render
  130630. */
  130631. Scene.prototype.freezeMaterials = function () {
  130632. for (var i = 0; i < this.materials.length; i++) {
  130633. this.materials[i].freeze();
  130634. }
  130635. };
  130636. /**
  130637. * Unfreeze all materials
  130638. * A frozen material will not be updatable but should be faster to render
  130639. */
  130640. Scene.prototype.unfreezeMaterials = function () {
  130641. for (var i = 0; i < this.materials.length; i++) {
  130642. this.materials[i].unfreeze();
  130643. }
  130644. };
  130645. /**
  130646. * Releases all held ressources
  130647. */
  130648. Scene.prototype.dispose = function () {
  130649. this.beforeRender = null;
  130650. this.afterRender = null;
  130651. this.skeletons = [];
  130652. this.morphTargetManagers = [];
  130653. this._transientComponents = [];
  130654. this._isReadyForMeshStage.clear();
  130655. this._beforeEvaluateActiveMeshStage.clear();
  130656. this._evaluateSubMeshStage.clear();
  130657. this._activeMeshStage.clear();
  130658. this._cameraDrawRenderTargetStage.clear();
  130659. this._beforeCameraDrawStage.clear();
  130660. this._beforeRenderTargetDrawStage.clear();
  130661. this._beforeRenderingGroupDrawStage.clear();
  130662. this._beforeRenderingMeshStage.clear();
  130663. this._afterRenderingMeshStage.clear();
  130664. this._afterRenderingGroupDrawStage.clear();
  130665. this._afterCameraDrawStage.clear();
  130666. this._afterRenderTargetDrawStage.clear();
  130667. this._afterRenderStage.clear();
  130668. this._beforeCameraUpdateStage.clear();
  130669. this._beforeClearStage.clear();
  130670. this._gatherRenderTargetsStage.clear();
  130671. this._gatherActiveCameraRenderTargetsStage.clear();
  130672. this._pointerMoveStage.clear();
  130673. this._pointerDownStage.clear();
  130674. this._pointerUpStage.clear();
  130675. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  130676. var component = _a[_i];
  130677. component.dispose();
  130678. }
  130679. this.importedMeshesFiles = new Array();
  130680. this.stopAllAnimations();
  130681. this.resetCachedMaterial();
  130682. // Smart arrays
  130683. if (this.activeCamera) {
  130684. this.activeCamera._activeMeshes.dispose();
  130685. this.activeCamera = null;
  130686. }
  130687. this._activeMeshes.dispose();
  130688. this._renderingManager.dispose();
  130689. this._processedMaterials.dispose();
  130690. this._activeParticleSystems.dispose();
  130691. this._activeSkeletons.dispose();
  130692. this._softwareSkinnedMeshes.dispose();
  130693. this._renderTargets.dispose();
  130694. this._registeredForLateAnimationBindings.dispose();
  130695. this._meshesForIntersections.dispose();
  130696. this._toBeDisposed = [];
  130697. // Abort active requests
  130698. for (var _b = 0, _c = this._activeRequests; _b < _c.length; _b++) {
  130699. var request = _c[_b];
  130700. request.abort();
  130701. }
  130702. // Events
  130703. this.onDisposeObservable.notifyObservers(this);
  130704. this.onDisposeObservable.clear();
  130705. this.onBeforeRenderObservable.clear();
  130706. this.onAfterRenderObservable.clear();
  130707. this.onBeforeRenderTargetsRenderObservable.clear();
  130708. this.onAfterRenderTargetsRenderObservable.clear();
  130709. this.onAfterStepObservable.clear();
  130710. this.onBeforeStepObservable.clear();
  130711. this.onBeforeActiveMeshesEvaluationObservable.clear();
  130712. this.onAfterActiveMeshesEvaluationObservable.clear();
  130713. this.onBeforeParticlesRenderingObservable.clear();
  130714. this.onAfterParticlesRenderingObservable.clear();
  130715. this.onBeforeDrawPhaseObservable.clear();
  130716. this.onAfterDrawPhaseObservable.clear();
  130717. this.onBeforeAnimationsObservable.clear();
  130718. this.onAfterAnimationsObservable.clear();
  130719. this.onDataLoadedObservable.clear();
  130720. this.onBeforeRenderingGroupObservable.clear();
  130721. this.onAfterRenderingGroupObservable.clear();
  130722. this.onMeshImportedObservable.clear();
  130723. this.onBeforeCameraRenderObservable.clear();
  130724. this.onAfterCameraRenderObservable.clear();
  130725. this.onReadyObservable.clear();
  130726. this.onNewCameraAddedObservable.clear();
  130727. this.onCameraRemovedObservable.clear();
  130728. this.onNewLightAddedObservable.clear();
  130729. this.onLightRemovedObservable.clear();
  130730. this.onNewGeometryAddedObservable.clear();
  130731. this.onGeometryRemovedObservable.clear();
  130732. this.onNewTransformNodeAddedObservable.clear();
  130733. this.onTransformNodeRemovedObservable.clear();
  130734. this.onNewMeshAddedObservable.clear();
  130735. this.onMeshRemovedObservable.clear();
  130736. this.onNewMaterialAddedObservable.clear();
  130737. this.onMaterialRemovedObservable.clear();
  130738. this.onNewTextureAddedObservable.clear();
  130739. this.onTextureRemovedObservable.clear();
  130740. this.onPrePointerObservable.clear();
  130741. this.onPointerObservable.clear();
  130742. this.onPreKeyboardObservable.clear();
  130743. this.onKeyboardObservable.clear();
  130744. this.onActiveCameraChanged.clear();
  130745. this.detachControl();
  130746. // Detach cameras
  130747. var canvas = this._engine.getRenderingCanvas();
  130748. if (canvas) {
  130749. var index;
  130750. for (index = 0; index < this.cameras.length; index++) {
  130751. this.cameras[index].detachControl(canvas);
  130752. }
  130753. }
  130754. // Release animation groups
  130755. while (this.animationGroups.length) {
  130756. this.animationGroups[0].dispose();
  130757. }
  130758. // Release lights
  130759. while (this.lights.length) {
  130760. this.lights[0].dispose();
  130761. }
  130762. // Release meshes
  130763. while (this.meshes.length) {
  130764. this.meshes[0].dispose(true);
  130765. }
  130766. while (this.transformNodes.length) {
  130767. this.removeTransformNode(this.transformNodes[0]);
  130768. }
  130769. // Release cameras
  130770. while (this.cameras.length) {
  130771. this.cameras[0].dispose();
  130772. }
  130773. // Release materials
  130774. if (this.defaultMaterial) {
  130775. this.defaultMaterial.dispose();
  130776. }
  130777. while (this.multiMaterials.length) {
  130778. this.multiMaterials[0].dispose();
  130779. }
  130780. while (this.materials.length) {
  130781. this.materials[0].dispose();
  130782. }
  130783. // Release particles
  130784. while (this.particleSystems.length) {
  130785. this.particleSystems[0].dispose();
  130786. }
  130787. // Release postProcesses
  130788. while (this.postProcesses.length) {
  130789. this.postProcesses[0].dispose();
  130790. }
  130791. // Release textures
  130792. while (this.textures.length) {
  130793. this.textures[0].dispose();
  130794. }
  130795. // Release UBO
  130796. this._sceneUbo.dispose();
  130797. if (this._alternateSceneUbo) {
  130798. this._alternateSceneUbo.dispose();
  130799. }
  130800. // Post-processes
  130801. this.postProcessManager.dispose();
  130802. // Remove from engine
  130803. index = this._engine.scenes.indexOf(this);
  130804. if (index > -1) {
  130805. this._engine.scenes.splice(index, 1);
  130806. }
  130807. this._engine.wipeCaches(true);
  130808. this._isDisposed = true;
  130809. };
  130810. Object.defineProperty(Scene.prototype, "isDisposed", {
  130811. /**
  130812. * Gets if the scene is already disposed
  130813. */
  130814. get: function () {
  130815. return this._isDisposed;
  130816. },
  130817. enumerable: true,
  130818. configurable: true
  130819. });
  130820. /**
  130821. * Call this function to reduce memory footprint of the scene.
  130822. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  130823. */
  130824. Scene.prototype.clearCachedVertexData = function () {
  130825. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  130826. var mesh = this.meshes[meshIndex];
  130827. var geometry = mesh.geometry;
  130828. if (geometry) {
  130829. geometry._indices = [];
  130830. for (var vbName in geometry._vertexBuffers) {
  130831. if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
  130832. continue;
  130833. }
  130834. geometry._vertexBuffers[vbName]._buffer._data = null;
  130835. }
  130836. }
  130837. }
  130838. };
  130839. /**
  130840. * This function will remove the local cached buffer data from texture.
  130841. * It will save memory but will prevent the texture from being rebuilt
  130842. */
  130843. Scene.prototype.cleanCachedTextureBuffer = function () {
  130844. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  130845. var baseTexture = _a[_i];
  130846. var buffer = baseTexture._buffer;
  130847. if (buffer) {
  130848. baseTexture._buffer = null;
  130849. }
  130850. }
  130851. };
  130852. /**
  130853. * Get the world extend vectors with an optional filter
  130854. *
  130855. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  130856. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  130857. */
  130858. Scene.prototype.getWorldExtends = function (filterPredicate) {
  130859. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  130860. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  130861. filterPredicate = filterPredicate || (function () { return true; });
  130862. this.meshes.filter(filterPredicate).forEach(function (mesh) {
  130863. mesh.computeWorldMatrix(true);
  130864. if (!mesh.subMeshes || mesh.subMeshes.length === 0 || mesh.infiniteDistance) {
  130865. return;
  130866. }
  130867. var boundingInfo = mesh.getBoundingInfo();
  130868. var minBox = boundingInfo.boundingBox.minimumWorld;
  130869. var maxBox = boundingInfo.boundingBox.maximumWorld;
  130870. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  130871. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  130872. });
  130873. return {
  130874. min: min,
  130875. max: max
  130876. };
  130877. };
  130878. // Picking
  130879. /**
  130880. * Creates a ray that can be used to pick in the scene
  130881. * @param x defines the x coordinate of the origin (on-screen)
  130882. * @param y defines the y coordinate of the origin (on-screen)
  130883. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  130884. * @param camera defines the camera to use for the picking
  130885. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  130886. * @returns a Ray
  130887. */
  130888. Scene.prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  130889. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  130890. var result = _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"].Zero();
  130891. this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);
  130892. return result;
  130893. };
  130894. /**
  130895. * Creates a ray that can be used to pick in the scene
  130896. * @param x defines the x coordinate of the origin (on-screen)
  130897. * @param y defines the y coordinate of the origin (on-screen)
  130898. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  130899. * @param result defines the ray where to store the picking ray
  130900. * @param camera defines the camera to use for the picking
  130901. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  130902. * @returns the current scene
  130903. */
  130904. Scene.prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  130905. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  130906. var engine = this._engine;
  130907. if (!camera) {
  130908. if (!this.activeCamera) {
  130909. throw new Error("Active camera not set");
  130910. }
  130911. camera = this.activeCamera;
  130912. }
  130913. var cameraViewport = camera.viewport;
  130914. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  130915. // Moving coordinates to local viewport world
  130916. x = x / this._engine.getHardwareScalingLevel() - viewport.x;
  130917. y = y / this._engine.getHardwareScalingLevel() - (this._engine.getRenderHeight() - viewport.y - viewport.height);
  130918. result.update(x, y, viewport.width, viewport.height, world ? world : _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].IdentityReadOnly, cameraViewSpace ? _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].IdentityReadOnly : camera.getViewMatrix(), camera.getProjectionMatrix());
  130919. return this;
  130920. };
  130921. /**
  130922. * Creates a ray that can be used to pick in the scene
  130923. * @param x defines the x coordinate of the origin (on-screen)
  130924. * @param y defines the y coordinate of the origin (on-screen)
  130925. * @param camera defines the camera to use for the picking
  130926. * @returns a Ray
  130927. */
  130928. Scene.prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  130929. var result = _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"].Zero();
  130930. this.createPickingRayInCameraSpaceToRef(x, y, result, camera);
  130931. return result;
  130932. };
  130933. /**
  130934. * Creates a ray that can be used to pick in the scene
  130935. * @param x defines the x coordinate of the origin (on-screen)
  130936. * @param y defines the y coordinate of the origin (on-screen)
  130937. * @param result defines the ray where to store the picking ray
  130938. * @param camera defines the camera to use for the picking
  130939. * @returns the current scene
  130940. */
  130941. Scene.prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  130942. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_16__["PickingInfo"]) {
  130943. return this;
  130944. }
  130945. var engine = this._engine;
  130946. if (!camera) {
  130947. if (!this.activeCamera) {
  130948. throw new Error("Active camera not set");
  130949. }
  130950. camera = this.activeCamera;
  130951. }
  130952. var cameraViewport = camera.viewport;
  130953. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  130954. var identity = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity();
  130955. // Moving coordinates to local viewport world
  130956. x = x / this._engine.getHardwareScalingLevel() - viewport.x;
  130957. y = y / this._engine.getHardwareScalingLevel() - (this._engine.getRenderHeight() - viewport.y - viewport.height);
  130958. result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());
  130959. return this;
  130960. };
  130961. Scene.prototype._internalPick = function (rayFunction, predicate, fastCheck) {
  130962. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_16__["PickingInfo"]) {
  130963. return null;
  130964. }
  130965. var pickingInfo = null;
  130966. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  130967. var mesh = this.meshes[meshIndex];
  130968. if (predicate) {
  130969. if (!predicate(mesh)) {
  130970. continue;
  130971. }
  130972. }
  130973. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  130974. continue;
  130975. }
  130976. var world = mesh.getWorldMatrix();
  130977. var ray = rayFunction(world);
  130978. var result = mesh.intersects(ray, fastCheck);
  130979. if (!result || !result.hit) {
  130980. continue;
  130981. }
  130982. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  130983. continue;
  130984. }
  130985. pickingInfo = result;
  130986. if (fastCheck) {
  130987. break;
  130988. }
  130989. }
  130990. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_16__["PickingInfo"]();
  130991. };
  130992. Scene.prototype._internalMultiPick = function (rayFunction, predicate) {
  130993. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_16__["PickingInfo"]) {
  130994. return null;
  130995. }
  130996. var pickingInfos = new Array();
  130997. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  130998. var mesh = this.meshes[meshIndex];
  130999. if (predicate) {
  131000. if (!predicate(mesh)) {
  131001. continue;
  131002. }
  131003. }
  131004. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  131005. continue;
  131006. }
  131007. var world = mesh.getWorldMatrix();
  131008. var ray = rayFunction(world);
  131009. var result = mesh.intersects(ray, false);
  131010. if (!result || !result.hit) {
  131011. continue;
  131012. }
  131013. pickingInfos.push(result);
  131014. }
  131015. return pickingInfos;
  131016. };
  131017. /** Launch a ray to try to pick a mesh in the scene
  131018. * @param x position on screen
  131019. * @param y position on screen
  131020. * @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
  131021. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  131022. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  131023. * @returns a PickingInfo
  131024. */
  131025. Scene.prototype.pick = function (x, y, predicate, fastCheck, camera) {
  131026. var _this = this;
  131027. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_16__["PickingInfo"]) {
  131028. return null;
  131029. }
  131030. var result = this._internalPick(function (world) {
  131031. _this.createPickingRayToRef(x, y, world, _this._tempPickingRay, camera || null);
  131032. return _this._tempPickingRay;
  131033. }, predicate, fastCheck);
  131034. if (result) {
  131035. result.ray = this.createPickingRay(x, y, _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity(), camera || null);
  131036. }
  131037. return result;
  131038. };
  131039. /** Use the given ray to pick a mesh in the scene
  131040. * @param ray The ray to use to pick meshes
  131041. * @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
  131042. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  131043. * @returns a PickingInfo
  131044. */
  131045. Scene.prototype.pickWithRay = function (ray, predicate, fastCheck) {
  131046. var _this = this;
  131047. var result = this._internalPick(function (world) {
  131048. if (!_this._pickWithRayInverseMatrix) {
  131049. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity();
  131050. }
  131051. world.invertToRef(_this._pickWithRayInverseMatrix);
  131052. if (!_this._cachedRayForTransform) {
  131053. _this._cachedRayForTransform = _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"].Zero();
  131054. }
  131055. _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"].TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  131056. return _this._cachedRayForTransform;
  131057. }, predicate, fastCheck);
  131058. if (result) {
  131059. result.ray = ray;
  131060. }
  131061. return result;
  131062. };
  131063. /**
  131064. * Launch a ray to try to pick a mesh in the scene
  131065. * @param x X position on screen
  131066. * @param y Y position on screen
  131067. * @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
  131068. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  131069. * @returns an array of PickingInfo
  131070. */
  131071. Scene.prototype.multiPick = function (x, y, predicate, camera) {
  131072. var _this = this;
  131073. return this._internalMultiPick(function (world) { return _this.createPickingRay(x, y, world, camera || null); }, predicate);
  131074. };
  131075. /**
  131076. * Launch a ray to try to pick a mesh in the scene
  131077. * @param ray Ray to use
  131078. * @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
  131079. * @returns an array of PickingInfo
  131080. */
  131081. Scene.prototype.multiPickWithRay = function (ray, predicate) {
  131082. var _this = this;
  131083. return this._internalMultiPick(function (world) {
  131084. if (!_this._pickWithRayInverseMatrix) {
  131085. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity();
  131086. }
  131087. world.invertToRef(_this._pickWithRayInverseMatrix);
  131088. if (!_this._cachedRayForTransform) {
  131089. _this._cachedRayForTransform = _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"].Zero();
  131090. }
  131091. _Culling_ray__WEBPACK_IMPORTED_MODULE_25__["Ray"].TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  131092. return _this._cachedRayForTransform;
  131093. }, predicate);
  131094. };
  131095. /**
  131096. * Force the value of meshUnderPointer
  131097. * @param mesh defines the mesh to use
  131098. */
  131099. Scene.prototype.setPointerOverMesh = function (mesh) {
  131100. if (this._pointerOverMesh === mesh) {
  131101. return;
  131102. }
  131103. if (this._pointerOverMesh && this._pointerOverMesh.actionManager) {
  131104. this._pointerOverMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(this._pointerOverMesh));
  131105. }
  131106. this._pointerOverMesh = mesh;
  131107. if (this._pointerOverMesh && this._pointerOverMesh.actionManager) {
  131108. this._pointerOverMesh.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_20__["ActionEvent"].CreateNew(this._pointerOverMesh));
  131109. }
  131110. };
  131111. /**
  131112. * Gets the mesh under the pointer
  131113. * @returns a Mesh or null if no mesh is under the pointer
  131114. */
  131115. Scene.prototype.getPointerOverMesh = function () {
  131116. return this._pointerOverMesh;
  131117. };
  131118. // Misc.
  131119. /** @hidden */
  131120. Scene.prototype._rebuildGeometries = function () {
  131121. for (var _i = 0, _a = this.geometries; _i < _a.length; _i++) {
  131122. var geometry = _a[_i];
  131123. geometry._rebuild();
  131124. }
  131125. for (var _b = 0, _c = this.meshes; _b < _c.length; _b++) {
  131126. var mesh = _c[_b];
  131127. mesh._rebuild();
  131128. }
  131129. if (this.postProcessManager) {
  131130. this.postProcessManager._rebuild();
  131131. }
  131132. for (var _d = 0, _e = this._components; _d < _e.length; _d++) {
  131133. var component = _e[_d];
  131134. component.rebuild();
  131135. }
  131136. for (var _f = 0, _g = this.particleSystems; _f < _g.length; _f++) {
  131137. var system = _g[_f];
  131138. system.rebuild();
  131139. }
  131140. };
  131141. /** @hidden */
  131142. Scene.prototype._rebuildTextures = function () {
  131143. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  131144. var texture = _a[_i];
  131145. texture._rebuild();
  131146. }
  131147. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_TextureDirtyFlag);
  131148. };
  131149. // Tags
  131150. Scene.prototype._getByTags = function (list, tagsQuery, forEach) {
  131151. if (tagsQuery === undefined) {
  131152. // returns the complete list (could be done with Tags.MatchesQuery but no need to have a for-loop here)
  131153. return list;
  131154. }
  131155. var listByTags = [];
  131156. forEach = forEach || (function (item) { return; });
  131157. for (var i in list) {
  131158. var item = list[i];
  131159. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"].MatchesQuery(item, tagsQuery)) {
  131160. listByTags.push(item);
  131161. forEach(item);
  131162. }
  131163. }
  131164. return listByTags;
  131165. };
  131166. /**
  131167. * Get a list of meshes by tags
  131168. * @param tagsQuery defines the tags query to use
  131169. * @param forEach defines a predicate used to filter results
  131170. * @returns an array of Mesh
  131171. */
  131172. Scene.prototype.getMeshesByTags = function (tagsQuery, forEach) {
  131173. return this._getByTags(this.meshes, tagsQuery, forEach);
  131174. };
  131175. /**
  131176. * Get a list of cameras by tags
  131177. * @param tagsQuery defines the tags query to use
  131178. * @param forEach defines a predicate used to filter results
  131179. * @returns an array of Camera
  131180. */
  131181. Scene.prototype.getCamerasByTags = function (tagsQuery, forEach) {
  131182. return this._getByTags(this.cameras, tagsQuery, forEach);
  131183. };
  131184. /**
  131185. * Get a list of lights by tags
  131186. * @param tagsQuery defines the tags query to use
  131187. * @param forEach defines a predicate used to filter results
  131188. * @returns an array of Light
  131189. */
  131190. Scene.prototype.getLightsByTags = function (tagsQuery, forEach) {
  131191. return this._getByTags(this.lights, tagsQuery, forEach);
  131192. };
  131193. /**
  131194. * Get a list of materials by tags
  131195. * @param tagsQuery defines the tags query to use
  131196. * @param forEach defines a predicate used to filter results
  131197. * @returns an array of Material
  131198. */
  131199. Scene.prototype.getMaterialByTags = function (tagsQuery, forEach) {
  131200. return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
  131201. };
  131202. /**
  131203. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  131204. * This allowed control for front to back rendering or reversly depending of the special needs.
  131205. *
  131206. * @param renderingGroupId The rendering group id corresponding to its index
  131207. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  131208. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  131209. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  131210. */
  131211. Scene.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  131212. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  131213. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  131214. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  131215. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  131216. };
  131217. /**
  131218. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  131219. *
  131220. * @param renderingGroupId The rendering group id corresponding to its index
  131221. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  131222. * @param depth Automatically clears depth between groups if true and autoClear is true.
  131223. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  131224. */
  131225. Scene.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  131226. if (depth === void 0) { depth = true; }
  131227. if (stencil === void 0) { stencil = true; }
  131228. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil, depth, stencil);
  131229. };
  131230. /**
  131231. * Gets the current auto clear configuration for one rendering group of the rendering
  131232. * manager.
  131233. * @param index the rendering group index to get the information for
  131234. * @returns The auto clear setup for the requested rendering group
  131235. */
  131236. Scene.prototype.getAutoClearDepthStencilSetup = function (index) {
  131237. return this._renderingManager.getAutoClearDepthStencilSetup(index);
  131238. };
  131239. Object.defineProperty(Scene.prototype, "blockMaterialDirtyMechanism", {
  131240. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  131241. get: function () {
  131242. return this._blockMaterialDirtyMechanism;
  131243. },
  131244. set: function (value) {
  131245. if (this._blockMaterialDirtyMechanism === value) {
  131246. return;
  131247. }
  131248. this._blockMaterialDirtyMechanism = value;
  131249. if (!value) { // Do a complete update
  131250. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_26__["Constants"].MATERIAL_AllDirtyFlag);
  131251. }
  131252. },
  131253. enumerable: true,
  131254. configurable: true
  131255. });
  131256. /**
  131257. * Will flag all materials as dirty to trigger new shader compilation
  131258. * @param flag defines the flag used to specify which material part must be marked as dirty
  131259. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  131260. */
  131261. Scene.prototype.markAllMaterialsAsDirty = function (flag, predicate) {
  131262. if (this._blockMaterialDirtyMechanism) {
  131263. return;
  131264. }
  131265. for (var _i = 0, _a = this.materials; _i < _a.length; _i++) {
  131266. var material = _a[_i];
  131267. if (predicate && !predicate(material)) {
  131268. continue;
  131269. }
  131270. material.markAsDirty(flag);
  131271. }
  131272. };
  131273. /** @hidden */
  131274. Scene.prototype._loadFile = function (url, onSuccess, onProgress, useOfflineSupport, useArrayBuffer, onError) {
  131275. var _this = this;
  131276. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadFile(url, onSuccess, onProgress, useOfflineSupport ? this.offlineProvider : undefined, useArrayBuffer, onError);
  131277. this._activeRequests.push(request);
  131278. request.onCompleteObservable.add(function (request) {
  131279. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  131280. });
  131281. return request;
  131282. };
  131283. /** @hidden */
  131284. Scene.prototype._loadFileAsync = function (url, useOfflineSupport, useArrayBuffer) {
  131285. var _this = this;
  131286. return new Promise(function (resolve, reject) {
  131287. _this._loadFile(url, function (data) {
  131288. resolve(data);
  131289. }, undefined, useOfflineSupport, useArrayBuffer, function (request, exception) {
  131290. reject(exception);
  131291. });
  131292. });
  131293. };
  131294. // Statics
  131295. Scene._uniqueIdCounter = 0;
  131296. /** The fog is deactivated */
  131297. Scene.FOGMODE_NONE = 0;
  131298. /** The fog density is following an exponential function */
  131299. Scene.FOGMODE_EXP = 1;
  131300. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  131301. Scene.FOGMODE_EXP2 = 2;
  131302. /** The fog density is following a linear function. */
  131303. Scene.FOGMODE_LINEAR = 3;
  131304. /**
  131305. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  131306. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131307. */
  131308. Scene.MinDeltaTime = 1.0;
  131309. /**
  131310. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  131311. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131312. */
  131313. Scene.MaxDeltaTime = 1000.0;
  131314. /** The distance in pixel that you have to move to prevent some events */
  131315. Scene.DragMovementThreshold = 10; // in pixels
  131316. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  131317. Scene.LongPressDelay = 500; // in milliseconds
  131318. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  131319. Scene.DoubleClickDelay = 300; // in milliseconds
  131320. /** If you need to check double click without raising a single click at first click, enable this flag */
  131321. Scene.ExclusiveDoubleClickMode = false;
  131322. return Scene;
  131323. }(_abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"]));
  131324. /***/ }),
  131325. /***/ "./sceneComponent.ts":
  131326. /*!***************************!*\
  131327. !*** ./sceneComponent.ts ***!
  131328. \***************************/
  131329. /*! exports provided: SceneComponentConstants, Stage */
  131330. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131331. "use strict";
  131332. __webpack_require__.r(__webpack_exports__);
  131333. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return SceneComponentConstants; });
  131334. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return Stage; });
  131335. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  131336. /**
  131337. * Groups all the scene component constants in one place to ease maintenance.
  131338. * @hidden
  131339. */
  131340. var SceneComponentConstants = /** @class */ (function () {
  131341. function SceneComponentConstants() {
  131342. }
  131343. SceneComponentConstants.NAME_EFFECTLAYER = "EffectLayer";
  131344. SceneComponentConstants.NAME_LAYER = "Layer";
  131345. SceneComponentConstants.NAME_LENSFLARESYSTEM = "LensFlareSystem";
  131346. SceneComponentConstants.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer";
  131347. SceneComponentConstants.NAME_PARTICLESYSTEM = "ParticleSystem";
  131348. SceneComponentConstants.NAME_GAMEPAD = "Gamepad";
  131349. SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue";
  131350. SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer";
  131351. SceneComponentConstants.NAME_DEPTHRENDERER = "DepthRenderer";
  131352. SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager";
  131353. SceneComponentConstants.NAME_SPRITE = "Sprite";
  131354. SceneComponentConstants.NAME_OUTLINERENDERER = "Outline";
  131355. SceneComponentConstants.NAME_PROCEDURALTEXTURE = "ProceduralTexture";
  131356. SceneComponentConstants.NAME_SHADOWGENERATOR = "ShadowGenerator";
  131357. SceneComponentConstants.NAME_OCTREE = "Octree";
  131358. SceneComponentConstants.NAME_PHYSICSENGINE = "PhysicsEngine";
  131359. SceneComponentConstants.NAME_AUDIO = "Audio";
  131360. SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER = 0;
  131361. SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  131362. SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
  131363. SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  131364. SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;
  131365. SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER = 0;
  131366. SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER = 1;
  131367. SceneComponentConstants.STEP_BEFORERENDERTARGETDRAW_LAYER = 0;
  131368. SceneComponentConstants.STEP_BEFORERENDERINGMESH_OUTLINE = 0;
  131369. SceneComponentConstants.STEP_AFTERRENDERINGMESH_OUTLINE = 0;
  131370. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;
  131371. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1;
  131372. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;
  131373. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1;
  131374. SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;
  131375. SceneComponentConstants.STEP_AFTERRENDERTARGETDRAW_LAYER = 0;
  131376. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER = 0;
  131377. SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 1;
  131378. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 2;
  131379. SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER = 3;
  131380. SceneComponentConstants.STEP_AFTERRENDER_AUDIO = 0;
  131381. SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 0;
  131382. SceneComponentConstants.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1;
  131383. SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 2;
  131384. SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3;
  131385. SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0;
  131386. SceneComponentConstants.STEP_POINTERMOVE_SPRITE = 0;
  131387. SceneComponentConstants.STEP_POINTERDOWN_SPRITE = 0;
  131388. SceneComponentConstants.STEP_POINTERUP_SPRITE = 0;
  131389. return SceneComponentConstants;
  131390. }());
  131391. /**
  131392. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  131393. * @hidden
  131394. */
  131395. var Stage = /** @class */ (function (_super) {
  131396. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Stage, _super);
  131397. /**
  131398. * Hide ctor from the rest of the world.
  131399. * @param items The items to add.
  131400. */
  131401. function Stage(items) {
  131402. return _super.apply(this, items) || this;
  131403. }
  131404. /**
  131405. * Creates a new Stage.
  131406. * @returns A new instance of a Stage
  131407. */
  131408. Stage.Create = function () {
  131409. return Object.create(Stage.prototype);
  131410. };
  131411. /**
  131412. * Registers a step in an ordered way in the targeted stage.
  131413. * @param index Defines the position to register the step in
  131414. * @param component Defines the component attached to the step
  131415. * @param action Defines the action to launch during the step
  131416. */
  131417. Stage.prototype.registerStep = function (index, component, action) {
  131418. var i = 0;
  131419. var maxIndex = Number.MAX_VALUE;
  131420. for (; i < this.length; i++) {
  131421. var step = this[i];
  131422. maxIndex = step.index;
  131423. if (index < maxIndex) {
  131424. break;
  131425. }
  131426. }
  131427. this.splice(i, 0, { index: index, component: component, action: action.bind(component) });
  131428. };
  131429. /**
  131430. * Clears all the steps from the stage.
  131431. */
  131432. Stage.prototype.clear = function () {
  131433. this.length = 0;
  131434. };
  131435. return Stage;
  131436. }(Array));
  131437. /***/ })
  131438. /******/ });
  131439. });
  131440. //# sourceMappingURL=babylon.max.js.map